Skip to content

Commit 32ae60f

Browse files
authored
Merge pull request #230 from EOMYS-Public/FEMM
[CO] Move store method from Magnetic models to OutMag object
2 parents f402a4b + 536f3dc commit 32ae60f

File tree

23 files changed

+152
-270
lines changed

23 files changed

+152
-270
lines changed

Tests/GUI/DMachineSetup/test_SMHoleMag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,11 @@ def test_s_plot(self, setup):
421421
setup["widget"] = SMHoleMag(
422422
machine=setup["test_obj"], matlib=setup["matlib"], is_stator=False
423423
)
424-
setup["widget"].s_plot()
424+
setup["widget"].s_plot(is_show_fig=False)
425425

426426
assert setup["widget"].machine.rotor.hole[0].Zh == 8
427427

428428
setup["widget"].machine.rotor.hole[0].W1 = 0.300
429-
setup["widget"].s_plot()
429+
setup["widget"].s_plot(is_show_fig=False)
430430

431431
assert setup["widget"].out_hole_pitch.text() == "Slot pitch = 360 / 2p = 45 °"

Tests/GUI/DMatLib/test_Workflow_Matlib.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ def setup(self):
6767

6868
self.app.quit()
6969

70+
topLevelWidgets = QtWidgets.QApplication.topLevelWidgets()
71+
for widget in topLevelWidgets:
72+
widget.close()
73+
7074
if is_clean_result:
7175
rmtree(work_path)
7276

@@ -174,6 +178,8 @@ def test_init(self, setup):
174178
self.widget.tab_hole.widget(0).w_hole.w_mat_1.mat_win.mat_win.mat.elec.rho
175179
== 1234.56789
176180
)
181+
182+
self.app.exit()
177183
# Close the Edit GUI and check Matlib modification
178184

179185
# Doesn't Work

pyleecan/Classes/Class_Dict.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4255,8 +4255,7 @@
42554255
"get_meshsolution",
42564256
"get_path_save_fea",
42574257
"get_path_save",
4258-
"comp_axes",
4259-
"store_output"
4258+
"comp_axes"
42604259
],
42614260
"mother": "Magnetics",
42624261
"name": "MagElmer",
@@ -4381,9 +4380,7 @@
43814380
"get_meshsolution",
43824381
"get_path_save_fem",
43834382
"build_meshsolution",
4384-
"solve_FEMM_parallel",
4385-
"comp_axes",
4386-
"store_output"
4383+
"solve_FEMM_parallel"
43874384
],
43884385
"mother": "Magnetics",
43894386
"name": "MagFEMM",
@@ -4430,7 +4427,7 @@
44304427
"desc": "To enforce user-defined values for FEMM main parameters ",
44314428
"max": "",
44324429
"min": "",
4433-
"name": "FEMM_dict",
4430+
"name": "FEMM_dict_enforced",
44344431
"type": "dict",
44354432
"unit": "",
44364433
"value": ""
@@ -4894,8 +4891,7 @@
48944891
"is_internal": false,
48954892
"methods": [
48964893
"run",
4897-
"comp_axes",
4898-
"store_output"
4894+
"comp_axes"
48994895
],
49004896
"mother": "",
49014897
"name": "Magnetics",
@@ -6655,7 +6651,8 @@
66556651
"desc": "Gather the magnetic module outputs",
66566652
"is_internal": false,
66576653
"methods": [
6658-
"comp_emf"
6654+
"comp_emf",
6655+
"store"
66596656
],
66606657
"mother": "",
66616658
"name": "OutMag",

pyleecan/Classes/MagElmer.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@
4646
except ImportError as error:
4747
comp_axes = error
4848

49-
try:
50-
from ..Methods.Simulation.MagElmer.store_output import store_output
51-
except ImportError as error:
52-
store_output = error
53-
5449

5550
from ._check import InitUnKnowClassError
5651
from .DXFImport import DXFImport
@@ -127,17 +122,6 @@ class MagElmer(Magnetics):
127122
)
128123
else:
129124
comp_axes = comp_axes
130-
# cf Methods.Simulation.MagElmer.store_output
131-
if isinstance(store_output, ImportError):
132-
store_output = property(
133-
fget=lambda x: raise_(
134-
ImportError(
135-
"Can't use MagElmer method store_output: " + str(store_output)
136-
)
137-
)
138-
)
139-
else:
140-
store_output = store_output
141125
# save and copy methods are available in all object
142126
save = save
143127
copy = copy

