Skip to content

Commit f5c21d8

Browse files
committed
Adjust pyAT sim param setting
We now use enable_6d instead of the misleading radiation_on, enable_6d is only called for linopt6. Also modify the validation exceptions to be more accurate
1 parent 1f4e53c commit f5c21d8

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/atip/simulator.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,14 @@ class SimParams:
2828

2929
def __post_init__(self):
3030
"""Check that we have a valid combination of simulation parameters."""
31-
if self.radiation:
32-
if self.linopt == LinoptType.LINOPT2 or self.linopt == LinoptType.LINOPT4:
31+
if self.linopt == LinoptType.LINOPT2 or self.linopt == LinoptType.LINOPT4:
32+
if self.emittance or self.radiation:
3333
raise ValueError(
34-
f"You must disable radiation to use linopt function: {self.linopt}",
34+
"Emittance and radiation calculations must be disabled when using "
35+
f"{self.linopt}",
3536
)
36-
else:
37-
if self.linopt == LinoptType.LINOPT6:
38-
raise ValueError(
39-
f"You cannot use linopt function: {self.linopt} with radiation "
40-
f"disabled.",
41-
)
42-
elif self.emittance:
37+
if self.linopt == LinoptType.LINOPT6:
38+
if not self.radiation and self.emittance:
4339
raise ValueError(
4440
"You cannot calculate emittance with radiation disabled",
4541
)
@@ -192,8 +188,8 @@ def __init__(
192188
sim_params = SimParams()
193189
self._sim_params = sim_params
194190

195-
if self._sim_params.radiation:
196-
self._at_lat.radiation_on()
191+
if self._sim_params.linopt == LinoptType.LINOPT6:
192+
self._at_lat.enable_6d()
197193

198194
# Initial phys data calculation.
199195
self._lattice_data = calculate_optics(self._at_lat, self._rp, self._sim_params)

0 commit comments

Comments
 (0)