pyNastran
pyNastran copied to clipboard
Does op2_geom support INCLUDEs?
Hello again! I'm revisiting some shear and moment interrogations on a model. I was able to get some great results using the GUI and see exactly what I expect. Now, I'm trying to automate it so I don't have to manually write the csv for each loadcase.
I tested this code out with a toy model of a cantilevered fake wing box, and the BWB from your example, and it worked great. However, when I try with my real model, I'm getting some input errors that I suspect relate to the usage of op2_geom.read_op2_geom()
. The only difference I see between my toy model and my real model (that I unfortunately cannot share) is that my real bdf has a bunch of INCLUDE statements.
So, does the read_op2_geom function support this? Below is my code and the error I'm getting.
import sys
from pathlib import Path
from IPython.display import Latex
import numpy as np
from matplotlib import __version__ as plotver
import matplotlib.pyplot as plt
import pyNastran
from pyNastran.bdf.bdf_interface import include_file
from pyNastran.bdf.bdf import BDF, read_bdf, CORD2R
from pyNastran.op2.op2 import OP2, read_op2
from pyNastran.op2.op2_geom import read_op2_geom, attach_op2_results_to_bdf
from pyNastran.bdf.mesh_utils.cut_model_by_plane import get_element_centroids, get_stations
from pyNastran.op2.tables.ogf_gridPointForces.smt import smt_setup, plot_smt
from pyNastran.utils.nastran_utils import run_nastran
Python version: 3.10.11 (tags/v3.10.11:7d4cc5a, Apr 5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]
Numpy version: 1.23.2
pyNastran version: 1.4.1
Matplotlib version: 3.5.3
model = read_op2_geom(
op2_filename,
include_results='grid_point_forces',
validate=True, xref=False,
build_dataframe=False,
mode='nx',
debug=False
) # No errors here. Model reads just fine and has elements, nodes, and grid_point_forces as expected.
gpforce = model.grid_point_forces[2101201]
(nids, nid_cd, xyz_cid0, icd_transform,
eids, element_centroids_cid0) = smt_setup(model) # <-- This is where we error out
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [20], in <cell line: 3>()
1 gpforce = model.grid_point_forces[2101201]
2 (nids, nid_cd, xyz_cid0, icd_transform,
----> 3 eids, element_centroids_cid0) = smt_setup(model)
File ~\.venv\base\lib\site-packages\pyNastran\op2\tables\ogf_gridPointForces\smt.py:216, in smt_setup(model)
213 def smt_setup(model: BDF) -> tuple[NDArrayNint, NDArrayN2int, NDArrayN3float,
214 dict[int, NDArrayNint], NDArrayNint, NDArrayN3float]:
215 nids, nid_cd, icd_transform, xyz_cid0 = get_nid_cd_xyz_cid0(model)
--> 216 eids, element_centroids_cid0 = get_element_centroids(model, fdtype='float64')
217 return nids, nid_cd, xyz_cid0, icd_transform, eids, element_centroids_cid0
File ~\.venv\base\lib\site-packages\pyNastran\bdf\mesh_utils\cut_model_by_plane.py:67, in get_element_centroids(model, idtype, fdtype)
65 centroid = np.zeros(3)
66 else:
---> 67 centroid = elem.Centroid()
68 element_centroids_cid0_list.append(centroid)
70 eids = np.array(eids_list, dtype=idtype)
File ~\.venv\base\lib\site-packages\pyNastran\bdf\cards\elements\bush.py:419, in CBUSH.Centroid(self)
417 def Centroid(self):
418 xyzs_list = []
--> 419 for nid in self.nodes_ref:
420 if nid is None:
421 continue
TypeError: 'NoneType' object is not iterable
My bdf_stats() look correct, but the above seems to indicate that I don't have centroidal data for the element definitions.
bdf.nodes: 80386
GRID : 80386
bdf.coords: 23
CORD2C : 11
CORD2R : 12
bdf.elements: 93904
CBAR : 11059
CBEAM : 110
CBUSH : 3790
CQUAD4 : 78233
CTRIA3 : 712
bdf.rigid_elements: 95
RBE2 : 95
RBE3 : 106
bdf.properties: 123
PBARL : 1
PBEAM : 1
PBUSH : 17
PSHELL : 104
bdf.masses: 52
CONM2 : 52
bdf.materials: 17
MAT1 : 9
MAT2 : 8
bdf.MATT1: 9
MATT1 : 9
bdf.tables_m: 10
TABLEM1 : 10