Simulation, FEA & CFD

Ansys Workbench, Simulia Abaqus - discretize geometry, assign materials and boundary conditions, solve, and extract results. SET PROMISE / WAIT FOR is the same async pattern as FETCH - a real solve runs minutes to hours, so it was never going to be a blocking call.

Static Structural - Bracket Under Load
NEW CAD BOX SIZE 80,40,10 SET ?bracket
AFTER CAD ?bracket FACE AT 0,20,5 SET ?mountFace
AFTER CAD ?bracket FACE AT 80,20,5 SET ?loadFace

AFTER SIM MESH ?bracket ELEMENT TYPE "tet10" SIZE 2 SET ?femesh
AFTER NEW SIM MATERIAL "Steel-4140" YOUNGS MODULUS 205000 POISSON RATIO 0.29 DENSITY 7850 YIELD STRENGTH 415 SET ?steel
AFTER SIM ?femesh ASSIGN MATERIAL ?steel
AFTER SIM ?femesh FIXED SUPPORT ON FACE ?mountFace
AFTER SIM ?femesh FORCE 0,0,-500 ON FACE ?loadFace

AFTER NEW SIM STUDY "static_structural" ON ?femesh SET ?study
AFTER SIM ?study SOLVE SET PROMISE ?results
AFTER WAIT FOR ?results SET ?solution
AFTER SIM ?solution SAFETY FACTOR SET ?fos
AFTER SIM ?solution EXTRACT STRESS "von_mises" SET ?stress
AFTER SIM ?solution CONTOUR PLOT ?stress SCALE "rainbow" SET ?stressImage

The Mesh

SIM MESH divides a solid into tetrahedra. SIZE is the largest element edge in millimetres. ELEMENT TYPE chooses the element: "tet4", four-node linear tetrahedra, is the default; "tet10" adds a node on every edge, and bends the way the material does - a cantilever meshed coarsely in "tet10" deflects within a few percent of the textbook answer, where "tet4" is noticeably too stiff. Any other type is an error.

SIM ?femesh REFINE REGION ?face FACTOR n meshes the part again with elements n times smaller around that face, easing back to SIZE away from it - where a load concentrates, or where a flow separates. Everything the mesh has been given stays on it.

Key Value
nodesPoints in the mesh
elementsTetrahedra in the mesh
element_type"tet4" or "tet10"
sizeThe SIZE it was meshed at

Flow - CFD

A flow study solves steady, incompressible flow - the Reynolds-averaged Navier-Stokes equations with a turbulence model - on the mesh. The meshed solid is the fluid: the air in a room, the water in a pipe. For flow around an object, mesh the space around it: a box with the object cut out of it, so the object's surface becomes a wall of the fluid. Every boundary is a face of that solid, picked with CAD ?solid FACE AT; faces not named are walls. Velocities are in m/s and pressures in Pa, whatever units the geometry was drawn in.

CFD - Drag on a Body in a Wind Tunnel
NEW CAD BOX SIZE 1000,400,300 SET ?tunnel
AFTER NEW CAD SKETCH ON PLANE "XY" SET ?sk
AFTER CAD ?sk CIRCLE CENTER 400,200 RADIUS 60 SET ?profile
AFTER CAD EXTRUDE ?profile HEIGHT 150 SET ?body
AFTER CAD BOOLEAN SUBTRACT ?tunnel WITH ?body SET ?air
AFTER CAD ?air FACE AT 0,200,150 SET ?inletFace
AFTER CAD ?air FACE AT 1000,200,150 SET ?outletFace
AFTER CAD ?air FACE AT 340,200,75 SET ?bodySurface

AFTER SIM MESH ?air SIZE 40 SET ?femesh
AFTER SIM ?femesh REFINE REGION ?bodySurface FACTOR 3
AFTER NEW SIM FLUID "Air" DENSITY 1.225 VISCOSITY 0.0000181 SET ?airFluid
AFTER SIM ?femesh ASSIGN FLUID ?airFluid
AFTER SIM ?femesh VELOCITY INLET 10,0,0 ON FACE ?inletFace
AFTER SIM ?femesh PRESSURE OUTLET 0 ON FACE ?outletFace
AFTER SIM ?femesh NO SLIP WALL ON FACE ?bodySurface

