constraint module

Define Constraint, which stores a constraint.

It saves it’s name, limits, and methods to evaluate if it is violated or not.

class Constraint(name, element_name, limits)[source]

Bases: DesignSpaceParameter

A single constraint.

For now, it can only be a synchronous phase limits. By convention, all calculations are done in rad, and phases are always printed in deg.

Parameters:
__post_init__()[source]

Convert values in deg for output if it is angle.

property kwargs: dict[str, bool]

Return the kwargs to send a get method.

property n_constraints: int

Return number of embedded constraints in this object.

A lower + and upper bound count as two constraints.

get_value(simulation_output)[source]

Get from the SimulationOutput the quantity called self.name.

Currently bugged. When trying too access phi_s, we get the value stored in SimulationOutput.elts instead of the one in SetOfCavitySettings. So we end up with the phi_s from the broken linac instead of the ones in the cavity settings we just tried.

Parameters:

simulation_output (SimulationOutput)

Return type:

float

evaluate(simulation_output)[source]

Check if constraint is respected.

They should be < 0.

Parameters:

simulation_output (SimulationOutput)

Return type:

tuple[float, float]

__init__(name, element_name, limits)
Parameters:
Return type:

None

_abc_impl = <_abc._abc_data object at 0x7318fb560600>