Truss model
This file contains a Python procedure to perform the analysis of example1 (found in most documents). In the main()
procedure:
- each object of the domain, i.e. Nodes, Elements, Constraints, and LoadPattern objects are created and then added to the Domain.
- the components of the analysis object are constructed and then the Analysis object is created.
- the analysis is performed.
- the results are printed - here the contents of Domain and end of the analysis operation.
from pyg3 import _pyg3
create a domain and a modelbuilder and build the model
theDomain = pyg3.domain.Domain()
print(theDomain)
create the nodes using constructor: Node(tag, ndof, crd1, crd2)
and then add them to the domain
nodes = [
pyg3.domain.Node(1, 2, 0.0, 0.0)
pyg3.domain.Node(2, 2, 144.0, 0.0)
pyg3.domain.Node(3, 2, 168.0, 0.0)
pyg3.domain.Node(4, 2, 72.0, 96.0)
]
for node in nodes: theDomain.addNode(node)
create an elastic material using constriuctor:
ElasticMaterialModel(tag, E) – theMaterial = pyg3.ElasticMaterial(1, 3000)
create the truss elements using constructor: Truss(tag, dim, nd1, nd2, Material &,A) and then add them to the domain
– Truss truss1 = pyg3.Truss(1, 2, 1, 4, theMaterial, 10.0) – Truss truss2 = pyg3.Truss(2, 2, 2, 4, theMaterial, 5.0)
– Truss truss3 = pyg3.Truss(3, 2, 3, 4, theMaterial, 5.0)
– theDomain.addElement(truss1) – theDomain.addElement(truss2) – theDomain.addElement(truss3)
create the single-point constraint objects using constructor: SP_Constraint(tag, nodeTag, dofID, value) and then add them to the domain
sp1 = pyg3.domain.SP_Constraint(1, 1, 0, 0.0)
sp2 = pyg3.domain.SP_Constraint(2, 1, 1, 0.0)
sp3 = pyg3.domain.SP_Constraint(3, 2, 0, 0.0)
sp4 = pyg3.domain.SP_Constraint(4, 2, 1, 0.0)
sp5 = pyg3.domain.SP_Constraint(5, 3, 0, 0.0)
sp6 = pyg3.domain.SP_Constraint(6, 3, 1, 0.0)
theDomain.addSP_Constraint(sp1)
theDomain.addSP_Constraint(sp2)
theDomain.addSP_Constraint(sp3)
theDomain.addSP_Constraint(sp4)
theDomain.addSP_Constraint(sp5)
theDomain.addSP_Constraint(sp6)
construct a linear time series object using constructor: LinearSeries()
theSeries = pyg3.domain.LinearSeries()
print(theSeries)
construct a load pattren using constructor: LoadPattern(tag)
and then set it’s TimeSeries and add it to the domain
theLoadPattern = pyg3.domain.LoadPattern(1)
print(theLoadPattern)
theLoadPattern.setTimeSeries(theSeries)
theDomain.addLoadPattern(theLoadPattern)
print(theDomain)
Construct a nodal load using constructor NodalLoad(tag, nodeID, Vector &)
. First construct a Vector of size 2 and set the values then construct the load and add it to the domain
theLoadValues = pyg3.Vector([100, -50])
theLoad = pyg3.domain.NodalLoad(1, 4, theLoadValues)
print(theLoad)
theDomain.addNodalLoad(theLoad, 1)
create an Analysis object to perform a static analysis of the model
AnalysisModel
of typeAnalysisModel
,EquiSolnAlgo
of typeLinear
StaticIntegrator
of typeLoadControl
ConstraintHandler
of type PenaltyDOF_Numberer
which uses RCMLinearSOE
of type Band SPD
and then the StaticAnalysis
object
theModel = pyg3.analysis.AnalysisModel()
print(theModel)
theSolnAlgo = pyg3.analysis.Linear()
print(theSolnAlgo)
theIntegrator = pyg3.analysis.LoadControl(1.0, 1, 1.0, 1.0)
theHandler = pyg3.analysis.PenaltyConstraintHandler(1.0e8,1.0e8)
theRCM = pyg3.graph.RCM()
print(theRCM)
theNumberer = pyg3.analysis.DOF_Numberer(theRCM)
print(theNumberer)
theSolver = pyg3.sys_of_eqn.BandSPDLinLapackSolver()
print(theSolver)
theSOE = pyg3.sys_of_eqn.BandSPDLinSOE(theSolver)
Build the analysis object.
theAnalysis = pyg3.analysis.StaticAnalysis(theDomain,
theHandler,
theNumberer,
theModel,
theSolnAlgo,
theSOE,
theIntegrator
)
print(theAnalysis)
perform the analysis & print out the results for the domain
numSteps = 1
theAnalysis.analyze(numSteps)
print("Analysis complete")