LS-DYNA Exporter#
Overview#
HelloTriangle provides functionality to export meshes and complete simulation setups
to LS-DYNA .k files. Supported features include:
Single or multiple meshes (
Mesh/HybridMesh)Node and element sets
Materials and sections (per-part)
Curves / amplitudes
Boundary conditions (BCs), including fixed and prescribed motion
Raw LS-DYNA snippet injection at different levels
Note
One part per mesh is supported.
Node and element numbering is global and continuous.
Advanced LS-DYNA features (e.g., contacts, termination control) must be provided via raw snippets in
model.extraorpart.extra.
Simulation setup dictionary#
The high-level user API is:
save_simulation(simulation_setup, "myinputfile.k")
The simulation_setup dictionary may contain the following top-level keys:
meshes: dictmaterials: dictsections: dictmodel: dict (optional)amplitudes: dict (optional)BCs: dict (optional)
Meshes and parts#
Each mesh is exported as a single LS-DYNA part.
Per-part configuration fields:
mesh:MeshorHybridMeshinstancesets:"all"→ export all node and element sets (default)Noneor[]→ export no setslist[str]→ export only the named sets
eltype:LS-DYNA element type, e.g.,
SHELL,SOLID,BEAM.Defaults are automatically mapped from HelloTriangle element types:
HelloTriangle type
LS-DYNA type
line2BEAMtri3SHELLquad4SHELLtet4SOLIDhex8SOLIDwedge6SOLIDmaterial: material name (str)section: section key (str) pointing tosectionsdictionaryextra: optional raw LS-DYNA snippet appended to the part
Note
HybridMesh cannot mix elements of different dimensionality (e.g., shells and solids) within the same part.
Node and element sets are assigned integer IDs and written as
*SET_NODE_LISTor*SET_SHELL/*SET_SOLID.Node IDs and element IDs are continuous across parts.
Materials and sections#
Materials#
Material dictionary fields:
type: currently onlyelasticis supportedparameters: dict of material properties:E: Young’s modulusnu: Poisson’s ratiorho: density (optional)
extra: optional raw LS-DYNA snippet for custom materials
Sections#
Section dictionary fields:
type:solidorshellthickness: required for shell sectionselform: optional element formulation (shells default = 2, solid default = 1)shrf: optional shell-specific parameternip: optional number of integration points for shellsextra: optional raw LS-DYNA snippet
Boundary conditions#
Supported BC types:
fixeddisplacementvelocityacceleration
BC dictionary fields:
target: dict with:mesh: mesh nameset: node set name
dofs: list of DOF indices (0-based, default all [0..5])0 = X, 1 = Y, 2 = Z, 3 = Rx, 4 = Ry, 5 = Rz
amplitude: optional amplitude name (required for displacement, velocity, acceleration)type: BC type
Note
Fixed BCs and prescribed motions are written globally.
LS-DYNA amplitudes define time-dependent behavior for displacement, velocity, or acceleration BCs.
Amplitudes (curves)#
Tabular amplitudes are supported.
Amplitude dictionary fields:
values: list of[time, value]pairsextra: optional raw LS-DYNA snippet
LS-DYNA amplitudes are written as *DEFINE_CURVE blocks.
Example: Cantilever beam with contact#
import numpy as np
cube = shapes.rectangle(div=[10, 4], dim=[10, 1], eltype="quad4")
fixed_nodes = np.where(np.isclose(cube.coords[:, 0], 0.0))[0]
cube.add_set(fixed_nodes, name="fixed")
sphere = shapes.sphere(long_div=18, lat_div=9).translate([9.0, 0.5, 1.5])
sphere_all = np.arange(len(sphere.coords))
sphere.add_set(sphere_all, name="Nall")
extra_settings = """*CONTACT_AUTOMATIC_SURFACE_TO_SURFACE
$# ssid msid sstyp mstyp
1 2 3 3
$# fs fd
0.2 0.1
$# sfsa sfsb
1.0 1.0
*CONTROL_TERMINATION
$# endtim endcyc dtmin endeng endmas
2.0 0 0.0 0.0 0.0
"""
simulation_setup = {
"meshes": {
"beam": {
"mesh": cube,
"sets": ["fixed"],
"material": "STEEL",
"eltype": "SHELL",
"section": "shell_sec",
},
"sphere": {
"mesh": sphere,
"sets": ["Nall"],
"material": "STEEL",
"eltype": "SHELL",
"section": "shell_sec",
},
},
"materials": {
"STEEL": {
"type": "elastic",
"parameters": {"E": 210e9, "nu": 0.3, "rho": 7800},
},
},
"sections": {
"shell_sec": {
"type": "shell",
"thickness": 0.4,
"elform": 2,
}
},
"amplitudes": {
"amp1": {
"values": [[0.0, 0.0], [2.0, -8.0]],
},
},
"BCs": {
"bc_fixed": {
"type": "fixed",
"target": {"mesh": "beam", "set": "fixed"},
},
"bc_disp": {
"type": "displacement",
"target": {"mesh": "sphere", "set": "Nall"},
"dofs": [2],
"amplitude": "amp1",
},
},
"model": {"extra": extra_settings},
}
save_simulation(simulation_setup, "cantilever_contact.k")