Skip to content

Commit 2a62fa5

Browse files
gmalinvepre-commit-ci[bot]PipKatMaxJPReySamuelopez-ansys
authored
Core loss electrical steel (#3829)
* 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]>
1 parent 69cbff1 commit 2a62fa5

File tree

2 files changed

+381
-13
lines changed

2 files changed

+381
-13
lines changed

_unittest/test_03_Materials.py

Lines changed: 107 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_02_create_material(self):
8282

8383
assert mat1.set_electrical_steel_coreloss(1, 2, 3, 4, 0.002)
8484
assert mat1.get_curve_coreloss_type() == "Electrical Steel"
85-
assert mat1.get_curve_coreloss_values()["core_loss_equiv_cut_depth"] == "0.002meter"
85+
assert mat1.get_curve_coreloss_values()["core_loss_equiv_cut_depth"] == 0.002
8686
assert mat1.set_hysteresis_coreloss(1, 2, 3, 4, 0.002)
8787
assert mat1.get_curve_coreloss_type() == "Hysteresis Model"
8888
assert mat1.set_bp_curve_coreloss([[0, 0], [10, 10], [20, 20]])
@@ -210,7 +210,7 @@ def test_08B_import_materials_from_excel(self):
210210
assert len(mats) == 2
211211

212212
def test_09_non_linear_materials(self, add_app):
213-
app = add_app(application=Maxwell3d)
213+
app = add_app(application=Maxwell3d, solution_type="Transient")
214214
mat1 = app.materials.add_material("myMat")
215215
mat1.permeability = [[0, 0], [1, 12], [10, 30]]
216216
mat1.permittivity = [[0, 0], [2, 12], [10, 30]]
@@ -274,3 +274,108 @@ def test_13_get_materials_in_project(self):
274274
assert isinstance(used_materials, list)
275275
for m in [mat for mat in self.aedtapp.materials if mat.is_used]:
276276
assert m.name in used_materials
277+
278+
def test_14_get_coreloss_coefficients(self):
279+
mat = self.aedtapp.materials.add_material("mat_test")
280+
# Test points_list_at_freq
281+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
282+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}
283+
)
284+
assert isinstance(coeff, list)
285+
assert len(coeff) == 3
286+
assert all(isinstance(c, float) for c in coeff)
287+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
288+
points_list_at_freq={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
289+
)
290+
assert isinstance(coeff, list)
291+
assert len(coeff) == 3
292+
assert all(isinstance(c, float) for c in coeff)
293+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
294+
points_list_at_freq={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
295+
)
296+
assert isinstance(coeff, list)
297+
assert len(coeff) == 3
298+
assert all(isinstance(c, float) for c in coeff)
299+
try:
300+
self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
301+
points_list_at_freq=[[0, 0], [1, 3.5], [2, 7.4]]
302+
)
303+
assert False
304+
except TypeError:
305+
assert True
306+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
307+
points_list_at_freq={
308+
60: [[0, 0], [1, 3.5], [2, 7.4]],
309+
100: [[0, 0], [1, 8], [2, 9]],
310+
150: [[0, 0], [1, 10], [2, 19]],
311+
}
312+
)
313+
assert isinstance(coeff, list)
314+
assert len(coeff) == 3
315+
assert all(isinstance(c, float) for c in coeff)
316+
# Test thickness
317+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
318+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm"
319+
)
320+
assert isinstance(coeff, list)
321+
assert len(coeff) == 3
322+
assert all(isinstance(c, float) for c in coeff)
323+
try:
324+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
325+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid"
326+
)
327+
assert False
328+
except TypeError:
329+
assert True
330+
try:
331+
coeff = self.aedtapp.materials["mat_test"].get_core_loss_coefficients(
332+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50
333+
)
334+
assert False
335+
except TypeError:
336+
assert True
337+
338+
def test_14_set_core_loss(self):
339+
mat = self.aedtapp.materials["mat_test"]
340+
# Test points_list_at_freq
341+
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
342+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}
343+
)
344+
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
345+
points_list_at_freq={"60Hz": [[0, 0], [1, 3.5], [2, 7.4]]}
346+
)
347+
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
348+
points_list_at_freq={"0.06kHz": [[0, 0], [1, 3.5], [2, 7.4]]}
349+
)
350+
try:
351+
self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
352+
points_list_at_freq=[[0, 0], [1, 3.5], [2, 7.4]]
353+
)
354+
assert False
355+
except TypeError:
356+
assert True
357+
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
358+
points_list_at_freq={
359+
60: [[0, 0], [1, 3.5], [2, 7.4]],
360+
100: [[0, 0], [1, 8], [2, 9]],
361+
150: [[0, 0], [1, 10], [2, 19]],
362+
}
363+
)
364+
# Test thickness
365+
assert self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
366+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="0.6mm"
367+
)
368+
try:
369+
coeff = self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
370+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness="invalid"
371+
)
372+
assert False
373+
except TypeError:
374+
assert True
375+
try:
376+
coeff = self.aedtapp.materials["mat_test"].set_coreloss_at_frequency(
377+
points_list_at_freq={60: [[0, 0], [1, 3.5], [2, 7.4]]}, thickness=50
378+
)
379+
assert False
380+
except TypeError:
381+
assert True

0 commit comments

Comments
 (0)