bmad-sim / bmad-ecosystem

Bmad simulation ecosystem for simulating high energy storage rings.
https://www.classe.cornell.edu/bmad/
13 stars 15 forks source link

BUG: Tao setting quad offsets does not affect orbit data, but does affect plot. #1311

Closed ChristopherMayes closed 2 days ago

ChristopherMayes commented 3 days ago

Describe the bug Setting the offset of a superimposed quad (with nonzero k1) in Tao does not change the orbit.

To Reproduce lat.bmad:

beginning[beta_a] = 10
beginning[beta_b] = 10
beginning[e_tot] = 100e6
parameter[geometry] = open

p1: pipe, L = 1
q1: quad, L = 0.1, superimpose, ref = p1, k1 = 1

lat: line = (p1)

use, lat

Run Tao.


tao -lat lat.bmad
[MESSAGE | 2024-NOV-19 10:42:09] tao_init:
    OpenMP active with number of threads: 12
[MESSAGE | 2024-NOV-19 10:42:09] bmad_parser:
    Lattice parse time(min): 0.00

Tao> set ele q1 x_offset = 0.001

Tao> sho value ele::q1[orbit.x]
     0.0000000000000000E+00

Tao> sho lat -at orbit.x
# Values shown are for the Downstream End of each Element (Girder at ref point):
# Index  name      key                      s       l     orbit.x
      0  BEGINNING Beginning_Ele        0.000     ---  0.0000E+00
      1  P1#1      Pipe                 0.450   0.450  0.0000E+00
      2  P1\Q1     Quadrupole           0.550   0.100  0.0000E+00
      3  P1#2      Pipe                 1.000   0.450  0.0000E+00
      4  END       Marker               1.000   0.000  0.0000E+00
Lord Elements:
      5  P1        Pipe                 1.000   1.000  0.0000E+00
      6  Q1        Quadrupole           0.550   0.100  0.0000E+00
# Index  name      key                      s       l     orbit.x
# Values shown are for the Downstream End of each Element (Girder at ref point):

Notice, however, that the plot shows the orbit deviation.

image

Expected behavior The value is expected to change to:

Tao> sho value ele::q1[orbit.x]
     4.9958347219740927E-06

This can be seen by putting q1[x_offset] = 0.001 into lat.bmad

Compiler and Operating system macOS with gcc13

ChristopherMayes commented 3 days ago

Last correct version:

conda install bmad=20241019.0 

...

Tao: show version
Date: 2024/10/14 20:57:28

Tao: set ele q1 x_offset = 0.001

Tao: sho value ele::q1[orbit.x]
     4.9958347219740927E-06
ChristopherMayes commented 3 days ago

The first appearance of the bug:

conda install bmad=20241023.0 
Tao: show version
Date: 2024/10/22 15:23:19

Tao: set ele q1 x_offset = 0.001

Tao: sho value ele::q1[orbit.x]
     0.0000000000000000E+00
DavidSagan commented 2 days ago

Fixed. This was a bookkeeping bug. Ironically enough, the bug was created in my quest to make Bmad faster. And I have added a regression test for this.