# example/14_nonlinear_dynamics/normal_form/k0_ampnf.py の出力 (k64、D = 5、nslice = 8、nslice_bend = 4。3 GeV の小さな FODO + 3 極の挿入光源 K0 = a・(1, -2, 1) rad、a = 0.06 (mpw_big は 0.075、pi_neg は -0.06))。
# mpw_big は垂直のチューンが 0.953 で整数に近い (最小の分母 0.03)。
## mpw {'a': 0.06}
  閉軌道 (リング先頭) |c| = 0.00e+00、ν0 = (0.696500, 0.932463)、結合 0.0e+00、最小の分母 0.209
  J¹ (ampnf) xx xy yy = 409.32 -429.38 615.16、ξ1 = 9.961 10.548
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.1e-07 (νx)、1.1e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.4e-07 (νx)、7.3e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 6.7e-07 (νx)、1.2e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 3.4e-07 (νx)、3.7e-06 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.32 -429.28 614.10、ampnf との相対差 8.3e-06 2.3e-04 1.7e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.3e-03 h20001 1.2e-04 h02001 1.2e-04
D:\work\SAD-master\Claude outputs\pysad\ampnf.py:609: RuntimeWarning: divide by zero encountered in scalar divide
  tw += [(m[0, 0] - m[1, 1]) / (2 * sm), m[0, 1] / sm]
D:\work\SAD-master\Claude outputs\pysad\ampnf.py:612: RuntimeWarning: invalid value encountered in scalar divide
  [0, 0, math.sqrt(by), 0], [0, 0, -ay / math.sqrt(by), 1 / math.sqrt(by)]])
Traceback (most recent call last):
  File "D:\work\SAD-master\Claude outputs\example_nonlinear_dynamics
ormal_form\k0_ampnf.py", line 81, in <module>
    run(k)
  File "D:\work\SAD-master\Claude outputs\example_nonlinear_dynamics
ormal_form\k0_ampnf.py", line 55, in run
    r = A.amplitude_tune(lat, D=D, nslice=8, **OPT)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\work\SAD-master\Claude outputs\pysad\ampnf.py", line 917, in amplitude_tune
    res = one_turn_series(lat, D=D, nslice=nslice, sd=sd, s=s, ops=ops, bend_cubic=bend_cubic, nslice_bend=nslice_bend, kin=kin, fringe=fringe, nslice_quad=nslice_quad)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\work\SAD-master\Claude outputs\pysad\ampnf.py", line 728, in one_turn_series
    Am, Ai, mus, tw, cpl = linear_modes(A)
                           ^^^^^^^^^^^^^^^
  File "D:\work\SAD-master\Claude outputs\pysad\ampnf.py", line 613, in linear_modes
    return Am, np.linalg.inv(Am), tuple(mus), tuple(tw), cpl
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\coding\AppData\Roaming\Python\Python312\site-packages\numpy\linalg\_linalg.py", line 659, in inv
    ainv = _umath_linalg.inv(a, signature=signature)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\coding\AppData\Roaming\Python\Python312\site-packages\numpy\linalg\_linalg.py", line 144, in _raise_linalgerror_singular
    raise LinAlgError("Singular matrix")
