bmad-sim / pytao

PyTao is Python interface for Tao, which is based on the Bmad subroutine library for relativistic charged–particle and X-ray simulations in accelerators and storage rings.
https://bmad-sim.github.io/pytao
GNU General Public License v3.0
9 stars 6 forks source link

Inconsistent quadrupole b1_gradient after issuing cavity phase & quad b1_gradient adjustments #74

Open MichaelEhrlichman opened 1 month ago

MichaelEhrlichman commented 1 month ago

pytao_bug_mwe.tar.gz

Example output:

$ ls                                                                                                                
bug.py  bugreport.lat                                                                                                                                                                                   
$ ./bug.py 1                                                                                                        
Issuing commands with tao.cmds and then set uni 1 recalculate.  Bug evident.                                                                                                                            
model b1_gradient:  0.0700389223336539                                                                                                                                                                  
model b1_gradient:  8.17823368208077                                                                                                                                                                    
model b1_gradient:  10.0                                                                                                                                                                                
model b1_gradient:  10.0
$ ./bug.py 2
Issuing commands with tao.cmds and then set glo lattice_calc_on=T.  Bug evident.
model b1_gradient:  0.0700389223336539
model b1_gradient:  8.17823368208077
model b1_gradient:  10.0
model b1_gradient:  10.0
$ ./bug.py 3
Issuing commands with tao.cmds with suppress_lattice_calc=F.  No bug.
model b1_gradient:  0.0700389223336539
model b1_gradient:  10.0
model b1_gradient:  10.0
model b1_gradient:  10.0
$ ./bug.py 4
Issuing commands by iterating tao.cmd.  No bug.
model b1_gradient:  0.0700389223336539
model b1_gradient:  10.0
model b1_gradient:  10.0
model b1_gradient:  10.0
MichaelEhrlichman commented 1 month ago

MWE also copied to lnx201.lns.cornell.edu at /home/ehrlichm/for_dcs/91/MWE.

ChristopherMayes commented 1 month ago

This looks like a Tao problem, not a PyTao problem:

tao -lat bugreport.lat -noplot -startup commands.tao 
[MESSAGE | 2024-MAY-30 16:46:04] tao_init:
    OpenMP active with number of threads: 10
Using startup file: commands.tao

Tao: set global lattice_calc_on = F

Tao: set ele CAV1 phi0 = -0.1

Tao: set ele Q1 b1_gradient = 10.0

Tao: set global lattice_calc_on = T

Tao: sho value ele::q1[b1_gradient]
     8.1782336820807657E+00

cmds.tao:

set global lattice_calc_on = F
set ele CAV1 phi0 = -0.1
set ele Q1 b1_gradient = 10.0
set global lattice_calc_on = T
sho value ele::q1[b1_gradient]

@MichaelEhrlichman report to @DavidSagan

MichaelEhrlichman commented 1 month ago

https://github.com/bmad-sim/bmad-ecosystem/issues/982