コード例 #1
0
ファイル: testcharminput.py プロジェクト: ramcdona/OpenVSP
def create_geom():
    vsp.ClearVSPModel()
    vsp.DeleteAllResults()

    wing_id = vsp.AddGeom("WING")
    rotor_id = vsp.AddGeom("PROP")
    vsp.SetParmVal(wing_id, "X_Rel_Location", "XForm", 10.0)
    vsp.Update()

    dg_mgr = vsp.run_degen_geom(set_index=vsp.SET_ALL)

    vsp.WriteVSPFile(os.path.join(path, "testfile.vsp3"))

    return dg_mgr, wing_id, rotor_id
コード例 #2
0
    def test_parasite_drag(self):
        import numpy as np
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        wing_id = vsp.AddGeom("WING")
        pod_id = vsp.AddGeom("POD")
        sref = vsp.GetParmVal(wing_id, "TotalArea", "WingGeom")

        res = vsp.parasitedrag_sweep(speeds=np.linspace(10, 250, 10),
                                     alts_ft=[0, 10000, 20000, 50000],
                                     sref=sref,
                                     length_unit=vsp.LEN_FT,
                                     speed_unit=vsp.V_UNIT_MPH)

        res.plot()
コード例 #3
0
    def test_parasite_drag(self):
        import numpy as np
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        wing_id = vsp.AddGeom("WING")
        pod_id = vsp.AddGeom("POD")
        sref = vsp.GetParmVal(wing_id, "TotalArea", "WingGeom")

        res = vsp.parasitedrag_sweep(speeds=np.linspace(10, 250, 10),
                                     alts_ft=[0, 10000, 20000, 50000],
                                     sref=sref,
                                     length_unit=vsp.LEN_FT,
                                     speed_unit=vsp.V_UNIT_MPH)
        ax = res.plot()
        plt.legend()
        plt.savefig(os.path.join(self.OUTPUT_FOLDER, "parasite.png"), dpi=300)
        self.assertTrue(True)
コード例 #4
0
    def test_get_prop_info(self):
        import matplotlib.pyplot as plt
        vsp.VSPRenew()
        vsp.ClearVSPModel()

        prop_id = vsp.AddGeom("PROP")

        valid_location = np.array([-30.0, 60.0, 0.0]).reshape((3, 1))

        vsp.SetParmVal(prop_id, "Y_Rel_Location", "XForm", valid_location[1,
                                                                          0])
        vsp.SetParmVal(prop_id, "X_Rel_Location", "XForm", valid_location[0,
                                                                          0])
        vsp.SetParmVal(prop_id, "Y_Rel_Rotation", "XForm", 0.0)
        vsp.SetParmVal(prop_id, "X_Rel_Rotation", "XForm", 0.0)
        vsp.SetParmVal(prop_id, "Sym_Planar_Flag", "Sym",
                       vsp.SYM_XZ | vsp.SYM_YZ)

        valid_location_sym = np.array(valid_location)
        valid_location_sym[1] *= -1.0
        valid_location_aft = np.array(valid_location)
        valid_location_aft[0] *= -1.0
        valid_location_aft_sym = np.array(valid_location_sym)
        valid_location_aft_sym[0] *= -1.0

        vsp.Update()

        prop_info = vsp.get_propeller_thrust_vectors(vsp.SET_ALL)

        # Plot prop objects
        vsp.plot_propeller_info(prop_info, vector_scale=30.0, markersize=5)
        plt.draw()
        plt.savefig(os.path.join(self.OUTPUT_FOLDER, "prop_plots.png"),
                    dpi=300)

        valid_thrust_dir = np.array([-1.0, 0.0, 0.0]).reshape((3, 1))
        valid_thrust_dir_aft_props = np.array([1.0, 0.0, 0.0]).reshape((3, 1))

        # Check thrust vectors
        npt.assert_allclose(prop_info[0].thrust_vector, valid_thrust_dir)
        npt.assert_allclose(prop_info[1].thrust_vector, valid_thrust_dir)
        npt.assert_allclose(prop_info[2].thrust_vector,
                            valid_thrust_dir_aft_props)
        npt.assert_allclose(prop_info[3].thrust_vector,
                            valid_thrust_dir_aft_props)

        # Check origins
        npt.assert_allclose(prop_info[0].hub_center, valid_location)
        npt.assert_allclose(prop_info[1].hub_center, valid_location_sym)
        npt.assert_allclose(prop_info[2].hub_center, valid_location_aft)
        npt.assert_allclose(prop_info[3].hub_center, valid_location_aft_sym)

        # Check rotation directions
        self.assertTrue(prop_info[0].rotation_direction == 1)
        self.assertTrue(prop_info[1].rotation_direction == -1)
        self.assertTrue(prop_info[2].rotation_direction == -1)
        self.assertTrue(prop_info[3].rotation_direction == 1)
