model
Model
Own a model's definitions, mesh parts, assembly, and exported solver process.
Each Model creates its own managers. Create definitions through those managers, assign them to mesh parts, assemble the parts, and export a solver script. Model construction and export do not launch OpenSees.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str | None
|
Default export basename, or None to require explicit filenames. |
None
|
model_path
|
str | None
|
Default export directory. Unknown configuration keywords are rejected instead of silently ignored. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
assembled_mesh |
UnstructuredGrid | None
|
Combined mesh after assembly, or None before assembly
and after |
material |
Material registry with |
|
section |
Beam, shell, fiber, and other section factories. |
|
transformation |
Coordinate-transformation definitions for elements. |
|
element |
Beam, brick, quad, and special element definitions. |
|
meshpart |
Factories and registry for discretized component meshes. |
|
assembler |
Section creation, mesh combination, and partitioning. |
|
interface |
Connections between separate model components. |
|
constraint |
Single-point and multipoint constraints through |
|
mass |
Nodal mass assignment helpers. |
|
damping |
Damping definitions. |
|
region |
Region definitions and damping association. |
|
group |
Node and element selection groups. |
|
mask |
Model selection masks. |
|
time_series |
Loading time-function definitions. |
|
ground_motion |
Ground-motion definitions referencing time series. |
|
load |
Load definitions used by patterns. |
|
pattern |
Load-pattern definitions. |
|
recorder |
Solver response-output definitions. |
|
actions |
Deferred solver commands. |
|
analysis |
Static/transient analyses and solution-stack factories. |
|
process |
Ordered solver operations included in the exported Tcl. |
|
events |
Model-owned lifecycle notification bus. |
|
spatial_transform |
Spatial mesh transformation service. |
Example
from femora import Model
model = Model(model_name="site", model_path="example_outputs/site")
soil = model.material.nd.elastic_isotropic(
user_name="soil", E=108000.0, nu=1.0 / 3.0, rho=1.8,
)
model.set_results_folder("results")
assert model.material.get_by_name("soil") is soil
assert model.assembled_mesh is None
Note
Femora does not convert units. Choose a consistent system for geometry, material stiffness, density, loads, and time. A Model is not a Jobs Workflow and its process is not a remote execution scheduler.
Initialize a Femora Model instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str | None
|
Name used for default exported filenames. |
None
|
model_path
|
str | None
|
Directory used for default exports. |
None
|
Methods:
| Name | Description |
|---|---|
set_model_info |
Update model information |
set_results_folder |
Store the output-folder setting used during recorder/export generation. |
get_results_folder |
Get the current results folder path |
export_to_tcl |
Export the model to a TCL file |
export_to_vtk |
Export the model to a vtk file |
export_to_json |
Export a lightweight structural snapshot of the model to JSON. |
print_info |
Print final-mesh point/cell counts, or 'No mesh found'. |
set_nodetag_start |
Set the starting tag number for nodes in exported TCL. |
set_eletag_start |
Set the starting tag number for elements in exported TCL. |
set_start_core_tag |
Set the starting tag number for cores in exported TCL. |
get_max_ele_tag |
Compute the last sequential export element tag from the cell count. |
get_max_node_tag |
Compute the last sequential export node tag from the point count. |
get_start_ele_tag |
Return the first exported solver element tag. |
get_start_node_tag |
Return the first exported solver node tag. |
get_femora_parts |
Return a detached metadata snapshot of registered source parts. |
clear_model |
Clear model definitions, assembled meshes, and ordered process steps. |
Methods:
set_model_info
Update model information
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
New model name |
None
|
model_path
|
str
|
New model path |
None
|
set_results_folder
Store the output-folder setting used during recorder/export generation.
This setter stores the supplied value as-is. It does not create the directory, inspect permissions, or change Python's working directory. Relative paths are interpreted by the generated solver commands in their execution environment, not resolved by this setter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_name
|
str
|
path to the results folder |
required |
get_results_folder
Get the current results folder path
Returns:
| Name | Type | Description |
|---|---|---|
folder |
str
|
The path to the results folder |
export_to_tcl
export_to_tcl(filename: str | None = None, progress_callback: Callable[..., None] | None = None, decimals: int = 5) -> bool
Export the model to a TCL file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename to export to. If None, uses model_name in model_path |
None
|
progress_callback
|
callable
|
Callback function to report progress. If None, uses tqdm progress bar. |
None
|
decimals
|
int
|
Coordinate precision passed to the Tcl exporter. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
True on success. Export/filesystem failures raise exceptions rather than returning False. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no filename is provided and model_name/model_path are not set |
export_to_vtk
Export the model to a vtk file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename to export to. If None, uses model_name in model_path |
None
|
write_info_json
|
bool
|
When True, also write a lightweight sidecar JSON file. |
False
|
indent
|
int
|
JSON indentation level for sidecar info. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
True on success. Missing assembly and write errors raise exceptions rather than returning False. |
export_to_json
Export a lightweight structural snapshot of the model to JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The filename to export to. If None, uses model_name in model_path |
None
|
indent
|
int
|
JSON indentation level. Defaults to 2. |
2
|
Returns:
| Name | Type | Description |
|---|---|---|
success |
bool
|
True if export was successful |
print_info
Print final-mesh point/cell counts, or 'No mesh found'.
This writes to stdout and returns None. It does not inspect convergence or validate the physical model.
set_nodetag_start
Set the starting tag number for nodes in exported TCL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_tag
|
int
|
First node tag to use (must be >= 1) |
required |
set_eletag_start
Set the starting tag number for elements in exported TCL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_tag
|
int
|
First element tag to use (must be >= 1) |
required |
set_start_core_tag
Set the starting tag number for cores in exported TCL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start_tag
|
int
|
First core tag to use (must be >= 0) |
required |
get_max_ele_tag
Compute the last sequential export element tag from the cell count.
Returns:
| Name | Type | Description |
|---|---|---|
tag |
int
|
Start tag plus cell count minus one, or -1 without assembly. This does not inspect arbitrary imported cell tags. |
get_max_node_tag
Compute the last sequential export node tag from the point count.
Returns:
| Name | Type | Description |
|---|---|---|
tag |
int
|
Start tag plus point count minus one, or -1 without assembly. This is not the number of free solver equations. |
get_start_ele_tag
Return the first exported solver element tag.
Returns:
| Name | Type | Description |
|---|---|---|
tag |
int
|
Export origin, independent of element-definition registry tags. |
get_start_node_tag
Return the first exported solver node tag.
Returns:
| Name | Type | Description |
|---|---|---|
tag |
int
|
Origin used when mapping zero-based assembled point indices. |
get_femora_parts
Return a detached metadata snapshot of registered source parts.
Returns:
| Type | Description |
|---|---|
list[dict]
|
list[dict]: Source-part records used by VTK export. This is not a |
list[dict]
|
mesh-part registry or a replacement for |
clear_model
Clear model definitions, assembled meshes, and ordered process steps.
Managers are retained but emptied, export tag starts reset to their defaults, and built-in lifecycle subscriptions are re-established. Custom event subscriptions are removed. Model name, model path, and the results-folder setting are retained.
This is destructive to the in-memory model. It does not delete exported
files or results, stop a running solver, or emit a solver wipe.
Previously held component references may be detached or stale; rebuild
definitions through the model's managers before assembling again.