Visualization based on plotly
Display OpenSeesPy Model
First load the necessary classes and functions, where GetFEMdata is used to get the model data from the current domain of OpenSeesPy,
and OpsVisPlotly is used to visualize the model.
Function load_ops_examples() is used to load predefined examples from opstool.
[3]:
import openseespy.opensees as ops
from opstool.vis import GetFEMdata, OpsVisPlotly
from opstool import load_ops_examples
Load the 3D Arch Bridge finite element model.
[4]:
load_ops_examples("ArchBridge")
Get the model data from the current domain. Of course, you can also run your own model code before instantiating GetFEMdata.
Parameter results_dir is used to specify the directory where the output file is saved.
[5]:
ModelData = GetFEMdata(results_dir="opstool_output")
ModelData.get_model_data()
Instantiating visualization class OpsVisPlotly.
[6]:
opsv = OpsVisPlotly(point_size=2, line_width=3, colors_dict=None, theme="plotly",
color_map="jet", on_notebook=True, results_dir="opstool_output")
Display the geometric information of the model, Input parameter explanation see class method model_vis().
[7]:
opsv.model_vis(show_node_label=False, show_ele_label=False,
show_local_crd=True, label_size=8,
show_outline=True,
opacity=1.0,
save_html=None)
Display Eigen Analysis
Note
Before performing the eigenvalue analysis, you need to ensure that the OpenSeesPy model is correct and that the mass is set.
Obtain the first 15 orders of modal data.
[8]:
ModelData.get_eigen_data(mode_tag=15)
Visualize eigenvalue modes. When you set a two-element list for the argument mode_tags and subplots is False, the method eigen_vis() returns a slide-style plot.
[9]:
opsv.eigen_vis(mode_tags=[1, 9], subplots=False,
alpha=None, show_outline=False,
show_origin=False, opacity=1.0,
show_face_line=False, save_html=None)
Of course, subplots set to True will return a multi-sub plot.
[11]:
opsv.eigen_vis(mode_tags=[2, 11], subplots=True,
alpha=None, show_outline=False,
show_origin=False, opacity=1.0,
show_face_line=False, save_html=None)
You can also create an html animation by eigen_anim().
[12]:
opsv.eigen_anim(mode_tag=6, alpha=None, show_outline=False,
opacity=1, framerate=3,
show_face_line=True,
save_html=None)
Display Node Deformation
First we use the function gen_grav_load() to generate the gravity load.
[13]:
from opstool.preprocessing import gen_grav_load
gen_grav_load(ts_tag=1, pattern_tag=1,
factor=-9.81, direction="Z")
Next, we save the node response data in each analysis step. I chose to do this to strip the visualization from the analysis, and you are free to tweak the analysis parameters, which is very helpful for debugging the convergence of the model!
Note that you must enter parameters analysis_tag and num_steps, the former to identify the different analysis types and the latter to tell get_node_resp_step() how many steps to output the data after.
In addition, it is also used get_frame_resp_step() here to obtain the response data of the frame elements.
[14]:
Nsteps = 10
ops.wipeAnalysis()
ops.system('BandGeneral')
ops.constraints('Transformation')
ops.numberer('RCM')
ops.test('NormDispIncr', 1.0e-12, 10, 3)
ops.algorithm('Newton')
ops.integrator('LoadControl', 1 / Nsteps)
ops.analysis('Static')
ModelData.reset_steps_state() # Important!!!!
for i in range(Nsteps):
ok = ops.analyze(1)
ModelData.get_node_resp_step(analysis_tag=1,
num_steps=Nsteps,
model_update=False)
ModelData.get_frame_resp_step(analysis_tag=1, num_steps=Nsteps,)
Visualize node displacement by method deform_vis(). Of course, velocity and acceleration are also optional, just change response to “vel” or “accel”.
[15]:
opsv.deform_vis(analysis_tag=1, slider=True,
response="disp", alpha=None,
show_outline=False, show_origin=True,
show_face_line=False, opacity=1,
save_html=None,
model_update=False)
Create an html animation by deform_anim().
[16]:
opsv.deform_anim(analysis_tag=1,
response="disp", alpha=None,
show_outline=False,
show_face_line=False, opacity=1,
save_html=None,
model_update=False)
Display Frame Element Response
When saving the node response data, we also save the response of the frame elemengts by method get_frame_resp_step(), which you can visualize in the following way.
[20]:
opsv.frame_resp_vis(analysis_tag=1,
ele_tags=None,
slider=True,
response="My",
show_values=False,
alpha=None,
opacity=1,
save_html=None)