femagtools 1.6.7__py3-none-any.whl → 1.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- femagtools/__init__.py +2 -2
- femagtools/bch.py +1 -1
- femagtools/dxfsl/area.py +334 -332
- femagtools/dxfsl/areabuilder.py +131 -10
- femagtools/dxfsl/conv.py +27 -9
- femagtools/dxfsl/converter.py +390 -125
- femagtools/dxfsl/corner.py +3 -0
- femagtools/dxfsl/femparser.py +1 -1
- femagtools/dxfsl/fslrenderer.py +290 -246
- femagtools/dxfsl/functions.py +4 -2
- femagtools/dxfsl/geom.py +1120 -886
- femagtools/dxfsl/journal.py +53 -22
- femagtools/dxfsl/machine.py +250 -74
- femagtools/dxfsl/plotrenderer.py +34 -3
- femagtools/dxfsl/shape.py +380 -103
- femagtools/dxfsl/symmetry.py +679 -110
- femagtools/femag.py +27 -2
- femagtools/forcedens.py +65 -40
- femagtools/fsl.py +71 -28
- femagtools/losscoeffs.py +46 -0
- femagtools/machine/effloss.py +8 -1
- femagtools/machine/im.py +3 -1
- femagtools/machine/pm.py +12 -11
- femagtools/machine/sizing.py +14 -11
- femagtools/machine/sm.py +114 -33
- femagtools/machine/utils.py +38 -34
- femagtools/model.py +12 -2
- femagtools/moo/population.py +1 -1
- femagtools/parstudy.py +17 -1
- femagtools/plot/__init__.py +1 -1
- femagtools/plot/char.py +24 -7
- femagtools/plot/forcedens.py +56 -29
- femagtools/plot/mcv.py +4 -1
- femagtools/plot/phasor.py +6 -1
- femagtools/poc.py +17 -10
- femagtools/templates/cogg_calc.mako +7 -1
- femagtools/templates/displ_stator_rotor.mako +33 -0
- femagtools/templates/fieldcalc.mako +10 -16
- femagtools/templates/pm_sym_f_cur.mako +1 -1
- femagtools/tks.py +3 -9
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/LICENSE +1 -0
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/METADATA +7 -4
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/RECORD +50 -49
- tests/engines/__init__.py +0 -20
- tests/geom/__init__.py +0 -20
- tests/moo/__init__.py +0 -20
- tests/test_model.py +8 -1
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/WHEEL +0 -0
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/entry_points.txt +0 -0
- {femagtools-1.6.7.dist-info → femagtools-1.7.0.dist-info}/top_level.txt +0 -0
femagtools/dxfsl/converter.py
CHANGED
@@ -1,18 +1,39 @@
|
|
1
1
|
"""read a dxf file and create a plot or fsl file
|
2
2
|
|
3
3
|
"""
|
4
|
+
import os
|
4
5
|
from pathlib import Path
|
5
6
|
from femagtools.dxfsl.geom import Geometry
|
6
7
|
from femagtools.dxfsl.shape import Shape
|
7
8
|
from femagtools.dxfsl.fslrenderer import FslRenderer, agndst
|
8
9
|
from femagtools.dxfsl.plotrenderer import PlotRenderer
|
9
|
-
from femagtools.dxfsl.
|
10
|
+
from femagtools.dxfsl.concat import Concatenation
|
11
|
+
from femagtools.dxfsl.functions import Timer, middle_angle
|
12
|
+
from femagtools.dxfsl.journal import Journal, getJournal
|
10
13
|
import logging
|
11
14
|
import logging.config
|
12
15
|
import numpy as np
|
13
16
|
import sys
|
14
17
|
|
15
18
|
logger = logging.getLogger(__name__)
|
19
|
+
journal = None
|
20
|
+
|
21
|
+
|
22
|
+
def plot_geom(doit, plt, geom, title="Plot", areas=True):
|
23
|
+
if not doit:
|
24
|
+
return
|
25
|
+
|
26
|
+
logger.info("Prepare Plot %s", title)
|
27
|
+
plt.render_elements(geom, Shape,
|
28
|
+
draw_inside=areas,
|
29
|
+
title=title,
|
30
|
+
show=True,
|
31
|
+
with_corners=True,
|
32
|
+
with_nodes=False,
|
33
|
+
neighbors=True,
|
34
|
+
write_id=areas,
|
35
|
+
with_legend=False,
|
36
|
+
fill_areas=areas)
|
16
37
|
|
17
38
|
|
18
39
|
def symmetry_search(machine,
|
@@ -48,16 +69,16 @@ def symmetry_search(machine,
|
|
48
69
|
logger.info("*** End of symmetry search for %s ***", kind)
|
49
70
|
return machine_ok
|
50
71
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
72
|
+
plot_geom(False, # for developer
|
73
|
+
plt, machine.geom,
|
74
|
+
title="Before Symmetry ({})".format(kind))
|
75
|
+
|
76
|
+
if machine.find_symmetry(symtol, is_inner, is_outer, None):
|
77
|
+
logger.info(" - {}: symmetry axis found".format(kind))
|
78
|
+
plot_geom(False, # for developer
|
79
|
+
plt, machine.geom,
|
80
|
+
title="Symmetry found")
|
55
81
|
|
56
|
-
machine_mirror = machine.get_symmetry_mirror()
|
57
|
-
machine_slice = machine
|
58
|
-
machine_slice.set_alfa_and_corners()
|
59
|
-
else:
|
60
|
-
logger.info(" - {}: symmetry axis found !!".format(kind))
|
61
82
|
if show_plots:
|
62
83
|
plt.render_elements(machine.geom, Shape,
|
63
84
|
title=kind+' (symmetrylines)',
|
@@ -69,20 +90,50 @@ def symmetry_search(machine,
|
|
69
90
|
logger.info(" - no slice extracted ?!?")
|
70
91
|
return machine
|
71
92
|
|
72
|
-
|
93
|
+
plot_geom(False, # for developer
|
94
|
+
plt, machine_slice.geom,
|
95
|
+
title="Slice of {}".format(kind))
|
96
|
+
|
97
|
+
# no third after slice
|
98
|
+
machine_mirror = machine_slice.get_symmetry_mirror(no_third=True)
|
99
|
+
|
100
|
+
if machine_mirror is not None:
|
101
|
+
machine_mirror.set_kind(kind)
|
102
|
+
logger.info("*** End of symmetry search for %s (symmetry and mirror) ***", kind)
|
103
|
+
return machine_mirror
|
104
|
+
|
105
|
+
machine_slice.set_kind(kind)
|
106
|
+
logger.info("*** End of symmetry search for %s (symmetry) ***", kind)
|
107
|
+
return machine_slice
|
108
|
+
|
109
|
+
# --- no symmetry slice found ---
|
110
|
+
logger.info(" - {}: no symmetry axis found".format(kind))
|
111
|
+
if show_plots:
|
112
|
+
if debug_mode:
|
113
|
+
plt.render_elements(machine.geom, Shape,
|
114
|
+
title=kind+' (no symmetry axis)',
|
115
|
+
draw_inside=True,
|
116
|
+
neighbors=True,
|
117
|
+
rows=rows, cols=cols, num=num, show=False)
|
118
|
+
else:
|
119
|
+
plt.add_emptyplot(rows, cols, num, 'no symmetry axis')
|
120
|
+
|
121
|
+
if not machine.is_startangle_zero():
|
122
|
+
logger.debug("Rotate geometry to 0.0")
|
123
|
+
machine.rotate_to(0.0)
|
124
|
+
machine.set_alfa_and_corners()
|
125
|
+
|
126
|
+
machine_mirror = machine.get_symmetry_mirror()
|
127
|
+
machine_slice = machine
|
128
|
+
machine_slice.set_alfa_and_corners()
|
73
129
|
|
74
130
|
if machine_mirror is None:
|
75
131
|
logger.info(" - no mirror found")
|
76
|
-
if not machine_slice.is_startangle_zero():
|
77
|
-
machine_slice.rotate_to(0.0)
|
78
|
-
machine_slice.set_alfa_and_corners()
|
79
|
-
|
80
132
|
machine_ok = machine_slice
|
81
133
|
else:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
rows=rows, cols=cols, num=num, show=True)
|
134
|
+
plot_geom(False, # for developer
|
135
|
+
plt, machine_mirror.geom,
|
136
|
+
title="After Mirror ({})".format(kind))
|
86
137
|
|
87
138
|
logger.info(" - mirror found")
|
88
139
|
machine_next_mirror = machine_mirror.get_symmetry_mirror()
|
@@ -93,15 +144,107 @@ def symmetry_search(machine,
|
|
93
144
|
|
94
145
|
machine_ok = machine_mirror
|
95
146
|
|
147
|
+
if not machine_ok.is_startangle_zero():
|
148
|
+
logger.debug("Rotate geometry to 0.0")
|
149
|
+
machine_ok.rotate_to(0.0)
|
150
|
+
machine_ok.set_alfa_and_corners()
|
151
|
+
|
96
152
|
machine_ok.set_kind(kind)
|
97
153
|
|
98
154
|
logger.info("*** End of symmetry search for %s ***", kind)
|
99
155
|
return machine_ok
|
100
156
|
|
101
157
|
|
158
|
+
def build_machine_rotor(machine, inner, mindist, plt, single=False):
|
159
|
+
logger.debug("Begin of build_machine_rotor")
|
160
|
+
if machine.has_windings():
|
161
|
+
logger.debug("do nothing here with windings in rotor")
|
162
|
+
logger.debug("End of build_machine_rotor")
|
163
|
+
return machine
|
164
|
+
|
165
|
+
if machine.is_mirrored():
|
166
|
+
logger.debug("Rotor is mirrored")
|
167
|
+
machine_temp = machine.undo_mirror()
|
168
|
+
machine_temp.geom.set_rotor()
|
169
|
+
machine_temp.search_rotor_subregions(single=single)
|
170
|
+
else:
|
171
|
+
machine_temp = machine
|
172
|
+
|
173
|
+
midangle = middle_angle(machine_temp.startangle,
|
174
|
+
machine_temp.endangle)
|
175
|
+
|
176
|
+
plot_geom(False, # for developer
|
177
|
+
plt, machine_temp.geom,
|
178
|
+
title="Inner Rotor check magnets {}".format(midangle))
|
179
|
+
|
180
|
+
rebuild = False
|
181
|
+
if machine_temp.geom.magnets_in_the_middle(midangle):
|
182
|
+
logger.debug("Magnets cut")
|
183
|
+
rebuild = machine_temp.create_mirror_lines_outside_magnets()
|
184
|
+
else:
|
185
|
+
if machine.is_mirrored():
|
186
|
+
logger.debug("Back to the mirrored machine")
|
187
|
+
machine_temp = machine # undo
|
188
|
+
rebuild = machine_temp.create_inner_auxiliary_arcs()
|
189
|
+
else:
|
190
|
+
rebuild = machine_temp.create_mirror_lines_outside_magnets()
|
191
|
+
if rebuild:
|
192
|
+
machine_temp.geom.area_list = []
|
193
|
+
|
194
|
+
if machine_temp.create_auxiliary_lines():
|
195
|
+
logger.debug("Auxiliary Lines created: rebuild subregions")
|
196
|
+
rebuild = True
|
197
|
+
if rebuild:
|
198
|
+
machine_temp.rebuild_subregions(single=single)
|
199
|
+
|
200
|
+
machine_temp.geom.recalculate_magnet_orientation()
|
201
|
+
machine_temp.delete_tiny_elements(mindist)
|
202
|
+
if inner:
|
203
|
+
machine_temp.create_inner_corner_areas()
|
204
|
+
|
205
|
+
if not machine_temp.is_mirrored():
|
206
|
+
machine_temp.create_boundery_nodes()
|
207
|
+
|
208
|
+
plot_geom(False, # for developer
|
209
|
+
plt, machine_temp.geom,
|
210
|
+
title="Final Rotor")
|
211
|
+
logger.debug("End of build_machine_rotor")
|
212
|
+
return machine_temp
|
213
|
+
|
214
|
+
|
215
|
+
def build_machine_stator(machine, inner, mindist, plt, single=False):
|
216
|
+
logger.debug("Begin of build_machine_stator")
|
217
|
+
if not machine.geom.is_stator():
|
218
|
+
logger.debug("Rotor with windings")
|
219
|
+
|
220
|
+
if machine.has_mirrored_windings():
|
221
|
+
logger.debug("undo mirrored windings")
|
222
|
+
machine_temp = machine.undo_mirror()
|
223
|
+
machine_temp.geom.set_stator()
|
224
|
+
machine_temp.search_stator_subregions(single=single)
|
225
|
+
machine_temp.create_mirror_lines_outside_windings()
|
226
|
+
else:
|
227
|
+
machine_temp = machine
|
228
|
+
if machine_temp.create_auxiliary_lines():
|
229
|
+
machine_temp.rebuild_subregions(single=single)
|
230
|
+
|
231
|
+
machine_temp.delete_tiny_elements(mindist)
|
232
|
+
if inner:
|
233
|
+
machine_temp.create_inner_corner_areas()
|
234
|
+
|
235
|
+
if not machine_temp.is_mirrored():
|
236
|
+
machine_temp.create_boundery_nodes()
|
237
|
+
|
238
|
+
plot_geom(False, # for developer
|
239
|
+
plt, machine_temp.geom,
|
240
|
+
title="Final Stator")
|
241
|
+
logger.debug("End of build_machine_stator")
|
242
|
+
return machine_temp
|
243
|
+
|
244
|
+
|
102
245
|
def convert(dxfile,
|
103
|
-
rtol=1e-
|
104
|
-
atol=
|
246
|
+
rtol=1e-04,
|
247
|
+
atol=1e-03,
|
105
248
|
mindist=0.0,
|
106
249
|
symtol=0.001,
|
107
250
|
sympart=0,
|
@@ -118,17 +261,28 @@ def convert(dxfile,
|
|
118
261
|
view_korr=False,
|
119
262
|
show_plots=False,
|
120
263
|
show_areas=False,
|
264
|
+
small_plots=False,
|
121
265
|
write_fsl=True,
|
122
266
|
write_png=False,
|
123
267
|
write_id=False,
|
268
|
+
full_model=False,
|
124
269
|
debug_mode=False):
|
125
270
|
layers = ()
|
126
271
|
conv = {}
|
127
272
|
|
128
|
-
|
129
|
-
|
273
|
+
input_file = Path(dxfile)
|
274
|
+
basename = input_file.stem
|
275
|
+
if part:
|
276
|
+
logger.info("***** start processing %s *****", basename)
|
277
|
+
else:
|
278
|
+
logger.info("***** start processing %s *****", basename)
|
130
279
|
timer = Timer(start_it=True)
|
131
280
|
|
281
|
+
journal = getJournal(name='converter', aktiv=debug_mode)
|
282
|
+
journal.get_journal(input_file.name)
|
283
|
+
journal.put_filename(str(input_file.resolve()))
|
284
|
+
journal.put('success', False)
|
285
|
+
|
132
286
|
if part:
|
133
287
|
if part[0] not in ('rotor', 'stator'):
|
134
288
|
logger.error('FATAL: Parameter rotor or stator expected')
|
@@ -151,28 +305,44 @@ def convert(dxfile,
|
|
151
305
|
split_cpy = split
|
152
306
|
|
153
307
|
try:
|
154
|
-
if
|
308
|
+
if input_file.suffix in ['.fem', '.FEM']:
|
155
309
|
from .femparser import femshapes
|
156
310
|
basegeom = Geometry(femshapes(dxfile),
|
157
311
|
rtol=rtol,
|
158
312
|
atol=atol,
|
159
|
-
split=split_ini
|
160
|
-
|
313
|
+
split=split_ini,
|
314
|
+
concatenate=True,
|
315
|
+
connect=True,
|
316
|
+
delete=True,
|
317
|
+
adjust=True,
|
318
|
+
main=True)
|
319
|
+
elif input_file.suffix in ['.dxf', '.DXF']:
|
161
320
|
from .dxfparser import dxfshapes
|
162
321
|
basegeom = Geometry(dxfshapes(dxfile,
|
163
322
|
mindist=mindist,
|
164
323
|
layers=layers),
|
165
324
|
rtol=rtol,
|
166
325
|
atol=atol,
|
167
|
-
split=split_ini
|
168
|
-
|
326
|
+
split=split_ini,
|
327
|
+
concatenate=True,
|
328
|
+
connect=True,
|
329
|
+
delete=True,
|
330
|
+
adjust=True,
|
331
|
+
main=True)
|
332
|
+
elif input_file.suffix in ['.svg', '.SVG']:
|
169
333
|
from .svgparser import svgshapes
|
170
334
|
basegeom = Geometry(svgshapes(dxfile),
|
171
335
|
rtol=rtol,
|
172
336
|
atol=atol,
|
173
|
-
split=split_ini
|
174
|
-
|
175
|
-
|
337
|
+
split=split_ini,
|
338
|
+
concatenate=True,
|
339
|
+
connect=True,
|
340
|
+
delete=True,
|
341
|
+
adjust=True,
|
342
|
+
main=True)
|
343
|
+
else:
|
344
|
+
logger.error("Unexpected file %s", input_file)
|
345
|
+
sys.exit(1)
|
176
346
|
except FileNotFoundError as ex:
|
177
347
|
logger.error(ex)
|
178
348
|
return dict()
|
@@ -180,33 +350,30 @@ def convert(dxfile,
|
|
180
350
|
logger.info("total elements %s", len(basegeom.g.edges()))
|
181
351
|
|
182
352
|
p = PlotRenderer()
|
353
|
+
if small_plots:
|
354
|
+
show_plots = False
|
183
355
|
|
184
356
|
if view_only:
|
185
357
|
logger.info("View only")
|
186
|
-
if view_korr:
|
187
|
-
logger.info("With Corrections")
|
188
|
-
basegeom.search_all_overlapping_elements()
|
189
|
-
basegeom.search_all_appendices()
|
190
|
-
|
191
358
|
p.render_elements(basegeom, Shape,
|
192
359
|
neighbors=True,
|
193
360
|
png=write_png,
|
194
361
|
show=True)
|
195
362
|
return dict()
|
196
363
|
|
197
|
-
|
364
|
+
plot_geom(False, # for developer
|
365
|
+
p, basegeom,
|
366
|
+
title="Before finding Machine")
|
198
367
|
|
199
368
|
machine_base = basegeom.get_machine()
|
200
369
|
if show_plots:
|
201
370
|
p.render_elements(basegeom, Shape,
|
202
|
-
title=
|
371
|
+
title=input_file.name,
|
203
372
|
with_hull=False,
|
204
373
|
rows=3, cols=2, num=1, show=debug_mode)
|
205
374
|
|
206
|
-
basegeom.search_all_appendices()
|
207
|
-
|
208
375
|
if not machine_base.is_a_machine():
|
209
|
-
logger.warn("it's Not a Machine
|
376
|
+
logger.warn("it's Not a Machine")
|
210
377
|
return dict(error='machine not detected')
|
211
378
|
|
212
379
|
if not (machine_base.part > 0):
|
@@ -240,7 +407,6 @@ def convert(dxfile,
|
|
240
407
|
rows=3, cols=2, num=2, show=False)
|
241
408
|
|
242
409
|
machine.repair_hull()
|
243
|
-
machine.geom.delete_all_appendices()
|
244
410
|
|
245
411
|
if machine.has_airgap():
|
246
412
|
logger.info("=== airgap is %s ===", machine.airgap_radius)
|
@@ -249,8 +415,60 @@ def convert(dxfile,
|
|
249
415
|
airgap=True,
|
250
416
|
inside=True,
|
251
417
|
split=split_cpy,
|
252
|
-
delete_appendices=True
|
253
|
-
|
418
|
+
delete_appendices=True,
|
419
|
+
concatenate=True,
|
420
|
+
connect=True)
|
421
|
+
machine_inner.set_inner()
|
422
|
+
machine_outer = machine.copy(startangle=0.0,
|
423
|
+
endangle=2*np.pi,
|
424
|
+
airgap=True,
|
425
|
+
inside=False,
|
426
|
+
split=split_cpy,
|
427
|
+
delete_appendices=True,
|
428
|
+
concatenate=True,
|
429
|
+
connect=True)
|
430
|
+
machine_outer.set_outer()
|
431
|
+
|
432
|
+
# check airgap
|
433
|
+
if machine.has_alternative_airgap():
|
434
|
+
bad_inner = machine_inner.check_airgap()
|
435
|
+
bad_outer = False
|
436
|
+
if not bad_inner:
|
437
|
+
bad_outer = machine_outer.check_airgap()
|
438
|
+
if bad_inner or bad_outer:
|
439
|
+
logger.warning("***** bad Airgap *****")
|
440
|
+
if bad_inner:
|
441
|
+
plot_geom(False, # for developer
|
442
|
+
p, machine_inner.geom,
|
443
|
+
title="Bad Inner Airgap Geometry")
|
444
|
+
if bad_outer:
|
445
|
+
plot_geom(False, # for developer
|
446
|
+
p, machine_outer.geom,
|
447
|
+
title="Bad Outer Airgap Geometry")
|
448
|
+
|
449
|
+
if machine.install_alternative_airgap():
|
450
|
+
logger.info("=== alternative airgap is %s ===",
|
451
|
+
machine.airgap_radius)
|
452
|
+
machine_inner = machine.copy(startangle=0.0,
|
453
|
+
endangle=2*np.pi,
|
454
|
+
airgap=True,
|
455
|
+
inside=True,
|
456
|
+
split=split_cpy,
|
457
|
+
delete_appendices=True,
|
458
|
+
concatenate=True,
|
459
|
+
connect=True)
|
460
|
+
machine_inner.set_inner()
|
461
|
+
machine_outer = machine.copy(startangle=0.0,
|
462
|
+
endangle=2*np.pi,
|
463
|
+
airgap=True,
|
464
|
+
inside=False,
|
465
|
+
split=split_cpy,
|
466
|
+
delete_appendices=True,
|
467
|
+
concatenate=True,
|
468
|
+
connect=True)
|
469
|
+
machine_outer.set_outer()
|
470
|
+
|
471
|
+
# inner part
|
254
472
|
machine_inner = symmetry_search(machine_inner,
|
255
473
|
p, # plot
|
256
474
|
inner_name,
|
@@ -262,14 +480,9 @@ def convert(dxfile,
|
|
262
480
|
num=3) # start num
|
263
481
|
machine_inner.set_inner()
|
264
482
|
machine_inner.check_and_correct_geom("Inner")
|
483
|
+
machine_inner.delete_tiny_elements(mindist)
|
265
484
|
|
266
|
-
|
267
|
-
endangle=2*np.pi,
|
268
|
-
airgap=True,
|
269
|
-
inside=False,
|
270
|
-
split=split_cpy,
|
271
|
-
delete_appendices=True)
|
272
|
-
|
485
|
+
# outer part
|
273
486
|
machine_outer = symmetry_search(machine_outer,
|
274
487
|
p, # plot
|
275
488
|
outer_name,
|
@@ -280,63 +493,100 @@ def convert(dxfile,
|
|
280
493
|
cols=2, # columns
|
281
494
|
num=4) # start num
|
282
495
|
machine_outer.check_and_correct_geom("Outer")
|
496
|
+
machine_outer.delete_tiny_elements(mindist)
|
283
497
|
|
284
498
|
machine_inner.sync_with_counterpart(machine_outer)
|
285
499
|
|
286
500
|
machine_inner.search_subregions()
|
287
501
|
machine_outer.search_subregions()
|
288
502
|
|
503
|
+
# Inner mirrored rotor
|
289
504
|
if machine_inner.geom.is_rotor():
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
if machine_outer.create_stator_auxiliary_lines():
|
315
|
-
machine_outer.rebuild_subregions()
|
505
|
+
machine_inner = build_machine_rotor(machine_inner,
|
506
|
+
True, # is inner
|
507
|
+
mindist,
|
508
|
+
p)
|
509
|
+
|
510
|
+
# Outer mirrored rotor
|
511
|
+
if machine_outer.geom.is_rotor():
|
512
|
+
machine_outer = build_machine_rotor(machine_outer,
|
513
|
+
False, # is outer
|
514
|
+
mindist,
|
515
|
+
p)
|
516
|
+
|
517
|
+
if machine_inner.geom.is_stator() or machine_inner.has_windings():
|
518
|
+
machine_inner = build_machine_stator(machine_inner,
|
519
|
+
True,
|
520
|
+
mindist,
|
521
|
+
p)
|
522
|
+
|
523
|
+
if machine_outer.geom.is_stator() or machine_outer.has_windings():
|
524
|
+
machine_outer = build_machine_stator(machine_outer,
|
525
|
+
False,
|
526
|
+
mindist,
|
527
|
+
p)
|
528
|
+
machine_inner.sync_with_counterpart(machine_outer)
|
316
529
|
|
317
|
-
|
318
|
-
|
319
|
-
machine_inner.geom.
|
320
|
-
|
530
|
+
logger.info("***** END of work: %s *****", basename)
|
531
|
+
|
532
|
+
if machine_inner.geom.is_rotor():
|
533
|
+
inner_title = "Rotor"
|
534
|
+
outer_title = "Stator"
|
535
|
+
else:
|
536
|
+
inner_title = "Stator"
|
537
|
+
outer_title = "Rotor"
|
538
|
+
|
539
|
+
plot_geom(False, # for developer
|
540
|
+
p, machine_inner.geom,
|
541
|
+
title="Final Inner Geometry")
|
542
|
+
|
543
|
+
plot_geom(False, # for developer
|
544
|
+
p, machine_outer.geom,
|
545
|
+
title="Final Outer Geometry")
|
321
546
|
|
322
547
|
if show_plots:
|
323
548
|
p.render_elements(machine_inner.geom, Shape,
|
324
|
-
draw_inside=True, title=
|
549
|
+
draw_inside=True, title=inner_title,
|
325
550
|
rows=3, cols=2, num=5, show=False,
|
326
551
|
with_corners=False,
|
327
552
|
with_nodes=False,
|
328
553
|
neighbors=False,
|
329
554
|
write_id=write_id,
|
555
|
+
draw_phi=True,
|
330
556
|
fill_areas=True)
|
331
557
|
|
332
558
|
p.render_elements(machine_outer.geom, Shape,
|
333
|
-
draw_inside=True, title=
|
559
|
+
draw_inside=True, title=outer_title,
|
334
560
|
rows=3, cols=2, num=6, show=False,
|
335
561
|
with_corners=False,
|
336
562
|
with_nodes=False,
|
337
563
|
neighbors=False,
|
338
564
|
write_id=write_id,
|
565
|
+
draw_phi=True,
|
566
|
+
fill_areas=True)
|
567
|
+
elif small_plots:
|
568
|
+
#p.figure(figsize=(9, 5)).suptitle(input_file.name, fontsize=16)
|
569
|
+
p.render_elements(machine_inner.geom, Shape,
|
570
|
+
draw_inside=True, title=inner_title,
|
571
|
+
rows=1, cols=2, num=1, show=False,
|
572
|
+
with_corners=False,
|
573
|
+
with_nodes=False,
|
574
|
+
neighbors=False,
|
575
|
+
write_id=write_id,
|
576
|
+
draw_phi=True,
|
577
|
+
fill_areas=True)
|
578
|
+
|
579
|
+
p.render_elements(machine_outer.geom, Shape,
|
580
|
+
draw_inside=True, title=outer_title,
|
581
|
+
rows=1, cols=2, num=2, show=False,
|
582
|
+
with_corners=False,
|
583
|
+
with_nodes=False,
|
584
|
+
neighbors=False,
|
585
|
+
write_id=write_id,
|
586
|
+
draw_phi=True,
|
339
587
|
fill_areas=True)
|
588
|
+
|
589
|
+
if show_plots or small_plots:
|
340
590
|
if write_png:
|
341
591
|
p.write_plot(basename)
|
342
592
|
else:
|
@@ -365,6 +615,10 @@ def convert(dxfile,
|
|
365
615
|
with_nodes=True,
|
366
616
|
single_view=True)
|
367
617
|
|
618
|
+
params = create_femag_parameters(machine_inner,
|
619
|
+
machine_outer,
|
620
|
+
nodedist)
|
621
|
+
|
368
622
|
if write_fsl:
|
369
623
|
if machine_inner.is_full() or machine_outer.is_full():
|
370
624
|
logger.warning("it's not possible to create fsl-file")
|
@@ -373,19 +627,20 @@ def convert(dxfile,
|
|
373
627
|
fslrenderer = FslRenderer(basename)
|
374
628
|
inner = fslrenderer.render(machine_inner, inner=True)
|
375
629
|
outer = fslrenderer.render(machine_outer, outer=True)
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
630
|
+
if full_model:
|
631
|
+
params['num_sl_gen'] = params.get('tot_num_slot', 0)
|
632
|
+
params['agndst'] = agndst(params.get('da1'),
|
633
|
+
params.get('da2'),
|
634
|
+
params.get('tot_num_slot'),
|
635
|
+
params.get('num_poles'), 1)
|
636
|
+
|
637
|
+
if params['external_rotor']:
|
638
|
+
conv['fsl_magnet'] = outer
|
639
|
+
conv['fsl_stator'] = inner
|
380
640
|
else:
|
381
641
|
conv['fsl_magnet'] = inner
|
382
|
-
conv['
|
383
|
-
|
384
|
-
params = create_femag_parameters(machine_inner,
|
385
|
-
machine_outer,
|
386
|
-
nodedist)
|
642
|
+
conv['fsl_stator'] = outer
|
387
643
|
|
388
|
-
conv.update(params)
|
389
644
|
conv['fsl'] = fslrenderer.render_main(
|
390
645
|
machine,
|
391
646
|
machine_inner, machine_outer,
|
@@ -393,6 +648,8 @@ def convert(dxfile,
|
|
393
648
|
params)
|
394
649
|
else:
|
395
650
|
# No airgap found. This must be an inner or outer part
|
651
|
+
logger.info("=== no airgap found ===")
|
652
|
+
|
396
653
|
name = "No_Airgap"
|
397
654
|
inner = False
|
398
655
|
outer = False
|
@@ -435,45 +692,54 @@ def convert(dxfile,
|
|
435
692
|
if part:
|
436
693
|
if part[0] == 'stator':
|
437
694
|
machine.geom.set_stator()
|
438
|
-
machine.
|
439
|
-
|
440
|
-
|
441
|
-
logger.info("undo mirror of stator")
|
442
|
-
machine = machine.undo_mirror()
|
443
|
-
machine.geom.set_stator()
|
444
|
-
machine.geom.search_stator_subregions(part[1])
|
445
|
-
machine.geom.looking_for_corners()
|
446
|
-
machine.create_mirror_lines_outside_windings()
|
447
|
-
if machine.create_stator_auxiliary_lines():
|
448
|
-
machine.rebuild_subregions()
|
695
|
+
machine.set_inner_or_outer(part[1])
|
696
|
+
machine.search_stator_subregions(single=True)
|
697
|
+
machine = build_machine_stator(machine, inner, mindist, p, single=True)
|
449
698
|
|
450
699
|
params = create_femag_parameters_stator(machine,
|
451
700
|
part[1])
|
452
701
|
else:
|
453
702
|
machine.geom.set_rotor()
|
454
|
-
machine.
|
455
|
-
machine.
|
456
|
-
|
457
|
-
machine.rebuild_subregions()
|
703
|
+
machine.set_inner_or_outer(part[1])
|
704
|
+
machine.search_rotor_subregions(single=True)
|
705
|
+
machine = build_machine_rotor(machine, inner, mindist, p, single=True)
|
458
706
|
|
459
707
|
params = create_femag_parameters_rotor(machine,
|
460
708
|
part[1])
|
461
709
|
else:
|
462
|
-
machine.
|
710
|
+
machine.search_subregions(single=True)
|
463
711
|
|
464
712
|
machine.delete_tiny_elements(mindist)
|
465
|
-
machine.
|
466
|
-
|
713
|
+
machine.create_inner_corner_areas()
|
714
|
+
|
715
|
+
logger.info("***** END of work: %s *****", basename)
|
716
|
+
|
717
|
+
if machine.geom.is_rotor():
|
718
|
+
title = "Rotor"
|
719
|
+
else:
|
720
|
+
title = "Stator"
|
467
721
|
|
468
722
|
if show_plots:
|
469
723
|
p.render_elements(machine.geom, Shape,
|
470
|
-
draw_inside=True, title=
|
724
|
+
draw_inside=True, title=title,
|
471
725
|
rows=3, cols=2, num=5, show=False,
|
472
726
|
with_corners=False,
|
473
727
|
with_nodes=False,
|
474
728
|
neighbors=False,
|
475
729
|
write_id=write_id,
|
476
730
|
fill_areas=True)
|
731
|
+
elif small_plots:
|
732
|
+
#p.figure().suptitle(input_file.name, fontsize=16)
|
733
|
+
p.render_elements(machine.geom, Shape,
|
734
|
+
draw_inside=True, title=title,
|
735
|
+
rows=1, cols=1, num=1, show=False,
|
736
|
+
with_corners=False,
|
737
|
+
with_nodes=False,
|
738
|
+
neighbors=False,
|
739
|
+
write_id=write_id,
|
740
|
+
fill_areas=True)
|
741
|
+
|
742
|
+
if show_plots or small_plots:
|
477
743
|
if write_png:
|
478
744
|
p.write_plot(basename)
|
479
745
|
else:
|
@@ -498,16 +764,18 @@ def convert(dxfile,
|
|
498
764
|
|
499
765
|
fslrenderer = FslRenderer(basename)
|
500
766
|
conv['fsl'] = fslrenderer.render(machine, inner, outer)
|
501
|
-
if params:
|
502
|
-
conv.update(params)
|
503
767
|
|
768
|
+
conv.update(params)
|
504
769
|
conv['name'] = basename
|
505
|
-
timer.stop("-- all done in %0.4f seconds --")
|
770
|
+
t = timer.stop("-- all done in %0.4f seconds --", info=True)
|
771
|
+
journal.put('time_total', t)
|
772
|
+
journal.put('success', True)
|
506
773
|
return conv
|
507
774
|
|
508
775
|
|
509
776
|
def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
510
777
|
if not (m_inner and m_outer):
|
778
|
+
logger.warning("inner %s outer %s", m_inner, m_outer)
|
511
779
|
return {}
|
512
780
|
|
513
781
|
params = {}
|
@@ -518,14 +786,14 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
518
786
|
parts_outer = int(m_outer.get_symmetry_part())
|
519
787
|
|
520
788
|
if parts_inner > parts_outer:
|
521
|
-
num_slots = parts_inner
|
522
|
-
num_poles = parts_outer
|
789
|
+
num_slots = int(parts_inner)
|
790
|
+
num_poles = int(parts_outer)
|
523
791
|
num_sl_gen = int(geom_inner.get_symmetry_copies()+1)
|
524
792
|
alfa_slot = geom_inner.get_alfa()
|
525
793
|
alfa_pole = geom_outer.get_alfa()
|
526
794
|
else:
|
527
|
-
num_slots = parts_outer
|
528
|
-
num_poles = parts_inner
|
795
|
+
num_slots = int(parts_outer)
|
796
|
+
num_poles = int(parts_inner)
|
529
797
|
num_sl_gen = int(geom_outer.get_symmetry_copies()+1)
|
530
798
|
alfa_slot = geom_outer.get_alfa()
|
531
799
|
alfa_pole = geom_inner.get_alfa()
|
@@ -534,14 +802,11 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
534
802
|
params['num_sl_gen'] = num_sl_gen
|
535
803
|
params['num_poles'] = num_poles
|
536
804
|
params['nodedist'] = nodedist
|
537
|
-
|
805
|
+
params['external_rotor'] = parts_inner > parts_outer
|
538
806
|
params['dy1'] = 2*geom_outer.max_radius
|
539
807
|
params['da1'] = 2*geom_outer.min_radius
|
540
808
|
params['da2'] = 2*geom_inner.max_radius
|
541
809
|
params['dy2'] = 2*geom_inner.min_radius
|
542
|
-
params['agndst'] = agndst(params['da1'], params['da2'],
|
543
|
-
num_slots, num_poles,
|
544
|
-
nodedist)
|
545
810
|
params['alfa_slot'] = alfa_slot
|
546
811
|
params['alfa_pole'] = alfa_pole
|
547
812
|
|
@@ -564,7 +829,7 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
564
829
|
def create_femag_parameters_stator(motor, position):
|
565
830
|
params = {}
|
566
831
|
num_slots = motor.get_num_slots()
|
567
|
-
params['tot_num_slot'] = num_slots
|
832
|
+
params['tot_num_slot'] = int(num_slots)
|
568
833
|
if position == 'in':
|
569
834
|
params['da2'] = 2*motor.geom.max_radius
|
570
835
|
params['dy2'] = 2*motor.geom.min_radius
|
@@ -577,7 +842,7 @@ def create_femag_parameters_stator(motor, position):
|
|
577
842
|
def create_femag_parameters_rotor(motor, position):
|
578
843
|
params = {}
|
579
844
|
num_poles = motor.get_num_poles()
|
580
|
-
params['num_poles'] = num_poles
|
845
|
+
params['num_poles'] = int(num_poles)
|
581
846
|
if position == 'in':
|
582
847
|
params['da2'] = 2*motor.geom.max_radius
|
583
848
|
params['dy2'] = 2*motor.geom.min_radius
|