Simulation
The simulation object.
- class onscale.Simulation(name: str, desc: str = '', tree_id: str | None = None, version: str | None = None)
Top-level simulation object.
This object is intended to be used as a context manager, in which all objects and actions are defined.
Examples
>>> import onscale as on >>> >>> >>> with on.Simulation("Static Solve") as sim: ... geom = on.CadFile("Swing_Arm.step") ... mesh = on.meshes.UnstructuredMesh('mesh1') ... mesh.set('min_h', 2.0) ... mesh >> geom.parts[0:3] ... materials = on.CloudMaterials("onscale") ... gold = materials["gold"] ... gold >> geom.parts[0] ... # Apply force vector to face ... force = on.loads.Force(10, [0, 0, -1]) ... force >> geom.parts[0].faces[192] ... # Fix another face ... fixed = on.loads.Fixed() ... fixed >> geom.parts[0].faces[590] ... # Set mesh level ... # Request outputs ... fsensor = on.sensors.FieldSensor(data=["Displacement", "Stress", "Strain"]) ... fsensor >> geom
- physics_types(node_id: str)
Get physics types for a single node in this simulation
- all_physics_types()
Get all physics types for all nodes in this simulation
- print_struct()
Print the underlying data struct, useful for debugging
- to_json() str
Return this simulation object as serialized JSON
- node_exists(node_name: str) bool
Returns true if the node_name exists as a rust NodeType
- get_binop_targets(uuid: str) List[Node]
Get all nodes that uuid is applied to via a binop.
- get_binop_lefts(uuid: str) List[Node]
Get all nodes that are applied to uuid via a binop.
- get_multiple_binop_targets(left_ids: List[str]) Dict[str, Set[Node]]
Do the operation of get_binop_targets on multiple nodes at once.
Improves performance over calling get_binop_targets many times.
- Returns:
Dictionary where keys are the uuid matching the given left_ids and values are a set of the target nodes.
- get_all_binop_targets() Dict[str, Set[Node]]
Like get_multiple_binop_targets, but for all binops in the simulation.
- get_multiple_binop_lefts(right_ids: List[str]) Dict[str, Set[Node]]
Do the operation of get_binop_lefts on multiple nodes at once.
Improves performance over calling get_binop_lefts many times.
- Returns:
Dictionary where keys are the uuid matching the given right_ids and values are a set of the left nodes.
- get_all_binop_lefts() Dict[str, Set[Node]]
Like get_multiple_binop_lefts, but for all binops in the simulation.