# Parameters configuration import openseespy.opensees as ops # Import OpenSeesPy for structural analysis import opsvis as opsv # Import opsvis for visualization import matplotlib.pyplot as plt # Import Matplotlib for plotting ops.wipe() # Clear any existing model # Define a 2D model with 3 degrees of freedom per node (DOF) ops.model('basic', '-ndm', 2, '-ndf', 3) # Frame dimensions colH = 4.e0 # Height of the columns (m) colSpacing = 8.e0 # Spacing between the columns (m) roofPeak = 3.e0 # Height of the roof peak above the top of columns (m) # Section properties: cross-sectional area (A) and moment of inertia (Iz) Acol, Adiag = 2.e-3, 6.e-3 IzCol, IzDiag = 1.6e-5, 5.4e-5 # Material property: Young's Modulus (E) E = 2.e11 # Elastic modulus (Pa) # Load configuration qDiag = 1.e4 # Uniform distributed load on the diagonal members (N/m) # Define the material property dictionary for columns and girders Ep = { 1: [2e11, 2e-3, 1.6e-5], # Columns 2: [2e11, 6e-3, 5.4e-5] # Diagonal members } # Define the node coordinates ops.node(1, 0, 0) # Bottom-left column node ops.node(2, 8.0, 0) # Bottom-right column node ops.node(3, 0, 4.0) # Top-left column node ops.node(4, 8.0, 4.0) # Top-right column node ops.node(5, 4.0, 7.0) # Peak of the roof # Define boundary conditions (supports) ops.fix(1, 1, 1, 1) # Fully fixed support at node 1 ops.fix(2, 1, 1, 1) # Fully fixed support at node 2 # Plot the model before defining elements opsv.plot_model() # Add title plt.title('plot_model before defining elements') # Define transformation type for elements (Linear) ops.geomTransf('Linear', 1) # Transformation ID 1 for linear transformation # Define column and diagonal elements (elastic beam-column elements) ops.element('elasticBeamColumn', 1, 1, 3, 2e-3, 2e11, 1.6e-5, 1) # Left column ops.element('elasticBeamColumn', 2, 2, 4, 2e-3, 2e11, 1.6e-5, 1) # Right column ops.element('elasticBeamColumn', 3, 3, 5, 6e-3, 2e11, 5.4e-5, 1) # Left diagonal ops.element('elasticBeamColumn', 4, 4, 5, 6e-3, 2e11, 5.4e-5, 1) # Right diagonal # Define external loads Wy = -1e4 # Uniform distributed load inward on diagonal members Wx = 0.0 # No distributed x-direction load # Create a dictionary to store element loads Ew = { 3: ['-beamUniform', Wy, Wx], # Distributed load on left diagonal 4: ['-beamUniform', -Wy, Wx] # Distributed load on right diagonal (reversed coordinate order) } # Define time series for constant loads ops.timeSeries('Constant', 1) # Define load pattern using the constant time series ops.pattern('Plain', 1, 1) # Applying point loads # No point loads in the system based on the problem statement # Applying distributed loads for etag in Ew: ops.eleLoad('-ele', etag, '-type', Ew[etag][0], Ew[etag][1], Ew[etag][2]) # Analysis settings ops.constraints('Transformation') ops.numberer('RCM') ops.system('BandGeneral') ops.test('NormDispIncr', 1.0e-6, 6, 2) ops.algorithm('Linear') ops.integrator('LoadControl', 1) ops.analysis('Static') ops.analyze(1) # Print the model data ops.printModel() # Plot the model after defining elements opsv.plot_model() plt.title('plot_model after defining elements') # Plot the applied loads on the model in 2D opsv.plot_loads_2d(nep=10, sfac=1, fig_wi_he=(10, 5), fig_lbrt=(0.1, 0.1, 0.9, 0.9), fmt_model_loads={'color': 'red', 'linewidth': 1.5}, node_supports=True, truss_node_offset=0.05, ax=None) # Plot deformations (scaled) after analysis opsv.plot_defo() # Plot internal force diagrams: N (axial), V (shear), M (moment) sfacN, sfacV, sfacM = 5.e-5, 5.e-5, 5.e-5 opsv.section_force_diagram_2d('N', sfacN) plt.title('Axial force distribution') opsv.section_force_diagram_2d('T', sfacV) plt.title('Shear force distribution') opsv.section_force_diagram_2d('M', sfacM) plt.title('Bending moment distribution') # Show all plots plt.show() # Exit the program exit()