HOME › FORUM › User Discussions › getting wrong answer in basic 2D truss problem
Tagged: 2D Truss
- This topic has 0 replies, 1 voice, and was last updated 2 years, 7 months ago by
Amar Arun.
-
AuthorPosts
-
October 13, 2020 at 8:26 am #32602
Amar Arun
Participanthey experts,
I am trying to analyze a basic 2D truss model, as given below :
import openseespy.opensees as ops
import openseespy.postprocessing.ops_vis as opsvimport numpy as np
import matplotlib.pyplot as plt
import matplotlib.lines as mlines# remove existing model
ops.wipe()# set modelbuilder
ops.model(‘basic’, ‘-ndm’, 2, ‘-ndf’, 2)global numnode,numelem
a=4
n=4
L=n*a
H=4
numnode=6
numelem=9
A=0.1
E=200.0e06
P=-10.e+3# create nodes
ops.node(1, 0.0, 0.0)
ops.node(2, 1*a, 0.0)
ops.node(3, 2*a, 0.0)
ops.node(4, 3*a, 0.0)
ops.node(5, 2*a, 1*H)
ops.node(6, 1*a, 1*H)# set boundary condition
ops.fix(1, 1, 1)
ops.fix(4, 0, 1)# define materials
ops.uniaxialMaterial(“Elastic”, 1, 200.0e06)# define elements
ops.element(“Truss”,1,1,2,A,1)
ops.element(“Truss”,2,2,3,A,1)
ops.element(“Truss”,3,3,4,A,1)
ops.element(“Truss”,4,4,5,A,1)
ops.element(“Truss”,5,5,6,A,1)
ops.element(“Truss”,6,6,1,A,1)
ops.element(“Truss”,7,6,2,A,1)
ops.element(“Truss”,8,6,3,A,1)
ops.element(“Truss”,9,5,3,A,1)# create TimeSeries
ops.timeSeries(“Linear”, 1)# create a plain load pattern
ops.pattern(“Plain”, 1, 1)# Create the nodal load – command: load nodeID xForce yForce
ops.load(2, 0.0, -60000)
ops.load(3, 0.0, -30000)def plot_structure():
plt.axis((-1.0, 20.0, -9.0, 10.0))
ax = plt.gca()
plt.axis(‘off’)
for eid in range(1, numelem + 1):
n1, n2 = ops.eleNodes(eid)
x1, y1 = ops.nodeCoord(n1)
x2, y2 = ops.nodeCoord(n2)
l = mlines.Line2D([x1, x2], [y1, y2])
ax.add_line(l)plt.show()
# Start of analysis generation
# create SOE
ops.system(“ProfileSPD”)# create DOF number
ops.numberer(“RCM”)# create constraint handler
ops.constraints(“Plain”)# create integrator
ops.integrator(“LoadControl”, 1.0)# create algorithm
ops.algorithm(“Linear”)# create analysis object
ops.analysis(“Static”)# perform the analysis
ops.analyze(1)ops.reactions()
def report_Solution():
print(‘nid X Y iDx iDy Ux Uy’)
for nid in range(1,numnode+1):
x,y=ops.nodeCoord(nid)
iDx,iDy=ops.nodeDOFs(nid)
ux = ops.nodeDisp(nid,1)
uy = ops.nodeDisp(nid,2)
print(‘%2d %8.3f %8.3f %3d %3d %12.4e %12.4e’%(nid,x,y,iDx,iDy,ux,uy))
print(‘eid n1 n2 Member Force’)
for eid in range(1,numelem+1):
n1,n2=ops.eleNodes(eid)
MF=ops.eleForce(eid)
print(‘%2d %2d %2d %10.4f’%(eid,n1,n2,MF[0]))
print(‘nid Rx Ry’)
for nid in [1,4]:
Rx,Ry,=ops.nodeReaction(nid)
print(‘%2d %10.4f %10.4f’%(nid,Rx,Ry))report_Solution()
plot_structure()but i am getting wrong elemental force in inclined members. Can you guys tell me what is wrong in my code.
i have attached the correct answer in each element below
-
AuthorPosts
- You must be logged in to reply to this topic.