コード例 #1
0
ファイル: test_recorder.py プロジェクト: msalehi2004/OpenSees
def test_recorder_time_step_can_handle_fp_precision():
    import tempfile
    opy.model('basic', '-ndm', 2, '-ndf', 3)
    opy.node(1, 0.0, 0.0)
    opy.node(2, 0.0, 5.0)
    opy.fix(2, 0, 1, 0)
    opy.fix(1, 1, 1, 1)
    opy.equalDOF(2, 1, 2)
    opy.mass(2, 1.0, 0.0, 0.0)
    opy.geomTransf('Linear', 1, '-jntOffset')
    opy.element('elasticBeamColumn', 1, 1, 2, 1.0, 1e+06, 0.00164493, 1)
    opy.timeSeries('Path', 1, '-dt', 0.1, '-values', 0.0, -0.001, 0.001,
                   -0.015, 0.033, 0.105, 0.18)
    opy.pattern('UniformExcitation', 1, 1, '-accel', 1)
    opy.rayleigh(0.0, 0.0159155, 0.0, 0.0)
    opy.wipeAnalysis()
    opy.algorithm('Newton')
    opy.system('SparseSYM')
    opy.numberer('RCM')
    opy.constraints('Transformation')
    opy.integrator('Newmark', 0.5, 0.25)
    opy.analysis('Transient')
    opy.test('EnergyIncr', 1e-07, 10, 0, 2)
    node_rec_ffp = tempfile.NamedTemporaryFile(delete=False).name
    ele_rec_ffp = tempfile.NamedTemporaryFile(delete=False).name
    rdt = 0.01
    adt = 0.001
    opy.recorder('Node', '-file', node_rec_ffp, '-precision', 16, '-dT', rdt,
                 '-rTolDt', 0.00001, '-time', '-node', 1, '-dof', 1, 'accel')
    opy.recorder('Element', '-file', ele_rec_ffp, '-precision', 16, '-dT', rdt,
                 '-rTolDt', 0.00001, '-time', '-ele', 1, 'force')

    opy.record()
    for i in range(1100):
        opy.analyze(1, adt)
        opy.getTime()
    opy.wipe()

    a = open(node_rec_ffp).read().splitlines()
    for i in range(len(a) - 1):
        dt = float(a[i + 1].split()[0]) - float(a[i].split()[0])
        assert abs(dt - 0.01) < adt * 0.1, (i, dt)
    a = open(ele_rec_ffp).read().splitlines()
    for i in range(len(a) - 1):
        dt = float(a[i + 1].split()[0]) - float(a[i].split()[0])
        assert abs(dt - 0.01) < adt * 0.1, (i, dt)
コード例 #2
0
ファイル: Example5.1.py プロジェクト: fmckenna/OpenSees
#        tag MX MY MZ   RX   RY   RZ
ops.mass( 9, m, m, 0.0, 0.0, 0.0, i)
ops.mass(14, m, m, 0.0, 0.0, 0.0, i)
ops.mass(19, m, m, 0.0, 0.0, 0.0, i)

# Define gravity loads
# create a Constant TimeSeries
ops.timeSeries("Constant", 1)
# create a Plain load pattern
ops.pattern("Plain", 1, 1, "-fact", 1.0)

for i in [5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18]:
    ops.load(i, 0.0, 0.0, -p, 0.0, 0.0, 0.0)

# set rayleigh damping factors
ops.rayleigh(0.0, 0.0, 0.0, 0.0018)

# Define earthquake excitation
# ----------------------------
dt = 0.02
# Set up the acceleration records for Tabas fault normal and fault parallel
ops.timeSeries("Path", 2, "-filePath", "tabasFN.txt", "-dt", dt, "-factor", g)
ops.timeSeries("Path", 3, "-filePath", "tabasFP.txt", "-dt", dt, "-factor", g)

# Define the excitation using the Tabas ground motion records
#                         tag dir         accel series args
ops.pattern("UniformExcitation", 2, 1, "-accel", 2)
ops.pattern("UniformExcitation", 3, 2, "-accel", 3)

# print model
#ops.printModel()
コード例 #3
0
# timeseries object for force history
op.timeSeries('Path', 2, '-dt', motionDT, '-filePath', velocityFile + '.txt',
              '-factor', cFactor)
