Brick element Response¶
Supported Brick elements include most brick elements in OpenSees, including:
✅ stdBrick
✅ bbarBrick
✅ Brick20N
✅ SSPbrick
✅ FourNodeTetrahedron
✅ brickUP
✅ bbarBrickUP
✅ 20_8_BrickUP
✅ SSPbrickUP
✅ ……
[1]:
import matplotlib.pyplot as plt
import numpy as np
import openseespy.opensees as ops
import opstool as opst
[2]:
opst.load_ops_examples("Pier-Brick")
# or your model code here
[3]:
# add gravity loads
ops.timeSeries("Linear", 1)
ops.pattern("Plain", 1, 1)
_ = opst.pre.gen_grav_load(direction="z", factor=-9.81)
[4]:
# plot
opst.vis.pyvista.set_plot_props(notebook=True)
fig = opst.vis.pyvista.plot_model(show_nodal_loads=True)
fig.show(jupyter_backend="static")
Result Saving¶
[5]:
Nsteps = 100
ops.system("BandGeneral")
# Create the constraint handler, the transformation method
ops.constraints("Transformation")
# Create the DOF numberer, the reverse Cuthill-McKee algorithm
ops.numberer("RCM")
# Create the convergence test, the norm of the residual with a tolerance of
# 1e-12 and a max number of iterations of 10
ops.test("NormDispIncr", 1.0e-12, 10, 3)
# Create the solution algorithm, a Newton-Raphson algorithm
ops.algorithm("Newton")
# Create the integration scheme, the LoadControl scheme using steps of 0.1
ops.integrator("LoadControl", 1 / Nsteps)
# Create the analysis object
ops.analysis("Static")
opstool allows us to save the data at each step of the analysis!
First, we create a database class using opstool.post.CreateODB, and then, during each step of the analysis, we call its method .fetch_response_step to retrieve the data for the current step.
Once all the analysis steps are completed, we use the .save_response method to save the data in one go.
compute_mechanical_measures is used to compute the mechanical measures, including various stress and strain measures.
project_gauss_to_nodes is used to project the Gauss point results to the nodes.
“copy”: The response of each node is copied from the Gaussian point closest to it.
“average”: The response of each node is equal to the weighted average of the responses of all Gaussian points of the element, with the weight being the integration point weight.
“extrapolate”: The nodal responses are obtained by extrapolating the element shape functions.
[6]:
ODB = opst.post.CreateODB(
odb_tag=1,
compute_mechanical_measures=True,
project_gauss_to_nodes="copy", # "extrapolate", "copy", "average"
)
for i in range(Nsteps):
# Perform the analysis step
ops.analyze(1)
# fetch the response step, every 10 steps for reducing the size of the ODB file
if (i + 1) % 10 == 0:
ODB.fetch_response_step()
# ODB.fetch_response_step() # or every step
ODB.save_response(zlib=True) # save the response to a file, zlib=True for compression
OPSTOOL :: All responses data with _odb_tag = 1 saved in .opstool.output/RespStepData-1.nc!
Result Reading¶
The provided function opstool.post.get_element_responses() make it easy to read element responses.
ele_type="Solid" is used to specify extracting the response of solid elements.
[7]:
all_resp = opst.post.get_element_responses(odb_tag=1, ele_type="Solid")
OPSTOOL :: Loading Solid response data from .opstool.output/RespStepData-1.nc ...
The result is an xarray DataSet object, and we can access the associated DataArray objects through .data_vars.
[8]:
all_resp.data_vars
[8]:
Data variables:
Stresses (time, eleTags, GaussPoints, stressDOFs) float32 2MB ...
Strains (time, eleTags, GaussPoints, strainDOFs) float32 2MB ...
StressesAtNodes (time, nodeTags, stressDOFs) float32 455kB 0.0 ......
StrainsAtNodes (time, nodeTags, strainDOFs) float32 390kB 0.0 ......
StressAtNodesErr (time, nodeTags, stressDOFs) float32 455kB 0.0 ......
StrainsAtNodesErr (time, nodeTags, strainDOFs) float32 390kB 0.0 ......
StressMeasures (time, eleTags, GaussPoints, measures) float32 2MB ...
StrainMeasures (time, eleTags, GaussPoints, measures) float32 2MB ...
StressMeasuresAtNodes (time, nodeTags, measures) float32 455kB 0.0 ... 1...
StrainMeasuresAtNodes (time, nodeTags, measures) float32 455kB 0.0 ... 5...
Stresses and Strains refer to the stress and strain at the Gauss points. Stress and strain consist of six components aligned with the global coordinate system, as well as additional stress measures:
[9]:
print(all_resp.stressDOFs.data)
print(all_resp.strainDOFs.data)
print(all_resp.measures.data)
['sigma11' 'sigma22' 'sigma33' 'sigma12' 'sigma23' 'sigma13' 'eta_r']
['eps11' 'eps22' 'eps33' 'eps12' 'eps23' 'eps13']
['p1' 'p2' 'p3' 'sigma_vm' 'tau_max' 'sigma_oct' 'tau_oct']
Although we analyzed 100 steps, we saved the data every 10 steps, so we only have data for 10 steps, and the time corresponds accordingly.
[10]:
print(all_resp.time.data)
[0. 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1. ]
[11]:
all_resp.attrs # attributes
[11]:
{'sigma11, sigma22, sigma33': 'Normal stress (strain) along x, y, z.',
'sigma12, sigma23, sigma13': 'Shear stress (strain).',
'p1, p2, p3': 'Principal stresses (strains).',
'eta_r': 'Ratio between the shear (deviatoric) stress and peak shear strength at the current confinement',
'sigma_vm': 'Von Mises stress.',
'tau_max': 'Maximum shear stress (strains).',
'sigma_oct': 'Octahedral normal stress (strains).',
'tau_oct': 'Octahedral shear stress (strains).'}
Below, we retrieve the stress and strain data, which is a 4D array. The dimensions are, in order, (‘time’, ‘eleTags’, ‘GaussPoints’, ‘DOFs’), and we can conveniently retrieve data based on these dimensions and their coordinates.
Gauss points results¶
[12]:
stresses = all_resp["Stresses"]
strains = all_resp["Strains"]
stress_measures = all_resp["StressMeasures"]
strain_measures = all_resp["StrainMeasures"]
print(stresses.dims)
print(strains.dims)
print(stress_measures.dims)
print(strain_measures.dims)
('time', 'eleTags', 'GaussPoints', 'stressDOFs')
('time', 'eleTags', 'GaussPoints', 'strainDOFs')
('time', 'eleTags', 'GaussPoints', 'measures')
('time', 'eleTags', 'GaussPoints', 'measures')
[13]:
stresses2 = stress_measures.sel(eleTags=1, measures="sigma_vm")
strains2 = strain_measures.sel(eleTags=1, measures="sigma_vm")
gauss_points = stresses2.coords["GaussPoints"].data
[14]:
for gp_no in gauss_points:
s = stresses2.sel(GaussPoints=gp_no)
d = strains2.sel(GaussPoints=gp_no)
plt.plot(d, s, label=f"GP{gp_no}")
plt.title("Ele 1 Stress-strain curve: sigma22")
plt.xlabel("Strain")
plt.ylabel("Stress")
plt.legend()
plt.show()
We can also compute averages along a specific dimension. For example, below, we calculate the average stress at the Gauss points:
[15]:
stresses2 = stress_measures.sel(measures="sigma_vm")
strains2 = strain_measures.sel(measures="sigma_vm")
stresses3 = stresses2.mean(dim="GaussPoints")
strains3 = strains2.mean(dim="GaussPoints")
[16]:
for eletag in np.arange(1, 11):
s = stresses3.sel(eleTags=eletag)
d = strains3.sel(eleTags=eletag)
plt.plot(d, s, label=f"Ele {eletag}")
plt.title("Mean stress-strain curve: sigma_vm")
plt.xlabel("Strain")
plt.ylabel("Stress")
plt.legend()
plt.show()
Results at nodes¶
[17]:
stress_measures = all_resp["StressMeasuresAtNodes"]
stresses = stress_measures.sel(measures="sigma_vm")
[18]:
print(stresses.dims)
('time', 'nodeTags')
[19]:
plt.plot(stresses.time, stresses.sel(nodeTags=10))
plt.title("Node 10: sigma_vm vs time")
plt.show()