hibtc / cpymad

Cython binding to MAD-X
http://hibtc.github.io/cpymad/
Other
27 stars 18 forks source link

Element redefinition and twiss #100

Closed Rasimilian closed 1 year ago

Rasimilian commented 3 years ago

Hello again! Here is a new potential problem. I'm redefining an element and trying to get a twiss in a loop. But at some point, twiss fails, the parameter of the element is set to 0 and the twiss table contains commas as a decimal separator... I usually use cpymad v1.6.0 - everything is good for this version. But for v1.9.0 I have this problem. If madx.elements.SIL1.k1 = 0.93011966 is commented nothing breaks. madx.command.quadrupole.clone('SIL1',l=0.288,k1=0.93011966) gives memory access outside program range, fatal. I guess the main problem is in the consecutive twiss calls. I need your expertise. Please.

madx = Madx(stdout=True)
madx.call(file='structure.txt')
madx.input('beam,particle=electron,energy=1.8;')
madx.input('use,sequence=RING;')

for i in range(20):
  # k1 = 0.93011966 - default value. Actually, it is not changed
  madx.elements.SIL1.k1 = 0.93011966
  print(madx.elements.SIL1) # check if the parameter is being changed or set to 0
  #madx.input('twiss,sequence=RING, centre=True;')
  madx.twiss(sequence='RING',centre=True)

madx.quit()
coldfix commented 3 years ago

Hi, I tried reproducing but didn't get any error. On which OS are you btw?

Rasimilian commented 3 years ago

Windows 10

Rasimilian commented 3 years ago

I checked on Linux and no problem was observed.

coldfix commented 3 years ago

Ok, it will take me a few days to check this on windows. Did you check whether the madx command line client has the same problem there?

Rasimilian commented 3 years ago

The madx command line works fine