AFTER NEW SIM STUDY "cfd_steady" ON ?femesh TURBULENCE MODEL "k_epsilon" SET ?study
AFTER SIM ?study SOLVE SET PROMISE ?results
AFTER WAIT FOR ?results SET ?solution
AFTER SIM ?solution EXTRACT DRAG FORCE ON FACE ?bodySurface SET ?drag
AFTER SIM ?solution EXTRACT STREAMLINES SET ?viz
AFTER EMIT "Drag: " & ?drag("drag") & " N, converged: " & ?solution("converged")

A cylinder 120 mm across and 150 mm tall in a 10 m/s stream has a drag coefficient near 1, about 1.1 N - which is what this answers, to within the coarseness of a 40 mm mesh.

Statement What it does
NEW SIM FLUID "name" DENSITY d VISCOSITY μThe fluid: density in kg/m³, dynamic viscosity in Pa·s. Air (1.225, 0.0000181) when no fluid is assigned
SIM ?m ASSIGN FLUID ?fFills the mesh with it
SIM ?m VELOCITY INLET x,y,z ON FACE ?fAir (or water) enters through that face at that velocity, m/s
SIM ?m PRESSURE OUTLET p ON FACE ?fLeaves through that face at that pressure, Pa (0 for open air). Every flow needs one
SIM ?m NO SLIP WALL ON FACE ?fA wall the flow sticks to. Faces not named are walls already; naming one is what lets drag be read off it by name
TURBULENCE MODEL on NEW SIM STUDY"k_epsilon" (default), "realizable_k_epsilon", "k_omega_sst", "k_omega", "spalart_allmaras" or "laminar"

Each of these is written without SET: it is kept on the mesh variable, and NEW SIM STUDY ... ON takes everything the mesh has been given at that moment - so give it first, then make the study.

Key on the solution Meaning
convergedtrue when every residual fell below its target before the iteration limit (400); false means read the numbers as an estimate, or refine the mesh
iterations, residualsHow many were run, and where each equation's residual ended
max_velocity, mean_velocitym/s, the mean weighted by volume
pressure_dropInlet minus outlet pressure, Pa
cells, patchesCells solved, and how many faces each boundary covered
Extract Answers
EXTRACT DRAG FORCE [ON FACE ?f]The force of the flow on that face - pressure plus wall friction - as force (x,y,z, N), drag (along the inlet flow), pressure_force and viscous_force. Without ON FACE, every wall
EXTRACT STREAMLINESLines traced through the velocity field from the inlet, drawn and coloured by speed; answers path (a PNG in /root/results), lines and max_speed
EXTRACT CONCENTRATION "name"How long air has been in the space, everywhere in it - the concentration of anything released evenly through the volume, as people breathing out CO₂ are. Answers mean_age and max_age (s), nominal_time_constant (volume over flow rate), air_change_effectiveness, and relative_mean / relative_max: the concentration relative to perfect mixing, where above 1 is stale air

Explicit Dynamics - Impacts

An explicit study steps an impact through time: the part is given a velocity, strikes what it is in contact with, and the material yields where it is overloaded. The solver is central-difference time integration with lumped mass, J2 plasticity - the material yields at its YIELD STRENGTH and hardens gently after - and penalty contact with Coulomb friction. Each time step is limited by how fast a stress wave crosses the smallest element, so a fine mesh over a long DURATION means many steps; past 60,000 the smallest elements are given extra mass until it fits (mass scaling, as every explicit code offers), and how much was added is answered as added_mass rather than hidden. Keep DURATION to the impact itself.

Explicit Dynamics - Bar Impact
NEW CAD BOX SIZE 100,20,20 SET ?bumper
AFTER NEW CAD BOX SIZE 10,200,200 SET ?barrier
AFTER CAD ?bumper FACE AT 0,10,10 SET ?bumperFace
AFTER CAD ?barrier FACE AT 0,100,100 SET ?barrierFace
AFTER SIM MESH ?bumper ELEMENT TYPE "tet4" SIZE 5 SET ?femesh
AFTER NEW SIM MATERIAL "Steel" YOUNGS MODULUS 205000 POISSON RATIO 0.29 DENSITY 7850 YIELD STRENGTH 250 SET ?steel
AFTER SIM ?femesh ASSIGN MATERIAL ?steel
AFTER SIM ?femesh INITIAL VELOCITY -15,0,0
AFTER SIM ?femesh CONTACT BETWEEN ?bumperFace AND ?barrierFace FRICTION 0.2

