一键导入
fea
Finite Element Analysis — beam elements, tetrahedral solid elements, MKL solver, HHT timestepper, breakable constraints, FEA contact surfaces.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Finite Element Analysis — beam elements, tetrahedral solid elements, MKL solver, HHT timestepper, breakable constraints, FEA contact surfaces.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Entry point for FSI-coupled hybrid plans (plan_type=fsi_in_scene) — any scene combining SPH fluid (water tanks, dam-break, wave channels) with multi-body dynamics, optionally with a wheeled vehicle. Pick this over mbs_in_scene whenever the plan involves a fluid domain (scene_objects with domain_type starting "sph_") or an FSI body registration (scene_objects with fsi_registration set). Routes to fsi/sph (always), veh/wheeled_vehicle (when vehicle present), and enforces FSI-specific invariants distinct from generic mbs_in_scene rigid scenes.
Entry point for rigid-body hybrid plans (plan_type=mbs_in_scene) combining a robot or vehicle with scene assets — NO fluid coupling. Routes to the correct domain skills and defines only high-level invariants. Use core/fsi_in_scene instead when the plan involves SPH fluid or FSI body registration.
Entry point for pure multi-body simulation plans (plan_type=mbs). Routes the agent to the correct mechanics, system, and camera skills and defines only high-level invariants.
Entry point for static scene plans (plan_type=scene). Routes the agent to the correct scene, system, and camera skills and defines only high-level invariants.
Set up SPH-based Fluid-Structure Interaction (FSI): create ChFsiFluidSystemSPH and ChFsiSystemSPH, configure fluid and SPH parameters, seed fluid particles with hydrostatic initialization, add container BCE boundary markers, register floating rigid bodies, optionally couple with a wheeled vehicle, and advance with sysFSI.DoStepDynamics(dT).
Translate a `geometry_relations` entry from the plan into correct PyChrono coordinate code. Read this whenever the plan declares a relation_name you have not previously encoded, and especially BEFORE writing SetPos / camera placement for any body that participates in a multi-body geometric constraint. Each subsection below is one canonical pattern named exactly as it appears in `plan.geometry_relations[i].relation_name`.
| name | fea |
| description | Finite Element Analysis — beam elements, tetrahedral solid elements, MKL solver, HHT timestepper, breakable constraints, FEA contact surfaces. |
| compatibility | pychrono >= 8.0 |
| metadata | {"domain":"mbs"} |
Model deformable structures using Chrono's FEA module: Euler-Bernoulli beam elements (e.g., breakable trees), tetrahedral solid elements (e.g., soft rubber obstacles), and breakable constraints that snap under load.
Use when the plan involves deformable bodies, flexible structures, breakable joints, or soft-body physics. FEA elements interact with rigid bodies through contact surfaces.
FEA requires ChSystemSMC and a direct solver (MKL). Iterative solvers diverge on FEA stiffness matrices.
import pychrono as chrono
import pychrono.fea as fea
import pychrono.pardisomkl as mkl
sys = chrono.ChSystemSMC()
sys.SetGravitationalAcceleration(chrono.ChVector3d(0, 0, -9.81))
sys.SetCollisionSystemType(chrono.ChCollisionSystem.Type_BULLET)
chrono.ChCollisionModel.SetDefaultSuggestedMargin(0.01)
# MKL direct solver (required for FEA)
sys.SetSolver(mkl.ChSolverPardisoMKL())
Choose based on element type:
Beam elements — HHT (Hilber-Hughes-Taylor) timestepper:
hht = chrono.ChTimestepperHHT(sys)
hht.SetAlpha(-0.3)
hht.SetMaxIters(200)
hht.SetAbsTolerances(1e-4)
hht.SetStepControl(False)
sys.SetTimestepper(hht)
Tetrahedral solid elements — Euler implicit:
sys.SetTimestepperType(chrono.ChTimestepper.Type_EULER_IMPLICIT_LINEARIZED)
Typical timestep for FEA stability: step_size = 5e-4.
Create flexible beams using ChBeamSectionEulerAdvanced and ChBuilderBeamEuler.
sec = fea.ChBeamSectionEulerAdvanced()
sec.SetAsCircularSection(diameter) # e.g., 0.10 for thin trunk, 0.25 for thick
sec.SetDensity(density) # e.g., 500-700 kg/m³ for wood
sec.SetYoungModulus(E) # e.g., 8e9-10e9 Pa for wood
sec.SetShearModulus(E * 0.35) # typically ~35% of Young's modulus
sec.SetRayleighDamping(0.05)
mesh = fea.ChMesh()
mesh.SetAutomaticGravity(True)
up = chrono.ChVector3d(1, 0, 0) # lateral reference direction
builder = fea.ChBuilderBeamEuler()
builder.BuildBeam(
mesh, sec, n_elements,
chrono.ChVector3d(x, y, z_start), # start point
chrono.ChVector3d(x, y, z_end), # end point
up,
)
# Fix the root node
builder.GetLastBeamNodes().front().SetFixed(True)
# Access tip node
tip = builder.GetLastBeamNodes().back()
sys.Add(mesh)
Must keep a reference to GetLastBeamNodes() before indexing. Without this, the SWIG temporary container is garbage-collected and node shared_ptrs become dangling — causing a segfault when GetPos() is called later.
# CORRECT: store the container first
beam_nodes = builder.GetLastBeamNodes()
nodes = [beam_nodes[i] for i in range(beam_nodes.size())]
# WRONG: indexing into a temporary
node = builder.GetLastBeamNodes()[0] # may segfault later
Also keep strong references to meshes, builders, sections, and contact surfaces in a dict or list to prevent premature GC.
Create soft deformable bodies from TetGen mesh files.
material = fea.ChContinuumElastic()
material.SetYoungModulus(0.5e6) # soft rubber
material.SetPoissonRatio(0.4)
material.SetRayleighDampingBeta(0.01)
material.SetDensity(1200) # kg/m³
mesh = fea.ChMesh()
mesh.SetAutomaticGravity(True)
# Non-uniform scale via ChMatrix33d diagonal
scale = chrono.ChMatrix33d(1)
scale.setitem(0, 0, 5.0) # X scale
scale.setitem(1, 1, 0.6) # Y scale
scale.setitem(2, 2, 15.0) # Z scale
fea.ChMeshFileLoader.FromTetGenFile(
mesh,
chrono.GetChronoDataFile("fea/beam.node"),
chrono.GetChronoDataFile("fea/beam.ele"),
material,
chrono.ChVector3d(0, 0, 0.3), # center position
scale,
)
sys.Add(mesh)
FEA meshes need explicit contact surfaces to interact with rigid bodies.
contact_mat = chrono.ChContactMaterialSMC()
contact_mat.SetFriction(0.5)
contact_mat.SetYoungModulus(1e7)
ct = fea.ChContactSurfaceNodeCloud(contact_mat)
ct.AddAllNodes(mesh, contact_radius) # radius around each node
mesh.AddContactSurface(ct)
contact_surf = fea.ChContactSurfaceMesh(contact_mat)
contact_surf.AddFacesFromBoundary(mesh, 0.002) # sphere-swept thickness
mesh.AddContactSurface(contact_surf)
Use ChLinkMateGeneric to join two FEA meshes (or an FEA mesh and a rigid body) with a constraint that can be broken when reaction forces exceed a threshold.
# Join top of lower trunk to bottom of upper trunk
lnk = chrono.ChLinkMateGeneric()
lnk.Initialize(node_top, node_bot, False,
node_top.Frame(), node_bot.Frame())
lnk.SetConstrainedCoords(True, True, True, True, True, True) # all 6 DOF
lnk.SetName("breakable_joint")
sys.Add(lnk)
if not lnk.IsBroken():
M = lnk.GetReaction2().torque.Length()
if M > break_threshold:
lnk.SetBroken(True)
print(f"Joint snapped! M={M:.0f} > {break_threshold}")
ChVisualShapeFEA causes a segfault with VSG on frame update. For beam elements with VSG, use rigid-body cylinder trackers that follow FEA node positions each frame:
# Create one cylinder body per beam segment
for i in range(len(nodes) - 1):
body = chrono.ChBody()
body.SetFixed(True)
body.EnableCollision(False)
cyl = chrono.ChVisualShapeCylinder(radius, segment_length)
cyl.SetColor(color)
body.AddVisualShape(cyl, chrono.ChFramed())
sys.Add(body)
# Each step: update cylinder pos/rot to match FEA node positions
ChVisualShapeFEA works with Irrlicht for tetrahedral meshes:
vis_surface = chrono.ChVisualShapeFEA()
vis_surface.SetFEMdataType(chrono.ChVisualShapeFEA.DataType_NODE_SPEED_NORM)
vis_surface.SetColormapRange(chrono.ChVector2d(0.0, 2.0))
vis_surface.SetSmoothFaces(True)
mesh.AddVisualShapeFEA(vis_surface)
# Wireframe overlay (undeformed reference)
vis_wire = chrono.ChVisualShapeFEA()
vis_wire.SetFEMdataType(chrono.ChVisualShapeFEA.DataType_SURFACE)
vis_wire.SetWireframe(True)
vis_wire.SetDrawInUndeformedReference(True)
mesh.AddVisualShapeFEA(vis_wire)
allowed_classes:
allowed_methods:
allowed_constants:
GetLastBeamNodes() containers, meshes, builders, sections, and contact surfaces. Failing to do so causes dangling pointers and segfaults.ChSystemSMC + ChSolverPardisoMKL. Iterative solvers (PSOR, etc.) will diverge.ChVisualShapeFEA segfaults with VSG. Use rigid-body cylinder trackers for beam visualization, or Irrlicht for tetrahedral visualization.5e-4 or smaller for FEA stability. Larger steps cause divergence.ChContactSurfaceNodeCloud or ChContactSurfaceMesh) — they do not participate in collision by default.