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.7276863619687, 2.0, 8)
(65.5984814738824, 12.0, 0)
(61.9204366255269, 10.0, -8)
(53.5085651751861, 4.0, -8)
(52.1074232044728, 6.0, 0)

Running skew: 0 Field current: 10
Sound power level [dB], electrical time order, space order:
(72.333173447735, 2.0, 8)
(65.1847772191526, 12.0, 0)
(64.0018895513338, 10.0, -8)
(57.9477621024406, 6.0, 0)
(53.6727826441104, 14.0, 8)

Running skew: 7.5 Field current: 5
Sound power level [dB], electrical time order, space order:
(68.0603698519591, 2.0, 8)
(52.3791765470471, 6.0, 0)
(51.3030010569856, 4.0, -8)
(49.8355349658732, 10.0, -8)
(49.3445496498163, 12.0, 0)

Running skew: 7.5 Field current: 10
Sound power level [dB], electrical time order, space order:
(71.7012705351003, 2.0, 8)
(55.0306134574829, 6.0, 0)
(52.1824725532946, 3.0, 8)
(50.4153803571974, 1.0, 0)
(50.3422557395374, 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.set_variable("MessageDisplayState", 2)
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 4.016 seconds)

Gallery generated by Sphinx-Gallery