Initializations

These two commands turn off the spell checker, 
otherwise we get spurious messages like...

Off[General::"spell"];
Off[General::"spell1"];

$TextStyle = {FontFamily -> "Times", 
          FontSize -> 19};

Load the graphics libraries.

<< Graphics`Graphics`
<< Graphics`ImplicitPlot`
<< LinearAlgebra`MatrixManipulation`

Set the Directory

SetDirectory["G:\users\B\Berrig\Public"];

Directory[]

Magnet position. Every magnet

magnet1, magnet1names

Clear[magnet1, magnet1names, low, high, ytxt]

magnet1[z_] := low   /;  z <     2.45000

magnet1[z_] := 
      high /;  
        z ≥     2.45000  &&  z<     7.40319   (* Magnet  1 *)

magnet1[z_] := 
      low   /;  z ≥     7.40319  &&  
          z <      8.45319

magnet1[z_] := 
      high /;  
        z ≥     8.45319  &&  z<   13.40638   (* Magnet  2 *)

magnet1[z_] := 
      low   /;  z ≥   13.40638  &&  
          z <    14.45638

magnet1[z_] := 
      high /;  
        z ≥   14.45638  &&  z<   19.40957   (* Magnet  3 *)

magnet1[z_] := 
      low   /;  z ≥   19.40957  &&  
          z <    20.45957

magnet1[z_] := 
      high /;  
        z ≥   20.45957  &&  z<   25.41276   (* Magnet  4 *)

magnet1[z_] := 
      low   /;  z ≥   25.41276  &&  
          z <    26.46276

magnet1[z_] := 
      high /;  
        z ≥   26.46276  &&  z<  31.41595    (* 
              Magnet  5 *)

magnet1[z_] := 
      low   /;  z ≥  31.41595  &&  
          z <    33.86595

magnet1[z_] := 
      high /;  
        z ≥   33.86595  &&  z<   38.81914    (* 
              Magnet  6 *)

magnet1[z_] := 
      low   /;  z ≥   38.81914  &&  
          z <    39.86914

magnet1[z_] := 
      high /;  
        z ≥   39.86914  &&  z<   44.82233    (* Magnet  7 *)

magnet1[z_] := 
      low   /;  z ≥   44.82233  &&  
          z <    45.87233

magnet1[z_] := 
      high /;  
        z ≥   45.87233  &&  z<   50.82552    (* Magnet  8 *)

magnet1[z_] := 
      low   /;  z ≥   50.82552  &&  
          z <    51.87552

magnet1[z_] := 
      high /;  
        z ≥   51.87552  &&  z<   56.82871   (* Magnet   9 *)

magnet1[z_] := 
      low   /;  z ≥   56.82871  &&  
          z <    57.87871

magnet1[z_] := 
      high /;  
        z ≥   57.87871  &&  z<  62.83190    (* Magnet  10 *)

magnet1[z_] := 
      low   /;  z ≥   62.83190  &&  
          z <   65.28190

magnet1[z_] := 
      high /;   z ≥  
            65.28190  &&  z <  70.23509   (* Magnet  11 *)

magnet1[z_] := 
      low   /;  z ≥   70.23509  &&  
          z <   71.28509

magnet1[z_] := 
      high /;   z ≥  
            71.28509  &&  z <  76.23828   (* Magnet  12 *)

magnet1[z_] := 
      low   /;  z ≥   76.23828  &&  
          z <   77.28828

magnet1[z_] := 
      high /;   z ≥  
            77.28828  &&  z <  82.24147   (* Magnet  13 *)

magnet1[z_] := 
      low   /;  z ≥   82.24147  &&  
          z <   83.29147

magnet1[z_] := 
      high /;   z ≥  
            83.29147   &&  z <  88.24466   (* Magnet  14 *)

magnet1[z_] := 
      low   /;  z ≥   88.24466  &&  
          z <   89.29466

magnet1[z_] := 
      high /;   z ≥  
            89.29466   &&  z <  94.24785   (* Magnet  15 *)

magnet1[z_] := 
      low   /;  z ≥   94.24785  &&  
          z <   96.69785

magnet1[z_] := 
      high /;   z ≥   96.69785  &&  z <101.65104   (* Magnet  16 *)

magnet1[z_] := 
      low   /;  z ≥  101.65104  &&  
          z < 102.70104

magnet1[z_] := 
      high /;   z ≥ 
            102.70104  &&  z <107.65423

magnet1[z_] := 
      low   /;  z ≥  107.65423  &&  
          z <  108.70423

magnet1[z_] := 
      high /;   z ≥ 
            108.70423  &&  z <113.65742

magnet1[z_] := 
      low   /;  z ≥  113.65742  &&  
          z <  114.70742

magnet1[z_] := 
      high /;   z ≥ 
            114.70742  &&  z <119.66061

magnet1[z_] := 
      low   /;  z ≥  119.66061  &&  
          z <  120.71061

magnet1[z_] := 
      high /;   z ≥ 
            120.71061  &&  z <125.66380

magnet1[z_] := 
      low   /;  z ≥  125.66380  &&  
          z < 128.11380

magnet1[z_] := 
      high /;   z ≥ 
            128.11380  &&  z <133.06699

magnet1[z_] := 
      low   /;  z ≥  133.06699  &&  
          z < 134.11699

magnet1[z_] := 
      high /;   z ≥ 
            134.11699  &&  z <139.07018

magnet1[z_] := 
      low   /;  z ≥ 139.07018  &&  
          z < 140.12018

magnet1[z_] := 
      high /;   z ≥ 
            140.12018  &&  z <145.07337

magnet1[z_] := 
      low   /;  z ≥  145.07337  &&  
          z <  146.12337

magnet1[z_] := 
      high /;   z ≥ 
            146.12337  &&  z <151.07656

magnet1[z_] := 
      low   /;  z ≥  
            151.07656  &&  z< 152.12656

magnet1[z_] := 
      high /;   z ≥ 
            152.12656  &&  z <157.07975

magnet1[z_] := 
      low   /;  z ≥  157.07975  &&  
          z <  159.52975

magnet1[z_] := 
      high /;   z ≥ 
            159.52975  &&  z <164.48294

magnet1[z_] := 
      low   /;  z ≥  164.48294  &&  
          z <  165.53294

magnet1[z_] := 
      high /;   z ≥ 
            165.53294  &&  z <170.48613

magnet1[z_] := 
      low   /;  z ≥  170.48613  &&  
          z <  171.53613

magnet1[z_] := 
      high /;   z ≥ 
            171.53613  &&  z <176.48932

magnet1[z_] := 
      low   /;  z ≥  176.48932  &&  
          z <  177.53932

