Skip to content

Commit

Permalink
Modifying BladeStiffenedShellConstitutive class to require fewer inpu…
Browse files Browse the repository at this point in the history
…ts (smdogroup#286)

* Modifying BladeStiffenedShellConstitutive class to require fewer inputs

* fixing test typo

* minor edit to example

* reordering kcorr/flangeFraction

* Small docstring improvements

---------

Co-authored-by: Alasdair Gray <[email protected]>
  • Loading branch information
timryanb and A-CGray authored Mar 11, 2024
1 parent 2e339f2 commit 9818a92
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 77 deletions.
21 changes: 5 additions & 16 deletions examples/mach_tutorial_wing/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
sparRibPlyAngles = np.deg2rad(np.array([0.0, -45.0, 45.0, 90.0])).astype(dtype)
sparRibPlyFracs = np.array([10.0, 35.0, 35.0, 20.0], dtype=dtype) / 100.0

kcorr = dtype(5.0 / 6.0) # shear correction factor

# ==============================================================================
# Design variable values, bounds, and scaling factors
# ==============================================================================
Expand Down Expand Up @@ -172,8 +170,6 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg
DVScales.append(panelThicknessScale)
currDVNum += 1

panelPlyFracNums = -np.ones(numPlies).astype(np.intc)

stiffenerHeightNum = currDVNum
DVScales.append(stiffenerHeightScale)
currDVNum += 1
Expand All @@ -182,30 +178,23 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg
DVScales.append(stiffenerThicknessScale)
currDVNum += 1

stiffenerPlyFracNums = -np.ones(numPlies).astype(np.intc)

con = constitutive.BladeStiffenedShellConstitutive(
panelPly=ply,
stiffenerPly=ply,
kcorr=kcorr,
panelLength=panelLength,
panelLengthNum=panelLengthNum,
stiffenerPitch=stiffenerPitch,
stiffenerPitchNum=stiffenerPitchNum,
panelThick=panelThickness,
panelThickNum=panelThicknessNum,
numPanelPlies=numPlies,
panelPlyAngles=plyAngles,
panelPlyFracs=panelPlyFractions,
panelPlyFracNums=panelPlyFracNums,
stiffenerHeight=stiffenerHeight,
stiffenerHeightNum=stiffenerHeightNum,
stiffenerThick=stiffenerThickness,
stiffenerThickNum=stiffenerThicknessNum,
numStiffenerPlies=numPlies,
stiffenerPlyAngles=plyAngles,
stiffenerPlyFracs=stiffenerPlyFractions,
stiffenerPlyFracNums=stiffenerPlyFracNums,
panelLengthNum=panelLengthNum,
stiffenerPitchNum=stiffenerPitchNum,
panelThickNum=panelThicknessNum,
stiffenerHeightNum=stiffenerHeightNum,
stiffenerThickNum=stiffenerThicknessNum,
)
con.setStiffenerPitchBounds(stiffenerPitchMin, stiffenerPitchMax)
con.setPanelThicknessBounds(panelThicknessMin, panelThicknessMax)
Expand Down
83 changes: 41 additions & 42 deletions tacs/constitutive.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -845,92 +845,91 @@ cdef class BladeStiffenedShellConstitutive(ShellConstitutive):
Ply model to use for the panel
stiffenerPly : tacs.constitutive.OrthotropicPly
Ply model to use for the stiffener
kcorr : float or complex
Shear correction factor, usually 5.0/6.0
panelLength : float or complex
Panel length DV value
panelLengthNum : int
Panel lenth DV number, passing a negative value tells TACS not to treat this as a DV
stiffenerPitch : float or complex
Stiffener pitch DV value
stiffenerPitchNum : int
DV number, passing a negative value tells TACS not to treat this as a DV
panelThick : float or complex
Panel thickness DV value
panelThickNum : int
DV number, passing a negative value tells TACS not to treat this as a DV
numPanelPlies : int
Number of distinct ply angles in the panel
panelPlyAngles : numpy.ndarray[float or complex]
Array of ply angles in the panel
panelPlyFracs : numpy.ndarray[float or complex]
Array of ply fractions in the panel
panelPlyFracNums : numpy.ndarray[np.intc]
Array of ply fraction DV numbers in the panel, passing negative values tells TACS not to treat that ply fraction as a DV
stiffenerHeight : float or complex
Stiffener height DV value
stiffenerHeightNum : int
DV number, passing a negative value tells TACS not to treat this as a DV
stiffenerThick : float or complex
Stiffener thickness DV value
stiffenerThickNum : int
DV number, passing a negative value tells TACS not to treat this as a DV
numStiffenerPlies : int
Number of distinct ply angles in the stiffener
stiffenerPlyAngles : numpy.ndarray[float or complex]
Array of ply angles for the stiffener
stiffenerPlyFracs : numpy.ndarray[float or complex]
Array of ply fractions for the stiffener
stiffenerPlyFracNums : numpy.ndarray[numpy.intc]
Array of ply fraction DV numbers for the stiffener, passing negative values tells TACS not to treat that ply fraction as a DV
kcorr : float or complex, optional
Shear correction factor, defaults to 5.0/6.0
flangeFraction : float, optional
Ratio of the stiffener base width to the stiffener height, by default 1.0
Ratio of the stiffener base width to the stiffener height. Defaults to 1.0
panelLengthNum : int, optional
Panel lenth DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1
stiffenerPitchNum : int, optional
Stiffener pitch DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1
panelThickNum : int, optional
Panel thickness DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1
panelPlyFracNums : numpy.ndarray[np.intc], optional
Array of ply fraction DV numbers in the panel, passing negative values tells TACS not to treat that ply fraction as a DV. Defaults to -1's
stiffenerHeightNum : int, optional
Stiffener height DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1
stiffenerThickNum : int, optional
Stiffener thickness DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1
stiffenerPlyFracNums : numpy.ndarray[numpy.intc], optional
Array of ply fraction DV numbers for the stiffener, passing negative values tells TACS not to treat that ply fraction as a DV. Defaults to -1's
Raises
------
ValueError
Raises error if panelPlyAngles, panelPlyFracs, or panelPlyFracNums do not have numPanelPlies entries
Raises error if panelPlyAngles, panelPlyFracs, or panelPlyFracNums do not have same number of entries
ValueError
Raises error if stiffenerPlyAngles, stiffenerPlyFracs, or stiffenerPlyFracNums do not have numStiffenerPlies entries
Raises error if stiffenerPlyAngles, stiffenerPlyFracs, or stiffenerPlyFracNums do not have same number of entries
"""
def __cinit__(
self,
OrthotropicPly panelPly,
OrthotropicPly stiffenerPly,
TacsScalar kcorr,
TacsScalar panelLength,
int panelLengthNum,
TacsScalar stiffenerPitch,
int stiffenerPitchNum,
TacsScalar panelThick,
int panelThickNum,
int numPanelPlies,
np.ndarray[TacsScalar, ndim=1, mode='c'] panelPlyAngles,
np.ndarray[TacsScalar, ndim=1, mode='c'] panelPlyFracs,
np.ndarray[int, ndim=1, mode='c'] panelPlyFracNums,
TacsScalar stiffenerHeight,
int stiffenerHeightNum,
TacsScalar stiffenerThick,
int stiffenerThickNum,
int numStiffenerPlies,
np.ndarray[TacsScalar, ndim=1, mode='c'] stiffenerPlyAngles,
np.ndarray[TacsScalar, ndim=1, mode='c'] stiffenerPlyFracs,
np.ndarray[int, ndim=1, mode='c'] stiffenerPlyFracNums,
TacsScalar flangeFraction = 1.0
TacsScalar kcorr = 5.0/6.0,
TacsScalar flangeFraction = 1.0,
int panelLengthNum = -1,
int stiffenerPitchNum = -1,
int panelThickNum = -1,
np.ndarray[int, ndim=1, mode='c'] panelPlyFracNums = None,
int stiffenerHeightNum = -1,
int stiffenerThickNum = -1,
np.ndarray[int, ndim=1, mode='c'] stiffenerPlyFracNums = None
):

if len(panelPlyAngles) != numPanelPlies:
raise ValueError('panelPlyAngles must have length numPanelPlies')
numPanelPlies = len(panelPlyAngles)
numStiffenerPlies = len(stiffenerPlyAngles)

if panelPlyFracNums is None:
panelPlyFracNums = -np.ones([numPanelPlies], dtype=np.intc)
if stiffenerPlyFracNums is None:
stiffenerPlyFracNums = -np.ones([numStiffenerPlies], dtype=np.intc)

if len(panelPlyFracs) != numPanelPlies:
raise ValueError('panelPlyFracs must have length numPanelPlies')
raise ValueError('panelPlyFracs must have same length as panelPlyAngles')
if len(panelPlyFracNums) != numPanelPlies:
raise ValueError('panelPlyFracNums must have length numPanelPlies')
if len(stiffenerPlyAngles) != numStiffenerPlies:
raise ValueError('stiffenerPlyAngles must have length numStiffenerPlies')
raise ValueError('panelPlyFracNums must have same length as panelPlyAngles')
if len(stiffenerPlyFracs) != numStiffenerPlies:
raise ValueError('stiffenerPlyFracs must have length numStiffenerPlies')
raise ValueError('stiffenerPlyFracs must have same length as stiffenerPlyAngles')
if len(stiffenerPlyFracNums) != numStiffenerPlies:
raise ValueError('stiffenerPlyFracNums must have length numStiffenerPlies')
raise ValueError('stiffenerPlyFracNums must have same length as stiffenerPlyAngles')


# Numpy's default int type is int64, but this is interpreted by Cython as a long.
if panelPlyFracNums.dtype != np.intc:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,26 +143,24 @@ def get_con(self, ply):
con = constitutive.BladeStiffenedShellConstitutive(
ply,
ply,
self.kcorr,
self.panelLength,
self.panelLengthNum,
self.stiffenerPitch,
self.stiffenerPitchNum,
self.panelThickness,
self.panelThicknessNum,
self.numPanelPlies,
self.panelPlyAngles,
self.panelPlyFracs,
self.panelPlyFracNums,
self.stiffenerHeight,
self.stiffenerHeightNum,
self.stiffenerThickness,
self.stiffenerThicknessNum,
self.numStiffenerPlies,
self.stiffenerPlyAngles,
self.stiffenerPlyFracs,
self.stiffenerPlyFracNums,
self.kcorr,
self.flangeFraction,
self.panelLengthNum,
self.stiffenerPitchNum,
self.panelThicknessNum,
self.panelPlyFracNums,
self.stiffenerHeightNum,
self.stiffenerThicknessNum,
self.stiffenerPlyFracNums
)
# Set the KS weight really low so that all failure modes make a
# significant contribution to the failure function derivatives
Expand Down
15 changes: 6 additions & 9 deletions tests/integration_tests/test_shell_blade_stiffened_plate_quad.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,21 @@ def elem_call_back(
con = constitutive.BladeStiffenedShellConstitutive(
panelPly=ply,
stiffenerPly=ply,
kcorr=5.0 / 6.0,
panelLength=self.dtype(lPanel),
panelLengthNum=dv_num,
stiffenerPitch=self.dtype(pStiff),
stiffenerPitchNum=dv_num + 1,
panelThick=self.dtype(tPlate),
panelThickNum=dv_num + 2,
numPanelPlies=len(plyAngles),
panelPlyAngles=plyAngles.astype(self.dtype),
panelPlyFracs=plyFractions.astype(self.dtype),
panelPlyFracNums=np.array([dv_num + 3], dtype=np.intc),
stiffenerHeight=self.dtype(hStiff),
stiffenerHeightNum=dv_num + 4,
stiffenerThick=self.dtype(tStiff),
stiffenerThickNum=dv_num + 5,
numStiffenerPlies=1,
stiffenerPlyAngles=plyAngles.astype(self.dtype),
stiffenerPlyFracs=plyFractions.astype(self.dtype),
panelLengthNum=dv_num,
stiffenerPitchNum=dv_num + 1,
panelThickNum=dv_num + 2,
panelPlyFracNums=np.array([dv_num + 3], dtype=np.intc),
stiffenerHeightNum=dv_num + 4,
stiffenerThickNum=dv_num + 5,
stiffenerPlyFracNums=np.array([dv_num + 6], dtype=np.intc),
)

Expand Down

0 comments on commit 9818a92

Please sign in to comment.