def get_disp(GRS): ops.timeSeries('Linear', 1) ops.pattern('Plain', 1, 1) for i in range(GRS.nbnBns): if GRS.LoadType == 0 \ or (GRS.GeomType in {0, 1, 2} and GRS.LoadType == 1 and GRS.nsAll.x[GRS.nbn[i]] <= 0) \ or (GRS.GeomType in {0, 1, 2} and GRS.LoadType == 2 and GRS.nsAll.y[GRS.nbn[i]] <= 0) \ or (GRS.GeomType in {4} and GRS.LoadType == 1 and GRS.nsAll.x[GRS.nbn[i]] <= GRS.span / 2) \ or (GRS.GeomType in {4} and GRS.LoadType == 2 and GRS.nsAll.y[GRS.nbn[i]] <= GRS.span / 2): ops.load(int(100 + GRS.nbn[i]), 0., 0., -1., 0., 0., 0.) ops.algorithm("Linear") ops.integrator("LoadControl", 1) ops.analysis('Static') ops.analyze(1) NDisp = np.zeros([GRS.nbNsAll, 3]) for j in range(GRS.nbNsAll): NDisp[j, 0] = ops.nodeDisp(int(j + 100), 1) NDisp[j, 1] = ops.nodeDisp(int(j + 100), 2) NDisp[j, 2] = ops.nodeDisp(int(j + 100), 3) return NDisp
def RunIterations2(GRS, Fz, printOn): ops.timeSeries('Linear', 1) ops.pattern('Plain', 1, 1) for i in range(GRS.nbnBns): ops.load(int(100 + GRS.nbn[i]), 0., 0., Fz * un.kN, 0., 0., 0.) GRS.GetTopNode() # ops.load(int(100+GRS.maxNsID), 0., 0., Fz * kN, 0., 0., 0.) # mid-point # create SOE ops.system('UmfPack') # create DOF number ops.numberer('RCM') # create constraint handler ops.constraints('Transformation') # create integrator ops.integrator("LoadControl", 1.0 / GRS.Steps) # create algorithm ops.algorithm("Newton") # create test ops.test('EnergyIncr', 1.e-10, 100) ops.analysis('Static') NDisp = np.zeros([GRS.Steps + 1, GRS.nbNsAll, 3]) # EDisp = np.zeros([GRS.Steps + 1, GRS.nbElAll, 6]) EForce = np.zeros([GRS.Steps + 1, GRS.nbElAll, 12]) reI = 0 reI = 0 lefutott = 1 for i in range(1, GRS.Steps + 1): hiba = ops.analyze(1) if hiba == 0: if i == 1: if printOn: print('analysis step 1 completed successfully') for j in range(GRS.nbNsAll): NDisp[i, j, 0] = -ops.nodeDisp(int(j + 100), 1) / un.mm # mm displacement NDisp[i, j, 1] = -ops.nodeDisp(int(j + 100), 2) / un.mm # mm displacement NDisp[i, j, 2] = -ops.nodeDisp(int(j + 100), 3) / un.mm # mm displacement for j in range(GRS.nbElAll): EForce[i, j] = ops.eleResponse(int(j + 1000), 'localForce') # EDisp[i, j] = ops.eleResponse(int(j + 1000), 'basicDeformation') else: lefutott = 0 reI = i if reI == 1: if printOn: print('analysis failed to converge in step ', i) break return lefutott, NDisp, EForce, reI
print("Fundamental period at start of pushover analysis: ", Tstart, "sec\n") # Change the integrator to take a min and max load increment ops.integrator("LoadControl", 1.0, 4, 0.02, 2.0) # record once at time 0 ops.record() # Perform the pushover analysis # Set some parameters maxU = 10.0; # Max displacement controlDisp = 0.0 ok = ops.analyze(1) while ((ok == 0) and (controlDisp < maxU)): ok = ops.analyze(1) controlDisp = ops.nodeDisp(3, 1) if (ok != 0): print("... trying an initial tangent iteration") ops.test("NormDispIncr", 1.0e-8, 4000, 0) ops.algorithm("ModifiedNewton", "-initial") ok = ops.analyze(1) ops.test("NormDispIncr", 1.0e-8, 10, 0) ops.algorithm("Newton") # Print a message to indicate if analysis successful or not if (ok == 0): print("\nPushover analysis completed SUCCESSFULLY\n") else: print("\nPushover analysis FAILED\n") # Print the state at node 3
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
# ------------------------------ # record once at time 0 ops.record() # Set some parameters maxU = 15.0 # Max displacement numSteps = int(maxU / dU) # Perform the analysis ok = ops.analyze(numSteps) if (ok != 0): currentDisp = ops.nodeDisp(3, 1) ok = 0 while ((ok == 0) and (currentDisp < maxU)): ok = ops.analyze(1) # if the analysis fails try initial tangent iteration if (ok != 0): print( "regular newton failed .. lets try an initial stiffness for this step" ) ops.test("NormDispIncr", 1.0E-12, 1000) ops.algorithm("ModifiedNewton", "-initial") ok = ops.analyze(1) if (ok == 0): print("that worked .. back to regular newton")
#---------------------------------------------------------- op.integrator('LoadControl', 0.05) op.numberer('RCM') op.system('SparseGeneral') op.constraints('Transformation') op.test('NormDispIncr', 1e-5, 20, 1) op.algorithm('Newton') op.analysis('Static') print("Starting Load Application...") op.analyze(201) print("Load Application finished...") #print("Loading Analysis execution time: [expr $endT-$startT] seconds.") #op.wipe op.reactions() Nodereactions = dict() Nodedisplacements = dict() for i in range(201,nodeTag+1): Nodereactions[i] = op.nodeReaction(i) Nodedisplacements[i] = op.nodeDisp(i) print('Node Reactions are: ', Nodereactions) print('Node Displacements are: ', Nodedisplacements)
ops.fix(2, 1, 1) ops.fix(3, 1, 1) ops.mass(4, 100.0, 100.0) ops.element('Truss', 2, 2, 4, 5.0, 1) ops.element('Truss', 3, 3, 4, 5.0, 1) ops.constraints('Transformation') ops.numberer('ParallelPlain') ops.test('NormDispIncr', 1e-6, 6, 2) ops.algorithm('Linear') etype = 'central_difference' etype = 'explicit_difference' # Comment out this line to run with central difference if etype == 'central_difference': ops.system('Mumps') ops.integrator('CentralDifference') else: # ops.system('Mumps') ops.system( 'MPIDiagonal') # Can use Mumps here but not sure if it scales as well ops.integrator('ExplicitDifference') ops.analysis('Transient') for i in range(30): print(f'######################################## run {i} ##') ops.analyze(1, 0.000001) print('PPP') ops.analyze(20, 0.00001) print(pid, ' Node 4: ', [ops.nodeCoord(4), ops.nodeDisp(4)]) print(pid, " COMPLETED")
# Finally perform the analysis # ------------------------------ # record once at time 0 ops.record() # Set some parameters maxU = 15.0; # Max displacement numSteps = int(maxU/dU) # Perform the analysis ok = ops.analyze(numSteps) if (ok != 0): currentDisp = ops.nodeDisp(3, 1) ok = 0 while ((ok == 0) and (currentDisp < maxU)): ok = ops.analyze(1) # if the analysis fails try initial tangent iteration if (ok != 0): print("regular newton failed .. lets try an initial stiffness for this step") ops.test("NormDispIncr", 1.0E-12, 1000) ops.algorithm("ModifiedNewton", "-initial") ok = ops.analyze(1) if (ok == 0): print("that worked .. back to regular newton") ops.test("NormDispIncr", 1.0E-12, 10) ops.algorithm("Newton")
def RunIterations(GRS, Fz, printOn): ops.timeSeries('Linear', 1) ops.pattern('Plain', 1, 1) loadA = np.linspace(0, -Fz, GRS.Steps + 1) # kN for i in range(GRS.nbnBns): if GRS.LoadType == 0 \ or (GRS.GeomType in {0, 1, 2} and GRS.LoadType == 1 and GRS.nsAll.x[GRS.nbn[i]] <= 0) \ or (GRS.GeomType in {0, 1, 2} and GRS.LoadType == 2 and GRS.nsAll.y[GRS.nbn[i]] <= 0) \ or (GRS.GeomType in {4} and GRS.LoadType == 1 and GRS.nsAll.x[GRS.nbn[i]] <= GRS.span / 2) \ or (GRS.GeomType in {4} and GRS.LoadType == 2 and GRS.nsAll.y[GRS.nbn[i]] <= GRS.span / 2): ops.load(int(100 + GRS.nbn[i]), 0., 0., Fz * un.kN, 0., 0., 0.) GRS.GetTopNode() # ops.load(int(100+GRS.maxNsID), 0., 0., Fz * kN, 0., 0., 0.) # mid-point # create SOE ops.system('UmfPack') # create DOF number ops.numberer('RCM') # create constraint handler ops.constraints('Transformation') # create test ops.test('EnergyIncr', 1.e-12, 10) # create algorithm ops.algorithm("Newton") NDisp = np.zeros([GRS.Steps + 1, GRS.nbNsAll, 3]) # EDisp = np.zeros([GRS.Steps + 1, GRS.nbElAll, 6]) EForce = np.zeros([GRS.Steps + 1, GRS.nbElAll, 12]) reI=0 reI = 0 lefutott = 1 i=0 load = 0 stepSize = 1.0 / GRS.Steps ops.integrator("LoadControl", stepSize) ops.analysis('Static') while ((-stepSize*Fz > GRS.MinStepSize) and (i<GRS.Steps)): hiba = ops.analyze(1) if hiba == 0: load += -stepSize * Fz i += 1 loadA[i] = load if i == 1: if printOn: print('analysis step 1 completed successfully') for j in range(GRS.nbNsAll): NDisp[i, j, 0] = - ops.nodeDisp(int(j + 100), 1) / un.mm # mm displacement NDisp[i, j, 1] = - ops.nodeDisp(int(j + 100), 2) / un.mm # mm displacement NDisp[i, j, 2] = - ops.nodeDisp(int(j + 100), 3) / un.mm # mm displacement for j in range(GRS.nbElAll): EForce[i, j] = ops.eleResponse(int(j+1000), 'localForce') # EDisp[i, j] = ops.eleResponse(int(j + 1000), 'basicDeformation') else: stepSize = stepSize/2 if printOn: print('analysis failed to converge in step ', i) ops.integrator("LoadControl", stepSize) lefutott = 0 reI = i if i == GRS.Steps: if reI == 1: if printOn: print('analysis failed to converge') return lefutott, NDisp, EForce, loadA, reI
# Change the integrator to take a min and max load increment ops.integrator("LoadControl", 1.0, 4, 0.02, 2.0) # record once at time 0 ops.record() # Perform the pushover analysis # Set some parameters maxU = 10.0 # Max displacement controlDisp = 0.0 ok = ops.analyze(1) while ((ok == 0) and (controlDisp < maxU)): ok = ops.analyze(1) controlDisp = ops.nodeDisp(3, 1) if (ok != 0): print("... trying an initial tangent iteration") ops.test("NormDispIncr", 1.0e-8, 4000, 0) ops.algorithm("ModifiedNewton", "-initial") ok = ops.analyze(1) ops.test("NormDispIncr", 1.0e-8, 10, 0) ops.algorithm("Newton") # Print a message to indicate if analysis succesfull or not if (ok == 0): print("\nPushover analysis completed SUCCESSFULLY\n") else: print("\nPushover analysis FAILED\n") # Print the state at node 3
ops.load(4, 100, -50) # print model #ops.Print() # create SOE ops.system("BandSPD") # create DOF number ops.numberer("RCM") # create constraint handler ops.constraints("Plain") # create algorithm ops.algorithm("Linear") # create integrator ops.integrator("LoadControl", 1.0) # create analysis object ops.analysis("Static") # perform the analysis ops.analyze(1) # print results print "node 4 displacement: ", ops.nodeDisp(4) ops.Print('node', 4) ops.Print('ele')
#ops.Print() # create SOE ops.system("BandSPD") # create DOF number ops.numberer("RCM") # create constraint handler ops.constraints("Plain") # create algorithm ops.algorithm("Linear") # create integrator ops.integrator("LoadControl", 1.0) # create analysis object ops.analysis("Static") # perform the analysis ops.analyze(1) # print results print "node 4 displacement: ", ops.nodeDisp(4) ops.Print('node',4) ops.Print('ele')