示例#1
0
    def test_point_mismatch(self):
        # load the wrong pointset on purpose
        csmFile = os.path.join(self.input_path, "inputFiles/esp/naca0010.csm")
        stlFile = os.path.join(self.input_path, "inputFiles/esp/naca0012_esp.stl")

        DVGeo = DVGeometryESP(csmFile)
        self.assertIsNotNone(DVGeo)

        testobj = mesh.Mesh.from_file(stlFile)
        # test mesh dim 0 is triangle index
        # dim 1 is each vertex of the triangle
        # dim 2 is x, y, z dimension
        p0 = testobj.vectors[:, 0, :]
        with self.assertRaises(ValueError):
            distglobal1 = DVGeo.addPointSet(p0, "airfoil_p0")
            self.assertGreater(distglobal1, 0.01)
示例#2
0
    def setup_cubemodel(self):
        # load the box model and build the box model
        csmFile = os.path.join(self.input_path, "inputFiles/esp/box.csm")
        DVGeo = DVGeometryESP(csmFile)
        self.assertIsNotNone(DVGeo)

        # add a point set on the surface
        vertex1 = np.array([-2.0, -2.0, -2.0])
        vertex2 = np.array([1.5, 1.5, 1.5])
        left = np.array([-2.0, -1.1, -1.1])
        right = np.array([1.5, -1.2, -0.1])
        front = np.array([0.25, 1.5, 0.3])
        back = np.array([1.2, -2.0, -0.3])
        top = np.array([0.0, 0.1, 1.5])
        bottom = np.array([-1.9, -1.1, -2.0])
        initpts = np.vstack([vertex1, vertex2, left, right, front, back, top, bottom, left, right])
        distglobal = DVGeo.addPointSet(initpts, "mypts", cache_projections=False)
        self.assertAlmostEqual(distglobal, 0.0, 8)

        # evaluate the points and check that they match
        DVGeo._updateESPModel()
        DVGeo._updateProjectedPts()
        self.assertTrue(DVGeo.pointSetUpToDate)
        self.assertAlmostEqual(np.linalg.norm(initpts - DVGeo.pointSets["mypts"].proj_pts), 0.0, 10)

        return DVGeo, initpts
示例#3
0
    def setup_airfoilmodel(self, kulfan=False, projtol=0.01):
        # load the csm file and pointset file
        if kulfan:
            csmFile = os.path.join(self.input_path, "inputFiles/esp/naca0012_kulfan.csm")
            max_dist_tol = 2
        else:
            csmFile = os.path.join(self.input_path, "inputFiles/esp/naca0012.csm")
            max_dist_tol = 3
        stlFile = os.path.join(self.input_path, "inputFiles/esp/naca0012_esp.stl")

        DVGeo = DVGeometryESP(csmFile, projTol=projtol)
        self.assertIsNotNone(DVGeo)

        testobj = mesh.Mesh.from_file(stlFile)
        # test mesh dim 0 is triangle index
        # dim 1 is each vertex of the triangle
        # dim 2 is x, y, z dimension
        p0 = testobj.vectors[:, 0, :]
        p1 = testobj.vectors[:, 1, :]
        p2 = testobj.vectors[:, 2, :]
        distglobal1 = DVGeo.addPointSet(p0, "airfoil_p0")
        distglobal2 = DVGeo.addPointSet(p1, "airfoil_p1")
        distglobal3 = DVGeo.addPointSet(p2, "airfoil_p2")

        distglobal = np.max(np.array([distglobal1, distglobal2, distglobal3]))
        self.assertAlmostEqual(distglobal, 0.0, max_dist_tol)

        # evaluate the points and check that they match
        DVGeo._updateESPModel()
        DVGeo._updateProjectedPts()
        self.assertTrue(DVGeo.pointSetUpToDate)
        updated_dist_max = np.max(np.sqrt(np.sum((p0 - DVGeo.pointSets["airfoil_p0"].proj_pts) ** 2, axis=1)))
        self.assertAlmostEqual(updated_dist_max, 0.0, max_dist_tol)
        updated_dist_max = np.max(np.sqrt(np.sum((p1 - DVGeo.pointSets["airfoil_p1"].proj_pts) ** 2, axis=1)))
        self.assertAlmostEqual(updated_dist_max, 0.0, max_dist_tol)
        updated_dist_max = np.max(np.sqrt(np.sum((p2 - DVGeo.pointSets["airfoil_p2"].proj_pts) ** 2, axis=1)))
        self.assertAlmostEqual(updated_dist_max, 0.0, max_dist_tol)
        return DVGeo, [p0, p1, p2]
