コード例 #1
0
    def test_2(self, train=False, refDeriv=False):
        """
        Test 2: Basic FFD, global DVs and local DVs
        """
        refFile = os.path.join(self.base_path, 'ref/test_DVGeometry_02.ref')
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test 2: Basic FFD, global DVs and local DVs")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            #create global DVs on the parent
            DVGeo.addGeoDVGlobal('mainX',
                                 -1.0,
                                 commonUtils.mainAxisPoints,
                                 lower=-1.,
                                 upper=0.,
                                 scale=1.0)
            #create local DVs on the parent
            DVGeo.addGeoDVLocal('xdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='x',
                                scale=1.0)
            DVGeo.addGeoDVLocal('ydir',
                                lower=-1.0,
                                upper=1.0,
                                axis='y',
                                scale=1.0)
            DVGeo.addGeoDVLocal('zdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='z',
                                scale=1.0)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #2
0
    def test_3(self, train=False, refDeriv=False):
        """
        Test 3: Basic + Nested FFD, global DVs only
        """
        refFile = os.path.join(self.base_path, 'ref/test_DVGeometry_03.ref')
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test 3: Basic + Nested FFD, global DVs only")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            #create global DVs on the parent
            DVGeo.addGeoDVGlobal('mainX',
                                 -1.0,
                                 commonUtils.mainAxisPoints,
                                 lower=-1.,
                                 upper=0.,
                                 scale=1.0)
            #create global DVs on the child
            DVGeoChild.addGeoDVGlobal('nestedX',
                                      -0.5,
                                      commonUtils.childAxisPoints,
                                      lower=-1.,
                                      upper=0.,
                                      scale=1.0)
            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #3
