From f6e87acbf7208c5403fd1ae205d23d95ac283914 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:04:30 -0500 Subject: [PATCH 1/5] Modifying BladeStiffenedShellConstitutive class to require fewer inputs --- examples/mach_tutorial_wing/analysis.py | 11 --- tacs/constitutive.pyx | 81 +++++++++---------- ...test_blade_sitffened_shell_constitutive.py | 16 ++-- .../test_shell_blade_stiffened_plate_quad.py | 15 ++-- 4 files changed, 53 insertions(+), 70 deletions(-) diff --git a/examples/mach_tutorial_wing/analysis.py b/examples/mach_tutorial_wing/analysis.py index ceb290dff..90c8f4b39 100644 --- a/examples/mach_tutorial_wing/analysis.py +++ b/examples/mach_tutorial_wing/analysis.py @@ -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 # ============================================================================== @@ -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 @@ -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, ) con.setStiffenerPitchBounds(stiffenerPitchMin, stiffenerPitchMax) con.setPanelThicknessBounds(panelThicknessMin, panelThicknessMax) diff --git a/tacs/constitutive.pyx b/tacs/constitutive.pyx index 267bfc308..1262c41f2 100644 --- a/tacs/constitutive.pyx +++ b/tacs/constitutive.pyx @@ -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 + 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 + DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + panelThickNum : int, optional + 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 + DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + stiffenerThickNum : int, optional + 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 + 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 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, + 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, + TacsScalar kcorr = 5.0/6.0, TacsScalar flangeFraction = 1.0 ): - 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: diff --git a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py index c93b80b5b..3605e793a 100644 --- a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py +++ b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py @@ -143,25 +143,23 @@ 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.panelLengthNum, + self.stiffenerPitchNum, + self.panelThicknessNum, + self.panelPlyFracNums, + self.stiffenerHeightNum, + self.stiffenerThicknessNum, self.stiffenerPlyFracNums, + self.kcorr, self.flangeFraction, ) # Set the KS weight really low so that all failure modes make a diff --git a/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py b/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py index 463d7d3bb..9f15e28c1 100644 --- a/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py +++ b/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py @@ -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), + tiffenerHeightNum=dv_num + 4, + stiffenerThickNum=dv_num + 5, stiffenerPlyFracNums=np.array([dv_num + 6], dtype=np.intc), ) From c7d643e054c181079836db13b3e7c2c095ee6b04 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:27:53 -0500 Subject: [PATCH 2/5] fixing test typo --- .../integration_tests/test_shell_blade_stiffened_plate_quad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py b/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py index 9f15e28c1..58bf14d9b 100644 --- a/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py +++ b/tests/integration_tests/test_shell_blade_stiffened_plate_quad.py @@ -135,7 +135,7 @@ def elem_call_back( stiffenerPitchNum=dv_num + 1, panelThickNum=dv_num + 2, panelPlyFracNums=np.array([dv_num + 3], dtype=np.intc), - tiffenerHeightNum=dv_num + 4, + stiffenerHeightNum=dv_num + 4, stiffenerThickNum=dv_num + 5, stiffenerPlyFracNums=np.array([dv_num + 6], dtype=np.intc), ) From 0b7cb65d0886c11943dc6120ac368f66dcf952e5 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:45:04 -0500 Subject: [PATCH 3/5] minor edit to example --- examples/mach_tutorial_wing/analysis.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/mach_tutorial_wing/analysis.py b/examples/mach_tutorial_wing/analysis.py index 90c8f4b39..ad05598d1 100644 --- a/examples/mach_tutorial_wing/analysis.py +++ b/examples/mach_tutorial_wing/analysis.py @@ -182,19 +182,19 @@ def elemCallBack(dvNum, compID, compDescript, elemDescripts, specialDVs, **kwarg panelPly=ply, stiffenerPly=ply, panelLength=panelLength, - panelLengthNum=panelLengthNum, stiffenerPitch=stiffenerPitch, - stiffenerPitchNum=stiffenerPitchNum, panelThick=panelThickness, - panelThickNum=panelThicknessNum, panelPlyAngles=plyAngles, panelPlyFracs=panelPlyFractions, stiffenerHeight=stiffenerHeight, - stiffenerHeightNum=stiffenerHeightNum, stiffenerThick=stiffenerThickness, - stiffenerThickNum=stiffenerThicknessNum, stiffenerPlyAngles=plyAngles, stiffenerPlyFracs=stiffenerPlyFractions, + panelLengthNum=panelLengthNum, + stiffenerPitchNum=stiffenerPitchNum, + panelThickNum=panelThicknessNum, + stiffenerHeightNum=stiffenerHeightNum, + stiffenerThickNum=stiffenerThicknessNum, ) con.setStiffenerPitchBounds(stiffenerPitchMin, stiffenerPitchMax) con.setPanelThicknessBounds(panelThicknessMin, panelThicknessMax) From 61c062946a2fe5af2acaed98209ed9be589ef7b5 Mon Sep 17 00:00:00 2001 From: Tim Brooks <41971846+timryanb@users.noreply.github.com> Date: Mon, 11 Dec 2023 11:50:00 -0500 Subject: [PATCH 4/5] reordering kcorr/flangeFraction --- tacs/constitutive.pyx | 14 +++++++------- .../test_blade_sitffened_shell_constitutive.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tacs/constitutive.pyx b/tacs/constitutive.pyx index 1262c41f2..864bc8172 100644 --- a/tacs/constitutive.pyx +++ b/tacs/constitutive.pyx @@ -863,6 +863,10 @@ cdef class BladeStiffenedShellConstitutive(ShellConstitutive): Array of ply angles for the stiffener stiffenerPlyFracs : numpy.ndarray[float or complex] Array of ply fractions for the stiffener + 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. 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 @@ -877,10 +881,6 @@ cdef class BladeStiffenedShellConstitutive(ShellConstitutive): 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 - 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. Defaults to 1.0 Raises ------ @@ -902,15 +902,15 @@ cdef class BladeStiffenedShellConstitutive(ShellConstitutive): TacsScalar stiffenerThick, np.ndarray[TacsScalar, ndim=1, mode='c'] stiffenerPlyAngles, np.ndarray[TacsScalar, ndim=1, mode='c'] stiffenerPlyFracs, + 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, - TacsScalar kcorr = 5.0/6.0, - TacsScalar flangeFraction = 1.0 + np.ndarray[int, ndim=1, mode='c'] stiffenerPlyFracNums = None ): numPanelPlies = len(panelPlyAngles) diff --git a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py index 3605e793a..4f1d11b93 100644 --- a/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py +++ b/tests/constitutive_tests/test_blade_sitffened_shell_constitutive.py @@ -152,15 +152,15 @@ def get_con(self, ply): self.stiffenerThickness, self.stiffenerPlyAngles, self.stiffenerPlyFracs, + self.kcorr, + self.flangeFraction, self.panelLengthNum, self.stiffenerPitchNum, self.panelThicknessNum, self.panelPlyFracNums, self.stiffenerHeightNum, self.stiffenerThicknessNum, - self.stiffenerPlyFracNums, - self.kcorr, - self.flangeFraction, + self.stiffenerPlyFracNums ) # Set the KS weight really low so that all failure modes make a # significant contribution to the failure function derivatives From d113fb6b2efb808e9ad4752195afa2a6a1d67bd1 Mon Sep 17 00:00:00 2001 From: Alasdair Gray Date: Fri, 15 Dec 2023 09:55:20 -0500 Subject: [PATCH 5/5] Small docstring improvements --- tacs/constitutive.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tacs/constitutive.pyx b/tacs/constitutive.pyx index 864bc8172..fb332bfd3 100644 --- a/tacs/constitutive.pyx +++ b/tacs/constitutive.pyx @@ -870,15 +870,15 @@ cdef class BladeStiffenedShellConstitutive(ShellConstitutive): 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 - DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + Stiffener pitch DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 panelThickNum : int, optional - DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + 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 - DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + Stiffener height DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 stiffenerThickNum : int, optional - DV number, passing a negative value tells TACS not to treat this as a DV. Defaults to -1 + 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