magnet1[z_] := 
      high /;   z ≥ 
            177.53932  &&  z <182.49251

magnet1[z_] := 
      low   /;  z ≥  182.49251  &&  
          z <  183.54251

magnet1[z_] := 
      high /;   z ≥ 
            183.54251  &&  z <188.49570

magnet1[z_] := 
      low   /;  z ≥  188.49570  &&  
          z <  190.94570

magnet1[z_] := 
      high /;   z ≥ 
            190.94570  &&  z <195.89889

magnet1[z_] := 
      low   /;  z ≥  195.89889  &&  
          z < 196.94889

magnet1[z_] := 
      high /;   z ≥ 
            196.94889  &&  z <201.90208

magnet1[z_] := 
      low   /;  z ≥  201.90208   &&  
          z < 202.95208

magnet1[z_] := 
      high /;   z ≥ 
            202.95208  &&  z <207.90527

magnet1[z_] := 
      low   /;  z ≥  207.90527  &&  
          z <  202.95208

magnet1[z_] := 
      high /;   z ≥ 
            202.95208  &&  z <207.90527

magnet1[z_] := 
      low   /;  z ≥  207.90527  &&  
          z <  208.95527

magnet1[z_] := 
      high /;   z ≥ 
            208.95527  &&  z <213.90846

magnet1[z_] := 
      low   /;  z ≥  213.90846  &&  
          z <  214.95846

magnet1[z_] := 
      high /;   z ≥ 
            214.95846  &&  z <219.91165

magnet1[z_] := 
      low   /;  z ≥  219.91165  &&  
          z <  222.36165

magnet1[z_] := 
      high /;   z ≥ 
            222.36165  &&  z <227.31484

magnet1[z_] := 
      low   /;  z ≥  227.31484  &&  
          z < 228.36484

magnet1[z_] := 
      high /;   z ≥ 
            228.36484  &&  z <233.31803

magnet1[z_] := 
      low   /;  z ≥  233.31803  &&  
          z < 234.36803

magnet1[z_] := 
      high /;   z ≥ 
            234.36803  &&  z <239.32122

magnet1[z_] := 
      low   /;  z ≥  239.32122  &&  
          z <  240.37122

magnet1[z_] := 
      high /;   z ≥ 
            240.37122  &&  z <245.32441

magnet1[z_] := 
      low   /;  z ≥  245.32441  &&  
          z <  246.37441

magnet1[z_] := 
      high /;   z ≥ 
            246.37441  &&  z <251.3276

magnet1[z_] := 
      low   /;  z ≥  251.32760  &&  
          z <  253.67460

magnet1[z_] := 
      high /;   z ≥ 253.67460  &&  z <258.73079   (* Magnet  41 *)

magnet1[z_] := 
      low   /;  z ≥  258.73079  &&  
          z <  259.78079

magnet1[z_] := 
      high /;   z ≥ 
            259.78079  &&  z <264.73398

magnet1[z_] := 
      low   /;  z ≥  264.73398  &&  
          z <  265.78398

magnet1[z_] := 
      high /;   z ≥ 
            265.78398  &&  z <270.73717

magnet1[z_] := 
      low   /;  z ≥ 270.73717  &&  
          z < 271.78717

magnet1[z_] := 
      high /;   z ≥ 
            271.78717  &&  z <276.74036

magnet1[z_] := 
      low   /;  z ≥  276.74036  &&  
          z < 277.79036

magnet1[z_] := 
      high /;   z ≥ 
            277.79036  &&  z <282.74355

magnet1[z_] := 
      low   /;  z ≥ 282.74355  &&  
          z <  285.19355

magnet1[z_] := 
      high /;   z ≥ 
            285.19355  &&  z <290.14674

magnet1[z_] := 
      low   /;  z ≥  290.14674  &&  
          z <  291.19674

magnet1[z_] := 
      high /;   z ≥ 
            291.19674  &&  z <296.14993

magnet1[z_] := 
      low   /;  z ≥  296.14993  &&  
          z < 297.19993

magnet1[z_] := 
      high /;   z ≥ 
            297.19993  &&  z <302.15312

magnet1[z_] := 
      low   /;  z ≥  302.15312 &&  
          z <  303.20312

magnet1[z_] := 
      high /;   z ≥ 
            303.20312  &&  z <308.15631

magnet1[z_] := 
      low   /;  z ≥  308.15631  &&  
          z <  309.20631

magnet1[z_] := 
      high /;   z ≥ 
            309.20631  &&  z <314.1595

magnet1[z_] := 
      low   /;  z ≥  
            314.1595   &&  z< 316.60950

magnet1[z_] := 
      high /;   z ≥ 
            316.60950  &&  z <321.56269

magnet1[z_] := 
      low   /;  z ≥  
            321.56269  &&  z< 322.61269

magnet1[z_] := 
      high /;   z ≥ 
            322.61269  &&  z <327.56588

magnet1[z_] := 
      low   /;   z ≥   327.56588  &&  
          z <  328.61588

magnet1[z_] := 
      high /;   z ≥ 
            328.61588  &&  z <333.56907

magnet1[z_] := 
      low   /;   z ≥ 333.56907  &&  
          z <  334.61907

magnet1[z_] := 
      high /;   z ≥ 
            334.61907  &&  z <339.57226

magnet1[z_] := 
      low   /;  z ≥  
            339.57226  &&  z< 340.62226

magnet1[z_] := 
      high /;   z ≥ 
            340.62226  &&  z <345.57545

magnet1[z_] := 
      low   /;  z ≥  345.57545  &&  
          z <  348.02545

magnet1[z_] := 
      high /;   z ≥ 
            348.02545  &&  z <352.97864

magnet1[z_] := 
      low   /;  z ≥  352.97864  &&  
          z <  354.02864

magnet1[z_] := 
      high /;   z ≥ 
            354.02864  &&  z <358.98183

magnet1[z_] := 
      low   /;  z ≥  
            358.98183  &&  z< 360.03183

magnet1[z_] := 
      high /;   z ≥ 
            360.03183  &&  z <364.98502

magnet1[z_] := 
      low   /;  z ≥  364.98502  &&  
          z <  366.03502

magnet1[z_] := 
      high /;   z ≥ 
            366.03502  &&  z <370.98821

magnet1[z_] := 
      low   /;  z ≥  370.98821  &&  
          z <  372.03821

magnet1[z_] := 
      high /;   z ≥ 
            372.03821  &&  z <376.99140

magnet1[z_] := 
      low   /;  z ≥  376.99140  &&  
          z <  379.44140

magnet1[z_] := 
      high /;   z ≥ 
            379.44140  &&  z <384.39459

