Models

Finite-element models define the problem: topology, active degrees of freedom, applied loads, and prescribed displacements. Solved state is returned as a separate nusa.result.StaticResult snapshot.

Model responsibilities

A model owns:

  • the ordered node collection;

  • the ordered element collection;

  • element-family compatibility validation;

  • active displacement and force DOFs;

  • applied nodal loads;

  • prescribed displacements.

A model does not own solved displacements, reactions, stresses, strains, or assembled solver state.

Common workflow

model = TrussModel("Example")
model.add_nodes([n1, n2])
model.add_element(element)
model.add_force(n2, (10.0, 0.0))
model.add_constraint(n1, ux=0.0, uy=0.0)

result = model.solve()

Nodes and elements

Use add_node / add_nodes and add_element / add_elements to build the topology:

model.add_nodes([n1, n2, n3])
model.add_elements([e1, e2])

NuSA assigns labels automatically when they are missing. Public labels may be strings, sparse integers, or other user-facing identifiers; the solver uses an internal contiguous ordering independent from those labels.

Loads and constraints

The generic model API validates components against the DOFs declared by each family.

Model family DOFs

Model

Displacements

Forces/actions

SpringModel

ux

fx

BarModel

ux

fx

TrussModel

ux, uy

fx, fy

BeamModel

uy, ur

fy, m

LinearTriangleModel

ux, uy

fx, fy

Examples:

truss.add_force(node, (1000.0, -500.0))
truss.add_constraint(node, ux=0.0, uy=0.0)

beam.add_force(node, (-1000.0,))
beam.add_moment(node, (250.0,))
beam.add_constraint(node, uy=0.0, ur=0.0)

Prescribed displacements are not limited to zero. For example:

model.add_constraint(node, ux=0.002)

Inspecting problem inputs

The model exposes the problem inputs before or after a solve:

model.applied_load(node)
model.prescribed_displacement(node)
model.applied_loads
model.prescribed_displacements

Free displacement DOFs in prescribed_displacements are represented by nan.

Solving

model.solve() is a convenience wrapper around nusa.analysis.LinearStaticAnalysis:

result = model.solve()

Calling it repeatedly creates independent results. The model itself remains a problem definition.

Model families

The five public model families are intentionally thin, declarative subclasses of nusa.model.Model. They primarily declare the compatible element type and active DOFs. BeamModel additionally provides add_moment as a family-specific convenience.

API reference

Finite-element problem model definitions.

class nusa.model.BarModel(name='Bar Model 01')[source]

Bases: Model

One-dimensional axial bar model.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

elements

Return a list of element objects.

load_dofs
n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

displacement_dofs = ('ux',)
element_type = 'bar'
force_dofs = ('fx',)
class nusa.model.BeamModel(name='Beam Model 01')[source]

Bases: Model

Euler-Bernoulli beam model.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

elements

Return a list of element objects.

n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

add_moment

add_moment(node, moment)[source]
displacement_dofs = ('uy', 'ur')
element_type = 'beam'
force_dofs = ('fy', 'm')
load_dofs = ('fy',)
class nusa.model.LinearTriangleModel(name='LT Model 01')[source]

Bases: Model

Two-dimensional constant-strain triangle model.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

elements

Return a list of element objects.

load_dofs
n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

displacement_dofs = ('ux', 'uy')
element_type = 'triangle'
force_dofs = ('fx', 'fy')
class nusa.model.Model(name='Model', mtype=None)[source]

Bases: object

Base class for finite-element problem definitions.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

element_type
elements

Return a list of element objects.

load_dofs
n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

add_constraint(node, **constraint)[source]

Prescribe one or more active displacement degrees of freedom.

add_element(element)[source]

Add an element to the model.

Parameters:
elementElement

Instance of an Element to be added.

Raises:
ValueError

If the element type does not match the model type.

add_elements(elements)[source]

Add multiple elements to the model.

Parameters:
elementslist

List of Element instances to be added.

add_force(node, force)[source]

Add a nodal force vector using the model’s declared load DOFs.

add_node(node)[source]

Add a node to the model.

Parameters:
nodeNode

Instance of a Node to be added.

Returns:
None
add_nodes(nodes)[source]

Add multiple nodes to the model.

Parameters:
nodeslist

List of Node instances to be added.

applied_load(node)[source]

Return explicitly applied load components for one node.

property applied_loads

Return the global vector of explicitly applied nodal loads.

Components follow node insertion order and force_dofs.

displacement_dofs = ()
element_type = None
property elements

Return a list of element objects.

Returns:
list

List of Element instances.

force_dofs = ()
load_dofs = None
property n_elements

Return the number of elements in the model.

Returns:
int

Total number of elements.

property n_nodes

Return the number of nodes in the model.

Returns:
int

Total number of nodes.

property nodes

Return a list of node objects.

Returns:
list

List of Node instances.

prescribed_displacement(node)[source]

Return prescribed displacement components for one node.

Unprescribed degrees of freedom are returned as numpy.nan.

property prescribed_displacements

Return the global prescribed-displacement vector.

Free degrees of freedom are represented by numpy.nan. Components follow node insertion order and displacement_dofs.

solve()[source]

Run a linear-static analysis and return a new StaticResult.

The model remains a problem definition: solving does not write displacements, forces, reactions, matrices, or result caches back to the model or its nodes.

class nusa.model.SpringModel(name='Spring Model 01')[source]

Bases: Model

One-dimensional spring model.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

elements

Return a list of element objects.

load_dofs
n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

displacement_dofs = ('ux',)
element_type = 'spring'
force_dofs = ('fx',)
class nusa.model.TrussModel(name='Truss Model 01')[source]

Bases: Model

Two-dimensional truss model.

Attributes:
applied_loads

Return the global vector of explicitly applied nodal loads.

elements

Return a list of element objects.

load_dofs
n_elements

Return the number of elements in the model.

n_nodes

Return the number of nodes in the model.

nodes

Return a list of node objects.

prescribed_displacements

Return the global prescribed-displacement vector.

Methods

add_constraint(node, **constraint)

Prescribe one or more active displacement degrees of freedom.

add_element(element)

Add an element to the model.

add_elements(elements)

Add multiple elements to the model.

add_force(node, force)

Add a nodal force vector using the model's declared load DOFs.

add_node(node)

Add a node to the model.

add_nodes(nodes)

Add multiple nodes to the model.

applied_load(node)

Return explicitly applied load components for one node.

prescribed_displacement(node)

Return prescribed displacement components for one node.

solve()

Run a linear-static analysis and return a new StaticResult.

displacement_dofs = ('ux', 'uy')
element_type = 'truss'
force_dofs = ('fx', 'fy')