Simple parametric sweep for SYNC machine#

This is a simple example showing a two-dimensional parametric sweep for a wound field synchronous motor varying continuous stator skew and field current.

Running skew: 0 Field current: 5
Sound power level [dB], electrical time order, space order:
(68.715680802405, 2.0, 8)
(65.6655425538224, 12.0, 0)
(61.9602918417768, 10.0, -8)
(53.5047465882269, 4.0, -8)
(52.0632556454324, 6.0, 0)

Running skew: 0 Field current: 10
Sound power level [dB], electrical time order, space order:
(72.3252609534223, 2.0, 8)
(65.1968444467469, 12.0, 0)
(64.0221636292951, 10.0, -8)
(58.0170169717154, 6.0, 0)
(53.705080908458, 14.0, 8)

Running skew: 7.5 Field current: 5
Sound power level [dB], electrical time order, space order:
(68.0478860885667, 2.0, 8)
(52.3488469520123, 6.0, 0)
(51.3004475000929, 4.0, -8)
(49.8667975623371, 10.0, -8)
(49.3468712552461, 12.0, 0)

Running skew: 7.5 Field current: 10
Sound power level [dB], electrical time order, space order:
(71.6922106439609, 2.0, 8)
(55.0628034540582, 6.0, 0)
(52.1725027948218, 3.0, 8)
(50.4051561671956, 1.0, 0)
(50.3511636859912, 10.0, -8)

import math

import ansys.motorcad.core as pymotorcad

# Open connection to Motor-CAD, and open e3 template (Sync machine)
mc = pymotorcad.MotorCAD()
mc.load_template("e3")
# Alternatively, use the following
# mc = pymotorcad.MotorCAD()
# mc.load_from_file('filename.mot')

# Ensure the transient calculation and force calculation are enabled
mc.set_variable("TorqueCalculation", True)
mc.set_variable("ElectromagneticForcesCalc_Load", True)

# Make sure continuous stator skew is enabled
mc.set_variable("SkewType", 1)

# Set up the sweep parameters, in this case for sync machine field current and skew angle
skew_angles = [0, 7.5]
field_currents = [5, 10]

# Run the sweep
for skew_angle in skew_angles:
    for field_current in field_currents:
        # Set the parameter(s) to sweep
        mc.set_variable("StatorSkew", skew_angle)
        mc.set_variable("DCFieldCurrent", field_current)

        # Tell the user what step we are on:
        print("Running skew: " + str(skew_angle) + " Field current: " + str(field_current))

        # Run the calculation
        mc.do_magnetic_calculation()

        # Find many steps have been run
        if mc.get_variable("MotorType_MotorLAB") == "IM":
            try:
                # Variable was renamed in 2024R1, try newer naming first
                numberOfCycles = mc.get_variable("IMSingleLoadNumberCycles_Rotating")
            except pymotorcad.MotorCADError:
                numberOfCycles = mc.get_variable("IMSingleLoadNumberCycles")
        else:
            numberOfCycles = mc.get_variable("TorqueNumberCycles")

        # Get the NVH data matrix
        nvh_data_raw = mc.get_magnetic_3d_graph("NVH_RadiatedPower_Level_OL", 1)

        # Find length of data available
        time_order_items = len(nvh_data_raw.y)
        space_order_items = len(nvh_data_raw.x)
        index_offset_space = math.floor(space_order_items / 2)

        # Iterate over data, storing as a list of tuples, so we can sort to find the biggest
        nvh_list = []
        for raw_time_order in range(time_order_items):
            electrical_order = raw_time_order / numberOfCycles
            for raw_space_order in range(space_order_items):
                space_order = raw_space_order - index_offset_space
                # Store a tuple of sound power level, electrical time order, space order
                nvh_list.append(
                    (
                        nvh_data_raw.data[raw_space_order][raw_time_order],
                        electrical_order,
                        space_order,
                    )
                )

        # Sort the list on NVH, from highest to lowest, and show top 5 orders
        nvh_list.sort(reverse=True)
        print("Sound power level [dB], electrical time order, space order:")
        for i in range(min(5, len(nvh_list))):
            print(nvh_list[i])
        print("")

Total running time of the script: (1 minutes 46.705 seconds)

Gallery generated by Sphinx-Gallery