op.pattern('Plain', 10, 2)
op.load(1, 1.0, 0.0, 0.0)

print("Dynamic loading created...")

op.constraints('Penalty', 1.0E16, 1.0E16)
op.test('NormDispIncr', 1e-3, 35, 1)
op.algorithm('KrylovNewton')
op.numberer('RCM')
op.system('ProfileSPD')
op.integrator('Newmark', gamma, beta)
op.rayleigh(a0, a1, 0.0, 0.0)
op.analysis('Transient')

# perform analysis with timestep reduction loop
ok = op.analyze(nSteps, dT)

# if analysis fails, reduce timestep and continue with analysis
if ok != 0:
    print("did not converge, reducing time step")
    curTime = op.getTime()
    mTime = curTime
    print("curTime: ", curTime)
    curStep = curTime / dT
    print("curStep: ", curStep)
    rStep = (nSteps - curStep) * 2.0
    remStep = np.int((nSteps - curStep) * 2.0)
コード例 #4
0
def get_inelastic_response(mass,
                           k_spring,
                           f_yield,
                           motion,
                           dt,
                           xi=0.05,
                           r_post=0.0):
    """
    Run seismic analysis of a nonlinear SDOF

    :param mass: SDOF mass
    :param k_spring: spring stiffness
    :param f_yield: yield strength
    :param motion: list, acceleration values
    :param dt: float, time step of acceleration values
    :param xi: damping ratio
    :param r_post: post-yield stiffness
    :return:
    """

    op.wipe()
    op.model('basic', '-ndm', 2, '-ndf', 3)  # 2 dimensions, 3 dof per node

    # Establish nodes
    bot_node = 1
    top_node = 2
    op.node(bot_node, 0., 0.)
    op.node(top_node, 0., 0.)

    # Fix bottom node
    op.fix(top_node, opc.FREE, opc.FIXED, opc.FIXED)
    op.fix(bot_node, opc.FIXED, opc.FIXED, opc.FIXED)
    # Set out-of-plane DOFs to be slaved
    op.equalDOF(1, 2, *[2, 3])

    # nodal mass (weight / g):
    op.mass(top_node, mass, 0., 0.)

    # Define material
    bilinear_mat_tag = 1
    mat_type = "Steel01"
    mat_props = [f_yield, k_spring, r_post]
    op.uniaxialMaterial(mat_type, bilinear_mat_tag, *mat_props)

    # Assign zero length element
    beam_tag = 1
    op.element('zeroLength', beam_tag, bot_node, top_node, "-mat",
               bilinear_mat_tag, "-dir", 1, '-doRayleigh', 1)

    # Define the dynamic analysis
    load_tag_dynamic = 1
    pattern_tag_dynamic = 1

    values = list(-1 * motion)  # should be negative
    op.timeSeries('Path', load_tag_dynamic, '-dt', dt, '-values', *values)
    op.pattern('UniformExcitation', pattern_tag_dynamic, opc.X, '-accel',
               load_tag_dynamic)

    # set damping based on first eigen mode
    angular_freq = op.eigen('-fullGenLapack', 1)**0.5
    alpha_m = 0.0
    beta_k = 2 * xi / angular_freq
    beta_k_comm = 0.0
    beta_k_init = 0.0

    op.rayleigh(alpha_m, beta_k, beta_k_init, beta_k_comm)

    # Run the dynamic analysis

    op.wipeAnalysis()

    op.algorithm('Newton')
    op.system('SparseGeneral')
    op.numberer('RCM')
    op.constraints('Transformation')
    op.integrator('Newmark', 0.5, 0.25)
    op.analysis('Transient')

    tol = 1.0e-10
    iterations = 10
    op.test('EnergyIncr', tol, iterations, 0, 2)
    analysis_time = (len(values) - 1) * dt
    analysis_dt = 0.001
    outputs = {
        "time": [],
        "rel_disp": [],
        "rel_accel": [],
        "rel_vel": [],
        "force": []
    }

    while op.getTime() < analysis_time:
        curr_time = op.getTime()
        op.analyze(1, analysis_dt)
        outputs["time"].append(curr_time)
        outputs["rel_disp"].append(op.nodeDisp(top_node, 1))
        outputs["rel_vel"].append(op.nodeVel(top_node, 1))
        outputs["rel_accel"].append(op.nodeAccel(top_node, 1))
        op.reactions()
        outputs["force"].append(
            -op.nodeReaction(bot_node, 1))  # Negative since diff node
    op.wipe()
    for item in outputs:
        outputs[item] = np.array(outputs[item])

    return outputs
