Skip to content

Commit

Permalink
Core loss electrical steel (#3829)
Browse files Browse the repository at this point in the history
* enhance core loss electrical steel

* implement core losses

* fix

* set_electrical_steel core losses with coefficients

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* remove imports

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add get coreloss coefficients test

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* set core loss test implement

* Update pyaedt/modules/Material.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modules/Material.py

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modules/Material.py

Co-authored-by: Kathy Pippert <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestions from code review

Co-authored-by: Kathy Pippert <[email protected]>

* Update pyaedt/modules/Material.py

Co-authored-by: Kathy Pippert <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update pyaedt/modules/Material.py

Co-authored-by: Kathy Pippert <[email protected]>

* fix comments review

* Apply suggestions from code review

Co-authored-by: Maxime Rey <[email protected]>

* fix comments review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix comments review

* fix docstring

* Fix return list

* fix regression error

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Kathy Pippert <[email protected]>
Co-authored-by: Maxime Rey <[email protected]>
Co-authored-by: Samuelopez-ansys <[email protected]>
  • Loading branch information
5 people authored Nov 23, 2023
1 parent 69cbff1 commit 2a62fa5
Show file tree
Hide file tree
Showing 2 changed files with 381 additions and 13 deletions.
109 changes: 107 additions & 2 deletions _unittest/test_03_Materials.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_02_create_material(self):

assert mat1.set_electrical_steel_coreloss(1, 2, 3, 4, 0.002)
assert mat1.get_curve_coreloss_type() == "Electrical Steel"
assert mat1.get_curve_coreloss_values()["core_loss_equiv_cut_depth"] == "0.002meter"
assert mat1.get_curve_coreloss_values()["core_loss_equiv_cut_depth"] == 0.002
assert mat1.set_hysteresis_coreloss(1, 2, 3, 4, 0.002)
assert mat1.get_curve_coreloss_type() == "Hysteresis Model"
assert mat1.set_bp_curve_coreloss([[0, 0], [10, 10], [20, 20]])
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_08B_import_materials_from_excel(self):
assert len(mats) == 2

def test_09_non_linear_materials(self, add_app):
app = add_app(application=Maxwell3d)
app = add_app(application=Maxwell3d, solution_type="Transient")
mat1 = app.materials.add_material("myMat")
mat1.permeability = [[0, 0], [1, 12], [10, 30]]
mat1.permittivity = [[0, 0], [2, 12], [10, 30]]
Expand Down Expand Up @@ -274,3 +274,108 @@ def test_13_get_materials_in_project(self):
assert isinstance(used_materials, list)
for m in [mat for mat in self.aedtapp.materials if mat.is_used]:
assert m.name in used_materials

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]]}
)
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]]}
)
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]]}
)
assert isinstance(coeff, list)
assert len(coeff) == 3
assert all(isinstance(c, float) for c in coeff)
try:
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]],
100: [[0, 0], [1, 8], [2, 9]],
150: [[0, 0], [1, 10], [2, 19]],
}
)
assert isinstance(coeff, list)
assert len(coeff) == 3
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"
)
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(
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(
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"]
# 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]]}
)
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
points_list_at_freq={"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]]}
)
try:
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]],
100: [[0, 0], [1, 8], [2, 9]],
150: [[0, 0], [1, 10], [2, 19]],
}
)
# 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(
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(
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50
)
assert False
except TypeError:
assert True
Loading

0 comments on commit 2a62fa5

Please sign in to comment.