diff --git a/_unittest/test_01_GeometryOperators.py b/_unittest/test_01_GeometryOperators.py index 20f66325f10..7e05f1c41a5 100644 --- a/_unittest/test_01_GeometryOperators.py +++ b/_unittest/test_01_GeometryOperators.py @@ -369,16 +369,12 @@ def test_orient_polygon(self): xo2, yo2 = go.orient_polygon(x2, y2, clockwise=True) assert x2 == xo2 assert y2 == yo2 - try: + with pytest.raises(ValueError) as excinfo: go.orient_polygon([1], [2], clockwise=True) - assert False - except ValueError as e: - assert str(e) == "'x' length must be >= 2" - try: + assert str(excinfo) == "'x' length must be >= 2" + with pytest.raises(ValueError) as excinfo: go.orient_polygon([1, 2, 3], [1, 2], clockwise=True) - assert False - except ValueError as e: - assert str(e) == "'y' must be same length as 'x'" + assert str(excinfo) == "'y' must be same length as 'x'" def test_is_collinear(self): assert go.is_collinear([1, 0, 0], [1, 0, 0]) diff --git a/_unittest/test_02_3D_modeler.py b/_unittest/test_02_3D_modeler.py index 8dc36cfa7ac..05fd26db2a9 100644 --- a/_unittest/test_02_3D_modeler.py +++ b/_unittest/test_02_3D_modeler.py @@ -382,11 +382,8 @@ def test_40_create_coordinate_system(self): assert cs.change_cs_mode(1) assert cs.change_cs_mode(2) - try: + with pytest.raises(ValueError): cs.change_cs_mode(3) - assert False - except ValueError: - assert True assert cs.change_cs_mode(0) assert cs.delete() assert len(self.aedtapp.modeler.coordinate_systems) == 1 diff --git a/_unittest/test_03_Materials.py b/_unittest/test_03_Materials.py index 4d64a0dee3e..535a8ae4e84 100644 --- a/_unittest/test_03_Materials.py +++ b/_unittest/test_03_Materials.py @@ -96,21 +96,12 @@ def test_02_create_material(self): assert mat1.material_appearance == [11, 22, 0] mat1.material_appearance = ["11", "22", "10"] assert mat1.material_appearance == [11, 22, 10] - try: + with pytest.raises(ValueError): mat1.material_appearance = [11, 22, 300] - assert False - except ValueError: - assert True - try: + with pytest.raises(ValueError): mat1.material_appearance = [11, -22, 0] - assert False - except ValueError: - assert True - try: + with pytest.raises(ValueError): mat1.material_appearance = [11, 22] - assert False - except ValueError: - assert True def test_03_create_modifiers(self): assert self.aedtapp.materials["new_copper2"].mass_density.add_thermal_modifier_free_form( @@ -298,13 +289,10 @@ def test_14_get_coreloss_coefficients(self): assert isinstance(coeff, list) assert len(coeff) == 3 assert all(isinstance(c, float) for c in coeff) - try: + with pytest.raises(TypeError): self.aedtapp.materials["mat_test"].get_core_loss_coefficients( points_list_at_freq=[[0, 0], [1, 3.5], [2, 7.4]] ) - assert False - except TypeError: - assert True coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients( points_list_at_freq={ 60: [[0, 0], [1, 3.5], [2, 7.4]], @@ -322,20 +310,14 @@ def test_14_get_coreloss_coefficients(self): assert isinstance(coeff, list) assert len(coeff) == 3 assert all(isinstance(c, float) for c in coeff) - try: - coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients( + with pytest.raises(TypeError): + self.aedtapp.materials["mat_test"].get_core_loss_coefficients( points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid" ) - assert False - except TypeError: - assert True - try: - coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients( + with pytest.raises(TypeError): + self.aedtapp.materials["mat_test"].get_core_loss_coefficients( points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50 ) - assert False - except TypeError: - assert True def test_14_set_core_loss(self): mat = self.aedtapp.materials["mat_test"] @@ -349,13 +331,10 @@ def test_14_set_core_loss(self): assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]} ) - try: + with pytest.raises(TypeError): self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq=[[0, 0], [1, 3.5], [2, 7.4]] ) - assert False - except TypeError: - assert True assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq={ 60: [[0, 0], [1, 3.5], [2, 7.4]], @@ -363,21 +342,27 @@ def test_14_set_core_loss(self): 150: [[0, 0], [1, 10], [2, 19]], } ) + assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( + points_list_at_freq={ + 60: [[0, 0], [1, 3.5], [2, 7.4]], + 100: [[0, 0], [1, 8], [2, 9]], + 150: [[0, 0], [1, 10], [2, 19]], + }, + core_loss_model_type="Power Ferrite", + ) + with pytest.raises(ValueError): + self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( + points_list_at_freq={80: [[0, 0], [1, 3.5], [2, 7.4]]}, core_loss_model_type="Power Ferrite" + ) # Test thickness assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm" ) - try: - coeff = self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( + with pytest.raises(TypeError): + self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid" ) - assert False - except TypeError: - assert True - try: - coeff = self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( + with pytest.raises(TypeError): + self.aedtapp.materials["mat_test"].set_coreloss_at_frequency( points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50 ) - assert False - except TypeError: - assert True diff --git a/_unittest/test_08_Primitives3D.py b/_unittest/test_08_Primitives3D.py index 4aa553bf993..84eca8e1095 100644 --- a/_unittest/test_08_Primitives3D.py +++ b/_unittest/test_08_Primitives3D.py @@ -701,12 +701,12 @@ def test_44_create_polyline_basic_segments(self): assert prim3D.create_polyline( position_list=test_points, segment_type=PolylineSegment("Spline", num_points=3), name="PL03_spline_3pt" ) - try: + with pytest.raises(ValueError) as execinfo: prim3D.create_polyline(position_list=test_points[0:3], segment_type="Spline", name="PL03_spline_str_3pt") - except ValueError as e: - assert str(e) == "The position_list argument must contain at least 4 points for segment of type Spline." - else: - assert False + assert ( + str(execinfo) + == "The 'position_list' argument must contain at least four points for segment of type 'Spline'." + ) assert prim3D.create_polyline( position_list=[[100, 100, 0]], segment_type=PolylineSegment("AngularArc", arc_center=[0, 0, 0], arc_angle="30deg"), @@ -1023,12 +1023,9 @@ def test_54a_create_spiral_and_add_segments(self): # test unclassified p11 = polyline_points[11] position_lst = [[-142, 130, 0], [-126, 63, 0], p11] - try: + with pytest.raises(ValueError) as execinfo: ind.insert_segment(position_lst, "Arc") - except ValueError as e: - assert str(e) == "Adding the segment result in an unclassified object. Undoing operation." - else: - assert False + assert str(execinfo) == "Adding the segment result in an unclassified object. Undoing operation." assert len(ind.points) == 64 assert len(ind.segment_types) == 55 diff --git a/_unittest/test_09_VariableManager.py b/_unittest/test_09_VariableManager.py index 3eac9011b0d..166f644eeca 100644 --- a/_unittest/test_09_VariableManager.py +++ b/_unittest/test_09_VariableManager.py @@ -253,18 +253,11 @@ def test_07_addition(self): v2 = Variable(3) v3 = Variable("3mA") v4 = Variable("10A") - - try: + with pytest.raises(AssertionError): v1 + v2 - assert False - except AssertionError: - pass - try: + with pytest.raises(AssertionError): v2 + v1 - assert False - except AssertionError: - pass result_1 = v2 + v2 result_2 = v3 + v4 result_3 = v3 + v3 @@ -286,17 +279,11 @@ def test_08_subtraction(self): v3 = Variable("3mA") v4 = Variable("10A") - try: + with pytest.raises(AssertionError): v1 - v2 - assert False - except AssertionError: - pass - try: + with pytest.raises(AssertionError): v2 - v1 - assert False - except AssertionError: - pass result_1 = v2 - v2 result_2 = v3 - v4 diff --git a/_unittest/test_16_3d_stackup.py b/_unittest/test_16_3d_stackup.py index a4e624dad62..a4655f14ae5 100644 --- a/_unittest/test_16_3d_stackup.py +++ b/_unittest/test_16_3d_stackup.py @@ -68,10 +68,8 @@ def test_02_line(self): def test_03_padstackline(self): p1 = self.st.add_padstack("Massimo", material="aluminum") p1.plating_ratio = 0.7 - try: + with pytest.raises(ValueError): p1.set_start_layer("non_existing_layer") - except ValueError: - assert True assert p1.set_start_layer("lay1") assert p1.set_stop_layer("top") p1.set_all_pad_value(1) diff --git a/_unittest/test_20_HFSS.py b/_unittest/test_20_HFSS.py index 1b59cd77f5b..16d2cdcf651 100644 --- a/_unittest/test_20_HFSS.py +++ b/_unittest/test_20_HFSS.py @@ -253,8 +253,8 @@ def test_06a_create_linear_count_sweep(self): assert sweep.props["Type"] == "Discrete" # Create a linear count sweep with the incorrect sweep type. - try: - sweep = self.aedtapp.create_linear_count_sweep( + with pytest.raises(AttributeError) as execinfo: + self.aedtapp.create_linear_count_sweep( setupname="MySetup", sweepname="IncorrectStep", unit="MHz", @@ -263,12 +263,10 @@ def test_06a_create_linear_count_sweep(self): num_of_freq_points=1234, sweep_type="Incorrect", ) - except AttributeError as e: - exception_raised = True assert ( - e.args[0] == "Invalid value for `sweep_type`. The value must be 'Discrete', 'Interpolating', or 'Fast'." + execinfo.args[0] + == "Invalid value for `sweep_type`. The value must be 'Discrete', 'Interpolating', or 'Fast'." ) - assert exception_raised self.aedtapp["der_var"] = "1mm" self.aedtapp["der_var2"] = "2mm" setup2 = self.aedtapp.create_setup("MySetup_2", setuptype=0) @@ -327,8 +325,8 @@ def test_06c_create_linear_step_sweep(self): assert sweep.props["Type"] == "Fast" # Create a linear step sweep with the incorrect sweep type. - try: - sweep = self.aedtapp.create_linear_step_sweep( + with pytest.raises(AttributeError) as execinfo: + self.aedtapp.create_linear_step_sweep( setupname="MySetup", sweepname="StepFast", unit=units, @@ -337,12 +335,10 @@ def test_06c_create_linear_step_sweep(self): step_size=step_size, sweep_type="Incorrect", ) - except AttributeError as e: - exception_raised = True assert ( - e.args[0] == "Invalid value for `sweep_type`. The value must be 'Discrete', 'Interpolating', or 'Fast'." + execinfo.args[0] + == "Invalid value for 'sweep_type'. The value must be 'Discrete', 'Interpolating', or 'Fast'." ) - assert exception_raised def test_06d_create_single_point_sweep(self): assert self.aedtapp.create_single_point_sweep( @@ -1157,37 +1153,28 @@ def test_45B_terminal_port(self): assert n_boundaries == 12 # Use two boxes with different dimensions. - try: + with pytest.raises(AttributeError) as execinfo: self.aedtapp.create_spiral_lumped_port(box1, box3) - except AttributeError as e: - assert e.args[0] == "The closest faces of the two objects must be identical in shape." - else: - assert False + assert execinfo.args[0] == "The closest faces of the two objects must be identical in shape." # Rotate box3 so that, box3 and box4 are not collinear anymore. # Spiral lumped port can only be created based on 2 collinear objects. box3.rotate(cs_axis="X", angle=90) - try: + with pytest.raises(AttributeError) as execinfo: self.aedtapp.create_spiral_lumped_port(box3, box4) - except AttributeError as e: - assert e.args[0] == "The two objects must have parallel adjacent faces." - else: - assert False + assert execinfo.args[0] == "The two objects must have parallel adjacent faces." # Rotate back box3 # rotate them slightly so that they are still parallel, but not aligned anymore with main planes. box3.rotate(cs_axis="X", angle=-90) box3.rotate(cs_axis="Y", angle=5) box4.rotate(cs_axis="Y", angle=5) - try: + with pytest.raises(AttributeError) as execinfo: self.aedtapp.create_spiral_lumped_port(box3, box4) - except AttributeError as e: assert ( - e.args[0] + execinfo.args[0] == "The closest faces of the two objects must be aligned with the main planes of the reference system." ) - else: - assert False self.aedtapp.delete_design("Design_Terminal_2", self.fall_back_name) def test_46_mesh_settings(self): @@ -1208,12 +1195,9 @@ def test_49_port_creation_exception(self): self.aedtapp.solution_type = "Modal" # Spiral lumped port can only be created in a 'Terminal' solution. - try: + with pytest.raises(Exception) as execinfo: self.aedtapp.create_spiral_lumped_port(box1, box2) - except Exception as e: - exception_raised = True - assert e.args[0] == "This method can be used only in Terminal solutions." - assert exception_raised + assert execinfo.args[0] == "This method can be used only in 'Terminal' solutions." self.aedtapp.solution_type = "Terminal" # Try to modify SBR+ TX RX antenna settings in a solution that is different from SBR+ diff --git a/_unittest/test_41_3dlayout_modeler.py b/_unittest/test_41_3dlayout_modeler.py index eaecdedfa8a..8157cde93d4 100644 --- a/_unittest/test_41_3dlayout_modeler.py +++ b/_unittest/test_41_3dlayout_modeler.py @@ -436,9 +436,8 @@ def test_18b_create_linear_step_sweep(self): assert sweep4.props["Sweeps"]["Data"] == "LIN 1GHz 10GHz 0.12GHz" # Create a linear step sweep with the incorrect sweep type. - exception_raised = False - try: - sweep_raising_error = self.aedtapp.create_linear_step_sweep( + with pytest.raises(AttributeError) as execinfo: + self.aedtapp.create_linear_step_sweep( setupname=setup_name, unit="GHz", freqstart=1, @@ -448,12 +447,10 @@ def test_18b_create_linear_step_sweep(self): sweep_type="Incorrect", save_fields=True, ) - except AttributeError as e: - exception_raised = True assert ( - e.args[0] == "Invalid value for `sweep_type`. The value must be 'Discrete', 'Interpolating', or 'Fast'." + execinfo.args[0] == "Invalid value for 'sweep_type'. The value must be 'Discrete', " + "'Interpolating', or 'Fast'." ) - assert exception_raised def test_18c_create_single_point_sweep(self): setup_name = "RF_create_single_point" @@ -475,19 +472,15 @@ def test_18c_create_single_point_sweep(self): ) assert sweep6.props["Sweeps"]["Data"] == "1GHz 2GHz 3GHz 4GHz" - exception_raised = False - try: - sweep7 = self.aedtapp.create_single_point_sweep( + with pytest.raises(AttributeError) as execinfo: + self.aedtapp.create_single_point_sweep( setupname=setup_name, unit="GHz", freq=[], sweepname="RFBoardSingle", save_fields=False, ) - except AttributeError as e: - exception_raised = True - assert e.args[0] == "Frequency list is empty. Specify at least one frequency point." - assert exception_raised + assert execinfo.args[0] == "Frequency list is empty. Specify at least one frequency point." def test_18d_delete_setup(self): setup_name = "SetupToDelete" diff --git a/_unittest/test_98_Icepak.py b/_unittest/test_98_Icepak.py index 71a50406707..57e2dd552ff 100644 --- a/_unittest/test_98_Icepak.py +++ b/_unittest/test_98_Icepak.py @@ -1450,8 +1450,5 @@ def test_73_conducting_plate(self): "Values": "Test_DataSet_Plate", }, ) - try: + with pytest.raises(AttributeError): self.aedtapp.assign_conducting_plate_with_conductance([box_face.id, "surfPlateTest"]) - assert False - except AttributeError: - assert True diff --git a/examples/03-Maxwell/Maxwell_Transformer_Coreloss.py b/examples/03-Maxwell/Maxwell_Transformer_Coreloss.py new file mode 100644 index 00000000000..cab8575bbf2 --- /dev/null +++ b/examples/03-Maxwell/Maxwell_Transformer_Coreloss.py @@ -0,0 +1,91 @@ +""" +Maxwell 3D: Transformer +----------------------- +This example shows how you can use PyAEDT to set core loss given a set +of Power-Volume [kw/m^3] curves at different frequencies. +""" +############################################################################### +# Perform required imports +# ~~~~~~~~~~~~~~~~~~~~~~~~ +# Perform required imports. + +from pyaedt import downloads +from pyaedt import generate_unique_folder_name +from pyaedt import Maxwell3d +from pyaedt.generic.constants import unit_converter +from pyaedt.generic.general_methods import read_csv_pandas + +################################################################################# +# Download .aedt file example +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Set local temporary folder to export the .aedt file to. + +temp_folder = generate_unique_folder_name() +aedt_file = downloads.download_file("core_loss_transformer", "Ex2-PlanarTransformer_2023R2.aedtz", temp_folder) +freq_curve_csv_25kHz = downloads.download_file("core_loss_transformer", "mf3_25kHz.csv", temp_folder) +freq_curve_csv_100kHz = downloads.download_file("core_loss_transformer", "mf3_100kHz.csv", temp_folder) +freq_curve_csv_200kHz = downloads.download_file("core_loss_transformer", "mf3_200kHz.csv", temp_folder) +freq_curve_csv_400kHz = downloads.download_file("core_loss_transformer", "mf3_400kHz.csv", temp_folder) +freq_curve_csv_700kHz = downloads.download_file("core_loss_transformer", "mf3_700kHz.csv", temp_folder) +freq_curve_csv_1MHz = downloads.download_file("core_loss_transformer", "mf3_1MHz.csv", temp_folder) + +data = read_csv_pandas(filename=freq_curve_csv_25kHz) +curves_csv_25kHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) +data = read_csv_pandas(filename=freq_curve_csv_100kHz) +curves_csv_100kHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) +data = read_csv_pandas(filename=freq_curve_csv_200kHz) +curves_csv_200kHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) +data = read_csv_pandas(filename=freq_curve_csv_400kHz) +curves_csv_400kHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) +data = read_csv_pandas(filename=freq_curve_csv_700kHz) +curves_csv_700kHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) +data = read_csv_pandas(filename=freq_curve_csv_1MHz) +curves_csv_1MHz = list(zip(data[data.columns[0]], + data[data.columns[1]])) + +############################################################################### +# Launch AEDT +# ~~~~~~~~~~~ +# Launch AEDT 2023 R2 in graphical mode. + +m3d = Maxwell3d(projectname=aedt_file, + designname="02_3D eddycurrent_CmXY_for_thermal", + specified_version="2023.2", + new_desktop_session=True, + non_graphical=False) + +############################################################################### +# Set core loss at frequencies +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Create a new material, create a dictionary of Power-Volume [kw/m^3] points for a set of frequencies +# retrieved from datasheet provided by supplier and finally set Power-Ferrite core loss model. + +mat = m3d.materials.add_material("newmat") +freq_25kHz = unit_converter(25, unit_system="Freq", input_units="kHz", output_units="Hz") +freq_100kHz = unit_converter(100, unit_system="Freq", input_units="kHz", output_units="Hz") +freq_200kHz = unit_converter(200, unit_system="Freq", input_units="kHz", output_units="Hz") +freq_400kHz = unit_converter(400, unit_system="Freq", input_units="kHz", output_units="Hz") +freq_700kHz = unit_converter(700, unit_system="Freq", input_units="kHz", output_units="Hz") +pv = {freq_25kHz: curves_csv_25kHz, + freq_100kHz: curves_csv_100kHz, + freq_200kHz: curves_csv_200kHz, + freq_400kHz: curves_csv_400kHz, + freq_700kHz: curves_csv_700kHz} +m3d.materials[mat.name].set_coreloss_at_frequency(points_list_at_freq=pv, + coefficient_setup="kw_per_cubic_meter", + core_loss_model_type="Power Ferrite") +coefficients = m3d.materials[mat.name].get_core_loss_coefficients(points_list_at_freq=pv, + coefficient_setup="kw_per_cubic_meter") + +################################################################################### +# Save project and close AEDT +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Save the project and close AEDT. + +m3d.save_project() +m3d.release_desktop() diff --git a/pyaedt/modules/Material.py b/pyaedt/modules/Material.py index 9be36f49b35..1963d72a260 100644 --- a/pyaedt/modules/Material.py +++ b/pyaedt/modules/Material.py @@ -2057,6 +2057,8 @@ def get_core_loss_coefficients( value, unit = decompose_variable_value(thickness) if not is_number(value) and not unit: raise TypeError("Thickness must be provided as a string with value and unit.") + if len(points_list_at_freq) <= 1 and core_loss_model_type == "Power Ferrite": + raise ValueError("At least 2 frequencies must be included.") props = OrderedDict({}) freq_keys = list(points_list_at_freq.keys()) for i in range(0, len(freq_keys)): @@ -2080,7 +2082,7 @@ def get_core_loss_coefficients( elif len(points_list_at_freq) > 1: props["CoreLossMultiCurveData"] = OrderedDict({}) props["CoreLossMultiCurveData"]["property_data"] = "coreloss_multi_curve_data" - props["CoreLossMultiCurveData"]["coreloss_unit"] = "w_per_cubic_meter" + props["CoreLossMultiCurveData"]["coreloss_unit"] = coefficient_setup props["CoreLossMultiCurveData"]["AllCurves"] = OrderedDict({}) props["CoreLossMultiCurveData"]["AllCurves"]["OneCurve"] = [] @@ -2096,9 +2098,15 @@ def get_core_loss_coefficients( props = self._get_args(props) props.pop(0) - props[0][-1][2] = "NAME:Points" - points = props[0][-1].pop(2) - props[0][-1][2].insert(0, points) + if len(points_list_at_freq) == 1: + props[0][-1][2] = "NAME:Points" + points = props[0][-1].pop(2) + props[0][-1][2].insert(0, points) + else: + for p in props[0][-1]: + if isinstance(p, list): + p[3].pop(2) + p[3][2].insert(0, "NAME:Points") coefficients = self.odefinition_manager.ComputeCoreLossCoefficients( core_loss_model_type, self.mass_density.evaluated_value, props[0] ) @@ -2185,6 +2193,8 @@ def set_coreloss_at_frequency( """ if not isinstance(points_list_at_freq, dict): raise TypeError("Points list at frequency must be provided as a dictionary.") + if len(points_list_at_freq) <= 1 and core_loss_model_type == "Power Ferrite": + raise ValueError("At least 2 frequencies must be included.") freq_keys = list(points_list_at_freq.keys()) for i in range(0, len(freq_keys)): if isinstance(freq_keys[i], str): @@ -2194,9 +2204,8 @@ def set_coreloss_at_frequency( points_list_at_freq[value] = points_list_at_freq[freq_keys[i]] del points_list_at_freq[freq_keys[i]] if "core_loss_type" not in self._props: - self._props["core_loss_type"] = OrderedDict( - {"property_type": "ChoiceProperty", "Choice": "Electrical Steel"} - ) + choice = "Electrical Steel" if core_loss_model_type == "Electrical Steel" else "Power Ferrite" + self._props["core_loss_type"] = OrderedDict({"property_type": "ChoiceProperty", "Choice": choice}) else: self._props.pop("core_loss_cm", None) self._props.pop("core_loss_x", None) @@ -2221,7 +2230,7 @@ def set_coreloss_at_frequency( elif len(points_list_at_freq) > 1: self._props["AttachedData"]["CoreLossMultiCurveData"] = OrderedDict({}) self._props["AttachedData"]["CoreLossMultiCurveData"]["property_data"] = "coreloss_multi_curve_data" - self._props["AttachedData"]["CoreLossMultiCurveData"]["coreloss_unit"] = "w_per_cubic_meter" + self._props["AttachedData"]["CoreLossMultiCurveData"]["coreloss_unit"] = coefficient_setup self._props["AttachedData"]["CoreLossMultiCurveData"]["AllCurves"] = OrderedDict({}) self._props["AttachedData"]["CoreLossMultiCurveData"]["AllCurves"]["OneCurve"] = [] @@ -2238,9 +2247,14 @@ def set_coreloss_at_frequency( coefficients = self.get_core_loss_coefficients( points_list_at_freq, thickness=thickness, conductivity=conductivity ) - self._props["core_loss_kh"] = str(coefficients[0]) - self._props["core_loss_kc"] = str(coefficients[1]) - self._props["core_loss_ke"] = str(coefficients[2]) + if core_loss_model_type == "Electrical Steel": + self._props["core_loss_kh"] = str(coefficients[0]) + self._props["core_loss_kc"] = str(coefficients[1]) + self._props["core_loss_ke"] = str(coefficients[2]) + else: + self._props["core_loss_cm"] = str(coefficients[0]) + self._props["core_loss_x"] = str(coefficients[1]) + self._props["core_loss_y"] = str(coefficients[2]) self._props["core_loss_kdc"] = str(kdc) self._props["core_loss_equiv_cut_depth"] = cut_depth return self.update()