コード例 #5
0
# Define dynamic loads
# --------------------
# Set some parameters
gmFile = "ARL360.g3"
dt = 0.02

# Set time series to be passed to uniform excitation
ops.timeSeries("Path", 2, "-filePath", gmFile, "-dt", dt, "-factor", g)

# Create UniformExcitation load pattern
#                               tag dir        tsTag
ops.pattern("UniformExcitation", 2, 1, "-accel", 2)

# Set the rayleigh damping factors for nodes & elements
ops.rayleigh(0.0, 0.0, 0.0, 0.000625)

# ----------------------------------------------------
# End of additional modelling for dynamic loads
# ----------------------------------------------------


# ---------------------------------------------------------
# Start of modifications to analysis for transient analysis
# ---------------------------------------------------------

# delete the old analysis and all its component objects
ops.wipeAnalysis()

# create the system of equation, a banded general storage scheme
ops.system("BandGeneral")
コード例 #6
0
ファイル: test_recorder.py プロジェクト: millen1m/OpenSees
def test_recorder_time_step_is_stable():
    opy.model('basic', '-ndm', 2, '-ndf', 2)
    opy.loadConst('-time', 1e+13)
    opy.node(1, 0.0, 0.0)
    opy.node(2, 0.5, 0.0)
    opy.node(3, 0.0, -0.5)
    opy.node(4, 0.5, -0.5)
    opy.equalDOF(3, 4, 1, 2)
    opy.node(5, 0.0, -1.0)
    opy.node(6, 0.5, -1.0)
    opy.equalDOF(5, 6, 1, 2)
    opy.node(7, 0.0, -1.5)
    opy.node(8, 0.5, -1.5)
    opy.equalDOF(7, 8, 1, 2)
    opy.node(9, 0.0, -2.0)
    opy.node(10, 0.5, -2.0)
    opy.equalDOF(9, 10, 1, 2)
    opy.node(11, 0.0, -2.5)
    opy.node(12, 0.5, -2.5)
    opy.equalDOF(11, 12, 1, 2)
    opy.node(13, 0.0, -3.0)
    opy.node(14, 0.5, -3.0)
    opy.equalDOF(13, 14, 1, 2)
    opy.fix(13, 0, 1)
    opy.fix(14, 0, 1)
    opy.node(15, 0.0, -3.0)
    opy.node(16, 0.0, -3.0)
    opy.fix(15, 1, 1)
    opy.fix(16, 0, 1)
    opy.equalDOF(13, 14, 1)
    opy.equalDOF(13, 16, 1)
    opy.nDMaterial('ElasticIsotropic', 1, 212500.0, 0.0, 1.7)
    opy.element('SSPquad', 1, 3, 4, 2, 1, 1, 'PlaneStrain', 1.0, 0.0, 16.677)
    opy.element('SSPquad', 2, 5, 6, 4, 3, 1, 'PlaneStrain', 1.0, 0.0, 16.677)
    opy.element('SSPquad', 3, 7, 8, 6, 5, 1, 'PlaneStrain', 1.0, 0.0, 16.677)
    opy.element('SSPquad', 4, 9, 10, 8, 7, 1, 'PlaneStrain', 1.0, 0.0, 16.677)
    opy.element('SSPquad', 5, 11, 12, 10, 9, 1, 'PlaneStrain', 1.0, 0.0,
                16.677)
    opy.element('SSPquad', 6, 13, 14, 12, 11, 1, 'PlaneStrain', 1.0, 0.0,
                16.677)
    opy.uniaxialMaterial('Viscous', 2, 212.5, 1.0)
    opy.element('zeroLength', 7, 15, 16, '-mat', 2, '-dir', 1)
    opy.constraints('Transformation')
    opy.test('NormDispIncr', 0.0001, 30, 0, 2)
    opy.algorithm('Newton', False, False, False)
    opy.numberer('RCM')
    opy.system('ProfileSPD')
    opy.integrator('Newmark', 0.5, 0.25)
    opy.analysis('Transient')
    opy.analyze(40, 1.0)
    opy.analyze(50, 0.5)
    opy.setTime(1.0e3)
    opy.wipeAnalysis()
    opy.recorder('Node', '-file', 'time_0_01.txt', '-precision', 16, '-dT',
                 0.01, '-rTolDt', 0.00001, '-time', '-node', 1, '-dof', 1,
                 'accel')
    opy.recorder('Element', '-file', 'etime_0_01.txt', '-precision', 16, '-dT',
                 0.01, '-rTolDt', 0.00001, '-time', '-ele', 1, 2, 'stress')
    opy.recorder('EnvelopeNode', '-file', 'entime_0_01.txt', '-precision', 16,
                 '-dT', 0.01, '-time', '-node', 1, '-dof', 1, 'accel')
    # opy.recorder('Drift', '-file', 'dtime_0_01.txt', '-precision', 16, '-dT', 0.01, '-time',
    #              '-iNode', 1, '-jNode', 2, '-dof', 1, '-perpDirn', 2)
    opy.timeSeries('Path', 1, '-dt', 0.01, '-values', -0.0, -0.0, -0.0, -0.0,
                   -0.0, -0.0, -0.0, -0.0, -7.51325e-05)
    opy.pattern('Plain', 1, 1)
    opy.load(13, 1.0, 0.0)
    opy.algorithm('Newton', False, False, False)
    opy.system('SparseGeneral')
    opy.numberer('RCM')
    opy.constraints('Transformation')
    opy.integrator('Newmark', 0.5, 0.25)
    opy.rayleigh(0.17952, 0.000909457, 0.0, 0.0)
    opy.analysis('Transient')
    opy.test('EnergyIncr', 1e-07, 10, 0, 2)
    opy.record()
    opy.analyze(1, 0.001)
    for i in range(1100):
        print(i)
        opy.analyze(1, 0.001)
        cur_time = opy.getTime()
    opy.wipe()

    a = open('time_0_01.txt').read().splitlines()
    for i in range(len(a) - 1):
        dt = float(a[i + 1].split()[0]) - float(a[i].split()[0])
        assert abs(dt - 0.01) < 0.0001, (i, dt)
