Unable to Create 0 Angle Bend with Finite Field

Issue #176 resolved
Laurie Nevay created an issue

It's not possible to force the angle induced in the beam line by a magnet to be 0 whilst having a finite B field specified.

Looking at BDSComponentFactory.cc on line 1168 CalculateAngleAndFieldRBend, we test on whether the values are finite or not as to whether they've been set. With the value explicitly set to 0 angle this is treated as not set and the field is used to calculate the angle.

The immediate solution was to set this to a very small value. I guess this is only really useful for testing.

Just to confirm, there is no way to know from the parser/element.h class whether a variable has been set or not?

Comments (4)

  1. Jochem Snuverink

    Confirmed that it is not possible to know whether an element variable has been set.

    We could add a similar mechanism as with options, however this will about double the amount of memory per element.

    Alternatively, we could add a boolean variable to element like "allowUnderpoweredBendWhenAngleZero" or something, which can be used to distinguish the cases.

  2. Laurie Nevay reporter

    Yes, I think perhaps the second option of a single boolean for this particular case would suffice. We've managed without recording whether a variable is set or not so far, so it would seem only to be strictly required for this.

    This could probably be set automatically in the parser if angle is specified I presume?

  3. Jochem Snuverink

    Yes, we can certainly set this value explicitly based if angle is non-zero. I think the end of Element::set(Parameters,string,type) is the right place for that.

  4. Log in to comment