AFTER NEW SIM STUDY "explicit_dynamics" ON ?femesh DURATION 0.001 SET ?study
AFTER SIM ?study SOLVE SET PROMISE ?results
AFTER WAIT FOR ?results SET ?solution
AFTER SIM ?solution EXTRACT PLASTIC STRAIN SET ?strain
AFTER SIM ?solution EXTRACT ENERGY "kinetic" HISTORY SET ?keCurve
AFTER SIM ?solution CONTOUR PLOT ?strain SCALE "rainbow" SET ?strainImage
Statement Meaning
INITIAL VELOCITY x,y,zThe whole part's velocity at the start, m/s
CONTACT BETWEEN ?a AND ?b FRICTION μThe face of the meshed part that strikes, and the face it strikes. The struck face is held rigid - a barrier, a wall, the floor - and acts as the plane it lies in
FIXED SUPPORT ON FACE ?fAs for a static study: that face does not move
DURATION on NEW SIM STUDYSeconds of the event to simulate
EXTRACT PLASTIC STRAINThe largest equivalent plastic strain anywhere in the part; 0 means it stayed elastic. CONTOUR PLOT of it draws where
EXTRACT ENERGY "kind" [HISTORY]"kinetic", "internal" or "plastic", in joules: the value at the end, or with HISTORY times, values and peak over the whole event

The solution also carries steps, time_step, added_mass (a fraction; 0 means none), max_displacement (mm), peak_contact_force (N), yielded_elements, and energy with all three at the end. The energy balance is the check worth reading first: kinetic energy lost should reappear as internal and plastic energy.

Saving a Study and Its Results

A solve runs for minutes or hours, so neither the study nor what it produced should die with the script that started it. SAVE INTO writes either one as native OcaltQL source text, the canonical stored form described on Arrays & Objects; OPEN reads it back. The saved file is readable and hand-editable - a study is its mesh reference, materials and boundary conditions, not bulk geometry.

Set Up Once, Solve Later
NEW CAD BOX SIZE 80,40,10 SET ?bracket
AFTER CAD ?bracket FACE AT 0,20,5 SET ?mountFace
AFTER CAD ?bracket FACE AT 80,20,5 SET ?loadFace
AFTER SIM MESH ?bracket ELEMENT TYPE "tet10" SIZE 4 SET ?femesh
AFTER SIM ?femesh FIXED SUPPORT ON FACE ?mountFace
AFTER SIM ?femesh FORCE 0,0,-500 ON FACE ?loadFace
AFTER NEW SIM STUDY "static_structural" ON ?femesh SET ?study
AFTER SIM ?study SAVE INTO "/root/studies/bracket.oql" SET ?path
Set Up Once, Solve Later (a later script)
(* ...a later script, or a scheduled job... *)
SIM OPEN "/root/studies/bracket.oql" SET ?study
AFTER SIM ?study SOLVE SET PROMISE ?results
AFTER WAIT FOR ?results SET ?solution
AFTER SIM ?solution SAVE INTO "/root/results/bracket.oql" SET ?respath
Re-Examine a Finished Solve Without Re-Solving
SIM RESULTS OPEN "/root/results/bracket.oql" SET ?solution
AFTER SIM ?solution SAFETY FACTOR SET ?fos
AFTER SIM ?solution EXTRACT STRESS "von_mises" SET ?stress
AFTER SIM ?solution CONTOUR PLOT ?stress SCALE "rainbow" SET ?stressImage

Study kinds: "static_structural", "cfd_steady" and "explicit_dynamics". Any other kind is an error when solved, not a quiet fallback to one of these.

SIM OPEN reads a study; SIM RESULTS OPEN reads a solved solution. They are separate because a study can be re-solved and a solution cannot - opening the wrong one is an error rather than a silent reinterpretation.