コード例 #5
0
    def test_plate_degen_geom(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        prop_id = vsp.AddGeom("PROP")

        vsp.Update()
        dg_mgr = vsp.run_degen_geom(set_index=vsp.SET_ALL)
        dg_mgr.degen_objs[prop_id].plot_copies_plates()
        plt.savefig(os.path.join(self.OUTPUT_FOLDER, "plates.png"), dpi=300)
コード例 #6
0
    def test_copy_paste_ids(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        prop_id1 = vsp.AddGeom("PROP")
        vsp.Update()

        vsp.CopyGeomToClipboard(prop_id1)
        prop_id2 = vsp.PasteGeomClipboard()

        self.assertTrue(prop_id1 != prop_id2[0])
コード例 #7
0
    def test_surface_patches(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        vsp.AddGeom("PROP")

        vsp.Update()

        components = vsp.export_surface_patches(vsp.SET_ALL,
                                                remove_degenerate=True)
        vsp.plot_surface_components(components)
コード例 #8
0
    def test_surface_patches(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        vsp.AddGeom("PROP")

        vsp.Update()

        components = vsp.export_surface_patches(vsp.SET_ALL,
                                                remove_degenerate=True)
        vsp.plot_surface_components(components)
        plt.savefig(os.path.join(self.OUTPUT_FOLDER, "surface_patches.png"),
                    dpi=300)
        self.assertTrue(True)
コード例 #9
0
    def test_parse_degen_geom(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        wing_id = vsp.AddGeom("WING")

        vsp.Update()

        vsp.SetIntAnalysisInput("DegenGeom", "WriteCSVFlag", [0], 0)
        vsp.SetIntAnalysisInput("DegenGeom", "WriteMFileFlag", [0], 0)

        degen_results_id = vsp.ExecAnalysis("DegenGeom")
        for degen_obj in vsp.parse_degen_geom(degen_results_id):
            print(degen_obj)
コード例 #10
0
    def test_simple_prop_degen(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        prop_id = vsp.AddGeom("PROP")
        vsp.Update()

        print(vsp.GetAnalysisInputNames("DegenGeom"))
        vsp.SetAnalysisInputDefaults("DegenGeom")
        vsp.PrintAnalysisInputs("DegenGeom")
        vsp.SetIntAnalysisInput("DegenGeom", "WriteCSVFlag", [0], 0)
        vsp.SetIntAnalysisInput("DegenGeom", "WriteMFileFlag", [0], 0)
        vsp.PrintAnalysisInputs("DegenGeom")

        self.assertTrue(True)
コード例 #11
0
    def test_degen_transform_mat(self):
        import degen_geom as dg
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        prop_id = vsp.AddGeom("PROP")

        vsp.SetParmVal(prop_id, "Y_Rel_Location", "XForm", 60.0)
        vsp.SetParmVal(prop_id, "Y_Rel_Rotation", "XForm", 90.0)
        vsp.SetParmVal(prop_id, "X_Rel_Rotation", "XForm", 10.0)
        vsp.SetParmVal(prop_id, "Sym_Planar_Flag", "Sym", vsp.SYM_XZ)

        vsp.Update()

        vsp.SetIntAnalysisInput("DegenGeom", "WriteCSVFlag", [0], 0)
        vsp.SetIntAnalysisInput("DegenGeom", "WriteMFileFlag", [0], 0)

        degen_results_id = vsp.ExecAnalysis("DegenGeom")
        degen_objects = vsp.parse_degen_geom(degen_results_id)

        degen_mgr = dg.DegenGeomMgr(degen_objects)
        dg_prop_comp = degen_mgr.degen_objs[prop_id]

        orig_copy = dg_prop_comp.copies[0]

        origin = orig_copy[0].transmat.get_translations()
        self.assertAlmostEqual(origin[0], 0.0, places=6)
        self.assertAlmostEqual(origin[1], 60.0, places=6)
        self.assertAlmostEqual(origin[2], 0.0, places=6)

        angles = orig_copy[0].transmat.get_angles()
        self.assertAlmostEqual(angles[0], 10.0, places=6)
        self.assertAlmostEqual(angles[1], 90.0, places=6)
        self.assertAlmostEqual(angles[2], 0.0, places=6)

        sym_copy = dg_prop_comp.copies[1]
        origin = sym_copy[0].transmat.get_translations()
        self.assertAlmostEqual(origin[0], 0.0, places=6)
        self.assertAlmostEqual(origin[1], -60.0, places=6)
        self.assertAlmostEqual(origin[2], 0.0, places=6)

        angles = sym_copy[0].transmat.get_angles()
        self.assertAlmostEqual(angles[0], -180.0 + 10.0, places=6)
        self.assertAlmostEqual(angles[1], 90.0, places=6)
        self.assertAlmostEqual(angles[2], 0.0, places=6)

        self.assertTrue(True)
コード例 #12
0
    def test_plate_degen_geom_area(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        prop_id = vsp.AddGeom("PROP")

        vsp.Update()
        dg_mgr = vsp.run_degen_geom(set_index=vsp.SET_ALL)
        prop_dg = dg_mgr.degen_objs[prop_id]

        for comp in prop_dg.copies.values():
            for surf in comp:
                for plate in surf.plates:
                    area_brute_force = plate._compute_areas_brute_force().sum()
                    area_vectorized = plate.compute_areas().sum()
                    self.assertAlmostEqual(area_brute_force,
                                           area_vectorized,
                                           delta=1.0e-1)
コード例 #13
0
    def test_double_mat(self):
        vsp.VSPRenew()
        vsp.ClearVSPModel()
        pod_id = vsp.AddGeom("POD")

        vsp.Update()

        degen_results_id = vsp.ExecAnalysis("DegenGeom")
        degen_ids = vsp.GetStringResults(degen_results_id, "Degen_DegenGeoms")

        for degen_id in degen_ids:
            surf_id = vsp.GetStringResults(degen_id, "surf", 0)[0]
            vsp.PrintResults(surf_id)
            areas = vsp.GetDoubleMatResults(surf_id, "area")

            print(areas[0][0])
        self.assertTrue(True)
コード例 #14
0
ファイル: test.py プロジェクト: valdezf10/OpenVSP
print("NUM_WSECT_DRIVER = ", vsp.NUM_WSECT_DRIVER)
print("SWEEP_WSECT_DRIVER = ", vsp.SWEEP_WSECT_DRIVER)
print("SWEEPLOC_WSECT_DRIVER = ", vsp.SWEEPLOC_WSECT_DRIVER)
print("SECSWEEPLOC_WSECT_DRIVER = ", vsp.SECSWEEPLOC_WSECT_DRIVER)

# ==== Use Case 1 ==== #
vsp.VSPCheckSetup()
errorMgr.PopErrorAndPrint(stdout)

types = vsp.GetGeomTypes()
errorMgr.PopErrorAndPrint(stdout)

print(types)

# Add Fuse
fuse_id = vsp.AddGeom("FUSELAGE")
errorMgr.PopErrorAndPrint(stdout)

# Add Pod
pod_id = vsp.AddGeom("POD", fuse_id)
errorMgr.PopErrorAndPrint(stdout)

# Set Name
vsp.SetGeomName(pod_id, "Pod")
errorMgr.PopErrorAndPrint(stdout)

# Change Length
len_id = vsp.GetParm(pod_id, "Length", "Design")
vsp.SetParmVal(len_id, 7.0)

# Change Finess Ratio
コード例 #15
0
ファイル: wing.py プロジェクト: tgilbert09/UAV-optimiser
print("SECSWEEPLOC_WSECT_DRIVER = ", vsp.SECSWEEPLOC_WSECT_DRIVER)

vsp.VSPRenew()
errorMgr.PopErrorAndPrint(stdout)



geoms = vsp.FindGeoms()

print("All geoms in Vehicle.")
print(geoms)

vsp.SetComputationFileName(vsp.DEGEN_GEOM_CSV_TYPE, 'wing_DegenGeom.csv')

# Wing Properties
wing_id = vsp.AddGeom("WING")
vsp.SetParmVal(wing_id, "TotalSpan", "WingGeom", 10)
vsp.SetParmVal(wing_id, "Sweep", "XSec_1", 0)
vsp.SetParmVal(wing_id, "Tip_Chord", "XSec_1", 0.3)
vsp.SetParmVal(wing_id, "Root_Chord", "XSec_1", 0.3)
vsp.SetParmVal(wing_id, "ThickChord", "XSecCurve_0", 0.18)
vsp.SetParmVal(wing_id, "Camber", "XSecCurve_0", 0.04)
vsp.SetParmVal(wing_id, "CamberLoc", "XSecCurve_0", 0.4)
vsp.SetParmVal(wing_id, "ThickChord", "XSecCurve_1", 0.18)
vsp.SetParmVal(wing_id, "Camber", "XSecCurve_1", 0.04)
vsp.SetParmVal(wing_id, "CamberLoc", "XSecCurve_1", 0.4)
vsp.SetParmVal(wing_id, "SectTess_U", "XSec_1", 30)

# Make the geometry file
vsp.ComputeDegenGeom(vsp.SET_ALL, vsp.DEGEN_GEOM_CSV_TYPE)
コード例 #16
0
    def test_degen_geom(self):
        # Test analysis manager
        vsp.VSPRenew()
        vsp.ClearVSPModel()

        # Print all types
        print(vsp.GetGeomTypes())

        prop_id = vsp.AddGeom("PROP")
        blank_id = vsp.AddGeom("BLANK")
        disk_id = vsp.AddGeom("Disk")
        vsp.SetParmVal(blank_id, "Point_Mass_Flag", "Mass", 1)
        vsp.SetParmVal(blank_id, "Point_Mass", "Mass", 5.0)
        wing_id = vsp.AddGeom("WING")
        pod_id = vsp.AddGeom("POD")
        vsp.AddSubSurf(pod_id, vsp.SS_RECTANGLE)
        vsp.AddSubSurf(wing_id, vsp.SS_CONTROL)

        vsp.Update()

        # Run Degen Geom
        print(vsp.FindGeoms())
        print(vsp.GetAnalysisInputNames("DegenGeom"))
        vsp.SetAnalysisInputDefaults("DegenGeom")
        vsp.SetIntAnalysisInput("DegenGeom", "WriteMFileFlag", [0], 0)
        vsp.SetIntAnalysisInput("DegenGeom", "WriteCSVFlag", [0], 0)
        vsp.PrintAnalysisInputs("DegenGeom")
        degen_results_id = vsp.ExecAnalysis("DegenGeom")

        print(vsp.GetAllResultsNames())
        vsp.PrintResults(degen_results_id)
        blank_ids = vsp.GetStringResults(degen_results_id, "Degen_BlankGeoms")
        degen_ids = vsp.GetStringResults(degen_results_id, "Degen_DegenGeoms")

        for blank_id in blank_ids:
            vsp.PrintResults(blank_id)

        for degen_id in degen_ids:
            vsp.PrintResults(degen_id)
            t = vsp.GetStringResults(degen_id, "type", 0)[0]
            if t == "DISK":
                disk_id = vsp.GetStringResults(degen_id, "disk", 0)[0]
                vsp.PrintResults(disk_id)
            surf_id = vsp.GetStringResults(degen_id, "surf", 0)[0]
            vsp.PrintResults(surf_id)
            areas = vsp.GetDoubleMatResults(surf_id, "area")

            plate_ids = vsp.GetStringResults(degen_id, "plates")
            for plate_id in plate_ids:
                vsp.PrintResults(plate_id)

            stick_ids = vsp.GetStringResults(degen_id, "sticks")
            for stick_id in stick_ids:
                vsp.PrintResults(stick_id)

            if t != "DISK":
                point_id = vsp.GetStringResults(degen_id, "point")[0]
                vsp.PrintResults(point_id)

            subsurf_ids = vsp.GetStringResults(degen_id, "subsurfs")
            for ss_id in subsurf_ids:
                vsp.PrintResults(ss_id)

            hinge_ids = vsp.GetStringResults(degen_id, "hinges")
            for hinge_id in hinge_ids:
                vsp.PrintResults(hinge_id)

        self.assertTrue(True)