コード例 #1
0
ファイル: utilities.py プロジェクト: zxp-proteus/OpenVSP
def run_degen_geom(set_index=None, set_name=None):
    """
    Runs degen geom on input set
    :param set_index: set index, will take precendence if both set index and set name are specified
    :param set_name: name of set, will be used if set index is not specified
    :return: degen geom manager object
    """
    import degen_geom as dg

    if set_index is None and set_name is None:
        raise ValueError("set_index and set_name cannot both be None")

    # Get set index from name, if set index was not specified
    if set_index is None:
        set_index = vsp.GetSetIndex(set_name)

    # Run degen geom on the input set
    vsp.SetAnalysisInputDefaults("DegenGeom")
    vsp.SetIntAnalysisInput("DegenGeom", "Set", [set_index], 0)
    vsp.SetIntAnalysisInput("DegenGeom", "WriteCSVFlag", [0], 0)
    vsp.SetIntAnalysisInput("DegenGeom", "WriteMFileFlag", [0], 0)
    degen_res_id = vsp.ExecAnalysis("DegenGeom")

    degen_objs = vsp.parse_degen_geom(degen_res_id)

    degen_mgr = dg.DegenGeomMgr(degen_objs)

    return degen_mgr
コード例 #2
0
def parasitedrag_sweep(speeds,
                       alts_ft,
                       sref=None,
                       length_unit=None,
                       speed_unit=vsp.V_UNIT_MACH,
                       set=None):
    """
    Runs a parasite drag sweep over a range of speeds and altitudes. For subsonic data only.

    :param speeds: list of speeds to sweep over
    :param alts_ft: list of altitudes to sweep over
    :param speed_unit: units of speed array
    :param set: vsp geometry set to use for build up
    :param length_unit: length unit of the vsp model
    :param sref: reference area
    :return: named tuple with results
    """
    # Reset default values to ensure values that have been read from a vsp file are used by default
    vsp.SetAnalysisInputDefaults('ParasiteDrag')

    # inputs that don't change during a sweep

    vsp.SetIntAnalysisInput("ParasiteDrag", "VelocityUnit", [speed_unit])
    if length_unit is not None:
        vsp.SetIntAnalysisInput("ParasiteDrag", "LengthUnit", [length_unit])

    vsp.SetStringAnalysisInput("ParasiteDrag", "FileName", ["/dev/null"])

    if set is not None:
        vsp.SetIntAnalysisInput("ParasiteDrag", "GeomSet", [set])

    if sref is not None:
        vsp.SetIntAnalysisInput("ParasiteDrag", "RefFlag", [0])
        vsp.SetDoubleAnalysisInput("ParasiteDrag", "Sref", [float(sref)])

    vsp.SetVSP3FileName('/dev/null')

    results = []
    first_val = True
    for speed in speeds:
        for alt in alts_ft:
            vsp.SetDoubleAnalysisInput("ParasiteDrag", "Vinf", [float(speed)])
            vsp.SetDoubleAnalysisInput("ParasiteDrag", "Altitude",
                                       [float(alt)])
            if first_val:
                vsp.SetIntAnalysisInput("ParasiteDrag", "RecomputeGeom",
                                        [True])
                first_val = False
            else:
                vsp.SetIntAnalysisInput("ParasiteDrag", "RecomputeGeom",
                                        [False])
            results.append(
                vsp.parse_results_object(vsp.ExecAnalysis("ParasiteDrag")))

    return ParasiteDragResults(results)
コード例 #3
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)
コード例 #4
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)