diff --git a/pyNastran/bdf/cards/elements/beam.py b/pyNastran/bdf/cards/elements/beam.py index 3190c8b7e..8368602b1 100644 --- a/pyNastran/bdf/cards/elements/beam.py +++ b/pyNastran/bdf/cards/elements/beam.py @@ -597,7 +597,7 @@ def center_of_mass_xform(self): #x = self.get_orientation_vector() return (ga + gb) / 2. - def get_orientation_vector(self, xyz): + def get_orientation_vector(self, xyz: np.ndarray): """ Element offsets are defined in a Cartesian system located at the connecting grid point. The components of the offsets are always diff --git a/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py b/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py index 1411dc426..489aa5c5c 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py +++ b/pyNastran/dev/bdf_vectorized3/bdf_interface/add_card.py @@ -1,5 +1,6 @@ from __future__ import annotations import sys +from itertools import count from collections import defaultdict from typing import Union, Optional, Any, cast, TYPE_CHECKING @@ -27,19 +28,19 @@ if TYPE_CHECKING: from pyNastran.nptyping_interface import NDArray3float, NDArray66float from pyNastran.dev.bdf_vectorized3.bdf import PARAM # BDF, - from pyNastran.dev.bdf_vectorized3.cards.grid import GRID + #from pyNastran.dev.bdf_vectorized3.cards.grid import GRID from pyNastran.dev.bdf_vectorized3.cards.coord import COORD # CORD1R, CORD1C, CORD1S, CORD2R, CORD2C, CORD2S - from pyNastran.dev.bdf_vectorized3.cards.loads.static_loads import LOAD, FORCE, FORCE1, FORCE2, MOMENT, MOMENT1, MOMENT2, LOADSET - from pyNastran.dev.bdf_vectorized3.cards.loads.static_pressure_loads import PLOAD, PLOAD1, PLOAD2, PLOAD4 # , PLOADX1 + #from pyNastran.dev.bdf_vectorized3.cards.loads.static_loads import LOAD, FORCE, FORCE1, FORCE2, MOMENT, MOMENT1, MOMENT2, LOADSET + #from pyNastran.dev.bdf_vectorized3.cards.loads.static_pressure_loads import PLOAD, PLOAD1, PLOAD2, PLOAD4 # , PLOADX1 #from pyNastran.dev.bdf_vectorized3.cards.loads.dynamic_loads import ( #DAREA, DELAY, DLOAD, DPHASE, LSEQ, QVECT, RANDPS, #TIC, RLOAD1, RLOAD2, TLOAD1, TLOAD2) #from pyNastran.dev.bdf_vectorized3.cards.elements.mass import CONM1, CONM2 #from pyNastran.dev.bdf_vectorized3.cards.elements.plot import PLOTEL #from pyNastran.dev.bdf_vectorized3.cards.elements.shear import CSHEAR, PSHEAR - from pyNastran.dev.bdf_vectorized3.cards.elements.shell import ( - CTRIA3, CTRIA6, CTRIAR, - CQUAD4, CQUAD8, CQUAD, CQUADR) + #from pyNastran.dev.bdf_vectorized3.cards.elements.shell import ( + #CTRIA3, CTRIA6, CTRIAR, + #CQUAD4, CQUAD8, CQUAD, CQUADR) #from pyNastran.dev.bdf_vectorized3.cards.elements.shell_axi import ( #CTRIAX, CTRIAX6, #CQUADX, CQUADX4, CQUADX8) @@ -56,8 +57,8 @@ #from pyNastran.dev.bdf_vectorized3.cards.elements.damper import CDAMP1, CDAMP2, CDAMP3, CDAMP4, CDAMP5, PDAMP, PDAMPT, CGAP, CVISC, PGAP, PVISC #from pyNastran.dev.bdf_vectorized3.cards.elements.nsm import NSM, NSM1, NSML, NSML1, NSMADD #from pyNastran.dev.bdf_vectorized3.cards.elements.rod import CROD, CTUBE, CONROD, PROD, PTUBE - from pyNastran.dev.bdf_vectorized3.cards.elements.solid import CTETRA, CPYRAM, CPENTA, CHEXA, PSOLID, PLSOLID # , PCOMPS, PCOMPLS - from pyNastran.dev.bdf_vectorized3.cards.materials import MAT1, MAT2, MAT8, MAT9 # MAT3, MAT4, MAT5, , MAT10, MAT10C, MAT11 + #from pyNastran.dev.bdf_vectorized3.cards.elements.solid import CTETRA, CPYRAM, CPENTA, CHEXA, PSOLID, PLSOLID # , PCOMPS, PCOMPLS + #from pyNastran.dev.bdf_vectorized3.cards.materials import MAT1, MAT2, MAT8, MAT9 # MAT3, MAT4, MAT5, , MAT10, MAT10C, MAT11 class AddCoords(BDFAttributes): @@ -65,7 +66,7 @@ def add_cord2r(self, cid: int, origin: Optional[Union[list[float], NDArray3float]], zaxis: Optional[Union[list[float], NDArray3float]], xzplane: Optional[Union[list[float], NDArray3float]], - rid: int=0, setup: bool=True, comment: str='') -> CORD2R: + rid: int=0, setup: bool=True, comment: str='') -> int: """ Creates the CORD2R card, which defines a rectangular coordinate system using 3 vectors. @@ -95,7 +96,7 @@ def add_cord2c(self, cid: int, origin: Optional[Union[list[float], NDArray3float]], zaxis: Optional[Union[list[float], NDArray3float]], xzplane: Optional[Union[list[float], NDArray3float]], - rid: int=0, setup: bool=True, comment: str='') -> CORD2C: + rid: int=0, setup: bool=True, comment: str='') -> int: """ Creates the CORD2C card, which defines a cylindrical coordinate system using 3 vectors. @@ -126,7 +127,7 @@ def add_cord2s(self, cid: int, origin: Optional[Union[list[float], NDArray3float]], zaxis: Optional[Union[list[float], NDArray3float]], xzplane: Optional[Union[list[float], NDArray3float]], - rid: int=0, setup: bool=True, comment: str='') -> CORD2S: + rid: int=0, setup: bool=True, comment: str='') -> int: """ Creates the CORD2C card, which defines a spherical coordinate system using 3 vectors. @@ -153,7 +154,7 @@ def add_cord2s(self, cid: int, setup=setup, comment=comment) return coord - def add_cord1r(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> CORD1R: + def add_cord1r(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> int: """ Creates the CORD1R card, which defines a rectangular coordinate system using 3 GRID points. @@ -175,7 +176,7 @@ def add_cord1r(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> CO coord = self.coord.add_cord1r(cid, g1, g2, g3, comment=comment) return coord - def add_cord1c(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> CORD1C: + def add_cord1c(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> int: """ Creates the CORD1C card, which defines a cylindrical coordinate system using 3 GRID points. @@ -197,7 +198,7 @@ def add_cord1c(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> CO coord = self.coord.add_cord1c(cid, g1, g2, g3, comment=comment) return coord - def add_cord1s(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> CORD1S: + def add_cord1s(self, cid: int, g1: int, g2: int, g3: int, comment: str='') -> int: """ Creates the CORD1S card, which defines a spherical coordinate system using 3 GRID points. @@ -258,7 +259,7 @@ def add_pelas(self, pid: int, k: float, ge: float=0., s: float=0., return prop def add_celas1(self, eid: int, pid: int, nids: list[int], - c1: int=0, c2: int=0, comment: str='') -> CELAS1: + c1: int=0, c2: int=0, comment: str='') -> int: """ Creates a CELAS1 card @@ -277,10 +278,10 @@ def add_celas1(self, eid: int, pid: int, nids: list[int], """ elem = self.celas1.add(eid, pid, nids, c1, c2, comment=comment) - return self.celas1 + return elem def add_celas2(self, eid: int, k: float, nids: list[int], - c1: int=0, c2: int=0, ge: float=0., s: float=0., comment: str='') -> CELAS2: + c1: int=0, c2: int=0, ge: float=0., s: float=0., comment: str='') -> int: """ Creates a CELAS2 card @@ -304,7 +305,7 @@ def add_celas2(self, eid: int, k: float, nids: list[int], """ elem = self.celas2.add(eid, k, nids, c1=c1, c2=c2, ge=ge, s=s, comment=comment) - return self.celas2 + return elem def add_celas3(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ @@ -342,10 +343,10 @@ def add_celas4(self, eid: int, k: float, nids: list[int], comment: str='') -> in """ elem = self.celas4.add(eid, k, nids, comment=comment) - return self.celas4 + return elem def add_cdamp1(self, eid: int, pid: int, nids: list[int], c1: int=0, c2: int=0, - comment: str='') -> CDAMP1: + comment: str='') -> int: """ Creates a CDAMP1 card @@ -364,10 +365,10 @@ def add_cdamp1(self, eid: int, pid: int, nids: list[int], c1: int=0, c2: int=0, """ elem = self.cdamp1.add(eid, pid, nids, c1=c1, c2=c2, comment=comment) - return self.cdamp1 + return elem def add_cdamp2(self, eid: int, b: float, nids: list[int], - c1: int=0, c2: int=0, comment: str='') -> CDAMP2: + c1: int=0, c2: int=0, comment: str='') -> int: """ Creates a CDAMP2 card @@ -387,9 +388,9 @@ def add_cdamp2(self, eid: int, b: float, nids: list[int], """ elem = self.cdamp2.add(eid, b, nids, c1=c1, c2=c2, comment=comment) - return self.cdamp2 + return elem - def add_cdamp3(self, eid: int, pid: int, nids: list[int], comment: str='') -> CDAMP3: + def add_cdamp3(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CDAMP3 card @@ -406,9 +407,9 @@ def add_cdamp3(self, eid: int, pid: int, nids: list[int], comment: str='') -> CD """ elem = self.cdamp3.add(eid, pid, nids, comment=comment) - return self.cdamp3 + return elem - def add_cdamp4(self, eid: int, b: float, nids: list[int], comment: str='') -> CDAMP4: + def add_cdamp4(self, eid: int, b: float, nids: list[int], comment: str='') -> int: """ Creates a CDAMP4 card @@ -425,9 +426,9 @@ def add_cdamp4(self, eid: int, b: float, nids: list[int], comment: str='') -> CD """ elem = self.cdamp4.add(eid, b, nids, comment=comment) - return self.cdamp4 + return elem - def add_cdamp5(self, eid: int, pid: int, nids: list[int], comment: str='') -> CDAMP5: + def add_cdamp5(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CDAMP5 card @@ -443,27 +444,27 @@ def add_cdamp5(self, eid: int, pid: int, nids: list[int], comment: str='') -> CD a comment for the card """ - elem = CDAMP5(eid, pid, nids, comment=comment) + elem = self.cdamp5.add(eid, pid, nids, comment=comment) self._add_methods._add_element_object(elem) return elem - def add_pdamp(self, pid: int, b: float, comment: str='') -> PDAMP: + def add_pdamp(self, pid: int, b: float, comment: str='') -> int: """Creates a PDAMP card""" prop = self.pdamp.add(pid, b, comment=comment) - return self.pdamp + return prop - def add_pdampt(self, pid: int, tbid: int, comment: str='') -> PDAMPT: + def add_pdampt(self, pid: int, tbid: int, comment: str='') -> int: """Creates a PDAMPT card""" prop = self.pdampt.add(pid, tbid, comment=comment) - return self.pdampt + return prop - def add_pdamp5(self, pid: int, mid: int, b: float, comment: str='') -> PDAMP5: + def add_pdamp5(self, pid: int, mid: int, b: float, comment: str='') -> int: """Creates a PDAMP5 card""" - prop = PDAMP5(pid, mid, b, comment=comment) + prop = self.pdamp5(pid, mid, b, comment=comment) self._add_methods._add_property_object(prop) return prop - def add_cvisc(self, eid: int, pid: int, nids: list[int], comment: str='') -> CVISC: + def add_cvisc(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CVISC card @@ -482,7 +483,7 @@ def add_cvisc(self, eid: int, pid: int, nids: list[int], comment: str='') -> CVI elem = self.cvisc.add(eid, pid, nids, comment=comment) return elem - def add_pvisc(self, pid: int, ce: float, cr: float, comment: str='') -> PVISC: + def add_pvisc(self, pid: int, ce: float, cr: float, comment: str='') -> int: """ Creates a PVISC card @@ -499,11 +500,11 @@ def add_pvisc(self, pid: int, ce: float, cr: float, comment: str='') -> PVISC: """ prop = self.pvisc.add(pid, ce, cr, comment=comment) - return self.pvisc + return prop def add_cgap(self, eid: int, pid: int, nids: list[int], x: Optional[list[int]], g0: Optional[int], - cid: Optional[int]=None, comment: str='') -> CGAP: + cid: Optional[int]=None, comment: str='') -> int: """ Creates a CGAP card @@ -530,13 +531,13 @@ def add_cgap(self, eid: int, pid: int, nids: list[int], """ elem = self.cgap.add(eid, pid, nids, x, g0, cid=cid, comment=comment) - return self.cgap + return elem def add_pgap(self, pid: int, u0: float=0., f0: float=0., ka: float=1.e8, kb: Optional[float]=None, mu1: float=0., kt: Optional[float]=None, mu2: Optional[float]=None, tmax: float=0., mar: float=100., trmin: float=0.001, - comment: str='') -> PGAP: + comment: str='') -> int: """ Defines the properties of the gap element (CGAP entry). @@ -578,18 +579,18 @@ def add_pgap(self, pid: int, u0: float=0., f0: float=0., """ prop = self.pgap.add(pid, u0, f0, ka, kb, mu1, kt, mu2, tmax, mar, trmin, comment=comment) - return self.pgap + return prop def add_cfast(self, eid: int, pid: int, Type: str, ida: int, idb: int, gs=None, ga=None, gb=None, - xs=None, ys=None, zs=None, comment: str='') -> CFAST: + xs=None, ys=None, zs=None, comment: str='') -> int: """Creates a CFAST card""" elem = self.cfast.add(eid, pid, Type, ida, idb, gs=gs, ga=ga, gb=gb, xs=xs, ys=ys, zs=zs, comment=comment) - return self.cfast + return elem def add_pfast(self, pid, d, kt1, kt2, kt3, mcid=-1, mflag=0, - kr1=0., kr2=0., kr3=0., mass=0., ge=0., comment='') -> PFAST: + kr1=0., kr2=0., kr3=0., mass=0., ge=0., comment='') -> int: """ Creates a PAST card @@ -615,13 +616,14 @@ def add_pfast(self, pid, d, kt1, kt2, kt3, mcid=-1, mflag=0, a comment for the card """ - prop = PFAST(pid, d, kt1, kt2, kt3, mcid=mcid, mflag=mflag, - kr1=kr1, kr2=kr2, kr3=kr3, mass=mass, ge=ge, comment=comment) + prop = self.pfast.add(pid, d, kt1, kt2, kt3, mcid=mcid, mflag=mflag, + kr1=kr1, kr2=kr2, kr3=kr3, mass=mass, ge=ge, + comment=comment) self._add_methods._add_property_object(prop) return prop def add_cbush(self, eid: int, pid: int, nids, x: Optional[list[float]], g0: Optional[int], cid=None, - s: float=0.5, ocid: int=-1, si: Optional[list[float]]=None, comment='') -> CBUSH: + s: float=0.5, ocid: int=-1, si: Optional[list[float]]=None, comment='') -> int: """ Creates a CBUSH card @@ -661,12 +663,12 @@ def add_cbush(self, eid: int, pid: int, nids, x: Optional[list[float]], g0: Opti """ elem = self.cbush.add(eid, pid, nids, x, g0, cid=cid, s=s, ocid=ocid, si=si, comment=comment) - return self.cbush + return elem def add_pbush(self, pid: int, k: list[float], b: list[float], ge: list[float], rcv: Optional[list[float]]=None, mass: Optional[float]=None, alpha: float=0., tref: float=0., coincident_length=None, - comment: str='') -> PBUSH: + comment: str='') -> int: """ Creates a PBUSH card, which defines a property for a PBUSH @@ -695,30 +697,30 @@ def add_pbush(self, pid: int, k: list[float], b: list[float], ge: list[float], """ prop = self.pbush.add(pid, k, b, ge, rcv=rcv, mass=mass, comment=comment) - return self.pbush + return prop def add_cbush1d(self, eid: int, pid: int, nids: list[int], cid: Optional[int]=None, - comment: str='') -> CBUSH1D: + comment: str='') -> int: """Creates a CBUSH1D card""" elem = self.cbush1d.add(eid, pid, nids, cid=cid, comment=comment) - return self.cbush1d + return elem def add_cbush2d(self, eid: int, pid: int, nids: list[int], cid: int=0, - plane: str='XY', sptid: Optional[int]=None, comment: str='') -> CBUSH2D: + plane: str='XY', sptid: Optional[int]=None, comment: str='') -> int: """Creates a CBUSH2D card""" elem = self.cbush2d.add(eid, pid, nids, cid=cid, plane=plane, sptid=sptid, comment=comment) - return self.cbush2d + return elem def add_pbush1d(self, pid: int, k: float=0., c: float=0., m: float=0., sa: float=0., se: float=0., optional_vars=None, - comment: str='') -> PBUSH1D: + comment: str='') -> int: """Creates a PBUSH1D card""" prop = self.pbush1d.add(pid, k=k, c=c, m=m, sa=sa, se=se, optional_vars=optional_vars, comment=comment) - return self.pbush1d + return prop - #def add_pbush2d(self, pid, k, c, m, sa, se, optional_vars, comment='') -> PBUSH2D: + #def add_pbush2d(self, pid, k, c, m, sa, se, optional_vars, comment='') -> int: #""" #Creates a PBUSH2D card #""" @@ -727,13 +729,13 @@ def add_pbush1d(self, pid: int, #return prop def add_pbusht(self, pid: int, k_tables: list[int], b_tables: list[int], - ge_tables: list[int], kn_tables: list[int], comment: str='') -> PBUSHT: + ge_tables: list[int], kn_tables: list[int], comment: str='') -> int: """Creates a PBUSHT card""" prop = self.pbusht.add(pid, k_tables, b_tables, ge_tables, kn_tables, comment=comment) - return self.pbusht + return prop - def add_pelast(self, pid: int, tkid: int=0, tgeid: int=0, tknid: int=0, comment: str='') -> PELAST: + def add_pelast(self, pid: int, tkid: int=0, tgeid: int=0, tknid: int=0, comment: str='') -> int: """ Creates a PELAST card @@ -751,7 +753,7 @@ def add_pelast(self, pid: int, tkid: int=0, tgeid: int=0, tknid: int=0, comment: a comment for the card """ - prop = PELAST(pid, tkid, tgeid, tknid, comment=comment) + prop = self.pelast.add(pid, tkid, tgeid, tknid, comment=comment) self._add_methods._add_pelast_object(prop) return prop @@ -874,7 +876,7 @@ def add_ptube(self, pid: int, mid: int, OD1: float, t: Optional[float]=None, """ prop = self.ptube.add(pid, mid, OD1, t=t, nsm=nsm, OD2=OD2, comment=comment) - return self.ptube + return prop def add_baror(self, pid: int, is_g0, g0, x, offt: str='GGG', comment: str='') -> BAROR: baror = BAROR(pid, g0, x, offt=offt, comment=comment) @@ -918,7 +920,7 @@ def add_cbar(self, eid: int, pid: int, nids: list[int], x: Optional[list[float]], g0: Optional[int], offt: str='GGG', pa: int=0, pb: int=0, wa: Optional[list[float]]=None, wb: Optional[list[float]]=None, - comment: str='', validate: bool=False) -> CBAR: + comment: str='', validate: bool=False) -> int: """ Adds a CBAR card @@ -953,7 +955,7 @@ def add_cbar(self, eid: int, pid: int, nids: list[int], assert nid in self.nodes, f'nid={nid!r} does not exist' elem = self.cbar.add(eid, pid, nids, x, g0, offt=offt, pa=pa, pb=pb, wa=wa, wb=wb, comment=comment) - return self.cbar + return elem #def add_pbarl_dvprel1(self, pid: int, mid: int, #Type: str, dim: list[float], dim_constraints: list[Any], @@ -1009,7 +1011,7 @@ def add_pbar(self, pid: int, mid: int, A: float=0., d1: float=0., d2: float=0., e1: float=0., e2: float=0., f1: float=0., f2: float=0., - k1: float=1.e8, k2: float=1.e8, comment: str='') -> PBAR: + k1: float=1.e8, k2: float=1.e8, comment: str='') -> int: """ Creates a PBAR card @@ -1039,10 +1041,10 @@ def add_pbar(self, pid: int, mid: int, A: float=0., prop = self.pbar.add(pid, mid, A=A, i1=i1, i2=i2, i12=i12, j=j, nsm=nsm, c1=c1, c2=c2, d1=d1, d2=d2, e1=e1, e2=e2, f1=f1, f2=f2, k1=k1, k2=k2, comment=comment) - return self.pbar + return prop def add_pbarl(self, pid: int, mid: int, bar_type: str, dim: list[float], - group: str='MSCBML0', nsm: float=0., comment: str='') -> PBARL: + group: str='MSCBML0', nsm: float=0., comment: str='') -> int: """ Creates a PBARL card, which defines A, I1, I2, I12, and J using dimensions rather than explicit values. @@ -1082,14 +1084,14 @@ def add_pbarl(self, pid: int, mid: int, bar_type: str, dim: list[float], """ prop = self.pbarl.add(pid, mid, bar_type, dim, group=group, nsm=nsm, comment=comment) - return self.pbarl + return prop def add_cbeam(self, eid: int, pid: int, nids: list[int], x: Optional[list[float]], g0: Optional[int], offt: str='GGG', bit=None, pa: int=0, pb: int=0, wa=None, wb=None, - sa: int=0, sb: int=0, comment: str='') -> CBEAM: + sa: int=0, sb: int=0, comment: str='') -> int: """ Adds a CBEAM card @@ -1136,7 +1138,7 @@ def add_cbeam(self, eid: int, pid: int, nids: list[int], """ elem = self.cbeam.add(eid, pid, nids, x, g0, offt=offt, bit=bit, pa=pa, pb=pb, wa=wa, wb=wb, sa=sa, sb=sb, comment=comment) - return self.cbeam + return elem def add_pbeam(self, pid, mid, xxb, so, area, i1, i2, i12, j, nsm=None, c1=None, c2=None, d1=None, d2=None, @@ -1145,7 +1147,7 @@ def add_pbeam(self, pid, mid, xxb, so, area, i1, i2, i12, j, nsm=None, nsia=0., nsib=None, cwa=0., cwb=None, m1a=0., m2a=0., m1b=None, m2b=None, n1a=0., n2a=0., n1b=None, n2b=None, - comment='') -> PBEAM: + comment='') -> int: """ .. todo:: fix 0th entry of self.so, self.xxb @@ -1200,12 +1202,12 @@ def add_pbeam(self, pid, mid, xxb, so, area, i1, i2, i12, j, nsm=None, nsia=nsia, nsib=nsib, cwa=cwa, cwb=cwb, m1a=m1a, m2a=m2a, m1b=m1b, m2b=m2b, n1a=n1a, n2a=n2a, n1b=n1b, n2b=n2b, comment=comment) - return self.pbeam + return prop def add_pbcomp(self, pid, mid, y, z, c, mids, area=0.0, i1=0.0, i2=0.0, i12=0.0, j=0.0, nsm=0.0, k1=1.0, k2=1.0, m1=0.0, m2=0.0, n1=0.0, n2=0.0, - symopt=0, comment='') -> PBCOMP: + symopt=0, comment='') -> int: """ Creates a PBCOMP card @@ -1250,15 +1252,15 @@ def add_pbcomp(self, pid, mid, y, z, c, mids, area, i1, i2, i12, j, nsm, k1, k2, m1, m2, n1, n2, symopt, comment=comment) - return self.pbcomp + return prop - def add_pbmsect(self, pid, mid, form, options, comment='') -> PBMSECT: + def add_pbmsect(self, pid, mid, form, options, comment='') -> int: """Creates a PBMSECT card""" prop = PBMSECT(pid, mid, form, options, comment=comment) self._add_methods._add_property_object(prop) return prop - def add_pbrsect(self, pid, mid, form, options, comment='') -> PBRSECT: + def add_pbrsect(self, pid, mid, form, options, comment='') -> int: """Creates a PBRSECT card""" prop = PBRSECT(pid, mid, form, options, comment=comment) self._add_methods._add_property_object(prop) @@ -1266,7 +1268,7 @@ def add_pbrsect(self, pid, mid, form, options, comment='') -> PBRSECT: def add_pbeam3(self, pid, mid, A, iz, iy, iyz=0., j=None, nsm=0., cy=0., cz=0., dy=0., dz=0., ey=0., ez=0., fy=0., fz=0., - comment='') -> PBEAM3: + comment='') -> int: """Creates a PBEAM3 card""" prop = PBEAM3(pid, mid, A, iz, iy, iyz=iyz, j=j, nsm=nsm, cy=cy, cz=cz, dy=dy, dz=dz, ey=ey, ez=ez, fy=fy, fz=fz, @@ -1276,7 +1278,7 @@ def add_pbeam3(self, pid, mid, A, iz, iy, iyz=0., j=None, nsm=0., def add_pbeaml(self, pid: int, mid: int, beam_type: str, xxb, dims, so=None, nsm=None, - group: str='MSCBML0', comment: str='') -> PBEAML: + group: str='MSCBML0', comment: str='') -> int: """ Creates a PBEAML card @@ -1308,7 +1310,7 @@ def add_pbeaml(self, pid: int, mid: int, beam_type: str, """ prop = self.pbeaml.add(pid, mid, beam_type, xxb, dims, group=group, so=so, nsm=nsm, comment=comment) - return self.pbeaml + return prop def add_pbeaml_dvprel1(self, pid: int, mid: int, beam_type: str, xxb, dims, dim_constraints, @@ -1373,7 +1375,7 @@ def add_pbeaml_dvprel1(self, pid: int, mid: int, beam_type: str, t_min_max = [t_min, t_max] dim_min_max = t_min_max xinit = t_init - x = 1 + #x = 1 else: xinit = dim @@ -1426,7 +1428,7 @@ def add_pbeaml_dvprel1(self, pid: int, mid: int, beam_type: str, return pbeaml, desvars, dvprels - def add_cbend(self, eid, pid, nids, g0, x, geom, comment='') -> CBEND: + def add_cbend(self, eid, pid, nids, g0, x, geom, comment='') -> int: """Creates a CBEND card""" elem = CBEND(eid, pid, nids, g0, x, geom, comment=comment) self._add_methods._add_element_object(elem) @@ -1435,7 +1437,7 @@ def add_cbend(self, eid, pid, nids, g0, x, geom, comment='') -> CBEND: def add_pbend(self, pid, mid, beam_type, A, i1, i2, j, c1, c2, d1, d2, e1, e2, f1, f2, k1, k2, nsm, rc, zc, delta_n, fsi, rm, t, p, rb, theta_b, - comment='') -> PBEND: + comment='') -> int: """Creates a PBEND card""" prop = PBEND(pid, mid, beam_type, A, i1, i2, j, c1, c2, d1, d2, e1, e2, f1, f2, k1, k2, @@ -1445,7 +1447,7 @@ def add_pbend(self, pid, mid, beam_type, A, i1, i2, j, return prop def add_cbeam3(self, eid, pid, nids, x, g0, wa, wb, wc, tw, s, - comment='') -> CBEAM3: + comment='') -> int: """Creates a CBEAM3 card""" elem = CBEAM3(eid, pid, nids, x, g0, wa, wb, wc, tw, s, comment=comment) @@ -1454,7 +1456,7 @@ def add_cbeam3(self, eid, pid, nids, x, g0, wa, wb, wc, tw, s, class Add2dElements(BDFAttributes): - def add_cshear(self, eid: int, pid: int, nids: list[int], comment: str='') -> CSHEAR: + def add_cshear(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CSHEAR card @@ -1471,10 +1473,10 @@ def add_cshear(self, eid: int, pid: int, nids: list[int], comment: str='') -> CS """ elem = self.cshear.add(eid, pid, nids, comment=comment) - return self.cshear + return elem def add_pshear(self, pid: int, mid: int, t: float, nsm: float=0., - f1: float=0., f2: float=0., comment: str='') -> PSHEAR: + f1: float=0., f2: float=0., comment: str='') -> int: """ Creates a PSHEAR card @@ -1497,12 +1499,12 @@ def add_pshear(self, pid: int, mid: int, t: float, nsm: float=0., """ prop = self.pshear.add(pid, mid, t, nsm=nsm, f1=f1, f2=f2, comment=comment) - return self.pshear + return prop def add_ctria3(self, eid: int, pid: int, nids: list[int], zoffset: float=0., theta_mcid: float=0.0, tflag: int=0, T1=None, T2=None, T3=None, - comment: str='') -> CTRIA3: + comment: str='') -> int: """ Creates a CTRIA3 card @@ -1535,12 +1537,12 @@ def add_ctria3(self, eid: int, pid: int, nids: list[int], elem = self.ctria3.add( eid, pid, nids, zoffset=zoffset, theta_mcid=theta_mcid, tflag=tflag, T1=T1, T2=T2, T3=T3, comment=comment) - return self.ctria3 + return elem def add_cquad4(self, eid: int, pid: int, nids: list[int], theta_mcid: Union[int, float]=0.0, zoffset: float=None, tflag: int=0, T1=None, T2=None, T3=None, T4=None, - comment='') -> CQUAD4: + comment='') -> int: """ Creates a CQUAD4 card @@ -1573,11 +1575,11 @@ def add_cquad4(self, eid: int, pid: int, nids: list[int], elem = self.cquad4.add( eid, pid, nids, theta_mcid=theta_mcid, zoffset=zoffset, tflag=tflag, T1=T1, T2=T2, T3=T3, T4=T4, comment=comment) - return self.cquad4 + return elem def add_ctria6(self, eid: int, pid: int, nids: list[int], theta_mcid: float=0., zoffset: float=0., - tflag: int=0, T1=None, T2=None, T3=None, comment: str='') -> CTRIA6: + tflag: int=0, T1=None, T2=None, T3=None, comment: str='') -> int: """ Creates a CTRIA6 card @@ -1610,11 +1612,11 @@ def add_ctria6(self, eid: int, pid: int, nids: list[int], elem = self.ctria6.add( eid, pid, nids, theta_mcid=theta_mcid, zoffset=zoffset, tflag=tflag, T1=T1, T2=T2, T3=T3, comment=comment) - return self.ctria6 + return elem def add_cquad8(self, eid: int, pid: int, nids: list[int], theta_mcid: Union[int, float]=0., zoffset: float=0., - tflag: int=0, T1=None, T2=None, T3=None, T4=None, comment: str='') -> CQUAD8: + tflag: int=0, T1=None, T2=None, T3=None, T4=None, comment: str='') -> int: """ Creates a CQUAD8 card @@ -1647,10 +1649,10 @@ def add_cquad8(self, eid: int, pid: int, nids: list[int], elem = self.cquad8.add( eid, pid, nids, theta_mcid=theta_mcid, zoffset=zoffset, tflag=tflag, T1=T1, T2=T2, T3=T3, T4=T4, comment=comment) - return self.cquad8 + return elem def add_cquad(self, eid: int, pid: int, nids: list[int], - theta_mcid: Union[int, float]=0., comment: str='') -> CQUAD: + theta_mcid: Union[int, float]=0., comment: str='') -> int: """ Creates a CQUAD card @@ -1710,11 +1712,11 @@ def add_ctriar(self, eid: int, pid: int, nids: list[int], elem = self.ctriar.add( eid, pid, nids, theta_mcid=theta_mcid, zoffset=zoffset, tflag=tflag, T1=T1, T2=T2, T3=T3, comment=comment) - return self.ctriar + return elem def add_cquadr(self, eid: int, pid: int, nids: list[int], theta_mcid: Union[int, float]=0.0, zoffset: float=0., tflag: int=0, - T1=None, T2=None, T3=None, T4=None, comment: str='') -> CQUADR: + T1=None, T2=None, T3=None, T4=None, comment: str='') -> int: """ Creates a CQUADR card @@ -1747,17 +1749,17 @@ def add_cquadr(self, eid: int, pid: int, nids: list[int], elem = self.cquadr.add( eid, pid, nids, theta_mcid=theta_mcid, zoffset=zoffset, tflag=tflag, T1=T1, T2=T2, T3=T3, T4=T4, comment=comment) - return self.cquadr + return elem - def add_snorm(self, nid: int, normal: list[float], cid: int=0, comment: str='') -> SNORM: + def add_snorm(self, nid: int, normal: list[float], cid: int=0, comment: str='') -> int: snorm = self.snorm.add(nid, normal, cid=cid, comment=comment) - return self.snorm + return snorm def add_pshell(self, pid: int, mid1: int=None, t: float=None, mid2: int=None, twelveIt3: float=1.0, mid3: int=None, tst: float=0.833333, nsm: float=0.0, z1: float=None, z2: float=None, mid4: int=None, - comment: str='') -> PSHELL: + comment: str='') -> int: """ Creates a PSHELL card @@ -1794,11 +1796,11 @@ def add_pshell(self, pid: int, mid1: int=None, t: float=None, mid3=mid3, tst=tst, nsm=nsm, z1=z1, z2=z2, mid4=mid4, comment=comment) - return self.pshell + return prop def add_pcomp(self, pid, mids, thicknesses, thetas=None, souts=None, nsm=0., sb=0., ft=None, tref=0., ge=0., lam=None, - z0=None, comment='') -> PCOMP: + z0=None, comment='') -> int: """ Creates a PCOMP card @@ -1840,11 +1842,11 @@ def add_pcomp(self, pid, mids, thicknesses, thetas=None, souts=None, prop = self.pcomp.add(pid, mids, thicknesses, thetas, souts, nsm=nsm, sb=sb, ft=ft, tref=tref, ge=ge, lam=lam, z0=z0, comment=comment) - return self.pcomp + return prop def add_pcompg(self, pid, global_ply_ids, mids, thicknesses, thetas=None, souts=None, nsm=0.0, sb=0.0, ft=None, tref=0.0, ge=0.0, lam=None, z0=None, - comment: str='') -> PCOMPG: + comment: str='') -> int: """ Creates a PCOMPG card @@ -1889,12 +1891,12 @@ def add_pcompg(self, pid, global_ply_ids, mids, thicknesses, thetas=None, souts= pid, global_ply_ids, mids, thicknesses, thetas=thetas, souts=souts, nsm=nsm, sb=sb, ft=ft, tref=tref, ge=ge, lam=lam, z0=z0, comment=comment) - return self.pcompg + return prop class Add3dElements(BDFAttributes): def add_ctetra(self, eid: int, pid: int, nids: list[int], - comment: str='') -> CTETRA: + comment: str='') -> int: """ Creates a CTETRA4/CTETRA10 @@ -1910,10 +1912,10 @@ def add_ctetra(self, eid: int, pid: int, nids: list[int], a comment for the card """ - self.ctetra.add(eid, pid, nids, comment=comment) - return self.ctetra + elem = self.ctetra.add(eid, pid, nids, comment=comment) + return elem - def add_cpyram(self, eid: int, pid: int, nids: list[int], comment: str='') -> CPYRAM: + def add_cpyram(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CPYRAM5/CPYRAM13 @@ -1929,10 +1931,10 @@ def add_cpyram(self, eid: int, pid: int, nids: list[int], comment: str='') -> CP a comment for the card """ - self.cpyram.add(eid, pid, nids, comment=comment) - return self.cpyram + elem = self.cpyram.add(eid, pid, nids, comment=comment) + return elem - def add_cpenta(self, eid: int, pid: int, nids: list[int], comment: str='') -> CPENTA: + def add_cpenta(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CPENTA6/CPENTA15 @@ -1948,11 +1950,11 @@ def add_cpenta(self, eid: int, pid: int, nids: list[int], comment: str='') -> CP a comment for the card """ - self.cpenta.add(eid, pid, nids, comment=comment) - return self.cpenta + elem = self.cpenta.add(eid, pid, nids, comment=comment) + return elem def add_chexa(self, eid: int, pid: int, - nids: list[int], comment: str='') -> CHEXA: + nids: list[int], comment: str='') -> int: """ Creates a CHEXA8/CHEXA20 @@ -1968,12 +1970,12 @@ def add_chexa(self, eid: int, pid: int, a comment for the card """ - self.chexa.add(eid, pid, nids, comment=comment) - return self.chexa + elem = self.chexa.add(eid, pid, nids, comment=comment) + return elem def add_psolid(self, pid: int, mid: int, cordm: int=0, integ: int=None, stress: str=None, isop=None, - fctn: str='SMECH', comment='') -> PSOLID: + fctn: str='SMECH', comment='') -> int: """ Creates a PSOLID card @@ -2007,10 +2009,10 @@ def add_psolid(self, pid: int, mid: int, cordm: int=0, prop = self.psolid.add( pid, mid, cordm=cordm, integ=integ, stress=stress, isop=isop, fctn=fctn, comment=comment) - return self.psolid + return prop def add_plsolid(self, pid: int, mid: int, stress_strain: str='GRID', - ge: float=0., comment: str='') -> PLSOLID: + ge: float=0., comment: str='') -> int: """ Creates a PLSOLID card @@ -2031,7 +2033,7 @@ def add_plsolid(self, pid: int, mid: int, stress_strain: str='GRID', """ prop = self.plsolid.add(pid, mid, stress_strain=stress_strain, ge=ge, comment=comment) - return self.plsolid + return prop class AddAero(BDFAttributes): @@ -2099,7 +2101,7 @@ def add_caero1(self, eid: int, pid: int, igroup: int, p4: NDArray3float, x43: float, cp: int=0, nspan: int=0, lspan: int=0, - nchord: int=0, lchord: int=0, comment: str='') -> CAERO1: + nchord: int=0, lchord: int=0, comment: str='') -> int: """ Defines a CAERO1 card, which defines a simplified lifting surface (e.g., wing/tail). @@ -2142,13 +2144,13 @@ def add_caero1(self, eid: int, pid: int, igroup: int, eid, pid, igroup, p1, x12, p4, x43, cp=cp, nspan=nspan, lspan=lspan, nchord=nchord, lchord=lchord, comment=comment) - return self.caero1 + return caero def add_caero2(self, eid: int, pid: int, igroup: int, p1: list[float], x12: float, cp: int=0, nsb: int=0, nint: int=0, - lsb: int=0, lint: int=0, comment: str='') -> CAERO2: + lsb: int=0, lint: int=0, comment: str='') -> int: """ Defines a CAERO2 card, which defines a slender body (e.g., fuselage/wingtip tank). @@ -2181,22 +2183,22 @@ def add_caero2(self, eid: int, pid: int, igroup: int, """ caero = self.caero2.add(eid, pid, igroup, p1, x12, cp=cp, nsb=nsb, nint=nint, lsb=lsb, lint=lint, comment=comment) - return self.caero2 + return caero def add_caero3(self, eid: int, pid: int, p1: np.ndarray, x12: float, p4: np.ndarray, x43: float, - cp: int=0, list_w: int=0, list_c1=None, list_c2=None, comment='') -> CAERO3: + cp: int=0, list_w: int=0, list_c1=None, list_c2=None, comment='') -> int: """Creates a CAERO3 card""" caero = self.caero3.add( eid, pid, p1, x12, p4, x43, cp=cp, list_w=list_w, list_c1=list_c1, list_c2=list_c2, comment=comment) - return self.caero3 + return caero def add_caero4(self, eid: int, pid: int, p1: np.ndarray, x12: float, p4: np.ndarray, x43: float, - cp: int=0, nspan: int=0, lspan: int=0, comment: str='') -> CAERO4: + cp: int=0, nspan: int=0, lspan: int=0, comment: str='') -> int: """ Defines a CAERO4 card, which defines a strip theory surface. @@ -2231,7 +2233,7 @@ def add_caero4(self, eid: int, pid: int, caero = self.caero4.add( eid, pid, p1, x12, p4, x43, cp=cp, nspan=nspan, lspan=lspan, comment=comment) - return self.caero4 + return caero def add_caero5(self, eid: int, pid: int, p1: list[float], x12: float, @@ -2239,12 +2241,12 @@ def add_caero5(self, eid: int, pid: int, cp: int=0, nspan: int=0, lspan: int=0, ntheory: int=0, - nthick: int=0, comment: str='') -> CAERO5: + nthick: int=0, comment: str='') -> int: """Creates a CAERO5 card""" caero = self.caero5.add( eid, pid, p1, x12, p4, x43, cp=cp, nspan=nspan, lspan=lspan, ntheory=ntheory, nthick=nthick, comment=comment) - return self.caero5 + return caero def add_caero7(self, eid: int, label: str, p1: np.ndarray, x12: float, @@ -2252,15 +2254,15 @@ def add_caero7(self, eid: int, label: str, cp: int=0, nspan: int=0, lspan: int=0, nchord: int=0, - p_airfoil: int=0, ztaic: int=0, comment: str='') -> CAERO7: + p_airfoil: int=0, ztaic: int=0, comment: str='') -> int: caero = self.caero7.add( eid, label, p1, x12, p4, x43, cp=cp, nspan=nspan, nchord=nchord, lspan=lspan, p_airfoil=p_airfoil, ztaic=ztaic, comment='') - return self.caero7 + return caero - def add_paero1(self, pid: int, caero_body_ids: Optional[list[int]]=None, comment='') -> PAERO1: + def add_paero1(self, pid: int, caero_body_ids: Optional[list[int]]=None, comment: str='') -> int: """ Creates a PAERO1 card, which defines associated bodies for the panels in the Doublet-Lattice method. @@ -2276,14 +2278,14 @@ def add_paero1(self, pid: int, caero_body_ids: Optional[list[int]]=None, comment """ paero = self.paero1.add(pid, caero_body_ids=caero_body_ids, comment=comment) - return self.paero1 + return paero def add_paero2(self, pid: int, orient: str, width: float, AR: float, thi: list[int], thn: list[int], lrsb: Optional[int]=None, lrib: Optional[int]=None, lth: Optional[int]=None, - comment: str='') -> PAERO2: + comment: str='') -> int: """ Creates a PAERO2 card, which defines additional cross-sectional properties for the CAERO2 geometry. @@ -2322,10 +2324,10 @@ def add_paero2(self, pid: int, orient: str, width: float, AR: float, paero = self.paero2.add( pid, orient, width, AR, thi, thn, lrsb=lrsb, lrib=lrib, lth=lth, comment=comment) - return self.paero2 + return paero def add_paero3(self, pid: int, nbox: int, ncontrol_surfaces: int, - x: list[float], y: list[float], comment: str='') -> PAERO3: + x: list[float], y: list[float], comment: str='') -> int: """ Creates a PAERO3 card, which defines the number of Mach boxes in the flow direction and the location of cranks and control @@ -2349,12 +2351,12 @@ def add_paero3(self, pid: int, nbox: int, ncontrol_surfaces: int, """ paero = self.paero3.add( pid, nbox, ncontrol_surfaces, x, y, comment=comment) - return self.paero3 + return paero def add_paero4(self, pid: int, docs: list[float], caocs: list[float], gapocs: list[float], cla: int=0, lcla: int=0, - circ: int=0, lcirc: int=0, comment: str='') -> PAERO4: + circ: int=0, lcirc: int=0, comment: str='') -> int: """ Parameters ---------- @@ -2393,13 +2395,13 @@ def add_paero4(self, pid: int, paero = self.paero4.add( pid, docs, caocs, gapocs, cla=cla, lcla=lcla, circ=circ, lcirc=lcirc, comment=comment) - return self.paero4 + return paero def add_paero5(self, pid: int, caoci: list[float], nalpha: int=0, lalpha: int=0, nxis: int=0, lxis: int=0, ntaus: int=0, ltaus: int=0, - comment='') -> PAERO5: + comment: str='') -> int: """Creates a PAERO5 card""" paero = self.paero5.add( pid, caoci, nalpha=nalpha, lalpha=lalpha, nxis=nxis, lxis=lxis, @@ -2409,7 +2411,7 @@ def add_paero5(self, pid: int, caoci: list[float], def add_spline1(self, eid: int, caero: int, box1: int, box2: int, setg: int, dz: float=0., method: str='IPS', usage: str='BOTH', nelements: int=10, - melements: int=10, comment: str='') -> SPLINE1: + melements: int=10, comment: str='') -> int: """ Creates a SPLINE1, which defines a surface spline. @@ -2452,7 +2454,7 @@ def add_spline1(self, eid: int, caero: int, box1: int, box2: int, setg: int, eid, caero, box1, box2, setg, dz=dz, method=method, usage=usage, nelements=nelements, melements=melements, comment=comment) - return self.spline1 + return spline def add_spline2(self, eid: int, caero: int, box1: int, box2: int, setg: int, @@ -2460,7 +2462,7 @@ def add_spline2(self, eid: int, caero: int, cid: int=0, dthx: float=0.0, dthy: float=0.0, usage: str='BOTH', - comment: str='') -> SPLINE2: + comment: str='') -> int: """ Creates a SPLINE2 card, which defines a beam spline. @@ -2502,14 +2504,14 @@ def add_spline2(self, eid: int, caero: int, spline = self.spline2.add( eid, caero, box1, box2, setg, dz=dz, dtor=dtor, cid=cid, dthx=dthx, dthy=dthy, usage=usage, comment=comment) - return self.spline2 + return spline def add_spline3(self, eid: int, caero: int, box_id: int, components: int, nodes: list[int], displacement_components: list[int], coeffs: list[float], - usage: str='BOTH', comment: str='') -> SPLINE3: + usage: str='BOTH', comment: str='') -> int: """ Creates a SPLINE3 card, which is useful for control surface constraints. @@ -2556,14 +2558,14 @@ def add_spline3(self, eid: int, caero: int, box_id: int, eid, caero, box_id, components, nodes, displacement_components, coeffs, usage=usage, comment=comment) - return self.spline3 + return spline def add_spline4(self, eid: int, caero: int, aelist: int, setg: int, dz: float=0., method: str='IPS', usage: str='BOTH', nelements: int=10, melements: int=10, ftype: Optional[str]='WF2', rcore: Optional[float]=None, - comment: str='') -> SPLINE4: + comment: str='') -> int: """ Creates a SPLINE4 card, which defines a curved Infinite Plate, Thin Plate, or Finite Plate Spline. @@ -2603,18 +2605,18 @@ def add_spline4(self, eid: int, caero: int, aelist: int, setg: int, spline = self.spline4.add( eid, caero, aelist, setg, dz, method, usage, nelements, melements, ftype=ftype, rcore=rcore, comment=comment) - return self.spline4 + return spline def add_spline5(self, eid: int, caero: int, aelist: int, setg: int, thx, thy, dz: float=0.0, dtor: float=1.0, cid: int=0, usage: str='BOTH', method: str='BEAM', - ftype: str='WF2', rcore=None, comment: str='') -> SPLINE5: + ftype: str='WF2', rcore=None, comment: str='') -> int: """Creates a SPLINE5 card""" assert isinstance(cid, int), cid - self.spline5.add( + spline = self.spline5.add( eid, caero, aelist, setg, thx, thy, dz=dz, dtor=dtor, cid=cid, usage=usage, method=method, ftype=ftype, rcore=rcore, comment=comment) - return self.spline5 + return spline def add_trim(self, sid: int, mach: float, q: float, labels: list[str], uxs: list[float], aeqr: float=1.0, @@ -2881,7 +2883,7 @@ def add_aestat(self, aestat_id: int, label: str, comment: str='') -> AESTAT: def add_aelink(self, aelink_id: int, label: str, independent_labels: list[str], linking_coefficients: list[float], - comment: str='') -> AELINK: + comment: str='') -> int: """ Creates an AELINK card, which defines an equation linking AESTAT and AESURF cards @@ -2902,9 +2904,9 @@ def add_aelink(self, aelink_id: int, label: str, """ aelink = self.aelink.add(aelink_id, label, independent_labels, linking_coefficients, comment=comment) - return self.aelink + return aelink - def add_aelist(self, sid: int, elements: list[int], comment: str='') -> AELIST: + def add_aelist(self, sid: int, elements: list[int], comment: str='') -> int: """ Creates an AELIST card, which defines the aero boxes for an AESURF/SPLINEx. @@ -2920,9 +2922,9 @@ def add_aelist(self, sid: int, elements: list[int], comment: str='') -> AELIST: """ aelist = self.aelist.add(sid, elements, comment=comment) - return self.aelist + return aelist - def add_aefact(self, sid: int, fractions: list[float], comment: str='') -> AEFACT: + def add_aefact(self, sid: int, fractions: list[float], comment: str='') -> int: """ Creates an AEFACT card, which is used by the CAEROx / PAEROx card to adjust the spacing of the sub-paneleing (and grid point @@ -2939,9 +2941,9 @@ def add_aefact(self, sid: int, fractions: list[float], comment: str='') -> AEFAC """ aefact = self.aefact.add(sid, fractions, comment=comment) - return self.aefact + return aefact - def add_diverg(self, sid: int, nroots: int, machs: list[float], comment: str='') -> DIVERG: + def add_diverg(self, sid: int, nroots: int, machs: list[float], comment: str='') -> int: """ Creates an DIVERG card, which is used in divergence analysis (SOL 144). @@ -2959,11 +2961,11 @@ def add_diverg(self, sid: int, nroots: int, machs: list[float], comment: str='') """ diverg = self.diverg.add(sid, nroots, machs, comment=comment) - return self.diverg + return diverg def add_csschd(self, sid: int, aesurf_id: int, lschd: int, lalpha: int=None, lmach: int=None, # aefact - comment: str='') -> CSSCHD: + comment: str='') -> int: """ Creates an CSSCHD card, which defines a specified control surface deflection as a function of Mach and alpha (used in SOL 144/146). @@ -2986,7 +2988,7 @@ def add_csschd(self, sid: int, aesurf_id: int, """ csschd = self.csschd.add(sid, aesurf_id, lschd, lalpha=lalpha, lmach=lmach, comment=comment) - return self.csschd + return csschd def add_aesurf(self, aesid: int, label: str, cid1: int, aelist_id1: int, @@ -2996,7 +2998,7 @@ def add_aesurf(self, aesid: int, label: str, pllim: float=-np.pi/2., pulim: float=np.pi/2., hmllim=None, hmulim=None, # hinge moment lower/upper limits tqllim=None, tqulim=None, # TABLEDi deflection limits vs. dynamic pressure - comment='') -> AESURF: + comment: str='') -> int: """ Creates an AESURF card, which defines a control surface @@ -3036,7 +3038,7 @@ def add_aesurf(self, aesid: int, label: str, pllim=pllim, pulim=pulim, hmllim=hmllim, hmulim=hmulim, tqllim=tqllim, tqulim=tqulim, comment=comment) - return self.aesurf + return aesurf def add_aesurfs(self, aesurfs_id: int, label: str, list1: int, list2: int, comment: str='') -> AESURFS: @@ -3116,7 +3118,7 @@ def F1(A, B, C, D, R): def add_desvar(self, desvar_id: int, label: str, xinit: float, xlb: float=-1e20, xub: float=1e20, delx=None, ddval: Optional[int]=None, - comment: str='') -> DESVAR: + comment: str='') -> int: """ Creates a DESVAR card @@ -3147,10 +3149,10 @@ def add_desvar(self, desvar_id: int, label: str, xinit: float, """ desvar = self.desvar.add(desvar_id, label, xinit, xlb, xub, delx=delx, ddval=ddval, comment=comment) - return self.desvar + return desvar def add_topvar(self, opt_id, label, ptype, xinit, pid, xlb=0.001, delxv=0.2, - power=3.0) -> TOPVAR: + power=3.0) -> int: """adds a TOPVAR""" topvar = TOPVAR(opt_id, label, ptype, xinit, pid, xlb=xlb, delxv=delxv, power=power) self._add_methods._add_topvar_object(topvar) @@ -3824,7 +3826,7 @@ def _add_param_nastran(self, key: str, values: list[Union[int, float, str]], # ----------------------------------------------------------------------------------- def add_grid(self, nid: int, xyz: Union[None, list[float], NDArray3float], - cp: int=0, cd: int=0, ps: int=0, seid: int=0, comment: str='') -> GRID: + cp: int=0, cd: int=0, ps: int=0, seid: int=0, comment: str='') -> int: """ Creates the GRID card @@ -3848,8 +3850,8 @@ def add_grid(self, nid: int, xyz: Union[None, list[float], NDArray3float], a comment for the card """ - self.grid.add(nid, xyz, cp=cp, cd=cd, ps=ps, seid=seid, comment=comment) - return self.grid + grid = self.grid.add(nid, xyz, cp=cp, cd=cd, ps=ps, seid=seid, comment=comment) + return grid def add_grdset(self, cp: int, cd: int, ps: str, seid: int, comment: str='') -> GRDSET: """ @@ -3924,7 +3926,7 @@ def add_epoint(self, ids: Union[int, list[int]], comment: str='') -> EPOINTs: epoint = self.epoint.add(ids, comment=comment) return epoint - def add_point(self, nid: int, xyz: Any, cp: int=0, comment: str='') -> POINT: + def add_point(self, nid: int, xyz: Any, cp: int=0, comment: str='') -> int: """ Creates the POINT card @@ -4041,7 +4043,7 @@ def _add_param_nasa95(self, key: str, values: list[Union[int, float, str]], self._add_methods._add_param_object(param) return param - def add_plotel(self, eid: int, nodes: list[int], comment: str='') -> PLOTEL: + def add_plotel(self, eid: int, nodes: list[int], comment: str='') -> int: """ Adds a PLOTEL card @@ -4058,7 +4060,7 @@ def add_plotel(self, eid: int, nodes: list[int], comment: str='') -> PLOTEL: elem = self.plotel.add(eid, nodes, comment=comment) return elem - def add_conm1(self, eid: int, nid: int, mass_matrix: NDArray66float, cid=0, comment='') -> CONM1: + def add_conm1(self, eid: int, nid: int, mass_matrix: NDArray66float, cid=0, comment='') -> int: """ Creates a CONM1 card @@ -4090,7 +4092,7 @@ def add_conm1(self, eid: int, nid: int, mass_matrix: NDArray66float, cid=0, comm def add_conm2(self, eid: int, nid: int, mass: float, cid: int=0, X: Optional[list[float]]=None, I: Optional[list[float]]=None, - comment: str='') -> CONM2: + comment: str='') -> int: """ Creates a CONM2 card @@ -4266,7 +4268,7 @@ def add_nsmadd(self, sid: int, sets: list[int], comment: str='') -> NSMADD: nsmadd = self.nsmadd.add(sid, sets, comment=comment) return nsmadd - def add_pmass(self, pid: int, mass: float, comment: str='') -> PMASS: + def add_pmass(self, pid: int, mass: float, comment: str='') -> int: """ Creates an PMASS card, which defines a mass applied to a single DOF @@ -4284,7 +4286,7 @@ def add_pmass(self, pid: int, mass: float, comment: str='') -> PMASS: return prop def add_cmass1(self, eid: int, pid: int, nids: list[int], - c1: int=0, c2: int=0, comment: str='') -> CMASS1: + c1: int=0, c2: int=0, comment: str='') -> int: """ Creates a CMASS1 card @@ -4306,7 +4308,7 @@ def add_cmass1(self, eid: int, pid: int, nids: list[int], return mass_obj def add_cmass2(self, eid: int, mass: float, nids: list[int], - c1: int, c2: int, comment: str='') -> CMASS2: + c1: int, c2: int, comment: str='') -> int: """ Creates a CMASS2 card @@ -4327,7 +4329,7 @@ def add_cmass2(self, eid: int, mass: float, nids: list[int], mass_obj = self.cmass2.add(eid, mass, nids, c1, c2, comment=comment) return mass_obj - def add_cmass3(self, eid: int, pid: int, nids: list[int], comment: str='') -> CMASS3: + def add_cmass3(self, eid: int, pid: int, nids: list[int], comment: str='') -> int: """ Creates a CMASS3 card @@ -4346,7 +4348,7 @@ def add_cmass3(self, eid: int, pid: int, nids: list[int], comment: str='') -> CM mass = self.cmass3.add(eid, pid, nids, comment=comment) return mass - def add_cmass4(self, eid: int, mass: float, nids: list[int], comment: str='') -> CMASS4: + def add_cmass4(self, eid: int, mass: float, nids: list[int], comment: str='') -> int: """ Creates a CMASS4 card @@ -4368,125 +4370,128 @@ def add_cmass4(self, eid: int, mass: float, nids: list[int], comment: str='') -> def add_pcomps(self, pid, global_ply_ids, mids, thicknesses, thetas, cordm=0, psdir=13, sb=None, nb=None, tref=0.0, ge=0.0, failure_theories=None, interlaminar_failure_theories=None, - souts=None, comment='') -> PCOMPS: + souts=None, comment='') -> int: """Creates a PCOMPS card""" prop = self.pcomps.add( pid, global_ply_ids, mids, thicknesses, thetas, cordm, psdir, sb, nb, tref, ge, failure_theories, interlaminar_failure_theories, souts, comment=comment) - return self.pcomps + return prop def add_plplane(self, pid, mid, cid=0, stress_strain_output_location='GRID', - comment='') -> PLPLANE: + comment='') -> int: """Creates a PLPLANE card""" prop = self.plplane.add( pid, mid, cid=cid, stress_strain_output_location=stress_strain_output_location, comment=comment) - return self.plplane + return prop def add_pplane(self, pid: int, mid: int, t: float=0.0, nsm: float=0.0, - formulation_option: int=0, comment: str='') -> PPLANE: + formulation_option: int=0, comment: str='') -> int: """Creates a PPLANE card""" prop = self.pplane.add( pid, mid, t=t, nsm=nsm, formulation_option=formulation_option, comment=comment) - return self.pplane + return prop - def add_cplstn3(self, eid: int, pid: int, nids: list[int], theta: float=0.0, comment: str='') -> CPLSTN3: + def add_cplstn3(self, eid: int, pid: int, nids: list[int], theta: float=0.0, + comment: str='') -> int: """Creates a CPLSTN4 card""" elem = self.cplstn3.add(eid, pid, nids, theta=theta, comment=comment) - return self.cplstn3 + return elem - def add_cplstn4(self, eid: int, pid: int, nids: list[int], theta: float=0.0, comment: str='') -> CPLSTN4: + def add_cplstn4(self, eid: int, pid: int, nids: list[int], theta: float=0.0, + comment: str='') -> int: """Creates a CPLSTN4 card""" elem = self.cplstn4.add(eid, pid, nids, theta=theta, comment=comment) - return self.cplstn4 + return elem def add_cplstn6(self, eid: int, pid: int, nids: list[int], theta: float=0.0, - comment: str='') -> CPLSTN6: + comment: str='') -> int: """Creates a CPLSTN6 card""" elem = self.cplstn6.add(eid, pid, nids, theta=theta, comment=comment) - return self.cplstn6 + return elem def add_cplstn8(self, eid: int, pid: int, nids: list[int], theta: float=0.0, - comment: str='') -> CPLSTN8: + comment: str='') -> int: """Creates a CPLSTN8 card""" elem = self.cplstn8.add(eid, pid, nids, theta=theta, comment=comment) - return self.cplstn8 + return elem def add_cplsts3(self, eid: int, pid: int, nids: list[int], theta: float=0.0, - tflag=0, T1=None, T2=None, T3=None, comment='') -> CPLSTS3: + tflag=0, T1=None, T2=None, T3=None, comment='') -> int: """Creates a CPLSTS3 card""" elem = self.cplsts3.add( eid, pid, nids, theta=theta, tflag=tflag, T1=T1, T2=T2, T3=T3, comment=comment) - return self.cplsts3 + return elem def add_cplsts4(self, eid: int, pid: int, nids: list[int], theta: float=0.0, - tflag=0, T1=None, T2=None, T3=None, T4=None, comment='') -> CPLSTS4: + tflag=0, T1=None, T2=None, T3=None, T4=None, + comment: str='') -> int: """Creates a CPLSTS4 card""" elem = self.cplsts4.add( eid, pid, nids, theta=theta, tflag=tflag, T1=T1, T2=T2, T3=T3, T4=T4, comment=comment) - return self.cplsts4 + return elem def add_cplsts6(self, eid: int, pid: int, nids: list[int], theta: float=0.0, tflag=0, thickness=None, - comment: str='') -> CPLSTS6: + comment: str='') -> int: """Creates a CPLSTS6 card""" elem = self.cplsts6.add(eid, pid, nids, theta=theta, tflag=tflag, thickness=thickness, comment=comment) - return self.cplsts6 + return elem def add_cplsts8(self, eid: int, pid: int, nids: list[int], theta: float=0.0, tflag: int=0, - thickness=None, comment: str='') -> CPLSTS8: + thickness=None, comment: str='') -> int: """Creates a CPLSTS8 card""" elem = self.cplsts8.add(eid, pid, nids, theta=theta, tflag=tflag, thickness=thickness, comment=comment) - return self.cplsts8 + return elem - def add_crac2d(self, eid, pid, nids, comment='') -> CRAC2D: + def add_crac2d(self, eid, pid, nids, comment: str='') -> int: """Creates a PRAC2D card""" elem = CRAC2D(eid, pid, nids, comment=comment) self._add_methods._add_element_object(elem) return elem def add_prac2d(self, pid, mid, thick, iplane, nsm=0., gamma=0.5, phi=180., - comment='') -> PRAC2D: + comment='') -> int: """Creates a PRAC2D card""" prop = PRAC2D(pid, mid, thick, iplane, nsm=nsm, gamma=gamma, phi=phi, comment=comment) self._add_methods._add_property_object(prop) return prop - def add_crac3d(self, eid, pid, nids, comment='') -> CRAC3D: + def add_crac3d(self, eid, pid, nids, comment: str='') -> int: """Creates a CRAC3D card""" elem = CRAC3D(eid, pid, nids, comment=comment) self._add_methods._add_element_object(elem) return elem - def add_prac3d(self, pid, mid, gamma=0.5, phi=180., comment='') -> PRAC3D: + def add_prac3d(self, pid, mid, gamma=0.5, phi=180., comment: str='') -> int: """Creates a PRAC3D card""" prop = PRAC3D(pid, mid, gamma=gamma, phi=phi, comment=comment) self._add_methods._add_property_object(prop) return prop - def add_genel_stiffness(self, eid, ul, ud, k, s=None) -> GENEL: + def add_genel_stiffness(self, eid, ul, ud, k, s=None) -> int: """creates a GENEL card using the stiffness (K) approach""" assert k is not None genel = self.genel.add(eid, ul, ud, k, None, s) - return self.genel + return genel - def add_genel_flexibility(self, eid, ul, ud, z, s=None) -> GENEL: + def add_genel_flexibility(self, eid, ul, ud, z, s=None) -> int: """creates a GENEL card using the flexiblity (Z) approach""" assert z is not None genel = self.genel.add(eid, ul, ud, None, z, s) - return self.genel + return genel #def add_axic(self, nharmonics, comment='') -> AXIC: #"""Creates a AXIC card""" @@ -4534,45 +4539,45 @@ def add_forceax(self, sid, ring_id, hid, scale, f_rtz, comment='') -> FORCEAX: forceax = self.forceax.add(sid, ring_id, hid, scale, f_rtz, comment=comment) return self.forceax - def add_ctrax3(self, eid, pid, nids, theta=0., comment='') -> CTRAX3: + def add_ctrax3(self, eid, pid, nids, theta=0., comment='') -> int: """Creates a CTRAX3 card""" elem = self.ctrax3.add(eid, pid, nids, theta=theta, comment=comment) - return self.ctrax3 + return elem - def add_ctrax6(self, eid, pid, nids, theta=0., comment='') -> CTRAX6: + def add_ctrax6(self, eid, pid, nids, theta=0., comment='') -> int: """Creates a CTRAX6 card""" elem = self.ctrax6.add(eid, pid, nids, theta=theta, comment=comment) - return self.ctrax6 + return elem def add_ctriax(self, eid: int, pid: int, nids: list[int], - theta_mcid: int|float=0., comment: str='') -> CTRIAX: + theta_mcid: int|float=0., comment: str='') -> int: """Creates a CTRIAX card""" elem = self.ctriax.add(eid, pid, nids, theta_mcid=theta_mcid, comment=comment) return self.ctriax def add_ctriax6(self, eid: int, mid: int, nids: list[int], theta: float=0., - comment: str='') -> CTRIAX: + comment: str='') -> int: """Creates a CTRIAX6 card""" elem = self.ctriax6.add(eid, mid, nids, theta=theta, comment=comment) - return self.ctriax6 + return elem def add_cquadx(self, eid: int, pid: int, nids: list[int], - theta_mcid: Union[int, float]=0., comment: str='') -> CQUADX: + theta_mcid: Union[int, float]=0., comment: str='') -> int: """Creates a CQUADX card""" elem = self.cquadx.add(eid, pid, nids, theta_mcid=theta_mcid, comment=comment) - return self.cquadx + return elem def add_cquadx4(self, eid: int, pid: int, nids: list[int], - theta: float=0., comment: str='') -> CQUADX4: + theta: float=0., comment: str='') -> int: """Creates a CQUADX4 card""" elem = self.cquadx4.add(eid, pid, nids, theta=theta, comment=comment) - return self.cquadx4 + return elem def add_cquadx8(self, eid: int, pid: int, nids: list[int], - theta: float=0., comment: str='') -> CQUADX8: + theta: float=0., comment: str='') -> int: """Creates a CQUADX8 card""" elem = self.cquadx8.add(eid, pid, nids, theta=theta, comment=comment) - return self.cquadx8 + return elem #def add_cihex1(self, eid, pid, nids, comment='') -> CIHEX1: #"""see CHEXA""" @@ -4603,7 +4608,7 @@ def add_cquadx8(self, eid: int, pid: int, nids: list[int], #return prop def add_creep(self, mid, T0, exp, form, tidkp, tidcp, tidcs, thresh, Type, - a, b, c, d, e, f, g, comment='') -> CREEP: + a, b, c, d, e, f, g, comment='') -> int: """Creates a CREEP card""" mat = CREEP(mid, T0, exp, form, tidkp, tidcp, tidcs, thresh, Type, a, b, c, d, e, f, g, comment=comment) @@ -4611,7 +4616,7 @@ def add_creep(self, mid, T0, exp, form, tidkp, tidcp, tidcs, thresh, Type, return mat def add_mat1(self, mid, E, G, nu, rho=0.0, a=0.0, tref=0.0, ge=0.0, St=0.0, - Sc=0.0, Ss=0.0, mcsid=0, comment='') -> MAT1: + Sc=0.0, Ss=0.0, mcsid=0, comment='') -> int: """ Creates a MAT1 card @@ -4646,46 +4651,46 @@ def add_mat1(self, mid, E, G, nu, rho=0.0, a=0.0, tref=0.0, ge=0.0, St=0.0, """ mat = self.mat1.add(mid, E, G, nu, rho=rho, alpha=a, tref=tref, ge=ge, St=St, Sc=Sc, Ss=Ss, mcsid=mcsid, comment=comment) - return self.mat1 + return mat def add_mat2(self, mid: float, G11: float, G12: float, G13: float, G22: float, G23: float, G33: float, rho: float=0., a1: Optional[float]=None, a2: Optional[float]=None, a3: Optional[float]=None, tref: float=0., ge: float=0., St: Optional[float]=None, Sc: Optional[float]=None, Ss: Optional[float]=None, - mcsid: Optional[int]=None, comment: str='') -> MAT2: + mcsid: Optional[int]=None, comment: str='') -> int: """Creates an MAT2 card""" mat = self.mat2.add(mid, G11, G12, G13, G22, G23, G33, rho, a1, a2, a3, tref=tref, ge=ge, St=St, Sc=Sc, Ss=Ss, mcsid=mcsid, comment=comment) - return self.mat2 + return mat def add_mat3(self, mid, ex, eth, ez, nuxth, nuthz, nuzx, rho=0.0, gzx=None, ax=0., ath=0., az=0., tref=0., ge=0., - comment='') -> MAT3: + comment='') -> int: """Creates a MAT3 card""" mat = self.mat3.add(mid, ex, eth, ez, nuxth, nuthz, nuzx, rho=rho, gzx=gzx, ax=ax, ath=ath, az=az, tref=tref, ge=ge, comment=comment) - return self.mat3 + return mat def add_mat4(self, mid, k, cp=0.0, rho=1.0, H=None, mu=None, hgen=1.0, ref_enthalpy=None, tch=None, tdelta=None, - qlat=None, comment='') -> MAT4: + qlat=None, comment='') -> int: """Creates a MAT4 card""" mat = self.mat4.add(mid, k, cp=cp, rho=rho, H=H, mu=mu, hgen=hgen, ref_enthalpy=ref_enthalpy, tch=tch, tdelta=tdelta, qlat=qlat, comment=comment) - return self.mat4 + return mat def add_mat5(self, mid, kxx=0., kxy=0., kxz=0., kyy=0., kyz=0., kzz=0., cp=0., - rho=1., hgen=1., comment='') -> MAT5: + rho=1., hgen=1., comment='') -> int: """Creates a MAT5 card""" mat = self.mat5.add(mid, kxx=kxx, kxy=kxy, kxz=kxz, kyy=kyy, kyz=kyz, kzz=kzz, cp=cp, rho=rho, hgen=hgen, comment=comment) - return self.mat5 + return mat def add_mat8(self, mid: int, e11: float, e22: float, nu12: float, g12: float=0.0, g1z: float=1e8, g2z: float=1e8, @@ -4697,7 +4702,7 @@ def add_mat8(self, mid: int, e11: float, e22: float, nu12: float, mat = self.mat8.add(mid, e11, e22, nu12, g12, g1z, g2z, rho=rho, a1=a1, a2=a2, tref=tref, xt=Xt, xc=Xc, yt=Yt, yc=Yc, s=S, ge=ge, f12=F12, strn=strn, comment=comment) - return self.mat8 + return mat def add_mat9(self, mid: int, G11=0., G12=0., G13=0., G14=0., G15=0., G16=0., @@ -4705,17 +4710,17 @@ def add_mat9(self, mid: int, G33=0., G34=0., G35=0., G36=0., G44=0., G45=0., G46=0., G55=0., G56=0., G66=0., - rho=0., A=None, tref=0., ge=0., comment='') -> MAT9: + rho=0., A=None, tref=0., ge=0., comment='') -> mat: """Creates a MAT9 card""" mat = self.mat9.add(mid, G11, G12, G13, G14, G15, G16, G22, G23, G24, G25, G26, G33, G34, G35, G36, G44, G45, G46, G55, G56, G66, rho, A, tref, ge, comment=comment) - return self.mat9 + return mat def add_mat10(self, mid, bulk, rho, c, ge=0.0, gamma=None, table_bulk=None, table_rho=None, table_ge=None, table_gamma=None, - comment='') -> MAT10: + comment='') -> int: """ Creates a MAT10 card @@ -4754,17 +4759,17 @@ def add_mat10(self, mid, bulk, rho, c, ge=0.0, gamma=None, table_bulk=table_bulk, table_rho=table_rho, table_ge=table_ge, table_gamma=table_gamma, comment=comment) - return self.mat10 + return mat def add_mat11(self, mid, e1, e2, e3, nu12, nu13, nu23, g12, g13, g23, rho=0.0, - a1=0.0, a2=0.0, a3=0.0, tref=0.0, ge=0.0, comment='') -> MAT11: + a1=0.0, a2=0.0, a3=0.0, tref=0.0, ge=0.0, comment='') -> int: """Creates a MAT11 card""" mat = self.mat11.add(mid, e1, e2, e3, nu12, nu13, nu23, g12, g13, g23, rho=rho, a1=a1, a2=a2, a3=a3, tref=tref, ge=ge, comment=comment) - return self.mat11 + return mat def add_mat3d(self, mid, e1, e2, e3, nu12, nu13, nu23, g12, g13, g23, rho=0.0, - comment='') -> MAT3D: + comment='') -> int: """ This is a VABS specific card that is almost identical to the MAT11. """ @@ -4775,7 +4780,7 @@ def add_mat3d(self, mid, e1, e2, e3, nu12, nu13, nu23, g12, g13, g23, rho=0.0, def add_matg(self, mid, idmem, behav, tabld, tablu, yprs, epl, gpl, gap=0., tab_yprs=None, tab_epl=None, - tab_gpl=None, tab_gap=None, comment='') -> MATG: + tab_gpl=None, tab_gap=None, comment='') -> int: """Creates a MATG card""" mat = MATG(mid, idmem, behav, tabld, tablu, yprs, epl, gpl, gap=gap, tab_yprs=tab_yprs, tab_epl=tab_epl, @@ -4785,7 +4790,7 @@ def add_matg(self, mid, idmem, behav, tabld, tablu, yprs, epl, gpl, gap=0., def add_mathe(self, mid, model, bulk, mus, alphas, betas, mooney, sussbat, aboyce, gent, - rho=0., texp=0., tref=0., ge=0., comment='') -> MATHE: + rho=0., texp=0., tref=0., ge=0., comment='') -> int: """Creates a MATHE card""" mat = MATHE(mid, model, bulk, mus, alphas, betas, mooney, sussbat, aboyce, gent, diff --git a/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py b/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py index 83481aabc..7766b327c 100644 --- a/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py +++ b/pyNastran/dev/bdf_vectorized3/bdf_interface/bdf_attributes.py @@ -1267,7 +1267,7 @@ def inertia_sum(self, element_id: Optional[np.ndarray]=None) -> tuple[float, np. log = self.log element_ids_all = [] inertias = [] - mass = 0. + total_mass = 0. mass_cg = np.zeros(3, dtype='float64') for card in self.elements: if card.n == 0 or card.type in NO_MASS: @@ -1280,8 +1280,16 @@ def inertia_sum(self, element_id: Optional[np.ndarray]=None) -> tuple[float, np. #inertiai = card.inertia() massi = card.mass() massi_sum = massi.sum() - centroid = card.centroid() - mass += massi_sum + assert massi.shape == (card.n, ), massi.shape + + if hasattr(card, 'center_of_mass'): + centroid = card.center_of_mass() + assert centroid.shape == (card.n, 3), centroid.shape + else: + centroid = card.centroid() + assert centroid.shape == (card.n, 3), centroid.shape + + total_mass += massi_sum if np.any(np.isnan(centroid)): log.error(f'{card.type} has nan centroid; centroid={centroid}') raise RuntimeError(f'{card.type} has nan centroid; centroid={centroid}') @@ -1291,13 +1299,13 @@ def inertia_sum(self, element_id: Optional[np.ndarray]=None) -> tuple[float, np. mass_cg += mass_centroid.sum(axis=0) inertias.append((massi, centroid)) - if mass == 0.: + if total_mass == 0.: cg = np.full(3, np.nan, dtype='float64') inertia = np.full(6, np.nan, dtype='float64') log.error('no elements with mass...inertia is nan') - return mass, cg, inertia + return total_mass, cg, inertia - cg = mass_cg / mass + cg = mass_cg / total_mass Ixx = 0. Iyy = 0. Izz = 0. @@ -1318,16 +1326,16 @@ def inertia_sum(self, element_id: Optional[np.ndarray]=None) -> tuple[float, np. #if fem1.wtmass != 1.0: #print('weight = %s' % (mass1 / fem1.wtmass)) - log.debug(f'mass = {mass}') + log.debug(f'mass = {total_mass}') log.debug(f'cg = {cg}') #print('Ixx=%s, Iyy=%s, Izz=%s \nIxy=%s, Ixz=%s, Iyz=%s' % tuple(inertia1)) log.debug(f'Ixx={Ixx:g} Iyy={Iyy:g} Izz={Izz:g}\nIxy={Ixy:g} Ixz={Ixz:g} Iyz={Iyz:g}') #if element_id is None: - return mass, cg, inertia + return total_mass, cg, inertia def inertia(self) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: """ - mass moment of inertia + [mass, cg, mass moment of inertia] """ log = self.log element_ids_all = [] @@ -1361,6 +1369,7 @@ def inertia(self) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: mass = np.hstack(masses) centroid = np.vstack(centroids) abs_mass = np.abs(mass).sum() + neids = len(element_id) #if abs_mass == 0.: #assert len(element_id) > 0, element_id #cg = np.full(3, np.nan, dtype='float64') @@ -1368,8 +1377,13 @@ def inertia(self) -> tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]: #log.error('no elements with mass...inertia is nan') #return element_id, abs_mass, cg, inertia mass_cg = mass[:, None] * centroid - cg = mass_cg.sum(axis=0) / mass.sum() - assert len(cg) == 3, cg + imass = (mass != 0) + cg = np.zeros(centroid.shape, dtype=centroid.dtype) + cg[imass] = mass_cg[imass, :] / mass + + #cg = mass_cg.sum(axis=0) / mass.sum() + #assert len(cg) == 3, cg + assert cg.shape == (neids, 3), cg.shape dxyz = centroid - cg dx = dxyz[:, 0] diff --git a/pyNastran/dev/bdf_vectorized3/cards/elements/bar.py b/pyNastran/dev/bdf_vectorized3/cards/elements/bar.py index 8b9f805fc..147c9b3ab 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/elements/bar.py +++ b/pyNastran/dev/bdf_vectorized3/cards/elements/bar.py @@ -113,7 +113,7 @@ def init_x_g0(card: BDFCard, eid: int): g0 = field5 x = [np.nan, np.nan, np.nan] elif isinstance(field5, float): - g0 = 0 + g0 = -1 x = np.array([field5, double_or_blank(card, 6, 'x2', default=np.nan), double_or_blank(card, 7, 'x3', default=np.nan)], dtype='float64') diff --git a/pyNastran/dev/bdf_vectorized3/cards/elements/beam.py b/pyNastran/dev/bdf_vectorized3/cards/elements/beam.py index d6bb05eee..d90a2cbd2 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/elements/beam.py +++ b/pyNastran/dev/bdf_vectorized3/cards/elements/beam.py @@ -101,6 +101,20 @@ def write_card(self, size: int=8, is_double: bool=False) -> str: return self.comment + print_card_16(card) class CBEAM(Element): + def __init__(self, model: BDF): + super().__init__(model) + self.property_id: np.array = np.array([], dtype='int32') + self.nodes: np.array = np.zeros((0, 2), dtype='int32') + self.offt: np.array = np.array([], dtype='|U3') + self.g0: np.array = np.array([], dtype='int32') + self.x: np.array = np.zeros((0, 3), dtype='float64') + self.pa: np.array = np.array([], dtype='int32') + self.pb: np.array = np.array([], dtype='int32') + self.wa: np.array = np.zeros((0, 3), dtype='float64') + self.wb: np.array = np.zeros((0, 3), dtype='float64') + self.sa: np.array = np.zeros([], dtype='int32') + self.sb: np.array = np.zeros([], dtype='int32') + def add(self, eid: int, pid: int, nids: list[int], x: Optional[list[float]], g0: Optional[int], offt: str='GGG', bit=None, @@ -172,7 +186,7 @@ def parse_cards(self): element_id[icard] = eid property_id[icard] = pid nodes[icard, :] = nids - if g0i is None: + if g0i is None or g0i == -1: x[icard, :] = xi else: g0[icard] = g0i @@ -241,8 +255,8 @@ def write_file(self, bdf_file: TextIOLike, nodes_ = array_str(self.nodes, size=size) pas = array_default_int(self.pa, default=0, size=size) pbs = array_default_int(self.pb, default=0, size=size) - for eid, pid, nodes, g0, x, offt, pa, pb, wa, wb in zip_longest(element_ids, property_ids, nodes_, - self.g0, self.x, self.offt, + for eid, pid, nodes, g0, x, is_g0, offt, pa, pb, wa, wb in zip_longest(element_ids, property_ids, nodes_, + self.g0, self.x, self.is_g0, self.offt, pas, pbs, self.wa, self.wb): n1, n2 = nodes w1a = set_blank_if_default(wa[0], default=0.0) @@ -252,7 +266,8 @@ def write_file(self, bdf_file: TextIOLike, w1b = set_blank_if_default(wb[0], default=0.0) w2b = set_blank_if_default(wb[1], default=0.0) w3b = set_blank_if_default(wb[2], default=0.0) - if g0 == -1: + + if is_g0: x1, x2, x3 = x # self.get_x_g0_defaults() else: x1 = g0 @@ -268,7 +283,15 @@ def write_file(self, bdf_file: TextIOLike, return @property - def all_properties(self): + def is_x(self) -> np.ndarray: + return self.g0 == -1 + + @property + def is_g0(self) -> np.ndarray: + return ~self.is_x + + @property + def all_properties(self) -> list[Union[PBEAM, PBEAML, PBCOMP]]: model = self.model return [model.pbeam, model.pbeaml, model.pbcomp] @@ -305,8 +328,328 @@ def centroid(self) -> np.ndarray: centroid = line_centroid(self.model, self.nodes) return centroid + def get_bar_vector(self, xyz1: np.ndarray) -> np.ndarray: + #if self.g0: + #v = xyz[self.g0] - xyz[self.Ga()] + #else: + #v = self.x + + # get the vector v, which defines the projection on to the elemental + # coordinate frame + is_g0 = self.is_g0 + is_x = self.is_x + v = np.full(self.x.shape, np.nan, dtype=self.x.dtype) + if np.any(is_g0): + grid_g0 = self.model.grid.slice_card_by_node_id(self.g0) + n0 = grid_g0.xyz_cid0() + v = n0 - xyz1 + + grid = self.model.grid + # get the cd frames for the nodes + + #n1 = self.nodes[:, 0] + #in1 = np.searchsorted(grid.node_id, n1) + #assert np.array_equal(grid.node_id[in1], n1) + #cd = grid.cd[in1] + + # get the cd frames for nodes A/B (1/2) + inode = np.searchsorted(grid.node_id, self.nodes) + assert np.array_equal(grid.node_id[inode], self.nodes) + cd = grid.cd[inode] + cd1 = cd[:, 0] + + if np.any(is_x): + if cd1.max() > 0: + v = cd1_ref.transform_node_to_global(elem.x) + cd1_ref = model.Coord(cd1) + cd2_ref = model.Coord(cd2) + else: + v[is_x, :] = self.x[is_x, :] + return v, cd + + def split_offt_vector(self) -> tuple[np.ndarray, np.ndarray, np.ndarray]: + neids = len(self.element_id) + offt_vector = np.full(neids, '', dtype='|U1') + offt_end_a = np.full(neids, '', dtype='|U1') + offt_end_b = np.full(neids, '', dtype='|U1') + for i, (offt_vectori, offt_end_ai, offt_end_bi) in enumerate(self.offt): + offt_vector[i] = offt_vectori + offt_end_a[i] = offt_end_ai + offt_end_b[i] = offt_end_bi + return offt_vector, offt_end_a, offt_end_b + def center_of_mass(self) -> np.ndarray: - return self.centroid() + log = self.model.log + neids = len(self.element_id) + grid = self.model.grid + xyz = grid.xyz_cid0() + nid = grid.node_id + inode = np.searchsorted(nid, self.nodes) + assert np.array_equal(nid[inode], self.nodes) + in1 = inode[:, 0] + in2 = inode[:, 1] + xyz1 = xyz[in1, :] + xyz2 = xyz[in2, :] + centroid = (xyz1 + xyz2) / 2. + assert centroid.shape[0] == self.nodes.shape[0] + + i = xyz2 - xyz1 + ihat_norm = np.linalg.norm(i, axis=1) + assert len(ihat_norm) == neids + if min(ihat_norm) == 0.: + msg = 'xyz1=%s xyz2=%s\n%s' % (xyz1, xyz2, self) + log.error(msg) + raise ValueError(msg) + i_offset = i / ihat_norm[:, np.newaxis] + + #log.info(f'x =\n{self.x}') + #log.info(f'g0 = {self.g0}') + v, cd = self.get_bar_vector(xyz1) + cd1 = cd[:, 0] + cd2 = cd[:, 1] + + offt_vector, offt_end_a, offt_end_b = self.split_offt_vector() + is_rotate_v = (offt_vector == 'G') + is_rotate_wa = (offt_end_a == 'G') + is_rotate_wb = (offt_end_b == 'G') + + #-------------------------------------------------------------------------- + # rotate v + #log.info(f'offt = {self.offt}') + #log.info(f'v0 =\n{v}') + #log.info(f'cd =\n{cd}') + if np.any(is_rotate_v): + # end A + # global - cid != 0 + cd1_vector = cd1[is_rotate_v] + icd1_vector = (cd1_vector != 0) + if np.any(icd1_vector): + v = cd1_ref.transform_node_to_global_assuming_rectangular(v) + del cd1_vector, icd1_vector + elif offt_vector == 'B': + # basic - cid = 0 + pass + else: + msg = f'offt_vector={offt_vector!r} is not supported; offt={elem.offt}' + log.error(msg) + raise RuntimeError(msg) + + #-------------------------------------------------------------------------- + # determine the bar vectors + #log.info(f'v =\n{v}') + #log.info(f'ihat =\n{i_offset}') + ihat = i_offset + vnorm = np.linalg.norm(v, axis=1) + vhat = v / vnorm[:, np.newaxis] # j + z = np.cross(ihat, vhat) # k + norm_z = np.linalg.norm(z, axis=1) + assert len(norm_z) == neids + + zhat = z / norm_z[:, np.newaxis] + yhat = np.cross(zhat, ihat) # j + norm_i = np.linalg.norm(ihat, axis=1) + norm_yhat = np.linalg.norm(yhat, axis=1) + xform_offset = np.dstack([ihat, yhat, zhat]) # 3x3 unit matrix + #del ihat, yhat, zhat, norm_z, norm_yhat + del norm_i, norm_z, norm_yhat + xform = xform_offset + #-------------------------------------------------------------------------- + # rotate wa + # wa defines the offset at end A + wa = self.wa.copy() # we're going to be inplace hacking it, so copy :) + if np.any(is_rotate_wa): + cd1_vector = cd1[is_rotate_v] + icd1_vector = (cd1_vector != 0) + if np.any(icd1_vector): + wa = cd1_ref.transform_node_to_global_assuming_rectangular(wa) + del cd1_vector, icd1_vector + elif offt_end_a == 'B': + pass + elif offt_end_a == 'O': + # rotate point wa from the local frame to the global frame + wa = wa @ xform_offset + #ia = n1 + wa + else: + msg = 'offt_end_a=%r is not supported; offt=%s' % (offt_end_a, self.offt) + log.error(msg) + raise NotImplementedError(msg) + #return v, None, None, xform_offset + + #-------------------------------------------------------------------------- + # rotate wb + # wb defines the offset at end B + wb = self.wb.copy() # we're going to be inplace hacking it, so copy :) + if np.any(is_rotate_wb): + cd2_vector = cd2[is_rotate_wb] + icd2_vector = (cd2_vector != 0) + if np.any(icd2_vector): + # MasterModelTaxi + wb = cd2_ref.transform_node_to_global_assuming_rectangular(wb) + del cd2_vector, icd2_vector + elif offt_end_b == 'B': + pass + elif offt_end_b == 'O': + # rotate point wb from the local frame to the global frame + wb = wb @ xform_offset + #ib = n2 + wb + else: + msg = 'offt_end_b=%r is not supported; offt=%s' % (offt_end_b, self.offt) + log.error(msg) + raise RuntimeError(msg) + #return v, wa, None, xform_offset + + #ihat = xform[0, :] + #yhat = xform[1, :] + #zhat = xform[2, :] + #wa, wb, _ihat, jhat, khat = out + + # we finally have the nodal coordaintes!!!! :) + p1 = xyz1 + wa + p2 = xyz2 + wb + # ---------------------------------- + # now some mass properties :( + jhat = yhat + khat = zhat + + mass_per_length = np.full(neids, np.nan, dtype='float64') + nsm_per_length = np.full(neids, np.nan, dtype='float64') + nsm_centroid = np.full((neids, 3), np.nan, dtype='float64') + + log.debug(f'property_id = {self.property_id}') + for prop in self.allowed_properties: + pids_common = np.union1d(prop.property_id, self.property_id) + #ind = prop.property_id[ipid] + if len(pids_common) == 0: + log.debug(f' skipping {prop.type}; pids={prop.property_id}') + continue + + ipid = np.searchsorted(prop.property_id, self.property_id) + ipid = ipid[ipid < len(prop.property_id)] + if len(ipid) == 0: + log.warning(f'skipping {prop.type}; pids={prop.property_id}') + continue + is_valid = (prop.property_id[ipid] == self.property_id) + ipid = ipid[is_valid] + + prop2 = prop.slice_card_by_property_id(pids_common) + log.info(f'running...{prop.type}: pids={prop.property_id}') + if prop.type == 'PBEAM': + #ipid = prop.index(self.property_id) + #ipid = np.array([pid for pid in self.property_id + #if pid in pids_common]) + #ipid = prop.index(pids_common, assume_sorted=True, + #inverse=False) + #ipidrev = prop.index(pids_common, assume_sorted=True, + #inverse=True) + #prop2 = prop.slice_card_by_id(ipid) + m1a = prop2.m1a + m1b = prop2.m1b + m2a = prop2.m2a + m2b = prop2.m2b + rho = prop2.rho() + + # we don't call the MassPerLength method so we can put the NSM centroid + # on a different axis (the PBEAM is weird) + mass_per_lengths_, nsm_per_lengths_ = prop2.rhoarea_nsm() + + #ipidrev2 = np.zeros(neids, ) + for jpid, pid, mpl, nsmpl in zip(count(), pids_common, + mass_per_lengths_, nsm_per_lengths_): + iipid = np.where(self.property_id == pid)[0] + if len(iipid) == 0: + log.warning(f' skipping {prop.type}; pid={pid}') + continue + #ipidrev2.append(_pid) + + nsm_n1 = (p1[iipid, :] + jhat[iipid, :] * m1a[jpid] + khat[iipid, :] * m2a[jpid]) + nsm_n2 = (p2[iipid, :] + jhat[iipid, :] * m1b[jpid] + khat[iipid, :] * m2b[jpid]) + #print("nsm_per_length=%s" % nsm_per_length) + #print("nsm_n1=%s" % nsm_n1) + #print("nsm_n2=%s" % nsm_n2) + nsm_centroid[iipid] = (nsm_n1 + nsm_n2) / 2. + mass_per_length[iipid] = mpl + nsm_per_length[iipid] = nsmpl + #nsm_centroid[iipid] = 0. + x = 1 + + #if nsm != 0.: + #p1_nsm = p1 + prop.ma + #p2_nsm = p2 + prop.mb + elif prop.type == 'PBEAML': + prop2 = prop.slice_card_by_property_id(pids_common) + mass_per_lengths_ = prop2.mass_per_length() + for jpid, pid, mpl in zip(count(), pids_common, mass_per_lengths_): + iipid = np.where(self.property_id == pid)[0] + if len(iipid) == 0: + log.warning(f' skipping {prop.type}; pid={pid}') + continue + mass_per_length[iipid] = mpl + + #mass_per_length = prop.MassPerLength() # includes simplified nsm + nsm_centroid[iipid, :] = (p1 + p2) / 2. + + # mass_per_length already includes nsm + nsm_per_length[iipid] = 0. + + #print('mass_per_lengths=%s nsm_per_lengths=%s' % ( + #mass_per_lengths, nsm_per_lengths)) + #print('mass_per_length=%s nsm_per_length=%s' % ( + #mass_per_length, nsm_per_length)) + elif prop.type == 'PBCOMP': + prop2 = prop.slice_card_by_property_id(pids_common) + mass_per_lengths_ = prop2.mass_per_length() + m1s = prop2.m1 + m2s = prop2.m2 + for jpid, pid, mpl, m1, m2 in zip(count(), pids_common, + mass_per_lengths_, m1s, m2s): + iipid = np.where(self.property_id == pid)[0] + if len(iipid) == 0: + log.warning(f' skipping {prop.type}; pid={pid}') + continue + mass_per_length[iipid] = mpl + + # already accounted for in mass_per_length + nsm_per_length[iipid] = 0.0 + + nsm_n1 = (p1[iipid, :] + jhat[iipid, :] * m1 + khat[jpid, :] * m2) + nsm_n2 = (p2[iipid, :] + jhat[iipid, :] * m1 + khat[jpid, :] * m2) + nsm_centroid[iipid, :] = (nsm_n1 + nsm_n2) / 2. + x = 1 + #elif prop.type == 'PBMSECT': + #continue + #mass_per_length = prop.MassPerLength() + #m = mass_per_length * length + #nsm = prop.nsm + elif prop.type == 'PBMSECT': + raise RuntimeError(prop) + #mass_per_length = 0. ## TODO: fix me + #nsm_per_length = prop.nsm + #nsm_centroid = (p1 + p2) / 2. + else: + raise NotImplementedError(prop.type) + + assert isinstance(mass_per_length, np.ndarray), mass_per_length + assert isinstance(nsm_per_length, np.ndarray), nsm_per_length + assert nsm_centroid.shape == (self.n, 3), nsm_centroid.shape + + assert not np.isnan(nsm_centroid.max()), nsm_centroid + assert not np.isnan(mass_per_length.max()), mass_per_length + assert not np.isnan(nsm_per_length.max()), nsm_per_length + total_mass = mass_per_length + nsm_per_length + + assert centroid.shape == (self.n, 3), centroid.shape + if total_mass == 0.0: + return centroid + + center_of_mass = (centroid * mass_per_length + nsm_centroid * nsm_per_length) / total_mass + assert not np.isnan(center_of_mass.max()), center_of_mass + assert mass_per_length.shape == (self.n, ), mass_per_length.shape + assert nsm_per_length.shape == (self.n, ), nsm_per_length.shape + assert total_mass.shape == (self.n, ), total_mass.shape + assert nsm_centroid.shape == (self.n, 3), nsm_centroid.shape + assert center_of_mass.shape == (self.n, 3), center_of_mass.shape + return center_of_mass + #return self.centroid() def area(self) -> np.ndarray: pid = self.property_id @@ -341,10 +684,15 @@ def volume(self) -> np.ndarray: L = self.length() return A * L + @property def is_offt(self) -> np.ndarray: is_offt = (self.g0 == -1) return is_offt + @property + def is_bit(self) -> np.ndarray: + return not self.is_offt + class PBEAM(Property): """ Defines the properties of a beam element (CBEAM entry). This element may be @@ -774,6 +1122,26 @@ def parse_cards(self): #if nsmi is None: #nsmi = np.zeros(nstations) + if m1ai is None: + m1ai = 0.0 + if m2ai is None: + m2ai = 0.0 + + if m1bi is None: + m1bi = m1ai + if m2bi is None: + m2bi = m2ai + + if n1ai is None: + n1ai = 0.0 + if n2ai is None: + n2ai = 0.0 + + if n1bi is None: + n1bi = n1ai + if n2bi is None: + n2bi = n2ai + nstationi = len(xxbi) property_id[icard] = pid material_id[icard] = mid @@ -870,7 +1238,7 @@ def _save(self, property_id, material_id, self.I1 = I1 self.I2 = I2 self.I12 = I12 - self.nsm = nsm + self._nsm = nsm self.c1 = c1 self.c2 = c2 @@ -931,7 +1299,7 @@ def __apply_slice__(self, prop: PBEAM, i: np.ndarray) -> None: prop.I1 = hslice_by_idim(i, istation, self.I1) prop.I2 = hslice_by_idim(i, istation, self.I2) prop.I12 = hslice_by_idim(i, istation, self.I12) - prop.nsm = hslice_by_idim(i, istation, self.nsm) + prop._nsm = hslice_by_idim(i, istation, self._nsm) prop.c1 = hslice_by_idim(i, istation, self.c1) prop.c2 = hslice_by_idim(i, istation, self.c2) @@ -964,19 +1332,23 @@ def allowed_materials(self) -> list[MAT1]: assert len(materials) > 0, f'{self.type}: all_allowed_materials={all_materials}\nall_materials={self.model.materials}' return materials - def mass_per_length(self) -> np.ndarray: - nproperties = len(self.property_id) + def rho(self) -> np.ndarray: rho = get_density_from_material(self.material_id, self.allowed_materials) - if rho.max() == 0. and rho.min() == 0. and self.nsm.max() == 0. and self.nsm.min() == 0.: - return np.zeros(nproperties, dtype=rho.dtype) + return rho + def mass_per_length(self) -> np.ndarray: + nproperties = len(self.property_id) + rho = self.rho() mass_per_length = np.zeros(nproperties, dtype='float64') + if rho.max() == 0. and rho.min() == 0. and self._nsm.max() == 0. and self._nsm.min() == 0.: + return mass_per_length + for i, rhoi, istation in zip(count(), rho, self.istation): istation0, istation1 = istation assert istation1 > istation0 xxb = self.xxb[istation0:istation1] area = self.A[istation0:istation1] - nsm = self.nsm[istation0:istation1] + nsm = self._nsm[istation0:istation1] mass_per_lengths = rhoi * area + nsm mass_per_lengthi = integrate_positive_unit_line(xxb, mass_per_lengths) mass_per_length[i] = mass_per_lengthi @@ -984,6 +1356,34 @@ def mass_per_length(self) -> np.ndarray: assert len(mass_per_length) == nproperties return mass_per_length + def rhoarea_nsm(self) -> np.ndarray: + nproperties = len(self.property_id) + rho = self.rho() + + nsm_per_length = np.zeros(nproperties, dtype='float64') + rho_area = np.zeros(nproperties, dtype='float64') + if rho.max() == 0. and rho.min() == 0. and self._nsm.max() == 0. and self._nsm.min() == 0.: + return rho_area, nsm_per_length + + #assert len(rho) == len(self.A) + assert len(rho) == len(nsm_per_length) + for i, istation in zip(count(), self.istation): + istation0, istation1 = istation + assert istation1 > istation0 + areai = self.A[istation0:istation1] + xxbi = self.xxb[istation0:istation1] + nsmi = self._nsm[istation0:istation1] + nsm_per_length[i] = integrate_positive_unit_line(xxbi, nsmi) + + rho_areas = rho[i] * areai # + nsmi + #mass_per_lengths = rho[i] * areai + nsmi + rho_area[i] = integrate_positive_unit_line(xxbi, rho_areas) + #mass_per_length[i] = integrate_positive_unit_line(xxbi, mass_per_lengths) + #rho_area[i] = mass_per_lengthi + + assert len(nsm_per_length) == nproperties + return rho_area, nsm_per_length + @property def is_small_field(self) -> bool: return max(self.property_id.max(), @@ -1019,7 +1419,7 @@ def write_file(self, bdf_file: TextIOLike, i1_ = self.I1[istation0:istation1] i2_ = self.I2[istation0:istation1] i12_ = self.I12[istation0:istation1] - nsm_ = self.nsm[istation0:istation1] + nsm_ = self._nsm[istation0:istation1] c1_ = self.c1[istation0:istation1] c2_ = self.c2[istation0:istation1] d1_ = self.d1[istation0:istation1] @@ -1196,14 +1596,14 @@ def __init__(self, model: BDF): #idim = self.idim self.Type = np.array([], dtype='|U8') self.group = np.array([], dtype='|U8') - self.nsm = np.array([], dtype='float64') + self._nsm = np.array([], dtype='float64') self.dims = np.zeros([], dtype='float64') - self.idim = np.zeros((0, 2), dtype='int32') # for all properties + #self.idim = np.zeros((0, 2), dtype='int32') # for all properties self.ndim = np.array([], dtype='int32') - self.istation = np.zeros((0, 2), dtype='int32') + #self.istation = np.zeros((0, 2), dtype='int32') self.nstation = np.array([], dtype='int32') #self.ndim = @@ -1216,9 +1616,11 @@ def slice_card_by_property_id(self, property_id: np.ndarray) -> PBEAML: return prop def add(self, pid: int, mid: int, beam_type: str, - xxb, dims, so=None, nsm=None, + xxb: list[float], dims: list[list[float]], + so=None, nsm=None, group: str='MSCBML0', comment: str='') -> int: nxxb = len(xxb) + self.model.log.info(f'pid={pid} so0={so} beam_type={beam_type!r} dims={dims} nsm0={nsm} xxb={xxb}') if so is None: so = ['YES'] * nxxb elif isinstance(so, str): @@ -1229,6 +1631,11 @@ def add(self, pid: int, mid: int, beam_type: str, elif isinstance(nsm, float_types): nsm = [nsm] * nxxb ndim = self.valid_types[beam_type] + + nstation = len(xxb) + self.model.log.info(f' nstation={nstation} ndim={ndim}') + assert nstation == len(dims), f'pid={pid} nstation={nstation} dims={dims}' + assert nstation == len(nsm), f'pid={pid} nstation={nstation} nsm={nsm}' self.cards.append((pid, mid, beam_type, group, xxb, so, nsm, ndim, dims, comment)) self.n += 1 return self.n @@ -1319,6 +1726,9 @@ def add_card(self, card: BDFCard, comment: str='') -> int: n += 1 ioffset += 1 assert len(card) > 5, card + + nstationi = len(xxb) + assert nstationi == len(nsm), f'pid={pid} nstation={nstationi} nsm={nsm}' self.cards.append((pid, mid, beam_type, group, xxb, so, nsm, ndim, dims, comment)) self.n += 1 return self.n @@ -1333,10 +1743,10 @@ def parse_cards(self) -> None: property_id = np.zeros(ncards, dtype='int32') material_id = np.zeros(ncards, dtype='int32') - idim = np.zeros((ncards, 2), dtype='int32') # for all properties + #idim = np.zeros((ncards, 2), dtype='int32') # for all properties ndim = np.zeros(ncards, dtype='int32') - istation = np.zeros((ncards, 2), dtype='int32') # for all properties + #istation = np.zeros((ncards, 2), dtype='int32') # for all properties nstation = np.zeros(ncards, dtype='int32') Type = np.full(ncards, '', dtype='|U8') @@ -1348,21 +1758,22 @@ def parse_cards(self) -> None: all_so = [] all_nsm = [] - idim0 = 0 - istation0 = 0 + #idim0 = 0 + #istation0 = 0 for icard, card in enumerate(self.cards): (pid, mid, beam_type, groupi, xxbi, soi, nsmi, ndimi, dims, comment) = card nstationi = len(xxbi) all_xxb.extend(xxbi) for dim in dims: + _bar_areaL('PBEAML', beam_type, dim, self) all_dims.extend(dim) all_so.extend(soi) all_nsm.extend(nsmi) #station.extend(xxbi) - idim1 = idim0 + ndimi * nstationi - istation1 = istation0 + nstationi + #idim1 = idim0 + ndimi * nstationi + #istation1 = istation0 + nstationi nstation[icard] = nstationi property_id[icard] = pid material_id[icard] = mid @@ -1370,14 +1781,14 @@ def parse_cards(self) -> None: Type[icard] = beam_type ndim[icard] = ndimi #assert nstationi >= 2, f'pid={pid} mid={mid} beam_type={beam_type!r} xxb={xxbi} dims={dims}' - print(f'pid={pid} mid={mid} beam_type={beam_type!r} xxb={xxbi} dims={dims}') - - idim[icard, :] = [idim0, idim1] - istation[icard, :] = [istation0, istation1] + #print(f'pid={pid} mid={mid} beam_type={beam_type!r} xxb={xxbi} dims={dims} nsm={nsmi}') + assert nstationi == len(nsmi), f'pid={pid} nstation={nstationi} nsmi={nsmi}' + #idim[icard, :] = [idim0, idim1] + #istation[icard, :] = [istation0, istation1] #self.nsm[icard] = nsm - idim0 = idim1 - istation0 = istation1 + #idim0 = idim1 + #istation0 = istation1 xxb = np.array(all_xxb, dtype='float64') dims = np.array(all_dims, dtype='float64') @@ -1386,8 +1797,8 @@ def parse_cards(self) -> None: #ndim_total = self.ndim.sum() self._save( property_id, material_id, - idim, ndim, - istation, nstation, + ndim, + nstation, Type, group, xxb, dims, so, nsm) nstation_total = self.nstation.sum() @@ -1396,12 +1807,34 @@ def parse_cards(self) -> None: assert self.xxb.shape[0] == nstation_total #assert len(self.dims) == ndim_total assert len(self.so) == nstation_total - assert len(self.nsm) == nstation_total + assert len(self._nsm) == nstation_total, f'nsm={self._nsm}; nstations_total={nstation_total}' self.cards = [] + @property + def istation(self) -> np.ndarray: + nprops = len(self.property_id) + istation = np.zeros((nprops, 2), dtype='int32') + csum = np.cumsum(self.nstation) + istation[:, 0] = np.hstack([0, csum[:-1]]) + istation[:, 1] = csum + return istation + + @property + def idim(self) -> np.ndarray: + nprops = len(self.property_id) + idim = np.zeros((nprops, 2), dtype='int32') + csum = np.cumsum(self.ndim * self.nstation) + idim[:, 0] = np.hstack([0, csum[:-1]]) + idim[:, 1] = csum + return idim + + #@property + #def idim(self) -> np.ndarray: + #return make_idim(self.n, self.ndim) + def _save(self, property_id: np.ndarray, material_id: np.ndarray, - idim: np.ndarray, ndim: np.ndarray, - istation: np.ndarray, nstation: np.ndarray, + ndim: np.ndarray, + nstation: np.ndarray, Type: np.ndarray, group: np.ndarray, xxb: np.ndarray, dims: np.ndarray, @@ -1409,27 +1842,24 @@ def _save(self, property_id: np.ndarray, material_id: np.ndarray, self.property_id = property_id self.material_id = material_id - assert idim.ndim == 2, idim.shape - assert idim.min() == 0, idim assert ndim.min() >= 1, idim - self.idim = idim self.ndim = ndim - assert istation.ndim == 2, istation.shape - assert istation.min() == 0, istation + #assert istation.ndim == 2, istation.shape + #assert istation.min() == 0, istation #assert nstation.min() >= 2, nstation assert nstation.min() >= 1, nstation - self.istation = istation + #self.istation = istation self.nstation = nstation self.Type = Type self.group = group - self.nsm = nsm + self._nsm = nsm self.xxb = xxb self.dims = dims self.so = so - self.nsm = nsm + self._nsm = nsm def __apply_slice__(self, prop: PBEAML, i: np.ndarray) -> None: prop.n = len(i) @@ -1439,27 +1869,30 @@ def __apply_slice__(self, prop: PBEAML, i: np.ndarray) -> None: #self.istation = hslice_by_idim(i, idim, elements) prop.Type = self.Type[i] prop.group = self.group[i] - prop.nsm = self.nsm[i] + #prop._nsm = self._nsm[i] idim = self.idim istation = self.istation prop.dims = hslice_by_idim(i, idim, self.dims) prop.xxb = hslice_by_idim(i, istation, self.xxb) + prop._nsm = hslice_by_idim(i, istation, self._nsm) #self.idim = np.zeros((ncards, 2), dtype='int32') # for all properties - prop.idim = self.idim[i, :] + #prop.idim = self.idim[i, :] prop.ndim = self.ndim[i] #self.istation = istation - prop.istation = self.istation[i, :] + #prop.istation = self.istation[i, :] prop.nstation = self.nstation[i] prop.so = self.so[i] - prop.nsm = self.nsm[i] + prop.n = len(i) - #@property - #def idim(self) -> np.ndarray: - #return make_idim(self.n, self.ndim) + nproperties = len(prop.property_id) + nstations = prop.nstation.sum() + assert len(prop.xxb) == nstations + assert len(prop.group) == nproperties + assert len(prop._nsm) == nstations def geom_check(self, missing: dict[str, np.ndarray]): mids = hstack_msg([prop.material_id for prop in self.allowed_materials], @@ -1491,7 +1924,7 @@ def write_file(self, bdf_file: TextIOLike, idim0, idim1 = idim istation0, istation1 = istation xxb = self.xxb[istation0:istation1] - nsm = self.nsm[istation0:istation1] + nsm = self._nsm[istation0:istation1] so = self.so[istation0:istation1] dims = self.dims[idim0 : idim1].reshape(nstation, ndim) @@ -1525,15 +1958,17 @@ def write_file(self, bdf_file: TextIOLike, def area(self) -> np.ndarray: nproperties = len(self.property_id) area = np.zeros(nproperties, dtype='float64') - for i, beam_type, ndim, idim, nstation, istation in zip(count(), self.Type, - self.ndim, self.idim, - self.nstation, self.istation,): + for i, pid, beam_type, ndim, idim, nstation, istation in zip(count(), self.property_id, self.Type, + self.ndim, self.idim, + self.nstation, self.istation,): idim0, idim1 = idim istation0, istation1 = istation xxb = self.xxb[istation0:istation1] #nsm = self.nsm[istation0:istation1] #so = self.so[istation0:istation1] dims = self.dims[idim0 : idim1].reshape(nstation, ndim) + dims_str = str(dims).replace('\n', '') + self.model.log.info(f'pid={pid} beam_type={beam_type!r} dims={dims_str} idim0={idim0} idim1={idim1}') #prop = pbarl(self.property_id[i], self.material_id[i], beam_type, dim) #A, I1, I2, I12 = A_I1_I2_I12(prop, beam_type, dim) @@ -1542,14 +1977,18 @@ def area(self) -> np.ndarray: area_i1_i2_i12 = _bar_areaL('PBEAML', beam_type, dim, self) areasi.append(area_i1_i2_i12[0]) if len(xxb) == 1: - areaii = areasi[i] + areaii = areasi[0] xxb = [0., 1.] areasi = [areaii, areaii] A = integrate_positive_unit_line(xxb, areasi) area[i] = A return area - def nsm_func(self) -> np.ndarray: + def rho(self) -> np.ndarray: + rho = get_density_from_material(self.material_id, self.allowed_materials) + return rho + + def nsm(self) -> np.ndarray: nproperties = len(self.property_id) nsm = np.zeros(nproperties, dtype='float64') for i, beam_type, ndim, idim, nstation, istation in zip(count(), self.Type, @@ -1558,7 +1997,7 @@ def nsm_func(self) -> np.ndarray: #idim0, idim1 = idim istation0, istation1 = istation xxb = self.xxb[istation0:istation1] - nsms = self.nsm[istation0:istation1] + nsms = self._nsm[istation0:istation1] #so = self.so[istation0:istation1] #dims = self.dims[idim0 : idim1].reshape(nstation, ndim) @@ -1568,8 +2007,10 @@ def nsm_func(self) -> np.ndarray: #for dim in dims: #area_i1_i2_i12 = _bar_areaL('PBEAML', beam_type, dim, self) #areasi.append(area_i1_i2_i12[0]) + + assert len(xxb) == len(nsms) if len(xxb) == 1: - nsmi = nsms[i] + nsmi = nsms[0] xxb = [0., 1.] nsms = [nsmi, nsmi] nsmi = integrate_positive_unit_line(xxb, nsms) @@ -1591,11 +2032,10 @@ def allowed_materials(self) -> list[MAT1]: assert len(materials) > 0, f'{self.type}: all_allowed_materials={all_materials}\nall_materials={self.model.materials}' return materials - def mass_per_length(self): - #nproperties = len(self.property_id) + def mass_per_length(self) -> np.ndarray: rho = get_density_from_material(self.material_id, self.allowed_materials) A = self.area() - nsm = self.nsm_func() + nsm = self.nsm() return rho * A + nsm @@ -1815,32 +2255,23 @@ def parse_cards(self) -> None: self.sort() def __apply_slice__(self, prop: PBCOMP, i: np.ndarray) -> None: - self.property_id = self.property_id[i] - self.material_id = self.material_id[i] + prop.property_id = self.property_id[i] + prop.material_id = self.material_id[i] - self.Type = self.Type[i] - self.group = self.group[i] - self.k = self.k[i, :] - self.m1 = self.m1[i] - self.m2 = self.m2[i] - self.n1 = self.n1[i] - self.n2 = self.n2[i] + prop.k = self.k[i, :] + prop.m1 = self.m1[i] + prop.m2 = self.m2[i] + prop.n1 = self.n1[i] + prop.n2 = self.n2[i] + prop.nsm = self.nsm[i] istation = self.istation - self.y = hslice_by_idim(i, istation, self.y) - self.z = hslice_by_idim(i, istation, self.z) - self.c = hslice_by_idim(i, istation, self.c) - self.material_ids = hslice_by_idim(i, istation, self.material_ids) - - self.c1 = hslice_by_idim(i, istation, self.c1) - self.c2 = hslice_by_idim(i, istation, self.c2) - self.d1 = hslice_by_idim(i, istation, self.d1) - self.d2 = hslice_by_idim(i, istation, self.d2) - self.e1 = hslice_by_idim(i, istation, self.e1) - self.e2 = hslice_by_idim(i, istation, self.e2) - self.f1 = hslice_by_idim(i, istation, self.f1) - self.f2 = hslice_by_idim(i, istation, self.f2) - self.nstation = self.nstation[i, :] + prop.y = hslice_by_idim(i, istation, self.y) + prop.z = hslice_by_idim(i, istation, self.z) + prop.c = hslice_by_idim(i, istation, self.c) + prop.material_ids = hslice_by_idim(i, istation, self.material_ids) + prop.nstation = self.nstation[i] + prop.n = len(i) @property def all_materials(self) -> list[Any]: @@ -1895,23 +2326,23 @@ def write_file(self, bdf_file: TextIOLike, property_ids, material_ids, self._area, self.i1, self.i2, self.i12, self.j, self.nsm, self.k, self.m1, self.m2, self.n1, self.n2, self.symopt, self.istation): - area = set_blank_if_default(A, 0.0) - j = set_blank_if_default(j, 0.0) - i1 = set_blank_if_default(i1, 0.0) - i2 = set_blank_if_default(i2, 0.0) - i12 = set_blank_if_default(i12, 0.0) - nsm = set_blank_if_default(nsm, 0.0) + area = set_blank_if_default(A, default=0.0) + j = set_blank_if_default(j, default=0.0) + i1 = set_blank_if_default(i1, default=0.0) + i2 = set_blank_if_default(i2, default=0.0) + i12 = set_blank_if_default(i12, default=0.0) + nsm = set_blank_if_default(nsm, default=0.0) - k1 = set_blank_if_default(k1, 1.0) - k2 = set_blank_if_default(k2, 1.0) + k1 = set_blank_if_default(k1, default=1.0) + k2 = set_blank_if_default(k2, default=1.0) - m1 = set_blank_if_default(m1, 0.0) - m2 = set_blank_if_default(m2, 0.0) + m1 = set_blank_if_default(m1, default=0.0) + m2 = set_blank_if_default(m2, default=0.0) - n1 = set_blank_if_default(n1, 0.0) - n2 = set_blank_if_default(n2, 0.0) + n1 = set_blank_if_default(n1, default=0.0) + n2 = set_blank_if_default(n2, default=0.0) - symopt = set_blank_if_default(symopt, 0) + symopt = set_blank_if_default(symopt, default=0) list_fields = ['PBCOMP', pid, mid, area, i1, i2, i12, j, nsm, k1, k2, m1, m2, n1, n2, symopt, None] @@ -1921,7 +2352,7 @@ def write_file(self, bdf_file: TextIOLike, c = self.c[istation0:istation1] mids = self.material_ids[istation0:istation1] for (yi, zi, ci, mid) in zip_longest(y, z, c, mids): - ci = set_blank_if_default(ci, 0.0) + ci = set_blank_if_default(ci, default=0.0) list_fields += [yi, zi, ci, mid, None, None, None, None] #assert len(y) > 0, list_fields bdf_file.write(print_card(list_fields)) diff --git a/pyNastran/dev/bdf_vectorized3/cards/elements/rod.py b/pyNastran/dev/bdf_vectorized3/cards/elements/rod.py index c1d1b6508..0cf199f96 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/elements/rod.py +++ b/pyNastran/dev/bdf_vectorized3/cards/elements/rod.py @@ -337,6 +337,14 @@ class PROD(Property): | PROD | 1 | 2 | 2.0 | 3.0 | 0.5 | 1.0 | +------+-----+-----+-----+-----+-----+-----+ """ + def __init__(self, model: BDF): + super().__init__(model) + self.material_id: np.ndarray = np.array([], dtype='int32') + self.A: np.ndarray = np.array([], dtype='float64') + self.J: np.ndarray = np.array([], dtype='float64') + self.c: np.ndarray = np.array([], dtype='float64') + self.nsm: np.ndarray = np.array([], dtype='float64') + def add(self, pid: int, mid: int, A: float, j: float=0., c: float=0., nsm: float=0., comment: str='') -> int: """ diff --git a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_bars.py b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_bars.py index ab1fe6d4e..b7f14cd17 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_bars.py +++ b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_bars.py @@ -227,14 +227,14 @@ def test_pbarl_1(self): dim = 42 nsm = 0.5 with self.assertRaises(KeyError): # bar_type - pbarl = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') + pbarl_id = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') bar_type = 'TUBE' with self.assertRaises(ValueError): # len(dim) = 1; not 2= - pbarl = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') + pbarl_id = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') dim = [1., 2.] - pbarl = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') + pbarl_id = model.add_pbarl(pid, mid, bar_type, dim, group=group, nsm=nsm, comment='comment') E = 3.0e7 G = None @@ -257,6 +257,7 @@ def test_pbarl_1(self): #pbarl.validate() #pbarl.group = 'MSCBML0' + pbarl = model.pbarl pbarl.dims = np.array([2.2, 1.1]) pbarl.validate() @@ -290,8 +291,9 @@ def test_pbarl_1(self): eid = 42 x = None g0 = None - cbar = model.add_cbar(eid, pid, [nid1, nid2], x, g0, offt='GGG', - pa=0, pb=0, wa=None, wb=None, comment='') + cbar_id = model.add_cbar(eid, pid, [nid1, nid2], x, g0, offt='GGG', + pa=0, pb=0, wa=None, wb=None, comment='') + cbar = model.cbar #with self.assertRaises(ValueError): cbar.validate() cbar.x = [0., 1., 2.] @@ -511,7 +513,8 @@ def test_pbar_nsm(self): E = 1.0 G = None nu = 0.3 - mat1 = model.add_mat1(mid, E, G, nu) + mat1_id = model.add_mat1(mid, E, G, nu) + mat1 = model.mat1 #---------------- card_lines = [ @@ -541,13 +544,15 @@ def test_pbarl_nsm(self): mid = 1 bar_type = 'BAR' dim = [1., 2.] # area = 2.0 - pbarl = model.add_pbarl(pid, mid, bar_type, dim, group='MSCBML0', nsm=1., - comment='') + pbarl_id = model.add_pbarl(pid, mid, bar_type, dim, group='MSCBML0', nsm=1., + comment='') + pbarl = model.pbarl E = 1.0 G = None nu = 0.3 - mat1 = model.add_mat1(mid, E, G, nu) + mat1_id = model.add_mat1(mid, E, G, nu) + mat1 = model.mat1 #---------------- card_lines = [ @@ -802,8 +807,9 @@ def test_bar_area(self): G = None nu = 0.3 model.add_mat1(mid, E, G, nu) + pbarl = model.pbarl for bar_type, dims, areai, i1 in shape_dims_area: - pbarl = model.add_pbarl(pid, mid, bar_type, dims, group=group, nsm=nsm, comment='comment') + pbarl_id = model.add_pbarl(pid, mid, bar_type, dims, group=group, nsm=nsm, comment='comment') model.setup() pbarl.validate() model.setup() diff --git a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_shells.py b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_shells.py index 501b57722..fdf7c3187 100644 --- a/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_shells.py +++ b/pyNastran/dev/bdf_vectorized3/cards/test/test_vector_shells.py @@ -767,11 +767,11 @@ def test_ctriar_cquadr(self): eid = 6 pid = 13 nids = [1, 2, 3] - ctriar = model.add_ctriar(eid, pid, nids, comment='ctriar') + ctriar_id = model.add_ctriar(eid, pid, nids, comment='ctriar') eid = 8 nids = [1, 2, 3, 4] - cquadr = model.add_cquadr(eid, pid, nids, comment='cquadr') + cquadr_id = model.add_cquadr(eid, pid, nids, comment='cquadr') #cquadr.raw_fields() mid = 42 @@ -782,6 +782,9 @@ def test_ctriar_cquadr(self): model.add_mat8(mid, e11, e22, nu12, rho=10.) model.setup() + ctriar = model.ctriar + cquadr = model.cquadr + #ctriar.raw_fields() ctriar.write(size=8) #ctriar.write(size=8, is_double=False) diff --git a/pyNastran/dev/bdf_vectorized3/test/all_tests.py b/pyNastran/dev/bdf_vectorized3/test/all_tests.py index a18fba691..14e7ad4a2 100644 --- a/pyNastran/dev/bdf_vectorized3/test/all_tests.py +++ b/pyNastran/dev/bdf_vectorized3/test/all_tests.py @@ -9,6 +9,7 @@ # good from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_dmig import * +from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_beams import * from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_bars import * from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_coords import * from pyNastran.dev.bdf_vectorized3.cards.test.test_vector_shells import TestShells diff --git a/pyNastran/f06/flutter_response.py b/pyNastran/f06/flutter_response.py index e8c18cff8..ef11b5136 100644 --- a/pyNastran/f06/flutter_response.py +++ b/pyNastran/f06/flutter_response.py @@ -695,7 +695,7 @@ def _get_symbols_colors_from_modes(self, modes) -> tuple[list[str], list[str]]: return symbols, colors def plot_vg_vf(self, fig=None, damp_axes=None, freq_axes=None, modes=None, - plot_type='tas', + plot_type: str='tas', clear=False, close=False, legend=True, xlim=None, ylim_damping=None, ylim_freq=None, vd_limit=None, damping_limit=None, diff --git a/pyNastran/f06/parse_flutter.py b/pyNastran/f06/parse_flutter.py index 819bddcad..f092c7fcf 100644 --- a/pyNastran/f06/parse_flutter.py +++ b/pyNastran/f06/parse_flutter.py @@ -288,8 +288,8 @@ def _get_units(units: Optional[Union[str, dict[str, str]]]) -> Optional[Union[st def plot_flutter_f06(f06_filename: str, - f06_units: dict[str, str]=None, - out_units: dict[str, str]=None, + f06_units: Optional[dict[str, str]]=None, + out_units: Optional[dict[str, str]]=None, make_alt: bool=False, plot_type: str='tas', modes: Optional[list[int]]=None, @@ -308,7 +308,6 @@ def plot_flutter_f06(f06_filename: str, export_zona_filename: Optional[str]=None, export_veas_filename: Optional[str]=None, export_f06_filename: Optional[str]=None, - export_csv_filename: Optional[str]=None, vg_filename: Optional[str]=None, vg_vf_filename: Optional[str]=None, root_locus_filename: Optional[str]=None, @@ -400,7 +399,6 @@ def plot_flutter_f06(f06_filename: str, export_zona_filename=export_zona_filename, export_veas_filename=export_veas_filename, export_f06_filename=export_f06_filename, - export_csv_filename=export_csv_filename, vg_filename=vg_filename, vg_vf_filename=vg_vf_filename, root_locus_filename=root_locus_filename, @@ -427,7 +425,6 @@ def make_flutter_plots(modes: list[int], flutters: dict[int, FlutterResponse], export_zona_filename: Optional[str]=None, export_veas_filename: Optional[str]=None, export_f06_filename: Optional[str]=None, - export_csv_filename: Optional[str]=None, vg_filename: Optional[str]=None, vg_vf_filename: Optional[str]=None, root_locus_filename: Optional[str]=None, @@ -456,7 +453,7 @@ def make_flutter_plots(modes: list[int], flutters: dict[int, FlutterResponse], for subcase, flutter in sorted(flutters.items()): if subcase not in subcases_set: continue - flutter = cast(FlutterResponse, flutter) # type: FlutterResponse + flutter = cast(FlutterResponse, flutter) _make_flutter_subcase_plot( modes, flutter, subcase, xlim, ylim_damping, ylim_freq, ylim_kfreq, plot_type, plot_vg, plot_vg_vf, plot_root_locus, plot_kfreq_damping, @@ -475,8 +472,6 @@ def make_flutter_plots(modes: list[int], flutters: dict[int, FlutterResponse], flutter.export_to_veas(export_veas_filename, modes=modes) if export_f06_filename: flutter.export_to_f06(export_f06_filename, modes=modes) - #if export_csv_filename: - #flutter.export_to_csv(export_csv_filename % subcase, modes=modes) if show: plt.show() @@ -485,7 +480,7 @@ def make_flutter_plots(modes: list[int], flutters: dict[int, FlutterResponse], def _make_flutter_subcase_plot(modes, flutter: FlutterResponse, subcase: int, xlim, ylim_damping, ylim_freq, ylim_kfreq, - plot_type, + plot_type: str, plot_vg: bool, plot_vg_vf: bool, plot_root_locus: bool, @@ -503,14 +498,14 @@ def _make_flutter_subcase_plot(modes, flutter: FlutterResponse, subcase: int, log: SimpleLogger=None): #_remove_neutrinos(flutter, log) if plot_vg: - filenamei = None if vg_filename is None else vg_filename % subcase + filenamei = None if vg_filename is None else (vg_filename % subcase) flutter.plot_vg(modes=modes, plot_type=plot_type, xlim=xlim, ylim_damping=ylim_damping, #vd_limit=vd_limit, png_filename=filenamei, show=False, clear=clear, close=close) if plot_vg_vf: - filenamei = None if vg_vf_filename is None else vg_vf_filename % subcase + filenamei = None if vg_vf_filename is None else (vg_vf_filename % subcase) flutter.plot_vg_vf(modes=modes, plot_type=plot_type, xlim=xlim, @@ -520,7 +515,7 @@ def _make_flutter_subcase_plot(modes, flutter: FlutterResponse, subcase: int, legend=legend, png_filename=filenamei, show=False, clear=clear, close=close) if plot_root_locus: - filenamei = None if root_locus_filename is None else root_locus_filename % subcase + filenamei = None if root_locus_filename is None else (root_locus_filename % subcase) flutter.plot_root_locus(modes=modes, fig=None, axes=None, xlim=None, ylim=None, @@ -529,7 +524,7 @@ def _make_flutter_subcase_plot(modes, flutter: FlutterResponse, subcase: int, show=False, close=close) if plot_kfreq_damping: - filenamei = None if kfreq_damping_filename is None else kfreq_damping_filename % subcase + filenamei = None if kfreq_damping_filename is None else (kfreq_damping_filename % subcase) flutter.plot_kfreq_damping(modes=modes, plot_type=plot_type, ylim_damping=ylim_damping, @@ -592,7 +587,7 @@ def _remove_neutrinos(flutter: FlutterResponse, log: SimpleLogger): def _find_modes_to_keep(flutter: FlutterResponse, log: SimpleLogger, - tol: float=1e-8) -> np.ndarray: + tol: float=1e-8) -> tuple[np.ndarray, np.ndarray]: """ FlutterResponse: subcase= 1 diff --git a/pyNastran/f06/test/test_f06_utils.py b/pyNastran/f06/test/test_f06_utils.py index 1dbb11ed6..d750dae63 100644 --- a/pyNastran/f06/test/test_f06_utils.py +++ b/pyNastran/f06/test/test_f06_utils.py @@ -27,6 +27,7 @@ from pyNastran.f06.parse_flutter import plot_flutter_f06, make_flutter_plots from pyNastran.f06.parse_trim import read_f06_trim +DIRNAME = os.path.dirname(__file__) PKG_PATH = pyNastran.__path__[0] MODEL_PATH = os.path.join(PKG_PATH, '..', 'models') @@ -227,6 +228,23 @@ def test_plot_flutter2(self): #kfreq_damping_filename=kfreq_damping_filename, show=False, clear=True, close=True) + export_zona_filename = os.path.join(DIRNAME, 'zona_%i.f06') + export_veas_filename = os.path.join(DIRNAME, 'flutter_%i.veas') + export_f06_filename = os.path.join(DIRNAME, 'flutter_%i.f06') + make_flutter_plots(modes, flutters, xlim, ylim_damping, ylim_freq, ylim_kfreq, + plot_type, + plot_vg=True, plot_vg_vf=True, + plot_root_locus=True, plot_kfreq_damping=True, + nopoints=True, noline=False, + export_zona_filename=export_zona_filename, + export_veas_filename=export_veas_filename, + export_f06_filename=export_f06_filename, + #vg_filename=vg_filename, + #vg_vf_filename=vg_vf_filename, + #root_locus_filename=root_locus_filename, + #kfreq_damping_filename=kfreq_damping_filename, + show=False, clear=True, close=True) + def test_cmd_line_plot_flutter(self): log = get_logger2(log=None, debug=None, encoding='utf-8') f06_filename = os.path.join(MODEL_PATH, 'aero', '2_mode_flutter', '0012_flutter.f06') diff --git a/pyNastran/f06/utils.py b/pyNastran/f06/utils.py index 4408fc5bd..77e29869d 100644 --- a/pyNastran/f06/utils.py +++ b/pyNastran/f06/utils.py @@ -16,7 +16,7 @@ USAGE_145 = ( 'Usage:\n' ' f06 plot_145 F06_FILENAME [--noline] [--modes MODES] [--subcases SUB] [--xlim XLIM] [--ylimdamp DAMP] [--ylimfreq FREQ]' - f'{PLOT_TYPES} [--kfreq] [--rootlocus] [--in_units IN] [--out_units OUT] [--nopoints] [--export_csv] [--export_zona] [--f06] ' + f'{PLOT_TYPES} [--kfreq] [--rootlocus] [--in_units IN] [--out_units OUT] [--nopoints] [--export_zona] [--f06] ' '[--vd_limit VD_LIMIT] [--damping_limit DAMPING_LIMIT]\n' ) USAGE_200 = ( @@ -77,7 +77,6 @@ def cmd_line_plot_flutter(argv=None, plot=True, show=True, log=None): ' --ylimdamp DAMP the damping limits (default=-0.3:0.3)\n' " --nopoints don't plot the points\n" " --noline don't plot the lines\n" - ' --export_csv export a CSV file\n' ' --export_zona export a zona file\n' ' --f06 export an F06 file (temporary)\n' ' --vd_limit VD_LIMIT add a Vd and 1.15*Vd line\n' @@ -172,11 +171,9 @@ def cmd_line_plot_flutter(argv=None, plot=True, show=True, log=None): export_f06 = data['--f06'] export_zona = data['--export_zona'] - export_csv = data['--export_csv'] export_f06_filename = None if export_f06 is False else 'nastran.f06' export_zona_filename = None if export_zona is False else 'nastran.zona' export_veas_filename = None if export_zona is False else 'nastran.veas' - export_csv_filename = None if export_csv is False else 'flutter_subcase_%d.csv' # TODO: need a new parameter vg_filename = None if export_zona is None else 'vg_subcase_%d.png' @@ -204,7 +201,6 @@ def cmd_line_plot_flutter(argv=None, plot=True, show=True, log=None): export_veas_filename=export_veas_filename, export_zona_filename=export_zona_filename, export_f06_filename=export_f06_filename, - export_csv_filename=export_csv_filename, vg_filename=vg_filename, vg_vf_filename=vg_vf_filename, root_locus_filename=root_locus_filename,