svenreiche / Genesis-1.3-Version4

Time-dependent, 3D Code to simulate the amplification process of a Free-electron Laser.
GNU General Public License v3.0
55 stars 27 forks source link

[BUG] Lattice element without parameters reports `Warning: Ignoring invalid format` #201

Open ken-lauer opened 2 weeks ago

ken-lauer commented 2 weeks ago

Describe the bug

Using v4.6.6

A lattice element such as a corrector without parameters specified:

C01: CORRECTOR = {  };

Results in the following repeated message during parsing:

*** Warning: Ignoring invalid format:  for element c01
*** Warning: Ignoring invalid format:  for element c01
...

My understanding of reading the code is that this defaults to l=0, cx=0, cy=0. Scientists on our team sometimes use this as a placeholder in the lattice until they are ready to assign some values.

To Reproduce

A simple tweak of example 1 to exhibit this:

corrector.lat ``` D1: DRIFT = { l = 0.44}; D2: DRIFT = { l = 0.24}; C01: CORRECTOR = { }; QF: QUADRUPOLE = { l = 0.080000, k1= 2.000000 }; QD: QUADRUPOLE = { l = 0.080000, k1= -2.000000 }; UND: UNDULATOR = { lambdau=0.015000, nwig=266, aw=0.84853, helical= True}; FODO: LINE={C01,UND,D1,QF,D2,UND,D1,QD,D2}; FEL: LINE={6*FODO}; ``` corrector.in ``` &setup rootname=corrector lattice=corrector.lat beamline=FEL lambda0=1e-10 gamma0=11357.82 delz=0.045000 shotnoise=0 nbins = 8 &end &lattice zmatch=9.5 &end &field power=5e3 dgrid=2.000000e-04 ngrid=255 waist_size=30e-6 &end &beam current=3000 delgam=1.000000 ex=4.000000e-07 ey=4.000000e-07 &end &track &end ```

Expected behavior

I don't think this should be a warning - this should just indicate "use all of the default values for the lattice element".

Additional context

In lume-genesis, we only write parameter values that differ from the defaults to avoid explicitly listing all parameters for every element.

svenreiche commented 1 week ago

In the Code there was the search for an '=' sign since the code expects at least one comment. I have changed it for all elements that a empty string of zero length (which is generated after the trimming) is ignored and the parsing is continue. It should work now. Can you check if it is ok for you. Then I can close the issue.

ken-lauer commented 1 week ago

Thanks for addressing this so quickly, @svenreiche! I ran my test case with your fix, and it appears to work well on my end.

It would be great to have a new release one day soon, if you can find the time.