magnet1[z_] := 
      low   /;  z ≥  384.39459  &&  
          z <  385.44459

magnet1[z_] := 
      high /;   z ≥ 
            385.44459  &&  z <390.39778

magnet1[z_] := 
      low   /;  z ≥  390.39778  &&  
          z < 391.44778

magnet1[z_] := 
      high /;   z ≥ 
            391.44778  &&  z <396.40097

magnet1[z_] := 
      low   /;  z ≥  396.40097  &&  
          z <  397.45097

magnet1[z_] := 
      high /;   z ≥ 
            397.45097  &&  z <402.40416

magnet1[z_] := 
      low   /;  z ≥  402.40416  &&  
          z < 403.45416

magnet1[z_] := 
      high /;   z ≥ 
            403.45416  &&  z <408.40735

magnet1[z_] := 
      low   /;  z ≥  408.40735  &&  
          z <  410.85735

magnet1[z_] := 
      high /;   z ≥ 
            410.85735  &&  z <415.81054

magnet1[z_] := 
      low   /;  z ≥  415.81054 &&  
          z <  416.86054

magnet1[z_] := 
      high /;   z ≥ 
            416.86054  &&  z <421.81373

magnet1[z_] := 
      low   /;  z ≥  421.81373  &&  
          z <  422.86373

magnet1[z_] := 
      high /;   z ≥ 
            422.86373  &&  z <427.81692

magnet1[z_] := 
      low   /;  z ≥ 427.81692  &&  
          z <  428.86692

magnet1[z_] := 
      high /;   z ≥ 
            428.86692  &&  z <433.82011

magnet1[z_] := 
      low   /;  z ≥  433.82011  &&  
          z <  434.87011

magnet1[z_] := 
      high /;   z ≥ 
            434.87011  &&  z <439.82330

magnet1[z_] := 
      low   /;  z ≥ 439.82330  &&  
          z <  442.2733

magnet1[z_] := 
      high /;   z ≥ 
            442.27330  &&  z <447.22649

magnet1[z_] := 
      low   /;  z ≥  447.22649  &&  
          z < 448.27649

magnet1[z_] := 
      high /;   z ≥ 
            448.27649  &&  z <453.22968

magnet1[z_] := 
      low   /;  z ≥  453.22968  &&  
          z <  454.27968

magnet1[z_] := 
      high /;   z ≥ 
            454.27968  &&  z <459.23287

magnet1[z_] := 
      low   /;  z ≥  459.23287  &&  
          z < 460.28287

magnet1[z_] := 
      high /;   z ≥ 
            460.28287  &&  z <465.23606

magnet1[z_] := 
      low   /;  z ≥  465.23606  &&  
          z < 466.28606

magnet1[z_] := 
      high /;   z ≥ 
            466.28606  &&  z <471.23925

magnet1[z_] := 
      low   /;  z ≥  471.23925  &&  
          z < 473.68925

magnet1[z_] := 
      high /;   z ≥ 
            473.68925  &&  z <478.64244

magnet1[z_] := 
      low   /;  z ≥  478.64244  &&  
          z <  479.69244

magnet1[z_] := 
      high /;   z ≥ 
            479.69244  &&  z <484.64563

magnet1[z_] := 
      low   /;  z ≥  484.64563  &&  
          z <  485.69563

magnet1[z_] := 
      high /;   z ≥ 
            485.69563  &&  z <490.64882

magnet1[z_] := 
      low   /;  z ≥  490.64882  &&  
          z < 491.69882

magnet1[z_] := 
      high /;   z ≥ 
            491.69882  &&  z <496.65201

magnet1[z_] := 
      low   /;  z ≥  496.65201   &&  
          z < 497.70201

magnet1[z_] := 
      high /;   z ≥ 
            497.70201  &&  z <502.65520

magnet1[z_] := 
      low   /;  z ≥  502.65520  &&  
          z <  505.10520

magnet1[z_] := 
      high /;   z ≥ 
            505.10520  &&  z <510.05839

magnet1[z_] := 
      low   /;  z ≥  510.05839  &&  
          z <  511.10839

magnet1[z_] := 
      high /;   z ≥ 
            511.10839  &&  z <516.06158

magnet1[z_] := 
      low   /;  z ≥  516.06158  &&  
          z <  517.11158

magnet1[z_] := 
      high /;   z ≥ 
            517.11158  &&  z <522.06477

magnet1[z_] := 
      low   /;  z ≥  522.06477  &&  
          z < 523.11477

magnet1[z_] := 
      high /;   z ≥ 
            523.11477  &&  z <528.06796

magnet1[z_] := 
      low   /;  z ≥  528.06796  &&  
          z <  529.11796

magnet1[z_] := 
      high /;   z ≥ 
            529.11796  &&  z <534.07115

magnet1[z_] := 
      low   /;  z ≥  534.07115  &&  
          z < 536.52115

magnet1[z_] := 
      high /;   z ≥ 
            536.52115  &&  z <541.47434

magnet1[z_] := 
      low   /;  z ≥  541.47434  &&  
          z < 542.52434

magnet1[z_] := 
      high /;   z ≥ 
            542.52434  &&  z <547.47753

magnet1[z_] := 
      low   /;  z ≥  547.47753  &&  
          z < 548.52753

magnet1[z_] := 
      high /;   z ≥ 
            548.52753  &&  z <553.48072

magnet1[z_] := 
      low   /;  z ≥ 553.48072  &&  
          z <  554.53072

magnet1[z_] := 
      high /;   z ≥ 
            554.53072  &&  z <559.48391

magnet1[z_] := 
      low   /;  z ≥  559.48391  &&  
          z <  560.53391

magnet1[z_] := 
      high /;   z ≥ 
            560.53391  &&  z <565.4871

magnet1[z_] := 
      low   /;  z ≥  565.48710  &&  
          z <  567.93710

magnet1[z_] := 
      high /;   z ≥ 
            567.93710  &&  z <572.89029

magnet1[z_] := 
      low   /;  z ≥  572.89029  &&  
          z <  573.94029

magnet1[z_] := 
      high /;   z ≥ 
            573.94029  &&  z <578.89348

magnet1[z_] := 
      low   /;  z ≥  578.89348  &&  
          z <  579.94348

magnet1[z_] := 
      high /;   z ≥ 
            579.94348  &&  z <584.89667

magnet1[z_] := 
      low   /;  z ≥  584.89667  &&  
          z < 585.94667

magnet1[z_] := 
      high /;   z ≥ 
            585.94667  &&  z <590.89986

magnet1[z_] := 
      low   /;  z ≥  590.89986 &&  
          z <  591.94986