numpy.linalg.LinAlgError: Singular matrix
## mpw_big {'a': 0.075}
  閉軌道 (リング先頭) |c| = 0.00e+00、ν0 = (0.696596, 0.952744)、結合 0.0e+00、最小の分母 0.030
  J¹ (ampnf) xx xy yy = 409.38 -509.17 987.37、ξ1 = 9.962 12.462
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 1.2e-07 (νx)、1.5e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 2.0e-07 (νx)、1.0e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 1.2e-05 (νx)、9.5e-05 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 4.1e-06 (νx)、3.9e-05 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.65 -508.71 985.51、ampnf との相対差 6.6e-04 9.0e-04 1.9e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 2.1e-03 h20001 1.8e-04 h02001 1.8e-04
## mpw_ang {'a': 0.06, 'ang': 0.01}
  閉軌道 (リング先頭) |c| = 1.64e-04、ν0 = (0.700457, 0.938134)、結合 0.0e+00、最小の分母 0.140
  J¹ (ampnf) xx xy yy = 411.39 -439.84 671.32、ξ1 = 9.943 10.834
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.2e-07 (νx)、1.2e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.5e-07 (νx)、7.7e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 1.0e-07 (νx)、4.4e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 9.0e-07 (νx)、4.3e-06 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 411.37 -439.73 670.16、ampnf との相対差 5.4e-05 2.5e-04 1.7e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.0e+00 h20001 2.9e-02 h02001 2.9e-02
## mpw_edge {'a': 0.06, 'ang': 0.01, 'e': (0.5, 0.5)}
  閉軌道 (リング先頭) |c| = 2.42e-05、ν0 = (0.696574, 0.944719)、結合 0.0e+00、最小の分母 0.131
  J¹ (ampnf) xx xy yy = 409.36 -466.03 780.17、ξ1 = 9.961 11.433
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.3e-07 (νx)、1.4e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.5e-07 (νx)、8.8e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 1.9e-06 (νx)、1.7e-05 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 1.7e-08 (νx)、1.1e-05 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.35 -465.92 778.78、ampnf との相対差 2.0e-05 2.2e-04 1.8e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.0e+00 h20001 4.1e-03 h02001 4.1e-03
## tilt {'a': 0.06, 'rot': 0.2}
  閉軌道 (リング先頭) |c| = 0.00e+00、ν0 = (0.697165, 0.931351)、結合 5.0e-02、最小の分母 0.143
  J¹ (ampnf) xx xy yy = 409.30 -425.31 605.04、ξ1 = 9.956 10.492
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.1e-07 (νx)、1.1e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.4e-07 (νx)、7.2e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 3.0e-07 (νx)、1.3e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 3.6e-06 (νx)、2.3e-07 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.29 -425.22 604.00、ampnf との相対差 2.8e-05 2.2e-04 1.7e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.4e-03 h10011 9.6e-04 h10101 5.0e-04
## pi {'a': 0.06, 'rot': 3.141592653589793}
  閉軌道 (リング先頭) |c| = 0.00e+00、ν0 = (0.696500, 0.932463)、結合 3.1e-17、最小の分母 0.138
  J¹ (ampnf) xx xy yy = 409.32 -429.36 615.05、ξ1 = 9.961 10.548
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.1e-07 (νx)、1.1e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.4e-07 (νx)、7.3e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 6.7e-07 (νx)、1.2e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 3.4e-07 (νx)、3.7e-06 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.32 -429.26 613.99、ampnf との相対差 8.3e-06 2.3e-04 1.7e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.3e-03 h20001 1.2e-04 h02001 1.2e-04
## pi_neg {'a': -0.06}
  閉軌道 (リング先頭) |c| = 0.00e+00、ν0 = (0.696500, 0.932463)、結合 0.0e+00、最小の分母 0.209
  J¹ (ampnf) xx xy yy = 409.32 -429.36 615.05、ξ1 = 9.961 10.548
  (Jx, Jy, δ) = (1e-06, 1e-06, 0): |追跡 − 級数| = 2.1e-07 (νx)、1.1e-06 (νy)
  (Jx, Jy, δ) = (2e-06, 5e-07, 0): |追跡 − 級数| = 3.4e-07 (νx)、7.3e-07 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, 0.001): |追跡 − 級数| = 6.7e-07 (νx)、1.2e-06 (νy)
  (Jx, Jy, δ) = (1e-06, 1e-06, -0.001): |追跡 − 級数| = 3.4e-07 (νx)、3.7e-06 (νy)
  J¹ (追跡 + NAFF のフィット) xx xy yy = 409.32 -429.26 613.99、ampnf との相対差 8.3e-06 2.3e-04 1.7e-03
  h (ampnf 対 追跡の 2 次のテイラー展開) の相対差の最大: h10002 1.3e-03 h20001 1.2e-04 h02001 1.2e-04
