Note
Go to the end to download the full example code.
Statically determinate truss bridge.
The system is statically determined and allows for relatively easy validation of calculated deformation, reactions and internal forces.
Author: Peter Mackenzie-Helnwein
from femedu.examples import Example
from femedu.domain import System, Node
from femedu.solver import NewtonRaphsonSolver
from femedu.elements.linear import Truss
from femedu.materials import FiberMaterial
class ExampleTruss02(Example):
def problem(self):
# initialize a system model
P = -10.0 # reference load on top nodes
B = 6.0 * 12 # with of one bay in inches
H = 8.0 * 12 # height of one bay in inches
# material model parameters
params = {'E': 10000., 'A': 3., 'nu': 0.0, 'fy': 1.e30}
model = System()
model.setSolver(NewtonRaphsonSolver())
# create nodes
nd0 = Node(0.0, 0.0)
nd1 = Node( B, 0.0)
nd2 = Node(2*B, 0.0)
nd3 = Node(3*B, 0.0)
nd4 = Node(4*B, 0.0)
nd5 = Node(0.5*B, H)
nd6 = Node(1.5*B, H)
nd7 = Node(2.5*B, H)
nd8 = Node(3.5*B, H)
model.addNode(nd0, nd1, nd2, nd3, nd4, nd5, nd6, nd7, nd8)
# create elements
model.addElement(Truss(nd0, nd1, FiberMaterial(params))) # bottom 1
model.addElement(Truss(nd1, nd2, FiberMaterial(params))) # bottom 2
model.addElement(Truss(nd2, nd3, FiberMaterial(params))) # bottom 3
model.addElement(Truss(nd3, nd4, FiberMaterial(params))) # bottom 4
model.addElement(Truss(nd5, nd6, FiberMaterial(params))) # upper 1
model.addElement(Truss(nd6, nd7, FiberMaterial(params))) # upper 2
model.addElement(Truss(nd7, nd8, FiberMaterial(params))) # upper 3
model.addElement(Truss(nd0, nd5, FiberMaterial(params))) # up right diag 1
model.addElement(Truss(nd1, nd6, FiberMaterial(params))) # up right diag 2
model.addElement(Truss(nd2, nd7, FiberMaterial(params))) # up right diag 3
model.addElement(Truss(nd3, nd8, FiberMaterial(params))) # up right diag 4
model.addElement(Truss(nd1, nd5, FiberMaterial(params))) # up left diag 1
model.addElement(Truss(nd2, nd6, FiberMaterial(params))) # up left diag 2
model.addElement(Truss(nd3, nd7, FiberMaterial(params))) # up left diag 3
model.addElement(Truss(nd4, nd8, FiberMaterial(params))) # up left diag 4
# define support(s)
nd0.fixDOF('ux', 'uy') # horizontal support left end
nd4.fixDOF('uy') # vertical support right end
# add loads
# .. load only the upper nodes
nd5.setLoad((P,), ('uy',))
nd6.setLoad((P,), ('uy',))
nd7.setLoad((P,), ('uy',))
nd8.setLoad((P,), ('uy',))
model.setLoadFactor(0.0)
model.plot(factor=1., filename="truss02_undeformed.png", title="Undeformed System", show_bc=1)
# analyze the model
model.setLoadFactor(1.0)
model.solve()
# write out report
model.report()
# create plots
model.plot(factor=50., filename="truss02_deformed.png", show_loads=1, show_reactions=1)
model.beamValuePlot('f',filename="truss02_forces.png")
Run the example by creating an instance of the problem and executing it by calling Example.run()
if __name__ == "__main__":
ex = ExampleTruss02()
ex.run()
/Users/pmackenz/Development/Educational/FEM.edu/venv/lib/python3.13/site-packages/matplotlib/quiver.py:678: RuntimeWarning: Mean of empty slice.
amean = a.mean()
/Users/pmackenz/Development/Educational/FEM.edu/venv/lib/python3.13/site-packages/numpy/_core/_methods.py:145: RuntimeWarning: invalid value encountered in scalar divide
ret = ret.dtype.type(ret / rcount)
+
System Analysis Report
=======================
Nodes:
---------------------
Node_27:
x: [0.000 0.000]
fix: ['ux', 'uy']
u: [0.000 0.000]
Node_28:
x: [72.000 0.000]
u: [0.018 -0.184]
Node_29:
x: [144.000 0.000]
u: [0.054 -0.250]
Node_30:
x: [216.000 0.000]
u: [0.090 -0.184]
Node_31:
x: [288.000 0.000]
fix: ['uy']
u: [0.108 0.000]
Node_32:
x: [36.000 96.000]
P: [0.000 -10.000]
u: [0.099 -0.115]
Node_33:
x: [108.000 96.000]
P: [0.000 -10.000]
u: [0.072 -0.244]
Node_34:
x: [180.000 96.000]
P: [0.000 -10.000]
u: [0.036 -0.244]
Node_35:
x: [252.000 96.000]
P: [0.000 -10.000]
u: [0.009 -0.115]
Elements:
---------------------
Truss: Node_27 to Node_28:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.00025000000000000033 stress:{'xx': np.float64(2.500000000000003), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 7.500000000000009
Truss: Node_28 to Node_29:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.0005000000000000004 stress:{'xx': np.float64(5.000000000000004), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 15.000000000000014
Truss: Node_29 to Node_30:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.0005000000000000003 stress:{'xx': np.float64(5.0000000000000036), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 15.00000000000001
Truss: Node_30 to Node_31:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.0002500000000000002 stress:{'xx': np.float64(2.500000000000002), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 7.500000000000007
Truss: Node_32 to Node_33:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.00037499999999999995 stress:{'xx': np.float64(-3.7499999999999996), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -11.249999999999998
Truss: Node_33 to Node_34:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0005000000000000002 stress:{'xx': np.float64(-5.000000000000003), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -15.000000000000007
Truss: Node_34 to Node_35:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0003750000000000001 stress:{'xx': np.float64(-3.7500000000000013), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -11.250000000000004
Truss: Node_27 to Node_32:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0007120003121097943 stress:{'xx': np.float64(-7.120003121097944), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -21.36000936329383
Truss: Node_28 to Node_33:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0003560001560548976 stress:{'xx': np.float64(-3.560001560548976), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -10.680004681646928
Truss: Node_29 to Node_34:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:2.5379253212048097e-20 stress:{'xx': np.float64(2.5379253212048096e-16), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 7.613775963614429e-16
Truss: Node_30 to Node_35:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.0003560001560548972 stress:{'xx': np.float64(3.560001560548972), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 10.680004681646915
Truss: Node_28 to Node_32:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:0.00035600015605489707 stress:{'xx': np.float64(3.5600015605489705), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 10.680004681646912
Truss: Node_29 to Node_33:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:2.7917178533252903e-19 stress:{'xx': np.float64(2.7917178533252904e-15), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: 8.375153559975872e-15
Truss: Node_30 to Node_34:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0003560001560548976 stress:{'xx': np.float64(-3.560001560548976), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -10.680004681646928
Truss: Node_31 to Node_35:
material properties: FiberMaterial(Material)({'E': 10000.0, 'A': 3.0, 'nu': 0.0, 'fy': 1e+30}) strain:-0.0007120003121097943 stress:{'xx': np.float64(-7.120003121097944), 'yy': 0.0, 'zz': 0.0, 'xy': 0.0}
internal force: -21.36000936329383
Total running time of the script: (0 minutes 0.072 seconds)