pyleecan/Classes/MagFEMM.py

Lines changed: 21 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,6 @@
5151
except ImportError as error:
5252
solve_FEMM_parallel = error
5353

54-
try:
55-
from ..Methods.Simulation.MagFEMM.comp_axes import comp_axes
56-
except ImportError as error:
57-
comp_axes = error
58-
59-
try:
60-
from ..Methods.Simulation.MagFEMM.store_output import store_output
61-
except ImportError as error:
62-
store_output = error
63-
6454

6555
from ._check import InitUnKnowClassError
6656
from .DXFImport import DXFImport
@@ -152,26 +142,6 @@ class MagFEMM(Magnetics):
152142
)
153143
else:
154144
solve_FEMM_parallel = solve_FEMM_parallel
155-
# cf Methods.Simulation.MagFEMM.comp_axes
156-
if isinstance(comp_axes, ImportError):
157-
comp_axes = property(
158-
fget=lambda x: raise_(
159-
ImportError("Can't use MagFEMM method comp_axes: " + str(comp_axes))
160-
)
161-
)
162-
else:
163-
comp_axes = comp_axes
164-
# cf Methods.Simulation.MagFEMM.store_output
165-
if isinstance(store_output, ImportError):
166-
store_output = property(
167-
fget=lambda x: raise_(
168-
ImportError(
169-
"Can't use MagFEMM method store_output: " + str(store_output)
170-
)
171-
)
172-
)
173-
else:
174-
store_output = store_output
175145
# save and copy methods are available in all object
176146
save = save
177147
copy = copy
@@ -184,7 +154,7 @@ def __init__(
184154
Kgeo_fineness=1,
185155
type_calc_leakage=0,
186156
file_name="",
187-
FEMM_dict=-1,
157+
FEMM_dict_enforced=-1,
188158
is_get_mesh=False,
189159
is_save_FEA=False,
190160
is_sliding_band=True,
@@ -231,8 +201,8 @@ def __init__(
231201
type_calc_leakage = init_dict["type_calc_leakage"]
232202
if "file_name" in list(init_dict.keys()):
233203
file_name = init_dict["file_name"]
234-
if "FEMM_dict" in list(init_dict.keys()):
235-
FEMM_dict = init_dict["FEMM_dict"]
204+
if "FEMM_dict_enforced" in list(init_dict.keys()):
205+
FEMM_dict_enforced = init_dict["FEMM_dict_enforced"]
236206
if "is_get_mesh" in list(init_dict.keys()):
237207
is_get_mesh = init_dict["is_get_mesh"]
238208
if "is_save_FEA" in list(init_dict.keys()):
@@ -278,7 +248,7 @@ def __init__(
278248
self.Kgeo_fineness = Kgeo_fineness
279249
self.type_calc_leakage = type_calc_leakage
280250
self.file_name = file_name
281-
self.FEMM_dict = FEMM_dict
251+
self.FEMM_dict_enforced = FEMM_dict_enforced
282252
self.is_get_mesh = is_get_mesh
283253
self.is_save_FEA = is_save_FEA
284254
self.is_sliding_band = is_sliding_band
@@ -315,7 +285,7 @@ def __str__(self):
315285
MagFEMM_str += "Kgeo_fineness = " + str(self.Kgeo_fineness) + linesep
316286
MagFEMM_str += "type_calc_leakage = " + str(self.type_calc_leakage) + linesep
317287
MagFEMM_str += 'file_name = "' + str(self.file_name) + '"' + linesep
318-
MagFEMM_str += "FEMM_dict = " + str(self.FEMM_dict) + linesep
288+
MagFEMM_str += "FEMM_dict_enforced = " + str(self.FEMM_dict_enforced) + linesep
319289
MagFEMM_str += "is_get_mesh = " + str(self.is_get_mesh) + linesep
320290
MagFEMM_str += "is_save_FEA = " + str(self.is_save_FEA) + linesep
321291
MagFEMM_str += "is_sliding_band = " + str(self.is_sliding_band) + linesep
@@ -359,7 +329,7 @@ def __eq__(self, other):
359329
return False
360330
if other.file_name != self.file_name:
361331
return False
362-
if other.FEMM_dict != self.FEMM_dict:
332+
if other.FEMM_dict_enforced != self.FEMM_dict_enforced:
363333
return False
364334
if other.is_get_mesh != self.is_get_mesh:
365335
return False
@@ -390,8 +360,10 @@ def as_dict(self):
390360
MagFEMM_dict["Kgeo_fineness"] = self.Kgeo_fineness
391361
MagFEMM_dict["type_calc_leakage"] = self.type_calc_leakage
392362
MagFEMM_dict["file_name"] = self.file_name
393-
MagFEMM_dict["FEMM_dict"] = (
394-
self.FEMM_dict.copy() if self.FEMM_dict is not None else None
363+
MagFEMM_dict["FEMM_dict_enforced"] = (
364+
self.FEMM_dict_enforced.copy()
365+
if self.FEMM_dict_enforced is not None
366+
else None
395367
)
396368
MagFEMM_dict["is_get_mesh"] = self.is_get_mesh
397369
MagFEMM_dict["is_save_FEA"] = self.is_save_FEA
@@ -422,7 +394,7 @@ def _set_None(self):
422394
self.Kgeo_fineness = None
423395
self.type_calc_leakage = None
424396
self.file_name = None
425-
self.FEMM_dict = None
397+
self.FEMM_dict_enforced = None
426398
self.is_get_mesh = None
427399
self.is_save_FEA = None
428400
self.is_sliding_band = None
@@ -511,20 +483,20 @@ def _set_file_name(self, value):
511483
""",
512484
)
513485

514-
def _get_FEMM_dict(self):
515-
"""getter of FEMM_dict"""
516-
return self._FEMM_dict
486+
def _get_FEMM_dict_enforced(self):
487+
"""getter of FEMM_dict_enforced"""
488+
return self._FEMM_dict_enforced
517489

518-
def _set_FEMM_dict(self, value):
519-
"""setter of FEMM_dict"""
490+
def _set_FEMM_dict_enforced(self, value):
491+
"""setter of FEMM_dict_enforced"""
520492
if type(value) is int and value == -1:
521493
value = dict()
522-
check_var("FEMM_dict", value, "dict")
523-
self._FEMM_dict = value
494+
check_var("FEMM_dict_enforced", value, "dict")
495+
self._FEMM_dict_enforced = value
524496

525-
FEMM_dict = property(
526-
fget=_get_FEMM_dict,
527-
fset=_set_FEMM_dict,
497+
FEMM_dict_enforced = property(
498+
fget=_get_FEMM_dict_enforced,
499+
fset=_set_FEMM_dict_enforced,
528500
doc=u"""To enforce user-defined values for FEMM main parameters
529501
530502
:Type: dict

pyleecan/Classes/Magnetics.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626
except ImportError as error:
2727
comp_axes = error
2828

29-
try:
30-
from ..Methods.Simulation.Magnetics.store_output import store_output
31-
except ImportError as error:
32-
store_output = error
33-
3429

3530
from ._check import InitUnKnowClassError
3631

@@ -59,17 +54,6 @@ class Magnetics(FrozenClass):
5954
)
6055
else:
6156
comp_axes = comp_axes
62-
# cf Methods.Simulation.Magnetics.store_output
63-
if isinstance(store_output, ImportError):
64-
store_output = property(
65-
fget=lambda x: raise_(
66-
ImportError(
67-
"Can't use Magnetics method store_output: " + str(store_output)
68-
)
69-
)
70-
)
71-
else:
72-
store_output = store_output
7357
# save and copy methods are available in all object
7458
save = save
7559
copy = copy

pyleecan/Classes/OutMag.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
except ImportError as error:
2222
comp_emf = error
2323

24+
try:
25+
from ..Methods.Output.OutMag.store import store
26+
except ImportError as error:
27+
store = error
28+
2429

2530
from ._check import InitUnKnowClassError
2631
from .MeshSolution import MeshSolution
@@ -31,6 +36,7 @@ class OutMag(FrozenClass):
3136

3237
VERSION = 1
3338

39+
# Check ImportError to remove unnecessary dependencies in unused method
3440
# cf Methods.Output.OutMag.comp_emf
3541
if isinstance(comp_emf, ImportError):
3642
comp_emf = property(
@@ -40,6 +46,15 @@ class OutMag(FrozenClass):
4046
)
4147
else:
4248
comp_emf = comp_emf
49+
# cf Methods.Output.OutMag.store
50+
if isinstance(store, ImportError):
51+
store = property(
52+
fget=lambda x: raise_(
53+
ImportError("Can't use OutMag method store: " + str(store))
54+
)
55+
)
56+
else:
57+
store = store
4358
# save and copy methods are available in all object
4459
save = save
4560
copy = copy

pyleecan/GUI/Dialog/DMachineSetup/SMHoleMag/SMHoleMag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def s_remove(self):
141141
self.tab_hole.removeTab(len(self.obj.hole) - 1)
142142
self.obj.hole.pop(-1)
143143

144-
def s_plot(self):
144+
def s_plot(self, is_show_fig=True):
145145
"""Try to plot the lamination
146146
147147
Parameters
@@ -160,7 +160,7 @@ def s_plot(self):
160160
if error: # Error => Display it
161161
QMessageBox().critical(self, self.tr("Error"), error)
162162
else: # No error => Plot the hole (No winding for LamSquirrelCage)
163-
self.machine.plot()
163+
self.machine.plot(is_show_fig=is_show_fig)
164164

165165
@staticmethod
166166
def check(lamination):

pyleecan/Generator/ClassesRef/Output/OutMag.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Variable name,Unit,Description (EN),Size,Type,Default value,Minimum value,Maximum value,,Package,Inherit,Methods,Constant Name,Constant Value,Class description
22
Time,s,Magnetic time Data object,Nt_tot,SciDataTool.Classes.DataND.Data,None,,,,Output,,comp_emf,VERSION,1,Gather the magnetic module outputs
3-
Angle,rad,Magnetic position Data object,Na_tot,SciDataTool.Classes.DataND.Data,None,,,,,,,,,
3+
Angle,rad,Magnetic position Data object,Na_tot,SciDataTool.Classes.DataND.Data,None,,,,,,store,,,
44
B,H,Airgap flux density VectorField object,"(Nt_tot,Na_tot)",SciDataTool.Classes.VectorField.VectorField,None,,,,,,,,,
55
Tem,N.m,Electromagnetic torque DataTime object,Nt_tot,SciDataTool.Classes.DataND.DataND,None,,,,,,,,,
66
Tem_av,N.m,Average Electromagnetic torque,,float,None,,,,,,,,,

pyleecan/Generator/ClassesRef/Simulation/MagElmer.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ file_name,,Name of the file to save the Elmer model,0,str,,,,,,,get_meshsolution
55
FEA_dict,,To enforce user-defined values for Elmer main parameters ,0,dict,,,,,,,get_path_save_fea,,,,
66
is_get_mesh,,To save FEA mesh for latter post-procesing ,0,bool,0,,,,,,get_path_save,,,,
77
is_save_FEA,,To save FEA mesh and solution in a file,0,bool,0,,,,,,comp_axes,,,,
8-
transform_list,,"List of dictionnary to apply transformation on the machine surfaces. Key: label (to select the surface), type (rotate or translate), value (alpha or delta)",0,list,[],,,,,,store_output,,,,
8+
transform_list,,"List of dictionnary to apply transformation on the machine surfaces. Key: label (to select the surface), type (rotate or translate), value (alpha or delta)",0,list,[],,,,,,,,,,
99
rotor_dxf,,To use a dxf version of the rotor instead of build_geometry,,DXFImport,None,,,,,,,,,,
1010
stator_dxf,,To use a dxf version of the rotor instead of build_geometry,,DXFImport,None,,,,,,,,,,
1111
import_file,,To import an existing simulation file,0,str,,,,,,,,,,,

0 commit comments

Comments
 (0)