示例#4
0
    def setup_cubemodel(self):
        # load the box model and build the box model
        csmFile = os.path.join(self.input_path, "../input_files/esp/box.csm")
        DVGeo = DVGeometryESP(csmFile)
        self.assertIsNotNone(DVGeo)

        # add a point set on the surface
        # distri
        vertex1 = np.array([-2.0, -2.0, -2.0])
        vertex2 = np.array([1.5, 1.5, 1.5])
        left = np.array([-2.0, -1.1, -1.1])
        right = np.array([1.5, -1.2, -0.1])
        front = np.array([0.25, 1.5, 0.3])
        back = np.array([1.2, -2.0, -0.3])
        top = np.array([0.0, 0.1, 1.5])
        bottom = np.array([-1.9, -1.1, -2.0])
        # distribute the pointset
        if self.comm.rank == 0:
            initpts = np.vstack([vertex1, vertex2, left, right])
        elif self.comm.rank == 1:
            initpts = np.vstack([front, back, top])
        elif self.comm.rank == 2:
            initpts = np.array([]).reshape((0, 3))
        elif self.comm.rank == 3:
            initpts = np.vstack([bottom, left, right])
        else:
            raise ValueError("Too many procs")
        distglobal = DVGeo.addPointSet(initpts, "mypts", cache_projections=False)

        self.assertAlmostEqual(distglobal, 0.0, 8)

        # evaluate the points and check that they match
        DVGeo._updateModel()
        DVGeo._updateProjectedPts()
        self.assertTrue(DVGeo.pointSetUpToDate)
        self.assertAlmostEqual(np.linalg.norm(initpts - DVGeo.pointSets["mypts"].proj_pts), 0.0, 10)

        return DVGeo, initpts
示例#5
0
                 mach=0.8,
                 altitude=10000,
                 areaRef=45.5,
                 chordRef=3.25,
                 evalFuncs=["cl", "cd"])

# Add angle of attack variable
ap.addDV("alpha", value=1.5, lower=0, upper=10.0, scale=0.1)
# rst aeroproblem (end)
# ======================================================================
#         Geometric Design Variable Set-up
# ======================================================================
# rst dvgeo (beg)
# Create DVGeometry object
DVGeo = DVGeometryESP("wing.csm",
                      suppress_stdout=True,
                      exclude_edge_projections=True)
DVGeo.addVariable("twist_local",
                  cols=[2, 3, 4, 5, 6, 7, 8],
                  lower=-10 * np.ones(7),
                  upper=10 * np.ones(7),
                  scale=0.1,
                  dh=0.0001)
DVGeo.addVariable("cst_u",
                  lower=0.0 * np.ones(8 * 7),
                  upper=1.0 * np.ones(8 * 7),
                  scale=1.0,
                  dh=0.0001)
DVGeo.addVariable("cst_l",
                  lower=-1.0 * np.ones(8 * 7),
                  upper=0.2 * np.ones(8 * 7),
示例#6
0
    def test_add_desvars(self):
        # load the box model and build the box model
        csmFile = os.path.join(self.input_path, "inputFiles/esp/box.csm")
        DVGeo = DVGeometryESP(csmFile)
        self.assertIsNotNone(DVGeo)

        # add variables with a mix of optional arguments
        DVGeo.addVariable("cubex0", lower=np.array([-10.0]), upper=np.array([10.0]), scale=0.1, dh=0.0001)
        self.assertEqual(DVGeo.getNDV(), 1)
        DVGeo.addVariable("cubey0")
        self.assertEqual(DVGeo.getNDV(), 2)
        DVGeo.addVariable("cubez0", lower=np.array([-10.0]), upper=np.array([10.0]))
        self.assertEqual(DVGeo.getNDV(), 3)

        # try to add a variable that isn't in the CSM file
        with self.assertRaises(Error):
            DVGeo.addVariable("cubew0")
示例#7
0
 def test_load_a_model(self):
     # load the box model and build the box model
     csmFile = os.path.join(self.input_path, "inputFiles/esp/box.csm")
     DVGeometryESP(csmFile)