magnet1[z_] := 
      high /;   z ≥ 
            591.94986  &&  z <596.90305

magnet1[z_] := 
      low   /;  z ≥  596.90305 &&  
          z <  599.35305

magnet1[z_] := 
      high /;   z ≥ 
            599.35305  &&  z <604.30624

magnet1[z_] := 
      low   /;  z ≥ 604.30624  &&  
          z <  605.35624

magnet1[z_] := 
      high /;   z ≥ 
            605.35624  &&  z <610.30943

magnet1[z_] := 
      low   /;  z ≥  610.30943  &&  
          z < 611.35943

magnet1[z_] := 
      high /;   z ≥ 
            611.35943  &&  z <616.31262

magnet1[z_] := 
      low   /;  z ≥ 616.31262 &&  z < 617.36262

magnet1[z_] := 
      high /;   z ≥ 
            617.36262  &&  z <622.31581

magnet1[z_] := 
      low   /;  z ≥  622.31581  &&  
          z <  623.36581

magnet1[z_] := 
      high /;   z ≥ 
            623.36581  &&  z <628.31900

magnet1[z_] := low   /;  z ≥   628.31900

Clear[ytxt];
magnet1names := 
        DisplayTogether[
Graphics[
            Text[StyleForm["1", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["2", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {11, 
                ytxt}]], 
Graphics[
            Text[StyleForm["3", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {17.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["4", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {22.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["5", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {29, 
                ytxt}]], 
Graphics[
            Text[StyleForm["6", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {36, 
                ytxt}]], 
Graphics[
            Text[StyleForm["7", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {42.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["8", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {48, 
                ytxt}]], 
Graphics[
            Text[StyleForm["9", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {54.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["10", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {60.3, 
                ytxt}]], 
Graphics[
            Text[StyleForm["11", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {67.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["12", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {73.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["13", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {80, 
                ytxt}]], 
Graphics[
            Text[StyleForm["14", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {86, 
                ytxt}]], 
Graphics[
            Text[StyleForm["15", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {91.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["16", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {99, 
                ytxt}]], 
Graphics[
            Text[StyleForm["17", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {105, 
                ytxt}]], 
Graphics[
            Text[StyleForm["18", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {111, 
                ytxt}]], 
Graphics[
            Text[StyleForm["19", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {117, 
                ytxt}]], 
Graphics[
            Text[StyleForm["20", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {123.2, 
                ytxt}]], 
Graphics[
            Text[StyleForm["21", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {131, 
                ytxt}]], 
Graphics[
            Text[StyleForm["22", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {136.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["23", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {143, 
                ytxt}]], 
Graphics[
            Text[StyleForm["24", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {149, 
                ytxt}]], 
Graphics[
            Text[StyleForm["25", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {155, 
                ytxt}]], 
Graphics[
            Text[StyleForm["26", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {162, 
                ytxt}]], 
Graphics[
            Text[StyleForm["27", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {168, 
                ytxt}]], 
Graphics[
            Text[StyleForm["28", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {174, 
                ytxt}]], 
Graphics[
            Text[StyleForm["29", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {180, 
                ytxt}]], 
Graphics[
            Text[StyleForm["30", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {186, 
                ytxt}]], 
Graphics[
            Text[StyleForm["31", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {194, 
                ytxt}]], 
Graphics[
            Text[StyleForm["32", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {200, 
                ytxt}]], 
Graphics[
            Text[StyleForm["33", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {206, 
                ytxt}]], 
Graphics[
            Text[StyleForm["34", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {212, 
                ytxt}]], 
Graphics[
            Text[StyleForm["35", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {217, 
                ytxt}]], 
Graphics[
            Text[StyleForm["36", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {225, 
                ytxt}]], 
Graphics[
            Text[StyleForm["37", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {231, 
                ytxt}]], 
Graphics[
            Text[StyleForm["38", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {237, 
                ytxt}]], 
Graphics[
            Text[StyleForm["39", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {243, 
                ytxt}]], 
Graphics[
            Text[StyleForm["40", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {248, 
                ytxt}]], 
Graphics[
            Text[StyleForm["41", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {256, 
                ytxt}]], 
Graphics[
            Text[StyleForm["42", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {262, 
                ytxt}]], 
Graphics[
            Text[StyleForm["43", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {268, 
                ytxt}]], 
Graphics[
            Text[
              StyleForm["44", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {274, 
                ytxt}]], 
Graphics[
            Text[StyleForm["45", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {280, 
                ytxt}]], 
Graphics[
            Text[StyleForm["46", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {287.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["47", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {293.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["48", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {299.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["49", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {305.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["50", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {312, 
                ytxt}]], 
Graphics[
            Text[StyleForm["51", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {319, 
                ytxt}]], 
Graphics[
            Text[StyleForm["52", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {325, 
                ytxt}]], 
Graphics[
            Text[StyleForm["53", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {331, 
                ytxt}]], 
Graphics[
            Text[StyleForm["54", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {337, 
                ytxt}]], 
Graphics[
            Text[StyleForm["55", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {343, 
                ytxt}]], 
Graphics[
            Text[StyleForm["56", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {350.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["57", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {356.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["58", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {362, 
                ytxt}]], 
Graphics[
            Text[StyleForm["59", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {368.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["60", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {374.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["61", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {382, 
                ytxt}]], 
Graphics[
            Text[StyleForm["62", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {388, 
                ytxt}]], 
Graphics[
            Text[StyleForm["63", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {394, 
                ytxt}]], 
Graphics[
            Text[StyleForm["64", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {400, 
                ytxt}]], 
Graphics[
            Text[StyleForm["65", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {406, 
                ytxt}]], 
Graphics[
            Text[StyleForm["66", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {413, 
                ytxt}]], 
Graphics[
            Text[StyleForm["67", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {419.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["68", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {425, 
                ytxt}]], 
Graphics[
            Text[StyleForm["69", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {431, 
                ytxt}]], 
Graphics[
            Text[StyleForm["70", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {437, 
                ytxt}]], 
Graphics[
            Text[StyleForm["71", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {444.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["72", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {450.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["73", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {456.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["74", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {462.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["75", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {468.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["76", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {476, 
                ytxt}]], 
Graphics[
            Text[StyleForm["77", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {482, 
                ytxt}]], 
Graphics[
            Text[StyleForm["78", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {488, 
                ytxt}]], 
Graphics[
            Text[StyleForm["79", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {494, 
                ytxt}]], 
Graphics[
            Text[StyleForm["80", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {500, 
                ytxt}]], 
Graphics[
            Text[StyleForm["81", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {507, 
                ytxt}]], 
Graphics[
            Text[StyleForm["82", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {513.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["83", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {519.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["84", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {525.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["85", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {531.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["86", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {539, 
                ytxt}]], 
Graphics[
            Text[StyleForm["87", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {545, 
                ytxt}]], 
Graphics[
            Text[
              StyleForm["88", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {551, 
                ytxt}]], 
Graphics[
            Text[StyleForm["89", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {557, 
                ytxt}]], 
Graphics[
            Text[StyleForm["90", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {563, 
                ytxt}]], 
Graphics[
            Text[StyleForm["91", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {570.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["92", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {576.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["93", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {582.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["94", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {588.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["95", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {594.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["96", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {602, 
                ytxt}]], 
Graphics[
            Text[StyleForm["97", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {608, 
                ytxt}]], 
Graphics[
            Text[StyleForm["98", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {614, 
                ytxt}]], 
Graphics[
            Text[StyleForm["99", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {620, 
                ytxt}]], 
Graphics[
            Text[StyleForm["100", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {626, 
                ytxt}]]
];

magnet1h1, magnet1h1names

Clear[magnet1h1, magnet1h1names];

low = 0; high = 1; ytxt = 1.5;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{40, 80}, {0, 
              10}}], 
magnet1h1 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 20}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h1names = 
        magnet1names
]

magnet1h5, magnet1h5names

Clear[magnet1h5, magnet1h5names];

low = 0; high = 5; ytxt = 7;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{40, 80}, {0, 
              10}}], 
magnet1h5 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 20}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h5names = 
        magnet1names
]

magnet1h20, magnet1h20names

Clear[magnet1h20, magnet1h20names];

low = 0; high = 20; ytxt = 23;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{40, 80}, {0, 
              25}}], 
magnet1h20 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 20}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h20names = 
        magnet1names
]

magnet1h100, magnet1h100names

Clear[magnet1h100, magnet1h100names];

low = 100; high = 105; ytxt = 110;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{0, 650}, {0, 
              130}}], 
magnet1h100 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 120}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h100names = 
        magnet1names
]

magnet1h110, magnet1h110names

Clear[magnet1h110, magnet1h110names];

low = 110; high = 115; ytxt = 120;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{0, 650}, {0, 
              130}}], 
magnet1h110 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 120}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h110names = 
        magnet1names
]

magnet1h120, magnet1h120names

Clear[magnet1h120, magnet1h120names];

low = 120; high = 125; ytxt = 130;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{0, 650}, {0, 
              140}}], 
magnet1h120 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 120}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h120names = 
        magnet1names
]

magnet1h130, magnet1h130names

Clear[magnet1h130, magnet1h130names];

low = 130; high = 135; ytxt = 140;
DisplayTogether[
Plot[0, {s, 20, 40}, 
        PlotRange -> {{0, 650}, {0, 
              140}}], 
magnet1h130 = 
        Plot[magnet1[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 120}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 1000], 
magnet1h130names = 
        magnet1names
]

Magnet position. Every 5 magnets

magnet5, magnet5names

Clear[magnet5, magnet5names, low, high, ytxt]

magnet5[z_] := low /;  z <     2.45000

magnet5[z_] := 
      high /;  
        z ≥     2.45000  &&  z<     7.40319   (* Magnet  1 *)

magnet5[z_] := 
      low /;  z ≥     7.40319  &&  
          z <    26.46276

magnet5[z_] := 
      high /;  
        z ≥   26.46276  &&  z<  31.41595    (* 
              Magnet  5 *)

magnet5[z_] := 
      low /;  z ≥   31.41595  &&  
          z <   57.87871

magnet5[z_] := 
      high /;  
        z ≥   57.87871  &&  z<  62.83190   (* Magnet 10 *)

magnet5[z_] := 
      low /;  z ≥   62.83190  &&  
          z <   89.29466

magnet5[z_] := 
      high /;  
        z ≥   89.29466  &&  z<  94.24785   (* Magnet 15 *)

magnet5[z_] := 
      low /;  z ≥   94.24785  &&  z < 120.71061

magnet5[z_] := 
      high /;  z ≥ 
            120.71061  &&  z<125.66380

magnet5[z_] := 
      low /;  z ≥ 125.66380  &&  z < 152.12656

magnet5[z_] := 
      high /;  z ≥ 
            152.12656  &&  z<157.07975

magnet5[z_] := 
      low /;  z ≥ 157.07975  &&  z < 183.54251

magnet5[z_] := 
      high /;  z ≥ 
            183.54251  &&  z<188.49570

magnet5[z_] := 
      low /;  z ≥ 
            188.49570  &&  z<214.95846

magnet5[z_] := 
      high /;  z ≥ 
            214.95846  &&  z<219.91165

magnet5[z_] := 
      low /;  z ≥ 
            219.91165  &&  z<246.37441

magnet5[z_] := 
      high /;  z ≥ 
            246.37441  &&  z<251.32760

magnet5[z_] := 
      low /;  z ≥ 251.32760  &&  z < 277.79036

magnet5[z_] := 
      high /;  z ≥ 
            277.79036  &&  z<282.74355

magnet5[z_] := 
      low /;  z ≥ 282.74355  &&  z < 309.20631

magnet5[z_] := 
      high /;  z ≥ 
            309.20631  &&  z<314.15950

magnet5[z_] := 
      low /;  z ≥ 314.15950  &&  z < 340.62226

magnet5[z_] := 
      high /;  z ≥ 
            340.62226  &&  z<345.57545

magnet5[z_] := 
      low /;  z ≥ 
            345.57545  &&  z<372.03821

magnet5[z_] := 
      high /;  z ≥ 
            372.03821  &&  z<376.99140

magnet5[z_] := 
      low /;  z ≥ 
            376.99140  &&  z<403.45416

magnet5[z_] := 
      high /;  z ≥ 
            403.45416  &&  z<408.40735

magnet5[z_] := 
      low /;  z ≥ 
            408.40735  &&  z<434.87011

magnet5[z_] := 
      high /;  z ≥ 
            434.87011  &&  z<439.82330

magnet5[z_] := 
      low /;  z ≥ 439.82330  &&  z < 466.28606

magnet5[z_] := 
      high /;  z ≥ 
            466.28606  &&  z<471.23925

magnet5[z_] := 
      low /;  z ≥ 
            471.23925  &&  z<497.70201

magnet5[z_] := 
      high /;  z ≥ 
            497.70201   &&  z<502.65520

magnet5[z_] := 
      low /;  z ≥ 502.65520  &&  z < 529.11796

magnet5[z_] := 
      high /;  z ≥ 
            529.11796  &&  z<534.07115

magnet5[z_] := 
      low /;  z ≥ 534.07115  &&  z < 560.53391

magnet5[z_] := 
      high /;  z ≥ 
            560.53391  &&  z<565.48710

magnet5[z_] := 
      low /;  z ≥ 
            565.48710  &&  z<591.94986

magnet5[z_] := 
      high /;  z ≥ 
            591.94986  &&  z<596.90305

magnet5[z_] := 
      low /;  z ≥ 596.90305  &&  z < 623.36581

magnet5[z_] := 
      high /;  
        z ≥ 623.36581  &&  z<628.31900  (* Magnet 100 *)

magnet5[z_] := low /;  z ≥ 628.31900

magnet5names := 
        DisplayTogether[
Graphics[
            Text[StyleForm["1", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["5", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {29, 
                ytxt}]], 
Graphics[
            Text[StyleForm["10", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {59, 
                ytxt}]], 
Graphics[
            Text[StyleForm["15", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {91.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["20", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {123, 
                ytxt}]], 
Graphics[
            Text[StyleForm["25", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {154, 
                ytxt}]], 
Graphics[
            Text[StyleForm["30", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {185, 
                ytxt}]], 
Graphics[
            Text[StyleForm["35", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {217, 
                ytxt}]], 
Graphics[
            Text[StyleForm["40", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {248, 
                ytxt}]], 
Graphics[
            Text[StyleForm["45", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {280, 
                ytxt}]], 
Graphics[
            Text[StyleForm["50", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {312, 
                ytxt}]], 
Graphics[
            Text[StyleForm["55", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {343, 
                ytxt}]], 
Graphics[
            Text[StyleForm["60", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {374.5, 
                ytxt}]], 
Graphics[
            Text[StyleForm["65", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {405, 
                ytxt}]], 
Graphics[
            Text[StyleForm["70", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {436, 
                ytxt}]], 
Graphics[
            Text[StyleForm["75", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {468, 
                ytxt}]], 
Graphics[
            Text[StyleForm["80", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {499, 
                ytxt}]], 
Graphics[
            Text[StyleForm["85", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {531, 
                ytxt}]], 
Graphics[
            Text[StyleForm["90", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {562, 
                ytxt}]], 
Graphics[
            Text[StyleForm["95", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {594, 
                ytxt}]], 
Graphics[
            Text[StyleForm["100", FontSize -> 16, 
                FontColor -> RGBColor[0, 0, 1]], {623, 
                ytxt}]]
];

magnet5h2, magnet5h2names

Clear[magnet5h2, magnet5h2names];
low = 2; high = 2.5; ytxt = 2.7;
DisplayTogether[
magnet5h2 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 10}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h2names = 
        magnet5names
]

magnet5h1, magnet5h1names

Clear[magnet5h1, magnet5h1names];
low = 0; high = 1; ytxt = 1.5;
DisplayTogether[
magnet5h1 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 10}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h1names = 
        magnet5names
]

magnet5h5, magnet5h5names

Clear[magnet5h5, magnet5h5names];
low = 0; high = 5; ytxt = 11;
DisplayTogether[
magnet5h5 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 10}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h5names = 
        magnet5names
]

magnet5h100, magnet5h100names

Clear[magnet5h100, magnet5h100names];
low = 100; high = 105; ytxt = 110;
DisplayTogether[
magnet5h100 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 135}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h100names = 
        magnet5names
]

magnet5h120, magnet5h120names

Clear[magnet5h120, magnet5h120names];
low = 120; high = 125; ytxt = 130;
DisplayTogether[
magnet5h120 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 135}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h120names = 
        magnet5names
]

magnet5h130, magnet5h130names

Clear[magnet5h130, magnet5h130names];
low = 130; high = 135; ytxt = 140;
DisplayTogether[
magnet5h130 = 
        Plot[magnet5[s], {s, 0, 640}, PlotRange -> {{0, 640}, {0, 135}}, 
          PlotStyle -> RGBColor[0, 0, 1], 
          PlotPoints -> 200], 
magnet5h130names = 
        magnet5names
]

Define functions for Aperture

GetField

Clear[GetField];
\(GetField[fields_, i_] := 
      Module[{}, 
If[
          Length[fields] < i\  || \ 
            fields[\([i]\)] == "", {"0", "Error"}, {fields[\([i]\)], "OK"}]
]\)

TestWithWarningFieldRealQ

Clear[TestWithWarningFieldRealQ];
TestWithWarningFieldRealQ[fields_, n_, Errormessage_] := 
      If[ GetField[fields, 
              n][[2]] != "Error", 
If[
          Head[fields[[n]]] === Real || 
            Head[fields[[n]]] === 
              Integer , 
True, 
Print[
            Errormessage]; False], 
Print[Errormessage]; 
        False
]

TestWithWarningFieldWordQ

Clear[TestWithWarningFieldWordQ];
TestWithWarningFieldWordQ[fields_, n_, Errormessage_] := 
      If[ GetField[fields, n][[2]] != "Error", 
        If[Head[fields[[n]]] == String, True, Print[Errormessage]; 
          False], 
Print[Errormessage]; 
        False
]

ReadLine

Clear[ReadLine];
ReadLine[line_, n_, section_, sectiontype_, start_, end_, 
        type_, hor_, horext_, horint_, offset_, ver_, Rs1_, Rl1_, Rs2_, Rl2_, 
        Rc_]:=Module[ {fields, Error},
Error = 0;
section = -1;sectiontype = -1;start = -1;end = -1;type = -1;hor = -1;horext = -1;horint = -1;offset = -1;ver = -1;Rs1 = -1;Rl1 = -1;Rs2 = -1;Rl2 = -1;Rc = -1;
fields = line ;
If[line == {}, 
              If[Error == 0, Error = -1;]; Return[Error];];


  
If[
TestWithWarningFieldRealQ[
                  fields,   1, "Error reading: section         in line: \
" <> ToString[n]], section = 
                    fields[[1]];, 
section = -1; 
                If[Error == 0, Error = -1];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,   4, "Error reading: sectiontype     in line: \
" <> ToString[n]], sectiontype = fields[[4]]; 
                If[sectiontype == 10, Error = -1; 
                  Return[Error]];, 
sectiontype = -1; 
                If[Error == 0, Error = -1];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,    6, "Error reading: start          in line: \
" <> ToString[n]], 
start     = 
                    fields[[6]];, 
If[Error == 0, 
                    Error = -10];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,    7, "Error reading: end            in line: \
" <> ToString[n]], 
end          = 
                    fields[[7]];, 
If[Error == 0, 
                    Error = -10];
];

  
If[
TestWithWarningFieldWordQ[
                  fields,    9, "Error reading: type           in line: \
" <> ToString[n]], 
type       = 
                    fields[[9]];, 
If[Error == 0, 
                    Error = -10];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,  
                  11, "Error reading: hor            in line: " <> 
                    ToString[n]], 
hor         = 
                    fields[[11]];, 
If[Error == 0, 
                    Error = -11];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,  
                  12, "Error reading: horext         in line: " <> 
                    ToString[
                      n]], 
horext         = 
                    fields[[12]];, 
If[Error == 0, 
                    Error = -11];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,  
                  12, "Error reading: horint         in line: " <> 
                    ToString[
                      n]], 
horint         = 
                    fields[[13]];, 
If[Error == 0, 
                    Error = -11];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,  
                  15, "Error reading: offset         in line: " <> 
                    ToString[n]], 
offset  = 
                    fields[[15]];, 
If[Error == 0, 
                    Error = -11];
];

  
If[
TestWithWarningFieldRealQ[
                  fields,  
                  16, "Error reading: ver            in line: " <> 
                    ToString[n]], 
ver         = 
                    fields[[16]];, 
If[Error == 0, 
                    Error = -10];
];

  
\(If[
\ \ TestWithWarningFieldRealQ[fields, 
                17, "Error reading: Rs1            in line: " <> 
                  ToString[n]], 
\(Rs1\ \ \ \ \ \ \ \  = 
                  fields[\([17]\)];\), 
\(If[Error == 0, 
                  Error = \(-2\)];\)
]\);

  
If[
TestWithWarningFieldRealQ[fields, 
                18, "Error reading: Rl1            in line: " <> 
                  ToString[n]], 
Rl1         = 
                  fields[[18]];, 
If[Error == 0, 
                  Error = -2];
];

  
If[
TestWithWarningFieldRealQ[fields, 
                19, "Error reading: Rs2            in line: " <> 
                  ToString[n]], 
Rs2         = 
                  fields[[19]];, 
If[Error == 0, 
                  Error = -3];
];

  
If[
TestWithWarningFieldRealQ[fields, 
                20, "Error reading: Rl2            in line: " <> 
                  ToString[n]], 
Rl2         = 
                  fields[[20]];, 
If[Error == 0, 
                  Error = -3];
];

  
\(If[
\ \ \ type == "st.cir", 
If[
\ \ TestWithWarningFieldRealQ[fields, 
                  21, "Error reading: Rc             in line: " <> 
                    ToString[
                      n]]\ , 
\ \ \(Rc\ \ \ \ \ \ \ \ \ \  = fields[\([21]\)];\)
\ , \(If[Error == 0, 
                    Error = \(-4\)];\)]
]\);

Return[Error]
]

CheckSections

Clear[CheckSections];   
CheckSections[Ap_, line_, sec_]:=Module[ {Error,  state, oldstate, section, oldsection, 
              sectiontype, oldsectiontype, count, sectiontypeunknown, 
              blankline, skipline, i},
Error = 0;
state = 0;
oldstate = 0;
section = 0;
oldsection  =  0;
sectiontype = 0;
oldsectiontype = 0;
count = 0;
For[i = 1,i < Length[Ap],i++,

oldstate = state;
section                 = Ap[[i]][[2]];
sectiontype        = Ap[[i]][[3]];
blankline            =  Ap[[i]][[1]] == -1;

sectiontypeunknown = 
                      sectiontype ≠ 0  &&  
                        sectiontype ≠ 1  &&  
                        sectiontype ≠ 2;
skipline                         =  sectiontype == 10;

If[
                      skipline  ==  True,  Continue[];];

Which[
state == 0  &&  blankline,state = 0,         
state == 0  && 
                          sectiontypeunknown,state = 0,     
state == 0  &&  
                          sectiontype == 0,state = 1,             
state == 0  &&  
                          sectiontype == 1,state = 1,             
state == 0  &&  
                          sectiontype == 2,state = 2,
state == 1  &&  
                          blankline,state = 3,
state == 1  &&  
                          sectiontypeunknown,state = 3,
state == 1  &&  
                          sectiontype == 0,state = 1,
state == 1  &&  
                          sectiontype == 1,state = 1,
state == 1  &&  
                          sectiontype == 2,state = 2,
state == 2  &&  
                          blankline,state = 3,
state == 2  && 
                          sectiontypeunknown,state = 3,
state == 2  &&  
                          sectiontype == 0,state = 1,
state == 2  &&  
                          sectiontype == 1,state = 1,
state == 2  &&  
                          sectiontype == 2,state = 2,
state == 3  &&  
                          blankline,state = 3,
state == 3  && 
                          sectiontypeunknown,state = 3,
state == 3  &&  
                          sectiontype == 0,state = 1,
state == 3  &&  
                          sectiontype == 1,state = 1,
state == 3  &&  
                          sectiontype == 2,state = 2
];


  

\(If\ [
                      state == 1\  && \ 
                        oldstate == 0, 
If[
                        section ≠ 1\  || \ 
                          sectiontype ≠ 
                            1, 
Print["Error. First Section. section=", section, " sectiontype=", 
                          sectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);

\(If[
                      state == 1\  && \ 
                        oldstate == 1, 
If[
                        section ≠ \ 
                          oldsection, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);

\(If[
                      state == 1\  && \ 
                        oldstate == 2, 
If[
                        section ≠ \ 
                          oldsection + 
                            1, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);


\(If[
                      state == 1\  && \ 
                        oldstate == 3, 
If[
                        section ≠ \ 
                          oldsection + 
                            1, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);


\(If[
                      state == 2\  && \ 
                        oldstate == 
                          0, 
Print["state=", 
                        state, "  oldstate=", 
                        oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                        sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                        oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                        i - 1]; 
sec = 
                        oldsection; 
line = 
                        i - 1; 
Error = \(-1\); 
Break[];
]\);


\(If[
                      state == 2\  && \ 
                        oldstate == 1, 
If[
                        section ≠ \ 
                          oldsection, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);


\(If[
                      state == 2\  && \ 
                        oldstate == 2, 
If[
                        section ≠ \ 
                          oldsection, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);


\(If[
                      state == 2\  && \ 
                        oldstate == 3, 
If[
                        section ≠ \ 
                          oldsection, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["The file is only valid to section ", oldsection, " corresponding to line ", 
                          i - 1]; 
sec = 
                          oldsection; 
line = 
                          i - 1; 
Error = \(-1\); 
Break[];
]; 
count\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \  = 
                        0; 
oldsection\ \ \ \ \ \ \ \ \  = 
                        section; 
oldsectiontype = 
                        sectiontype;
]\);





\(If[
                      state == 3\  && \ 
                        oldstate == 
                          3, 
\(count++\); 
If[count > 7, 
Print["state=", 
                          state, "  oldstate=", 
                          oldstate]; 
Print["Error.  section=", section, " sectiontype=", 
                          sectiontype]; 
Print["Error.  oldsection=", oldsection, " oldsectiontype=", 
                          oldsectiontype]; 
Print["Error.  count=", 
                          count, " Number of consecutive times in state 2"]; 
Print["The file is only valid to section ", 
                          oldsection, " corresponding to line ", 
                          i - 9]; 
sec = 
                          oldsection; 
line = 
                          i - 9; 
Error = \(-1\); 
Break[];
];
]\);

];  
Return[Error]
]

CheckAllSectorLengths

Clear[CheckAllSectorLengths];   
CheckAllSectorLengths[Ap_, maxline_]:=Module[ \({Error, sect, typ, beginline, endline, 
          i}, 
Error = 0; 
sect = 
          1; 
typ = 
          1; 


For[
          i = 3, i < 
            maxline, \(i++\), 

Clear[
            beginline, endline]; 
Error\  = \ 
            CheckSectorLength[Ap, maxline, i, beginline, endline, sect, 
              typ]; 
While[\ 
            beginline\  ≠ \ True\  && \ 
              endline ≠ \ 
                True, 
\(i++\); 
Clear[
              beginline, endline]; 
Error\  = \ 
              CheckSectorLength[Ap, maxline, i, beginline, endline, sect, 
                typ]; 
If[
              i ≥ \ maxline + 2, \ Error = \(-3\); 
              Break[];];
]; 

 (*\ \(Print["maxline ", maxline, " sect ", 
                sect, 
" typ =", 
                typ, " beginline = ", \ beginline, \ " endline = ", \ 
                endline, " Error =", Error, \ " i =", 
                i\ ];\)\ \ *) 

If[
            Error\  == \(-3\), 
            Print[" Error. Section ", 
              sect, " does not exist or sectiontype ", 
              typ, " does not exist for this section. Error = ", \ 
              Error]; \ Break[];]; 

If[
            typ == 0\  || \ 
              typ == 1, 
\(typ = 
                2;\), 
\(sect++\); 
If[\ 
              sect == 1\  || \ sect == 6\  || sect == 11\  || 
                sect == 16\  || sect == 21\  || 
                sect == 26\  || sect == 31\  || 
                sect == 36\  || sect == 41\  || 
                sect == 46\  || sect == 51\  || 
                sect == 56\  || sect == 61\  || 
                sect == 66\  || sect == 71\  || 
                sect == 76\  || sect == 81\  || 
                sect == 86\  || sect == 91\  || 
                sect == 96\ , \(typ = 1;\), \(typ = 
                  0;\)];
];

]; 

Return[Error]\)
]

CheckSectorLength

Clear[CheckSectorLength];
CheckSectorLength[Ap_, maxline_, line_, beginline_, endline_, 
        sect_, typ_]:=Module[ {Error, lines,  state, oldstate, section, sectiontype, i, 
            sectiontypeunknown, blankline},
Error = 0;
state = 0;
oldstate  =  0;
section = 0;
sectiontype = 0;
lines = {};
beginline = False;
endline = False;

  

For[i = Max[3, line - 15],i < maxline + 2,i++,

section                 = Ap[[i]][[2]];
sectiontype        = Ap[[i]][[3]];

  


blankline = Ap[[i]][[1]] == -1;
sectiontypeunknown = 
                    sectiontype ≠ 0  &&  
                      sectiontype ≠ 1  &&  
                      sectiontype ≠ 2;
endoffile  =  
                    i ≥ maxline;
skipline    =  
                    sectiontype == 10;

If[
                    skipline  ==  True,  Continue[];];


If[
                    state == 0, 
If[
                      section  <  sect,  
                      Continue[]]; 
If[section  >  sect, 
                      Error = -2; Break[]];
];


oldstate               = state;


  
Which[
state == 0  &&  
                        sectiontype == typ,state = 1,
state == 1  &&  
                        sectiontype ≠  typ,state = 2,
state == 1  &&  
                        blankline,state = 2,   
state == 1  &&  
                        endoffile == True, state = 2   
];

  


  
If[
                    state == 1  &&  oldstate == 0, lines = {i}; 
                    If[line == i, beginline = True];];

If[
                    state == 1  &&  
                      oldstate == 1, lines = Join[lines, {i}];];

If[state == 2  &&  oldstate == 1,

  

If[line == lines[[Length[lines]]], 
                          endline = True];

  
\(If[\(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)] == 
                              0\  && \ \((\(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)] ≠ 
                                  0\  || \ \(Ap[\([lines[\([Length[
                                        lines]]\)]]\)]\)[\([5]\)] ≠ 
                                  1050)\), 
Error = \(-1\); 
Print["Error in CheckSectorLength. Section ", \(Ap[\([lines[\([1]\)]]\)]\)[\([2]\)], " section type ", \(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)], " start =", \(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)], " end = ", \ \(Ap[\([lines[\([Length[lines]]\)]]\)]\)[\([5]\)]\ ];
]\);

  
\(If[\(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)] == 
                              1\  && \ \((\(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)] ≠ 
                                  0\  || \ \(Ap[\([lines[\([Length[
                                        lines]]\)]]\)]\)[\([5]\)] ≠ 
                                  2450)\), 
Error = \(-1\); 
Print["Error in CheckSectorLength. Section ", \(Ap[\([lines[\([1]\)]]\)]\)[\([2]\)], " section type ", \(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)], " start =", \(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)], " end = ", \(Ap[\([lines[\([Length[
                                        lines]]\)]]\)]\)[\([5]\)]\ ];
]\);

  
\(If[\(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)] == 
                              2\  && \((\(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)] ≠ 0\  || \ \(Ap[\([lines[\([Length[lines]]\)]]\)]\)[\([5]\)] < 
                                  4941.4 - 
                                    11.79 || \ \(Ap[\([lines[\([Length[
                                        lines]]\)]]\)]\)[\([5]\)] > 
                                  4941.4 + 
                                    11.79)\), 
Error = \(-1\); 
Print["Error in CheckSectorLength. Section ", \(Ap[\([lines[\([1]\)]]\)]\)[\([2]\)], " section type ", \(Ap[\([lines[\([1]\)]]\)]\)[\([3]\)], " start =", \(Ap[\([lines[\([1]\)]]\)]\)[\([4]\)], " end = ", \ \(Ap[\([lines[\([Length[lines]]\)]]\)]\)[\([5]\)]\ ];
]\);

Break[];
]; 




];   


Return[Error]
]

GetVerA