Linear triangle elements
The linear triangle is a three-node constant-strain triangle (CST) for 2D plane
stress. Each node contributes ux and uy displacement DOFs, with
corresponding fx and fy nodal forces.
Use nusa.model.LinearTriangleModel with
nusa.element.LinearTriangle.
Element properties
A CST element requires Young’s modulus E, Poisson’s ratio nu, and
thickness t:
element = LinearTriangle(
(n1, n2, n3),
E=200e9,
nu=0.3,
t=0.1,
)
The canonical element result contains constant strain and stress components:
strain_xx
strain_yy
strain_xy
stress_xx
stress_yy
stress_xy
Example: single CST element
The following example builds a single triangular element, constrains two nodes, applies an in-plane load, solves the model, and plots nodal fields.
1# -*- coding: utf-8 -*-
2# ***********************************
3# Author: Pedro Jorge De Los Santos
4# E-mail: delossantosmfq@gmail.com
5# License: MIT License
6# ***********************************
7
8import matplotlib.pyplot as plt
9
10from nusa import LinearTriangle, LinearTriangleModel, Node, plot_model
11
12
13def build_model():
14 model = LinearTriangleModel("Single CST")
15
16 n1 = Node((0.0, 0.0))
17 n2 = Node((1.0, 0.5))
18 n3 = Node((0.0, 1.0))
19
20 model.add_nodes([n1, n2, n3])
21 model.add_element(
22 LinearTriangle((n1, n2, n3), E=200e9, nu=0.3, t=0.1)
23 )
24 model.add_constraint(n1, ux=0.0, uy=0.0)
25 model.add_constraint(n3, ux=0.0, uy=0.0)
26 model.add_force(n2, (1000.0, 0.0))
27 return model
28
29
30def main():
31 model = build_model()
32 plot_model(model)
33
34 result = model.solve()
35 result.plot_nodal_field("ux")
36 result.plot_nodal_field("stress_xx")
37 plt.show()
38
39
40if __name__ == "__main__":
41 main()
Element and nodal fields
Element fields are read directly from the canonical element results:
result.element_field("stress_xx")
Nodal fields can be recovered from element values:
result.nodal_field("stress_xx")
For the current CST implementation, element scalar fields are recovered to nodes using arithmetic averaging over adjacent elements.
Derived fields
NuSA also provides selected derived nodal fields:
result.nodal_field("displacement_magnitude")
result.nodal_field("von_mises_stress")
Legacy short aliases such as sxx and seqv are still accepted by the
post-processing helpers, while the canonical names are preferred in new code.
Visualization
Problem geometry, loads, and constraints are plotted from the model:
from nusa import plot_model
plot_model(model)
Solved scalar fields are plotted from the result:
result.plot_nodal_field("stress_xx")
result.plot_element_field("stress_xx")
This distinction is especially useful for continuum problems because the mesh belongs to the problem definition while stress/strain fields belong to a particular analysis result.