/
OpenSeesPy_Example.py
89 lines (64 loc) · 1.72 KB
/
OpenSeesPy_Example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
print("==========================")
import sys
sys.path.append('path/to/directory/of/pyd/file')
from opensees import *
# ------------------------------
# Start of model generation
# -----------------------------
print("Starting Truss example")
# remove existing model
wipe()
# set modelbuilder
model('basic', '-ndm', 2, '-ndf', 2)
# create nodes
node(1, 0.0, 0.0)
node(2, 144.0, 0.0)
node(3, 168.0, 0.0)
node(4, 72.0, 96.0)
# set boundary condition
fix(1, 1, 1)
fix(2, 1, 1)
fix(3, 1, 1)
# define materials
uniaxialMaterial("Elastic", 1, 3000.0)
# define elements
element("Truss",1,1,4,10.0,1)
element("Truss",2,2,4,5.0,1)
element("Truss",3,3,4,5.0,1)
# create TimeSeries
timeSeries("Linear", 1)
# create a plain load pattern
pattern("Plain", 1, 1)
# Create the nodal load - command: load nodeID xForce yForce
load(4, 100.0, -50.0)
# ------------------------------
# Start of analysis generation
# ------------------------------
# create SOE
system("BandSPD")
# create DOF number
numberer("RCM")
# create constraint handler
constraints("Plain")
# create integrator
integrator("LoadControl", 1.0)
# create algorithm
algorithm("Linear")
# create analysis object
analysis("Static")
# ------------------------------
# Finally perform the analysis
# ------------------------------
# perform the analysis
analyze(1)
results = open('results.out','a+')
ux = nodeDisp(4,1)
uy = nodeDisp(4,2)
if abs(ux-0.53009277713228375450)<1e-12 and abs(uy+0.17789363846931768864)<1e-12:
results.write('PASSED : Truss.py\n');
print("Passed!")
else:
results.write('FAILED : Truss.py\n');
print("Failed!")
results.close()
print("==========================")