Of course.
import os
import pandas as pd
import pyNastran
pkg_path = pyNastran.__path__[0]
from pyNastran.op2.op2 import read_op2
from pyNastran.utils.nastran_utils import run_nastran
# Initialize the OP2 object
op2_filename=('sp_bar_area_export_20240516_narrowed_down_fem1_sim1-acceleration_static_cases_run01.op2')
isat = read_op2(op2_filename, build_dataframe=True, debug=False, skip_undefined_matrices=True,exclude_results='*strain_energy')
# Get OP2 stats
stats = isat.get_op2_stats(short=True)
print(stats)
When "stats" prints out it shows this:
params:
K6ROT = 100.0
OIBULK = 'YES'
OMACHPR = 'YES'
POST = -2
POSTEXT = 'YES'
UNITSYS = 'MN-MM'
op2_results.eqexin: EQEXIN(nid, ndof, doftype); nnodes=4091
op2_results.gpdt: GPDT(nid_cp_cd_ps, xyz); nnodes=4091
op2_results.bgpdt: BGPDT(cd, xyz); nnodes=4091
op2_results.stress.cbeam_stress[1]
op2_results.stress.cbeam_stress[2]
op2_results.stress.cbeam_stress[3]
op2_results.stress.cbeam_stress[4]
op2_results.stress.cbeam_stress[5]
op2_results.stress.cquad4_composite_stress[1]
op2_results.stress.cquad4_composite_stress[2]
op2_results.stress.cquad4_composite_stress[3]
op2_results.stress.cquad4_composite_stress[4]
op2_results.stress.cquad4_composite_stress[5]
op2_results.stress.ctria3_composite_stress[1]
op2_results.stress.ctria3_composite_stress[2]
op2_results.stress.ctria3_composite_stress[3]
op2_results.stress.ctria3_composite_stress[4]
op2_results.stress.ctria3_composite_stress[5]
op2_results.failure_indices.cquad4_composite_force[1]
op2_results.failure_indices.cquad4_composite_force[2]
op2_results.failure_indices.cquad4_composite_force[3]
op2_results.failure_indices.cquad4_composite_force[4]
op2_results.failure_indices.cquad4_composite_force[5]
displacements[1]
displacements[2]
displacements[3]
displacements[4]
displacements[5]
spc_forces[1]
spc_forces[2]
spc_forces[3]
spc_forces[4]
spc_forces[5]
I then want to see the data frames of each of them, but the only data frames that woll work are highlighted in yellow above. The code I use in the console to look at a dataframe is this:
op2_results.stress.ctria3_composite_stress = isat.op2_results.stress.ctria3_composite_stress[5] .data_frame
The error simply says: *** NameError: name 'op2_results' is not defined. So this is mny confusion how come there are several lines above that have "op2_results" that prelude them, but when converting them to a data frame it does not recognize them? I know my op2 file has all those results, but I can't extract them via this method. Thanks for the help.
Upon typing I solved it!!!!!!!
Here is what needs to happen. With any line that contains 'op2_results', like
op2_results.stress.ctria3_composite_stress[5] above, simply parse out everything before the element type.
ex:
op2_results.stress.ctria3_composite_stress[5] -> ctria3_composite_stress[5], you can then convert to data frame by ctria3_composite_stress=isat.ctria3_composite_stress[5].data_frame
Thanks!