valve
Modules
valve_torch_system module
- class ValveTorchSystem(waterFlowRateMax=0.01594896331738437, valveAuthority=1, **kwargs)[source]
Bases:
System,ModuleA valve system model implemented with PyTorch for gradient-based optimization.
This model represents a valve that controls water flow rate based on valve position. The valve characteristic is modeled using the valve authority equation, which provides a more accurate representation of the valve’s behavior compared to a simple linear relationship.
- Parameters:
waterFlowRateMax (
Optional[float]) – Maximum water flow rate [kg/s]valveAuthority (
Optional[float]) – Valve authority (0-1)**kwargs – Additional keyword arguments
Mathematical Formulation
The valve characteristic is calculated using the valve authority equation:
\[u_{norm} = \frac{u}{\sqrt{u^2 (1-a) + a}}\]- where:
\(u\) is the valve position (0-1)
\(a\) is the valve authority (0-1)
\(u_{norm}\) is the normalized valve position
The water flow rate is then calculated as:
\[\dot{m}_w = u_{norm} \cdot \dot{m}_{w,max}\]- where:
\(\dot{m}_w\) is the water flow rate [kg/s]
\(\dot{m}_{w,max}\) is the maximum water flow rate [kg/s]
- param waterFlowRateMax:
Maximum water flow rate [kg/s]
- type waterFlowRateMax:
float
- param valveAuthority:
Valve authority (0-1), where: - 0: Linear characteristic - 1: Equal percentage characteristic - Values in between: Mixed characteristic
- type valveAuthority:
float
Notes
- Valve Authority Characteristics:
Linear (a = 0): Flow rate is directly proportional to valve position
Equal Percentage (a = 1): Flow rate changes exponentially with valve position
Mixed (0 < a < 1): Combination of linear and equal percentage characteristics
- Implementation Details:
The model uses PyTorch tensors for gradient-based optimization
All parameters are stored as non-trainable PyTorch parameters
The valve authority equation provides better control at low flow rates
The model assumes ideal valve behavior (no hysteresis or deadband)
- do_step(secondTime, dateTime, step_size, stepIndex)[source]
Perform one step of the valve system simulation.
The valve characteristic is calculated using the valve authority equation: u_norm = u / sqrt(u^2 * (1-a) + a) where: - u is the valve position (0-1) - a is the valve authority (0-1) - u_norm is the normalized valve position
The water flow rate is then calculated as: m_w = u_norm * waterFlowRateMax
- Return type:
None
- initialize(start_time, end_time, step_size, simulator)[source]
Initialize the valve system.
- Return type:
None
- property config
Get the configuration of the valve system.
- property input: dict
Get the input ports of the valve system.
- Returns:
- Dictionary containing input ports:
”valvePosition”: Valve position (0-1)
- Return type:
dict
- property output: dict
Get the output ports of the valve system.
- Returns:
- Dictionary containing output ports:
”valvePosition”: Valve position (0-1)
”waterFlowRate”: Water flow rate [kg/s]
- Return type:
dict
- sp = [<twin4build.translator.translator.SignaturePattern object>]