Skip to content

Commit

Permalink
Refactoring arguments in Material Class (#4535)
Browse files Browse the repository at this point in the history
Co-authored-by: maxcapodi78 <Shark78>
Co-authored-by: Samuel Lopez <[email protected]>
  • Loading branch information
maxcapodi78 and Samuelopez-ansys authored Apr 18, 2024
1 parent e03436c commit 85bd251
Show file tree
Hide file tree
Showing 7 changed files with 175 additions and 174 deletions.
36 changes: 18 additions & 18 deletions _unittest/test_03_Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,29 +290,29 @@ def test_14_get_coreloss_coefficients(self):
mat = self.aedtapp.materials.add_material("mat_test")
# Test points_list_at_freq
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}
)
assert isinstance(coeff, list)
assert len(coeff) == 3
assert all(isinstance(c, float) for c in coeff)
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
points_list_at_freq={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
)
assert isinstance(coeff, list)
assert len(coeff) == 3
assert all(isinstance(c, float) for c in coeff)
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
points_list_at_freq={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
)
assert isinstance(coeff, list)
assert len(coeff) == 3
assert all(isinstance(c, float) for c in coeff)
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]]
points_at_frequency=[[0, 0], [1, 3.5], [2, 7.4]]
)
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
points_list_at_freq={
points_at_frequency={
60: [[0, 0], [1, 3.5], [2, 7.4]],
100: [[0, 0], [1, 8], [2, 9]],
150: [[0, 0], [1, 10], [2, 19]],
Expand All @@ -323,45 +323,45 @@ def test_14_get_coreloss_coefficients(self):
assert all(isinstance(c, float) for c in coeff)
# Test thickness
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm"
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm"
)
assert isinstance(coeff, list)
assert len(coeff) == 3
assert all(isinstance(c, float) for c in coeff)
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"
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid"
)
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
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50
)

def test_14_set_core_loss(self):
mat = self.aedtapp.materials["mat_test"]
# Test points_list_at_freq
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}
)
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
)
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
points_at_frequency={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
)
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]]
points_at_frequency=[[0, 0], [1, 3.5], [2, 7.4]]
)
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={
points_at_frequency={
60: [[0, 0], [1, 3.5], [2, 7.4]],
100: [[0, 0], [1, 8], [2, 9]],
150: [[0, 0], [1, 10], [2, 19]],
}
)
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={
points_at_frequency={
60: [[0, 0], [1, 3.5], [2, 7.4]],
100: [[0, 0], [1, 8], [2, 9]],
150: [[0, 0], [1, 10], [2, 19]],
Expand All @@ -370,17 +370,17 @@ def test_14_set_core_loss(self):
)
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"
points_at_frequency={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"
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm"
)
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"
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid"
)
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
points_at_frequency={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50
)
2 changes: 1 addition & 1 deletion _unittest/test_13_LoadAEDTFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_07_load_material_file(self):
def test_08_add_material_from_amat(self, mat1):
mat_file = os.path.join(local_path, "example_models", test_subfolder, "material_sample.amat")
dd = load_entire_aedt_file(mat_file)
newmat = mat1.materials.add_material("foe_mat", props=dd["mat_example_1"])
newmat = mat1.materials.add_material("foe_mat", properties=dd["mat_example_1"])
assert newmat.conductivity.value == "1100000"
assert newmat.thermal_conductivity.value == "13.8"
assert newmat.mass_density.value == "8055"
Expand Down
2 changes: 1 addition & 1 deletion _unittest/test_28_Maxwell3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def test_36_set_bp_curve_loss(self):
[[0, 0], [0.6, 1.57], [1.0, 4.44], [1.5, 20.562], [2.1, 44.23]],
kdc=0.002,
cut_depth=0.0009,
punit="w/kg",
units="w/kg",
bunit="tesla",
frequency=50,
thickness="0.5mm",
Expand Down
2 changes: 1 addition & 1 deletion examples/03-Maxwell/Maxwell_Transformer_Coreloss.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
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,
coefficients = m3d.materials[mat.name].get_core_loss_coefficients(points_at_frequency=pv,
coefficient_setup="kw_per_cubic_meter")

###################################################################################
Expand Down
2 changes: 1 addition & 1 deletion pyaedt/modeler/advanced_cad/stackup_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def duplicate_parametrize_material(
if duplicated_material.name == cloned_material_name: # return that material.
return duplicated_material
duplicated_material = self._app.materials.duplicate_material(
material_name, cloned_material_name, props=list_of_properties
material_name, cloned_material_name, properties=list_of_properties
)
# duplicated_material = DuplicatedParametrizedMaterial(
# application, material_name, cloned_material_name, list_of_properties
Expand Down
Loading

0 comments on commit 85bd251

Please sign in to comment.