コード例 #7
0
# --------------------------


# ---------------------------------------
# Create and Perform the dynamic analysis
# ---------------------------------------

# Remove the static analysis & reset the time to 0.0
ops.wipeAnalysis()
ops.setTime(0.0)

# Now remove the loads and let the beam vibrate
ops.remove("loadPattern", 1)

# add some mass proportional damping
ops.rayleigh(0.01, 0.0, 0.0, 0.0)

# Create the transient analysis
ops.test("EnergyIncr", 1.0E-10, 20, 0)
ops.algorithm("Newton")
ops.numberer("RCM")
ops.constraints("Plain")
ops.system("ProfileSPD")
ops.integrator("Newmark", 0.5, 0.25)
ops.analysis("Transient")

# record once at time 0
ops.record()

# Perform the transient analysis (20 sec)
#         numSteps dt
コード例 #8
0
ファイル: Example5.1.py プロジェクト: losusca/1190924
#        tag MX MY MZ   RX   RY   RZ
ops.mass(9, m, m, 0.0, 0.0, 0.0, i)
ops.mass(14, m, m, 0.0, 0.0, 0.0, i)
ops.mass(19, m, m, 0.0, 0.0, 0.0, i)

# Define gravity loads
# create a Constant TimeSeries
ops.timeSeries("Constant", 1)
# create a Plain load pattern
ops.pattern("Plain", 1, 1, "-fact", 1.0)

for i in [5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18]:
    ops.load(i, 0.0, 0.0, -p, 0.0, 0.0, 0.0)

# set rayleigh damping factors
ops.rayleigh(0.0, 0.0, 0.0, 0.0018)

# Define earthquake excitation
# ----------------------------
dt = 0.02
# Set up the acceleration records for Tabas fault normal and fault parallel
ops.timeSeries("Path", 2, "-filePath", "tabasFN.txt", "-dt", dt, "-factor", g)
ops.timeSeries("Path", 3, "-filePath", "tabasFP.txt", "-dt", dt, "-factor", g)

# Define the excitation using the Tabas ground motion records
#                         tag dir         accel series args
ops.pattern("UniformExcitation", 2, 1, "-accel", 2)
ops.pattern("UniformExcitation", 3, 2, "-accel", 3)

# print model
#ops.printModel()