0
    def test_7(self, train=False, refDeriv=False):
        """
        Test 7: Basic + Nested FFD, local DVs only on parent
        """
        refFile = os.path.join(self.base_path, 'ref/test_DVGeometry_07.ref')
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print(
                "Test 7: Basic + Nested FFD, local DVs only on parent")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            #create local DVs on the parent
            DVGeo.addGeoDVLocal('xdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='x',
                                scale=1.0)
            DVGeo.addGeoDVLocal('ydir',
                                lower=-1.0,
                                upper=1.0,
                                axis='y',
                                scale=1.0)
            DVGeo.addGeoDVLocal('zdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='z',
                                scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #4
0
    def test_8(self, train=False, refDeriv=False):
        """
        Test 8: Basic + Nested FFD, local DVs only on child
        """
        refFile = os.path.join(self.base_path, 'ref/test_DVGeometry_08.ref')
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print(
                "Test 8: Basic + Nested FFD, local DVs only on child")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            DVGeoChild.addGeoDVLocal('childxdir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='x',
                                     scale=1.0)
            DVGeoChild.addGeoDVLocal('childydir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='y',
                                     scale=1.0)
            DVGeoChild.addGeoDVLocal('childzdir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='z',
                                     scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #5
0
    def test_11_rot7(self, train=False, refDeriv=False):
        """
        Test 11: Basic + Nested FFD, global DVs and local DVs on parent local on child
        """
        refFile = os.path.join(self.base_path, "ref/test_DVGeometry_11.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print(
                "Test 11: Basic + Nested FFD, global DVs and local DVs on parent local on child, using rotType=7"
            )
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path, rotType=7)

            # create global DVs on the parent
            DVGeo.addGlobalDV("mainX", -1.0, commonUtils.mainAxisPoints, lower=-1.0, upper=0.0, scale=1.0)
            # create local DVs on the parent
            DVGeo.addLocalDV("xdir", lower=-1.0, upper=1.0, axis="x", scale=1.0)
            DVGeo.addLocalDV("ydir", lower=-1.0, upper=1.0, axis="y", scale=1.0)
            DVGeo.addLocalDV("zdir", lower=-1.0, upper=1.0, axis="z", scale=1.0)

            # create global DVs on the child
            DVGeoChild.addLocalDV("childxdir", lower=-1.1, upper=1.1, axis="x", scale=1.0)
            DVGeoChild.addLocalDV("childydir", lower=-1.1, upper=1.1, axis="y", scale=1.0)
            DVGeoChild.addLocalDV("childzdir", lower=-1.1, upper=1.1, axis="z", scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #6
0
    def test_5(self, train=False, refDeriv=False):
        """
        Test 5: Basic + Nested FFD, global DVs and local DVs on both parent and child
        """
        refFile = os.path.join(self.base_path, 'ref/test_DVGeometry_05.ref')
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print(
                "Test 5: Basic + Nested FFD, global DVs and local DVs on both parent and child"
            )
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            #create global DVs on the parent
            DVGeo.addGeoDVGlobal('mainX',
                                 -1.0,
                                 commonUtils.mainAxisPoints,
                                 lower=-1.,
                                 upper=0.,
                                 scale=1.0)
            #create local DVs on the parent
            DVGeo.addGeoDVLocal('xdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='x',
                                scale=1.0)
            DVGeo.addGeoDVLocal('ydir',
                                lower=-1.0,
                                upper=1.0,
                                axis='y',
                                scale=1.0)
            DVGeo.addGeoDVLocal('zdir',
                                lower=-1.0,
                                upper=1.0,
                                axis='z',
                                scale=1.0)
            #create global DVs on the child
            DVGeoChild.addGeoDVGlobal('nestedX',
                                      -0.5,
                                      commonUtils.childAxisPoints,
                                      lower=-1.,
                                      upper=0.,
                                      scale=1.0)
            DVGeoChild.addGeoDVLocal('childxdir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='x',
                                     scale=1.0)
            DVGeoChild.addGeoDVLocal('childydir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='y',
                                     scale=1.0)
            DVGeoChild.addGeoDVLocal('childzdir',
                                     lower=-1.1,
                                     upper=1.1,
                                     axis='z',
                                     scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #7
0
    def test_24_rot0_nonaligned(self, train=False, refDeriv=False):
        """
        Test 24
        This test ensures that the scaling attributes (scale_x, scale_y, and scale_z) are effective when rotType=0 is selected.
        Moreover, this test ensures that rotType=0 reference axis can handle (given appropriate input parameters) FFD blocks that are not aligned with the main system of reference, e.g. the blades of a 3-bladed wind turbine rotor.
        The newly added input parameters rot0ang and rot0axis are used to provide the user control on this.
        The operations that pyGeo performs for this test are the following:
        We start from an initial "vertical" FFD box which, using the combination of rotType=0, rot0ang=-90, and rot0axis=[1,0,0] for addRefAxis(), is first rotated to have its "spanwise" axis along the y axis.
        Then, the script scales the 2nd section along the z axis for a "thickness" increase and the 4th section along the x axis for "chord" increase, it adds a +/- 30 deg twist respectively, and finally rotates the deformed FFD back in the initial position.
        The twist is added to ensure that the operation order is maintained, and the scaling preserves the orthogonality of the FFD in the section plane.
        This is a particular case as the FFD box is already aligned with the main axis and we "flip" the y and z axes, but the same criteria can be applied to a general rotation.
        """
        refFile = os.path.join(self.base_path, "ref/test_DVGeometry_24.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test twist and scaling for FFDs non-aligned to main system of reference")
            DVGeo = DVGeometry(os.path.join(self.base_path, "../../input_files/2x1x8_rectangle.xyz"))
            rotType = 0
            xfraction = 0.5
            nRefAxPts = DVGeo.addRefAxis("RefAx", xFraction=xfraction, alignIndex="k", rotType=rotType, rot0ang=-90)

            fix_root_sect = 1
            nTwist = nRefAxPts - fix_root_sect

            DVGeo.addGlobalDV(dvName="twist", value=[0] * nTwist, func=commonUtils.twist, lower=-90, upper=90, scale=1)
            DVGeo.addGlobalDV(
                dvName="thickness", value=[1.0] * nTwist, func=commonUtils.thickness, lower=0.7, upper=5.0, scale=1
            )
            DVGeo.addGlobalDV(
                dvName="chord", value=[1.0] * nTwist, func=commonUtils.chord, lower=0.7, upper=5.0, scale=1
            )

            commonUtils.testSensitivities(DVGeo, refDeriv, handler, pointset=2)

            x = DVGeo.getValues()

            # Modifying the twist
            keyName = "twist"
            twistTest = [30, 0, -30]
            x[keyName] = twistTest

            # Modifying the chord
            keyName = "thickness"
            thickTest = [3.0, 1.0, 1.0]
            x[keyName] = thickTest

            # Modifying the chord
            keyName = "chord"
            chordTest = [1.0, 1.0, 2.0]
            x[keyName] = chordTest

            DVGeo.setDesignVars(x)

            DVGeo.update("testPoints")
            FFD_coords = DVGeo.FFD.coef.copy()

            handler.root_add_val("Updated FFD coordinates", FFD_coords, rtol=1e-12, atol=1e-12)
コード例 #8
0
    def test_1(self, train=False, refDeriv=False):
        """
        Test 1: Basic FFD, global DVs
        """
        refFile = os.path.join(self.base_path, "ref/test_DVGeometry_01.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test 1: Basic FFD, global DVs")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)
            # create global DVs on the parent
            DVGeo.addGlobalDV("mainX", -1.0, commonUtils.mainAxisPoints, lower=-1.0, upper=0.0, scale=1.0)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #9
0
    def test_ffdSplineOrder(self, train=False, refDeriv=False):
        """
        Test custom FFD spline order
        """
        refFile = os.path.join(self.base_path, "ref/test_ffd_spline_order.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test custom FFD spline order")
            ffdfile = os.path.join(self.base_path, "../../input_files/deform_geometry_ffd.xyz")
            DVGeo = DVGeometry(ffdfile, kmax=6)

            # create local DVs
            DVGeo.addLocalDV("xdir", lower=-1.0, upper=1.0, axis="x", scale=1.0)
            DVGeo.addLocalDV("ydir", lower=-1.0, upper=1.0, axis="y", scale=1.0)
            DVGeo.addLocalDV("zdir", lower=-1.0, upper=1.0, axis="z", scale=1.0)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler, pointset=3)
コード例 #10
0
    def test_9(self, train=False, refDeriv=False):
        """
        Test 9: Basic + Nested FFD, local DVs only on parent, global on child
        """
        refFile = os.path.join(self.base_path, "ref/test_DVGeometry_09.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test 9: Basic + Nested FFD, local DVs only on parent, global on child")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            # create local DVs on the parent
            DVGeo.addLocalDV("xdir", lower=-1.0, upper=1.0, axis="x", scale=1.0)
            DVGeo.addLocalDV("ydir", lower=-1.0, upper=1.0, axis="y", scale=1.0)
            DVGeo.addLocalDV("zdir", lower=-1.0, upper=1.0, axis="z", scale=1.0)

            DVGeoChild.addGlobalDV("nestedX", -0.5, commonUtils.childAxisPoints, lower=-1.0, upper=0.0, scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)
コード例 #11
0
    def test_6(self, train=False, refDeriv=False):
        """
        Test 6: Basic + Nested FFD, local DVs only
        """
        refFile = os.path.join(self.base_path, "ref/test_DVGeometry_06.ref")
        with BaseRegTest(refFile, train=train) as handler:
            handler.root_print("Test 6: Basic + Nested FFD, local DVs only")
            DVGeo, DVGeoChild = commonUtils.setupDVGeo(self.base_path)

            # create local DVs on the parent
            DVGeo.addLocalDV("xdir", lower=-1.0, upper=1.0, axis="x", scale=1.0)
            DVGeo.addLocalDV("ydir", lower=-1.0, upper=1.0, axis="y", scale=1.0)
            DVGeo.addLocalDV("zdir", lower=-1.0, upper=1.0, axis="z", scale=1.0)

            DVGeoChild.addLocalDV("childxdir", lower=-1.1, upper=1.1, axis="x", scale=1.0)
            DVGeoChild.addLocalDV("childydir", lower=-1.1, upper=1.1, axis="y", scale=1.0)
            DVGeoChild.addLocalDV("childzdir", lower=-1.1, upper=1.1, axis="z", scale=1.0)

            DVGeo.addChild(DVGeoChild)

            commonUtils.testSensitivities(DVGeo, refDeriv, handler)