Sensors
Output sensor definitions.
Field Sensors
- class onscale.sensors.FieldSensor(data: str | List[str] | FieldData | List[FieldData] | List[str | FieldData] = [], spatial_filters: None | str | List[str] | FieldSpatialFilter | List[FieldSpatialFilter] | List[str | FieldSpatialFilter] = [], start: None | int | Trigger = None, duration: int | None = None, sample_rate: int | None = None, sample_aggregation: str | None = None, sample_aggregations: None | str | List[str] | FieldSampleAggregation | List[FieldSampleAggregation] | List[str | FieldSampleAggregation] = [], sample_count: int | None = None, alias: str | None = None)
FieldSensors collect data for each of the requested data outputs for the entire model at the nodes of the mesh.
Examples
>>> import onscale as on >>> >>> with on.Simulation('field') as sim: ... geom = on.CadFile('test') ... # Field sensor using strings ... field_sensor1 = on.sensors.FieldSensor(data=['VonMises', ... 'Displacement']) ... field_sensor1 >> geom.parts[0] ... # Field sensor using enums ... field_sensor2 = on.sensors.FieldSensor(data=[on.FieldData.VONMISES, ... on.FieldData.DISPLACEMENT]) ... field_sensor2 >> geom.parts[0]
- Parameters:
data –
List of data sets to request. These can either be represented as strings such as
"Displacement"
or enums such ason.sensors.probes.Displacement
Acoustic Fields
AcousticPressure
Electrical Fields
ElectricField
Voltage
ElectricCharge
MagneticField
Fluid Fields
Velocity
Pressure
Vorticity
WallHeatFlux
WallShearStress
WallHeatTransferCoefficient
SpecificTurbulentEnergy
QCriterion
TurbulenceIntensity
Mechanical Fields
Displacement
Acceleration
VonMises
Stress
Strain
EigenVector
PrincipalStress
PrincipalStressDirection
PrincipalStrain
PrincipalStrainDirection
StrainEnergyDensity
PlasticStrain
EquivalentPlasticStrain
MechanicalMaterialDirection
Thermal Fields
Temperature
ThermalMaterialDirection
’stress’, ‘temperature’, or ‘vonmises’.
spatial_filters – Filter functions for data.
start – When to start outputting data. Either an int of the time step to start outputting data, or a trigger based on Probes. If None, will start at beginning of simulation.
duration – After how many time steps to stop outputting data. If None, will output until end of simulation.
sample_rate – The number of time steps per sample output. A sample_rate of 1 will output every time step, while a sample_rate of 3 will output every 3rd time step. If None, will output once at the end of the simulation.
sample_aggregation – DEPRECATED, use sample_aggregations.
sample_aggregations – List of names of the aggregation functions to apply for each sample period. Possible values are ‘mean’, ‘sum’, ‘min’, ‘max’, ‘std’, ‘first’, and ‘last’. If sample_rate is 5 and sample_aggregation is ‘mean’, then the mean of values for each 5 steps is output.
sample_count – The total number of time steps to generate sample output for.
alias – Optional alias for this node.
- apply(other: Geometry | Selection | SelectionSet | Search | BoundPlane | Point | Body | GeometryCollection | List[Geometry | Selection | SelectionSet | Search | BoundPlane | Point | Body | GeometryCollection])
Apply this field sensor to a geometry :param other: A geometry object.
- Returns:
Applied Field Sensor object.
- to_fields(target: Geometry | Selection | SelectionSet | Search | BoundPlane | Point | Body | GeometryCollection | List[Geometry | Selection | SelectionSet | Search | BoundPlane | Point | Body | GeometryCollection], tree: Simulation | None = None) List[Field]
Flatten this field sensor into a concrete list of fields.
- Parameters:
tree – The simulation tree to create this node under. If not given, will create in a new dummy simulation to avoid polluting the context.
- Returns:
Concrete field objects equivalent to this field sensor
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
Probe Sensor
- class onscale.sensors.ProbeSensor(data: str | List[str] | ProbeData | List[ProbeData] | List[str | ProbeData] = [], spatial_aggregations: None | str | List[str] = [], time_aggregations: None | str | List[str] = [], fixed: bool = False, alias: str | None = None)
ProbeSensors collect data resulting in a single value at each time step for each of the requested probe data outputs. They are either recorded at a single point in the mesh, or over some domain of the mesh along with a spatial aggregation function and optionally a time aggregation function.
Examples
>>> import onscale as on >>> >>> with on.Simulation('probe') as sim: ... geom = on.CadFile('test') ... # Probe sensor using strings ... probe_sensor1 = on.sensors.ProbeSensor( ... data=['Stress', ... 'Strain', ... 'Displacement_X'], ... spatial_aggregations=['Max', 'Min', 'Mean'] ) ... probe_sensor1 >> geom.parts[0] ... # Probe sensor using enums ... probe_sensor2 = on.sensors.ProbeSensor( ... data=[on.ProbeData.STRESS, ... on.ProbeData.STRAIN, ... on.ProbeData.DISPLACEMENT_X], ... spatial_aggregations=[on.ProbeSpatialAggregation.MAX, ... on.ProbeSpatialAggregation.MIN, ... on.ProbeSpatialAggregation.MEAN] ) ... probe_sensor2 >> geom.parts[0]
- Parameters:
data –
List of data sets to request. These can either be represented as strings such as
"Displacement"
or enums such ason.ProbeData.DISPLACEMENT
Acoustic Fields
AcousticPressure
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
Fluid Fields
Pressure
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
Mechanical Fields
Displacement
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point, Rigid Body,Deformable Body
Rotation
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point, Rigid Body,Deformable Body
Stress
Available components - XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
Strain
Available components - XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
VonMises
Available components - n/a
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
ResultantForce
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Sum
Valid targets - Surface
ResultantMoment
Available components - Magnitude, X, Y, Z
Available spatial aggregations - Sum
Valid targets - Surface
EigenFrequencies
Available components - n/a
Available spatial aggregations - Sum
Valid targets - CAD geometry, Volume
MassParticipationFactor
Available components - n/a
Available spatial aggregations - Sum
Valid targets - CAD geometry, Volume
EffectiveMassParticipationFactor
Available components - n/a
Available spatial aggregations - Sum
Valid targets - CAD geometry, Volume
CumulativeMassParticipationFactor
Available components - n/a
Available spatial aggregations - Sum
Valid targets - CAD geometry, Volume
StrainEnergy
Available components - n/a
Available spatial aggregations - Sum
Valid targets - Volume
KineticEnergy
Available components - n/a
Available spatial aggregations - Sum
Valid targets - Volume
Thermal Fields
Temperature
Available components - n/a
Available spatial aggregations - Min, Max, Mean
Valid targets - Volume, Surface, Edge, Point
spatial_aggregations – Aggregation functions for spatial data. One ore more of ‘mean’, ‘sum’, ‘min’, ‘max’. By default they will all be selected.
time_aggregations – Aggregation functions for data over time. One ore more of ‘mean’, ‘sum’, ‘min’, ‘max’, ‘last’, ‘first’.
fixed – If False (default), probe sensors will move along with mesh deformations. If True, the probe sensor will be fixed at the global coordinate position it was placed.
alias – Optional alias for this node.
- apply(other: Selection | Search | SelectionSet | BoundPlane | Point | Body | GeometryCollection)
Apply this probe sensor to a geometry :param other: A geometry object.
- Returns:
Applied Probe Sensor object.
- to_probes(target: Selection | Search | SelectionSet | BoundPlane | Point | Body | GeometryCollection, tree: Simulation | None = None, spatial_ags=[], alias: str | None = None) List[Probe]
Flatten this probe sensor into a concrete list of probes.
- Parameters:
tree – The simulation tree to create this node under. If not given, will create in a new dummy simulation to avoid polluting the context.
- Returns:
Concrete probe objects equivalent to this probe sensor
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.
Reaction Sensor
- class onscale.sensors.ReactionSensor(alias: str | None = None)
ReactionSensors request reaction outputs for constraints.
Examples
>>> import onscale as on >>> >>> with on.Simulation('field') as sim: ... ... geom = on.CadFile('test') ... restraint = on.loads.Restraint(x=True, y=True, z=True) ... restraint >> geom.parts[0] ... reaction_sensor = on.sensors.ReactionSensor() ... reaction_sensor >> restraint
- Parameters:
alias – Optional alias for this node.
- apply(other: Fixed | Restraint | Displacement | Rotation | Symmetry | Temperature | Convection | Radiation | FluidPressure | Voltage | Contact)
Apply this reaction sensor to a constraint :param other: A constraint object.
- Returns:
Applied Reaction Sensor object.
- static from_dict(data: Dict[str, Any], sim: Simulation | None = None) Node
Construct this node from serialized dictionary data
- to_json() str
Convert this node into JSON representation
- property uuid: str
Get the UUID associated with this node.