pogona.objects.ObjectPumpPeristaltic
- class pogona.objects.ObjectPumpPeristaltic[source]
Bases:
ObjectPumpVolume
Model for a peristaltic pump that tries to avoid overdosing by ramping down the flow speed towards the end of an injection.
We want the injection volume to remain constant. For a static flow pump (ObjectPumpVolume), the flow rate \(r\) is constant over the entire injection duration \(T\) and equal to the maximum flow rate \(R\).
At the end of what would be a constant injection, we stop at time \(T-t\) and decrease the flow speed linearly in \(n\) steps. In order to maintain the original injection volume, the following must hold for intermediate flow rates \(h_i\):
\[\begin{split}\sum_{i=0}^{n-1} h_i \cdot s &= t \cdot R \\ \Rightarrow h_i &= \frac{n-i}{n+1} \cdot R\end{split}\]The step size \(s\) must thus be
\[\begin{split}s &= t \cdot R \cdot \left(\sum_{i=0}^{n-1} h_i\right)^{-1} \\ &= tR\left(\frac{Rn}{2}\right)^{-1} = \frac{2t}{n}.\end{split}\]If we don’t want to define the time \(t\) we want to cut off from the original injection duration, but instead the ramp-down time \(t_s\), we can convert between it and \(t\) like so:
\[t_s = n \cdot s = 2t\]Attributes
Unique name of this component, unless it is "Generic component".
Whether to insert dummy points at the boundary of the mesh, and where exactly.
The name of this type of object.
Object index, set by the scene manager.
Path to all OpenFOAM simulation cases.
Number of in-between steps between the highest flow rate and the pump being turned off.
A constant time in which to linearly ramp down the flow speed from its maximum to 0.
Notify subscribed sensors based on object mesh cells.
Methods
__init__
()finalize
(simulation_kernel)find_latest_time_step
(path)- return
The highest-valued subdirectory of path that is named
get_closest_cell_centre_id
(position)- returns
Array of closest cell centers to position.
If an Object supports sensor subscriptions, some OpenFOAM case with a non-zero flow rate should exist (i.e., a vector field for which this Object has self.is_active == True).
get_flow
(simulation_kernel, position_global, ...)- returns
A unique string for the current configuration of this object.
get_outlet_area
(outlet_name)get_path
([use_latest_time_step, fallback])- param use_latest_time_step
Find the latest time step in path.
initialize
(simulation_kernel, init_stage)Use
InitStages
to initialize this Component instance.load_current_vector_field
(simulation_kernel)Update the flow rate inside this Object based on the changed flow rate of the inlet with name inlet_name, then propagate this change to any Object connected to this Object's outlets.
process_new_time_step
(simulation_kernel, ...)Update the pump activity based on the current time (since an injection started).
set_arguments
(**kwargs)Read arguments as key value pairs and set this component's member variables accordingly.
set_interpolation_method
(interpolation_method)start_injection
(simulation_kernel)Start an injection.
- finalize(simulation_kernel: SimulationKernel)
- static find_latest_time_step(path: str) str
- Returns
The highest-valued subdirectory of path that is named only after a floating point value. E.g., if there are ‘{path}/0/’ and ‘{path}/0.1/’, this will return ‘0.1’.
- get_closest_cell_centre_id(position: ndarray)
- Returns
Array of closest cell centers to position. If there’s only one position, output is squeezed. None if this Object is inactive. See documentation of cKDTree.query().
- get_current_mesh_global()
- get_current_mesh_local()
- get_fallback_mesh_index() Optional[str]
If an Object supports sensor subscriptions, some OpenFOAM case with a non-zero flow rate should exist (i.e., a vector field for which this Object has self.is_active == True). If this object is initially inactive, however, we still need to know where to find this mesh for the initialization of the SensorManager.
- Returns
A valid mesh index independent of this Object’s is_active status. None if this Object does not support sensor subscriptions.
- get_flow(simulation_kernel: SimulationKernel, position_global: ndarray, sim_time: float)
- get_mesh_index() str
- Returns
A unique string for the current configuration of this object. Used for caching.
- get_outlet_area(outlet_name: str)
- get_path(use_latest_time_step=False, fallback=False) str
- Parameters
use_latest_time_step – Find the latest time step in path. If False, use this Object’s _default_time_str, which may still be set to ‘latest’, which has the same effect.
fallback – Use get_fallback_mesh_index instead of get_mesh_index.
- Returns
Path to the OpenFOAM files for this object.
- get_transformation() Transformation
- get_vector_field_manager() Optional[VectorFieldManager]
- initialize(simulation_kernel: SimulationKernel, init_stage: InitStages)[source]
Use
InitStages
to initialize this Component instance.
- load_current_vector_field(simulation_kernel: SimulationKernel)
- process_changed_inlet_flow_rate(simulation_kernel: SimulationKernel, inlet_name: str, flow_rate: float)
Update the flow rate inside this Object based on the changed flow rate of the inlet with name inlet_name, then propagate this change to any Object connected to this Object’s outlets.
Should also update is_active accordingly.
- process_new_time_step(simulation_kernel: SimulationKernel, notification_stage: NotificationStages)[source]
Update the pump activity based on the current time (since an injection started).
- set_arguments(**kwargs)
Read arguments as key value pairs and set this component’s member variables accordingly. Validity of the argument values will be checked in
initialize()
.
- set_interpolation_method(interpolation_method: Interpolation)
- start_injection(simulation_kernel: SimulationKernel)[source]
Start an injection.
- Warning: ObjectPumpPeristaltic only supports injection_volume,
not injection_duration.
- component_name = 'Generic component'
Unique name of this component, unless it is “Generic component”.
- dummy_boundary_points = 'NONE'
Whether to insert dummy points at the boundary of the mesh, and where exactly. This may help with interpolation.
- flow_rate = 0
- id
Unique integer component ID
- injection_flow_mlpmin = 10.0
- injection_volume_l = 0.001
- inlets: List[str]
Names of the inlets in the OpenFOAM mesh.
- property is_active
- name: str = 'Peristaltic pump'
The name of this type of object. Not a unique identifier like Component.component_name!
- object_id = -1
Object index, set by the scene manager.
- openfoam_cases_path = ''
Path to all OpenFOAM simulation cases. Subclasses may use this as the base path to find their respective meshes via get_path().
- outlets: List[str]
Names of the outlets in the OpenFOAM mesh.
- ramp_down_steps = 1
Number of in-between steps between the highest flow rate and the pump being turned off.
- ramp_down_time = 0.0
A constant time in which to linearly ramp down the flow speed from its maximum to 0.
Should be lower than twice of what the injection duration would be if the flow rate were constant. If equal to twice this hypothetical injection duration, the injection should start with the first intermediate step immediately.
In the limited data we have so far (for lack of a proper high-speed camera), it looks as though this time is constant for a given flow rate and varying injection volumes.
- rotation = [0, 0, 0]
- scale = [1, 1, 1]
- translation = [0, 0, 0]
- use_sensor_subscriptions = 'USE_DEFAULT'
Notify subscribed sensors based on object mesh cells. This speeds up simulation. Only disable this if you are constrained by memory or if the object does not have a mesh in the first place. If None, use the SensorManager’s default_use_sensor_subscriptions.
- property walls_patch_names