forked from yulee/OpenSees
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_ground_motion.py
More file actions
32 lines (28 loc) · 903 Bytes
/
example_ground_motion.py
File metadata and controls
32 lines (28 loc) · 903 Bytes
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
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import openseespy.opensees as ops
import numpy as np
# Create a basic model with a single node
ops.wipe()
ops.model('basic', '-ndm', 1, '-ndf', 1)
ops.node(1, 0.0); ops.fix(1, 1)
ops.node(2, 0.0); ops.mass(2, 1.0)
ops.uniaxialMaterial('Elastic', 1, 100.0)
ops.damping('Uniform', 1, 0.05, 1.0, 100.0)
ops.element('zeroLength', 1, 1, 2, '-mat', 1, '-dir', 1, '-damp', 1)
ops.timeSeries('Sine', 1, 0.0, 100.0, 0.628, '-factor', -10.0)
ops.pattern('UniformExcitation', 1, 1, '-accel', 1)
ops.analysis('Transient')
ops.recorder('Node', '-file', 'disp.out', '-time', '-node', 2, '-dof', 1, 'disp')
ops.analyze(1000, 0.01)
ops.wipe()
data = np.loadtxt('disp.out')
plt.figure()
plt.plot(data[:, 0], data[:, 1])
plt.xlabel('Time')
plt.ylabel('Displacement')
plt.grid()
plt.show()
#######
plt.savefig('./build/Release/ground_motion.png')