femagtools 1.6.8__py3-none-any.whl → 1.7.1__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 +343 -406
- femagtools/dxfsl/areabuilder.py +139 -12
- femagtools/dxfsl/conv.py +27 -9
- femagtools/dxfsl/converter.py +406 -127
- 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 +1204 -893
- femagtools/dxfsl/journal.py +58 -22
- femagtools/dxfsl/machine.py +254 -75
- femagtools/dxfsl/plotrenderer.py +38 -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 +11 -7
- femagtools/machine/sizing.py +15 -12
- 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.8.dist-info → femagtools-1.7.1.dist-info}/LICENSE +1 -0
- {femagtools-1.6.8.dist-info → femagtools-1.7.1.dist-info}/METADATA +7 -4
- {femagtools-1.6.8.dist-info → femagtools-1.7.1.dist-info}/RECORD +51 -50
- {femagtools-1.6.8.dist-info → femagtools-1.7.1.dist-info}/WHEEL +1 -1
- tests/engines/__init__.py +0 -20
- tests/geom/__init__.py +0 -20
- tests/moo/__init__.py +0 -20
- tests/test_model.py +8 -1
- tests/test_sizing.py +2 -2
- {femagtools-1.6.8.dist-info → femagtools-1.7.1.dist-info}/entry_points.txt +0 -0
- {femagtools-1.6.8.dist-info → femagtools-1.7.1.dist-info}/top_level.txt +0 -0
femagtools/dxfsl/converter.py
CHANGED
@@ -1,18 +1,42 @@
|
|
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
|
+
draw_groups=False,
|
30
|
+
draw_phi=True,
|
31
|
+
critical=True,
|
32
|
+
title=title,
|
33
|
+
show=True,
|
34
|
+
with_corners=True,
|
35
|
+
with_nodes=False,
|
36
|
+
neighbors=True,
|
37
|
+
write_id=areas,
|
38
|
+
with_legend=False,
|
39
|
+
fill_areas=areas)
|
16
40
|
|
17
41
|
|
18
42
|
def symmetry_search(machine,
|
@@ -48,16 +72,16 @@ def symmetry_search(machine,
|
|
48
72
|
logger.info("*** End of symmetry search for %s ***", kind)
|
49
73
|
return machine_ok
|
50
74
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
75
|
+
plot_geom(False, # for developer
|
76
|
+
plt, machine.geom,
|
77
|
+
title="Before Symmetry ({})".format(kind))
|
78
|
+
|
79
|
+
if machine.find_symmetry(symtol, is_inner, is_outer, None):
|
80
|
+
logger.info(" - {}: symmetry axis found".format(kind))
|
81
|
+
plot_geom(False, # for developer
|
82
|
+
plt, machine.geom,
|
83
|
+
title="Symmetry found")
|
55
84
|
|
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
85
|
if show_plots:
|
62
86
|
plt.render_elements(machine.geom, Shape,
|
63
87
|
title=kind+' (symmetrylines)',
|
@@ -69,20 +93,50 @@ def symmetry_search(machine,
|
|
69
93
|
logger.info(" - no slice extracted ?!?")
|
70
94
|
return machine
|
71
95
|
|
72
|
-
|
96
|
+
plot_geom(False, # for developer
|
97
|
+
plt, machine_slice.geom,
|
98
|
+
title="Slice of {}".format(kind))
|
99
|
+
|
100
|
+
# no third after slice
|
101
|
+
machine_mirror = machine_slice.get_symmetry_mirror(no_third=True)
|
102
|
+
|
103
|
+
if machine_mirror is not None:
|
104
|
+
machine_mirror.set_kind(kind)
|
105
|
+
logger.info("*** End of symmetry search for %s (symmetry and mirror) ***", kind)
|
106
|
+
return machine_mirror
|
107
|
+
|
108
|
+
machine_slice.set_kind(kind)
|
109
|
+
logger.info("*** End of symmetry search for %s (symmetry) ***", kind)
|
110
|
+
return machine_slice
|
111
|
+
|
112
|
+
# --- no symmetry slice found ---
|
113
|
+
logger.info(" - {}: no symmetry axis found".format(kind))
|
114
|
+
if show_plots:
|
115
|
+
if debug_mode:
|
116
|
+
plt.render_elements(machine.geom, Shape,
|
117
|
+
title=kind+' (no symmetry axis)',
|
118
|
+
draw_inside=True,
|
119
|
+
neighbors=True,
|
120
|
+
rows=rows, cols=cols, num=num, show=False)
|
121
|
+
else:
|
122
|
+
plt.add_emptyplot(rows, cols, num, 'no symmetry axis')
|
123
|
+
|
124
|
+
if not machine.is_startangle_zero():
|
125
|
+
logger.debug("Rotate geometry to 0.0")
|
126
|
+
machine.rotate_to(0.0)
|
127
|
+
machine.set_alfa_and_corners()
|
128
|
+
|
129
|
+
machine_mirror = machine.get_symmetry_mirror()
|
130
|
+
machine_slice = machine
|
131
|
+
machine_slice.set_alfa_and_corners()
|
73
132
|
|
74
133
|
if machine_mirror is None:
|
75
134
|
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
135
|
machine_ok = machine_slice
|
81
136
|
else:
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
rows=rows, cols=cols, num=num, show=True)
|
137
|
+
plot_geom(False, # for developer
|
138
|
+
plt, machine_mirror.geom,
|
139
|
+
title="After Mirror ({})".format(kind))
|
86
140
|
|
87
141
|
logger.info(" - mirror found")
|
88
142
|
machine_next_mirror = machine_mirror.get_symmetry_mirror()
|
@@ -93,16 +147,108 @@ def symmetry_search(machine,
|
|
93
147
|
|
94
148
|
machine_ok = machine_mirror
|
95
149
|
|
150
|
+
if not machine_ok.is_startangle_zero():
|
151
|
+
logger.debug("Rotate geometry to 0.0")
|
152
|
+
machine_ok.rotate_to(0.0)
|
153
|
+
machine_ok.set_alfa_and_corners()
|
154
|
+
|
96
155
|
machine_ok.set_kind(kind)
|
97
156
|
|
98
157
|
logger.info("*** End of symmetry search for %s ***", kind)
|
99
158
|
return machine_ok
|
100
159
|
|
101
160
|
|
161
|
+
def build_machine_rotor(machine, inner, mindist, plt, single=False):
|
162
|
+
logger.debug("Begin of build_machine_rotor")
|
163
|
+
if machine.has_windings():
|
164
|
+
logger.debug("do nothing here with windings in rotor")
|
165
|
+
logger.debug("End of build_machine_rotor")
|
166
|
+
return machine
|
167
|
+
|
168
|
+
if machine.is_mirrored():
|
169
|
+
logger.debug("Rotor is mirrored")
|
170
|
+
machine_temp = machine.undo_mirror()
|
171
|
+
machine_temp.delete_tiny_elements(mindist)
|
172
|
+
machine_temp.geom.set_rotor()
|
173
|
+
machine_temp.search_rotor_subregions(single=single)
|
174
|
+
else:
|
175
|
+
machine_temp = machine
|
176
|
+
|
177
|
+
midangle = middle_angle(machine_temp.startangle,
|
178
|
+
machine_temp.endangle)
|
179
|
+
|
180
|
+
plot_geom(False, # for developer
|
181
|
+
plt, machine_temp.geom,
|
182
|
+
title="Inner Rotor check magnets {}".format(midangle))
|
183
|
+
|
184
|
+
rebuild = False
|
185
|
+
if machine_temp.geom.magnets_in_the_middle(midangle):
|
186
|
+
logger.debug("Magnets cut")
|
187
|
+
rebuild = machine_temp.create_mirror_lines_outside_magnets()
|
188
|
+
else:
|
189
|
+
if machine.is_mirrored():
|
190
|
+
logger.debug("Back to the mirrored machine")
|
191
|
+
machine_temp = machine # undo
|
192
|
+
rebuild = machine_temp.create_inner_auxiliary_arcs()
|
193
|
+
else:
|
194
|
+
rebuild = machine_temp.create_mirror_lines_outside_magnets()
|
195
|
+
if rebuild:
|
196
|
+
machine_temp.geom.area_list = []
|
197
|
+
|
198
|
+
if machine_temp.create_auxiliary_lines():
|
199
|
+
logger.debug("Auxiliary Lines created: rebuild subregions")
|
200
|
+
rebuild = True
|
201
|
+
if rebuild:
|
202
|
+
machine_temp.rebuild_subregions(single=single)
|
203
|
+
|
204
|
+
machine_temp.geom.recalculate_magnet_orientation()
|
205
|
+
if inner:
|
206
|
+
machine_temp.create_inner_corner_areas()
|
207
|
+
|
208
|
+
if not machine_temp.is_mirrored():
|
209
|
+
machine_temp.create_boundery_nodes()
|
210
|
+
|
211
|
+
plot_geom(False, # for developer
|
212
|
+
plt, machine_temp.geom,
|
213
|
+
title="Final Rotor")
|
214
|
+
logger.debug("End of build_machine_rotor")
|
215
|
+
return machine_temp
|
216
|
+
|
217
|
+
|
218
|
+
def build_machine_stator(machine, inner, mindist, plt, single=False):
|
219
|
+
logger.debug("Begin of build_machine_stator")
|
220
|
+
if not machine.geom.is_stator():
|
221
|
+
logger.debug("Rotor with windings")
|
222
|
+
|
223
|
+
if machine.has_mirrored_windings():
|
224
|
+
logger.debug("undo mirrored windings")
|
225
|
+
machine_temp = machine.undo_mirror()
|
226
|
+
machine_temp.delete_tiny_elements(mindist)
|
227
|
+
machine_temp.geom.set_stator()
|
228
|
+
machine_temp.search_stator_subregions(single=single)
|
229
|
+
machine_temp.create_mirror_lines_outside_windings()
|
230
|
+
else:
|
231
|
+
machine_temp = machine
|
232
|
+
if machine_temp.create_auxiliary_lines():
|
233
|
+
machine_temp.rebuild_subregions(single=single)
|
234
|
+
|
235
|
+
if inner:
|
236
|
+
machine_temp.create_inner_corner_areas()
|
237
|
+
|
238
|
+
if not machine_temp.is_mirrored():
|
239
|
+
machine_temp.create_boundery_nodes()
|
240
|
+
|
241
|
+
plot_geom(False, # for developer
|
242
|
+
plt, machine_temp.geom,
|
243
|
+
title="Final Stator")
|
244
|
+
logger.debug("End of build_machine_stator")
|
245
|
+
return machine_temp
|
246
|
+
|
247
|
+
|
102
248
|
def convert(dxfile,
|
103
|
-
rtol=1e-
|
104
|
-
atol=
|
105
|
-
mindist=0.
|
249
|
+
rtol=1e-04,
|
250
|
+
atol=1e-03,
|
251
|
+
mindist=0.01,
|
106
252
|
symtol=0.001,
|
107
253
|
sympart=0,
|
108
254
|
split=False,
|
@@ -118,17 +264,33 @@ def convert(dxfile,
|
|
118
264
|
view_korr=False,
|
119
265
|
show_plots=False,
|
120
266
|
show_areas=False,
|
267
|
+
small_plots=False,
|
121
268
|
write_fsl=True,
|
122
269
|
write_png=False,
|
123
270
|
write_id=False,
|
271
|
+
full_model=False,
|
124
272
|
debug_mode=False):
|
125
273
|
layers = ()
|
126
274
|
conv = {}
|
127
275
|
|
128
|
-
|
129
|
-
|
276
|
+
input_file = Path(dxfile)
|
277
|
+
if not input_file.is_file():
|
278
|
+
logger.error("File %s is not available", input_file)
|
279
|
+
sys.exit(1)
|
280
|
+
|
281
|
+
basename = input_file.stem
|
282
|
+
if part:
|
283
|
+
logger.info("***** start processing %s (%s) *****", basename, part)
|
284
|
+
else:
|
285
|
+
logger.info("***** start processing %s *****", basename)
|
130
286
|
timer = Timer(start_it=True)
|
131
287
|
|
288
|
+
journal = getJournal(name='converter', aktiv=debug_mode)
|
289
|
+
journal.get_journal(input_file.name)
|
290
|
+
journal.put_filename(str(input_file.resolve()))
|
291
|
+
journal.set('success', False)
|
292
|
+
journal.write_journal()
|
293
|
+
|
132
294
|
if part:
|
133
295
|
if part[0] not in ('rotor', 'stator'):
|
134
296
|
logger.error('FATAL: Parameter rotor or stator expected')
|
@@ -151,28 +313,44 @@ def convert(dxfile,
|
|
151
313
|
split_cpy = split
|
152
314
|
|
153
315
|
try:
|
154
|
-
if
|
316
|
+
if input_file.suffix in ['.fem', '.FEM']:
|
155
317
|
from .femparser import femshapes
|
156
318
|
basegeom = Geometry(femshapes(dxfile),
|
157
319
|
rtol=rtol,
|
158
320
|
atol=atol,
|
159
|
-
split=split_ini
|
160
|
-
|
321
|
+
split=split_ini,
|
322
|
+
concatenate=True,
|
323
|
+
connect=True,
|
324
|
+
delete=True,
|
325
|
+
adjust=True,
|
326
|
+
main=True)
|
327
|
+
elif input_file.suffix in ['.dxf', '.DXF']:
|
161
328
|
from .dxfparser import dxfshapes
|
162
329
|
basegeom = Geometry(dxfshapes(dxfile,
|
163
330
|
mindist=mindist,
|
164
331
|
layers=layers),
|
165
332
|
rtol=rtol,
|
166
333
|
atol=atol,
|
167
|
-
split=split_ini
|
168
|
-
|
334
|
+
split=split_ini,
|
335
|
+
concatenate=True,
|
336
|
+
connect=True,
|
337
|
+
delete=True,
|
338
|
+
adjust=True,
|
339
|
+
main=True)
|
340
|
+
elif input_file.suffix in ['.svg', '.SVG']:
|
169
341
|
from .svgparser import svgshapes
|
170
342
|
basegeom = Geometry(svgshapes(dxfile),
|
171
343
|
rtol=rtol,
|
172
344
|
atol=atol,
|
173
|
-
split=split_ini
|
174
|
-
|
175
|
-
|
345
|
+
split=split_ini,
|
346
|
+
concatenate=True,
|
347
|
+
connect=True,
|
348
|
+
delete=True,
|
349
|
+
adjust=True,
|
350
|
+
main=True)
|
351
|
+
else:
|
352
|
+
logger.error("Unexpected file %s", input_file)
|
353
|
+
sys.exit(1)
|
176
354
|
except FileNotFoundError as ex:
|
177
355
|
logger.error(ex)
|
178
356
|
return dict()
|
@@ -180,33 +358,30 @@ def convert(dxfile,
|
|
180
358
|
logger.info("total elements %s", len(basegeom.g.edges()))
|
181
359
|
|
182
360
|
p = PlotRenderer()
|
361
|
+
if small_plots:
|
362
|
+
show_plots = False
|
183
363
|
|
184
364
|
if view_only:
|
185
365
|
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
366
|
p.render_elements(basegeom, Shape,
|
192
367
|
neighbors=True,
|
193
368
|
png=write_png,
|
194
369
|
show=True)
|
195
370
|
return dict()
|
196
371
|
|
197
|
-
|
372
|
+
plot_geom(False, # for developer
|
373
|
+
p, basegeom,
|
374
|
+
title="Before finding Machine")
|
198
375
|
|
199
376
|
machine_base = basegeom.get_machine()
|
200
377
|
if show_plots:
|
201
378
|
p.render_elements(basegeom, Shape,
|
202
|
-
title=
|
379
|
+
title=input_file.name,
|
203
380
|
with_hull=False,
|
204
381
|
rows=3, cols=2, num=1, show=debug_mode)
|
205
382
|
|
206
|
-
basegeom.search_all_appendices()
|
207
|
-
|
208
383
|
if not machine_base.is_a_machine():
|
209
|
-
logger.warn("it's Not a Machine
|
384
|
+
logger.warn("it's Not a Machine")
|
210
385
|
return dict(error='machine not detected')
|
211
386
|
|
212
387
|
if not (machine_base.part > 0):
|
@@ -240,7 +415,6 @@ def convert(dxfile,
|
|
240
415
|
rows=3, cols=2, num=2, show=False)
|
241
416
|
|
242
417
|
machine.repair_hull()
|
243
|
-
machine.geom.delete_all_appendices()
|
244
418
|
|
245
419
|
if machine.has_airgap():
|
246
420
|
logger.info("=== airgap is %s ===", machine.airgap_radius)
|
@@ -249,8 +423,60 @@ def convert(dxfile,
|
|
249
423
|
airgap=True,
|
250
424
|
inside=True,
|
251
425
|
split=split_cpy,
|
252
|
-
delete_appendices=True
|
253
|
-
|
426
|
+
delete_appendices=True,
|
427
|
+
concatenate=True,
|
428
|
+
connect=True)
|
429
|
+
machine_inner.set_inner()
|
430
|
+
machine_outer = machine.copy(startangle=0.0,
|
431
|
+
endangle=2*np.pi,
|
432
|
+
airgap=True,
|
433
|
+
inside=False,
|
434
|
+
split=split_cpy,
|
435
|
+
delete_appendices=True,
|
436
|
+
concatenate=True,
|
437
|
+
connect=True)
|
438
|
+
machine_outer.set_outer()
|
439
|
+
|
440
|
+
# check airgap
|
441
|
+
if machine.has_alternative_airgap():
|
442
|
+
bad_inner = machine_inner.check_airgap()
|
443
|
+
bad_outer = False
|
444
|
+
if not bad_inner:
|
445
|
+
bad_outer = machine_outer.check_airgap()
|
446
|
+
if bad_inner or bad_outer:
|
447
|
+
logger.warning("***** bad Airgap *****")
|
448
|
+
if bad_inner:
|
449
|
+
plot_geom(False, # for developer
|
450
|
+
p, machine_inner.geom,
|
451
|
+
title="Bad Inner Airgap Geometry")
|
452
|
+
if bad_outer:
|
453
|
+
plot_geom(False, # for developer
|
454
|
+
p, machine_outer.geom,
|
455
|
+
title="Bad Outer Airgap Geometry")
|
456
|
+
|
457
|
+
if machine.install_alternative_airgap():
|
458
|
+
logger.info("=== alternative airgap is %s ===",
|
459
|
+
machine.airgap_radius)
|
460
|
+
machine_inner = machine.copy(startangle=0.0,
|
461
|
+
endangle=2*np.pi,
|
462
|
+
airgap=True,
|
463
|
+
inside=True,
|
464
|
+
split=split_cpy,
|
465
|
+
delete_appendices=True,
|
466
|
+
concatenate=True,
|
467
|
+
connect=True)
|
468
|
+
machine_inner.set_inner()
|
469
|
+
machine_outer = machine.copy(startangle=0.0,
|
470
|
+
endangle=2*np.pi,
|
471
|
+
airgap=True,
|
472
|
+
inside=False,
|
473
|
+
split=split_cpy,
|
474
|
+
delete_appendices=True,
|
475
|
+
concatenate=True,
|
476
|
+
connect=True)
|
477
|
+
machine_outer.set_outer()
|
478
|
+
|
479
|
+
# inner part
|
254
480
|
machine_inner = symmetry_search(machine_inner,
|
255
481
|
p, # plot
|
256
482
|
inner_name,
|
@@ -262,14 +488,9 @@ def convert(dxfile,
|
|
262
488
|
num=3) # start num
|
263
489
|
machine_inner.set_inner()
|
264
490
|
machine_inner.check_and_correct_geom("Inner")
|
491
|
+
machine_inner.delete_tiny_elements(mindist)
|
265
492
|
|
266
|
-
|
267
|
-
endangle=2*np.pi,
|
268
|
-
airgap=True,
|
269
|
-
inside=False,
|
270
|
-
split=split_cpy,
|
271
|
-
delete_appendices=True)
|
272
|
-
|
493
|
+
# outer part
|
273
494
|
machine_outer = symmetry_search(machine_outer,
|
274
495
|
p, # plot
|
275
496
|
outer_name,
|
@@ -280,63 +501,103 @@ def convert(dxfile,
|
|
280
501
|
cols=2, # columns
|
281
502
|
num=4) # start num
|
282
503
|
machine_outer.check_and_correct_geom("Outer")
|
504
|
+
machine_outer.delete_tiny_elements(mindist)
|
283
505
|
|
284
506
|
machine_inner.sync_with_counterpart(machine_outer)
|
285
507
|
|
286
508
|
machine_inner.search_subregions()
|
287
509
|
machine_outer.search_subregions()
|
288
510
|
|
511
|
+
# Inner mirrored rotor
|
289
512
|
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()
|
513
|
+
machine_inner = build_machine_rotor(machine_inner,
|
514
|
+
True, # is inner
|
515
|
+
mindist,
|
516
|
+
p)
|
517
|
+
|
518
|
+
# Outer mirrored rotor
|
519
|
+
if machine_outer.geom.is_rotor():
|
520
|
+
machine_outer = build_machine_rotor(machine_outer,
|
521
|
+
False, # is outer
|
522
|
+
mindist,
|
523
|
+
p)
|
524
|
+
|
525
|
+
if machine_inner.geom.is_stator() or machine_inner.has_windings():
|
526
|
+
machine_inner = build_machine_stator(machine_inner,
|
527
|
+
True,
|
528
|
+
mindist,
|
529
|
+
p)
|
530
|
+
|
531
|
+
if machine_outer.geom.is_stator() or machine_outer.has_windings():
|
532
|
+
machine_outer = build_machine_stator(machine_outer,
|
533
|
+
False,
|
534
|
+
mindist,
|
535
|
+
p)
|
536
|
+
machine_inner.sync_with_counterpart(machine_outer)
|
316
537
|
|
317
|
-
machine_inner.
|
318
|
-
machine_outer.
|
319
|
-
|
320
|
-
logger.info("END of work: %s", basename)
|
538
|
+
machine_inner.search_critical_elements(mindist)
|
539
|
+
machine_outer.search_critical_elements(mindist)
|
540
|
+
|
541
|
+
logger.info("***** END of work: %s *****", basename)
|
542
|
+
|
543
|
+
if machine_inner.geom.is_rotor():
|
544
|
+
inner_title = "Rotor"
|
545
|
+
outer_title = "Stator"
|
546
|
+
else:
|
547
|
+
inner_title = "Stator"
|
548
|
+
outer_title = "Rotor"
|
549
|
+
|
550
|
+
plot_geom(False, # for developer
|
551
|
+
p, machine_inner.geom,
|
552
|
+
title="Final Inner Geometry")
|
553
|
+
|
554
|
+
plot_geom(False, # for developer
|
555
|
+
p, machine_outer.geom,
|
556
|
+
title="Final Outer Geometry")
|
321
557
|
|
322
558
|
if show_plots:
|
323
559
|
p.render_elements(machine_inner.geom, Shape,
|
324
|
-
draw_inside=True, title=
|
560
|
+
draw_inside=True, title=inner_title,
|
325
561
|
rows=3, cols=2, num=5, show=False,
|
326
562
|
with_corners=False,
|
327
563
|
with_nodes=False,
|
328
564
|
neighbors=False,
|
329
565
|
write_id=write_id,
|
566
|
+
draw_phi=True,
|
330
567
|
fill_areas=True)
|
331
568
|
|
332
569
|
p.render_elements(machine_outer.geom, Shape,
|
333
|
-
draw_inside=True, title=
|
570
|
+
draw_inside=True, title=outer_title,
|
334
571
|
rows=3, cols=2, num=6, show=False,
|
335
572
|
with_corners=False,
|
336
573
|
with_nodes=False,
|
337
574
|
neighbors=False,
|
338
575
|
write_id=write_id,
|
576
|
+
draw_phi=True,
|
577
|
+
fill_areas=True)
|
578
|
+
elif small_plots:
|
579
|
+
#p.figure(figsize=(9, 5)).suptitle(input_file.name, fontsize=16)
|
580
|
+
p.render_elements(machine_inner.geom, Shape,
|
581
|
+
draw_inside=True, title=inner_title,
|
582
|
+
rows=1, cols=2, num=1, show=False,
|
583
|
+
with_corners=False,
|
584
|
+
with_nodes=False,
|
585
|
+
neighbors=False,
|
586
|
+
write_id=write_id,
|
587
|
+
draw_phi=True,
|
588
|
+
fill_areas=True)
|
589
|
+
|
590
|
+
p.render_elements(machine_outer.geom, Shape,
|
591
|
+
draw_inside=True, title=outer_title,
|
592
|
+
rows=1, cols=2, num=2, show=False,
|
593
|
+
with_corners=False,
|
594
|
+
with_nodes=False,
|
595
|
+
neighbors=False,
|
596
|
+
write_id=write_id,
|
597
|
+
draw_phi=True,
|
339
598
|
fill_areas=True)
|
599
|
+
|
600
|
+
if show_plots or small_plots:
|
340
601
|
if write_png:
|
341
602
|
p.write_plot(basename)
|
342
603
|
else:
|
@@ -365,6 +626,10 @@ def convert(dxfile,
|
|
365
626
|
with_nodes=True,
|
366
627
|
single_view=True)
|
367
628
|
|
629
|
+
params = create_femag_parameters(machine_inner,
|
630
|
+
machine_outer,
|
631
|
+
nodedist)
|
632
|
+
|
368
633
|
if write_fsl:
|
369
634
|
if machine_inner.is_full() or machine_outer.is_full():
|
370
635
|
logger.warning("it's not possible to create fsl-file")
|
@@ -373,19 +638,20 @@ def convert(dxfile,
|
|
373
638
|
fslrenderer = FslRenderer(basename)
|
374
639
|
inner = fslrenderer.render(machine_inner, inner=True)
|
375
640
|
outer = fslrenderer.render(machine_outer, outer=True)
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
641
|
+
if full_model:
|
642
|
+
params['num_sl_gen'] = params.get('tot_num_slot', 0)
|
643
|
+
params['agndst'] = agndst(params.get('da1'),
|
644
|
+
params.get('da2'),
|
645
|
+
params.get('tot_num_slot'),
|
646
|
+
params.get('num_poles'), 1)
|
647
|
+
|
648
|
+
if params['external_rotor']:
|
649
|
+
conv['fsl_magnet'] = outer
|
650
|
+
conv['fsl_stator'] = inner
|
380
651
|
else:
|
381
652
|
conv['fsl_magnet'] = inner
|
382
|
-
conv['
|
383
|
-
|
384
|
-
params = create_femag_parameters(machine_inner,
|
385
|
-
machine_outer,
|
386
|
-
nodedist)
|
653
|
+
conv['fsl_stator'] = outer
|
387
654
|
|
388
|
-
conv.update(params)
|
389
655
|
conv['fsl'] = fslrenderer.render_main(
|
390
656
|
machine,
|
391
657
|
machine_inner, machine_outer,
|
@@ -393,6 +659,8 @@ def convert(dxfile,
|
|
393
659
|
params)
|
394
660
|
else:
|
395
661
|
# No airgap found. This must be an inner or outer part
|
662
|
+
logger.info("=== no airgap found ===")
|
663
|
+
|
396
664
|
name = "No_Airgap"
|
397
665
|
inner = False
|
398
666
|
outer = False
|
@@ -417,6 +685,7 @@ def convert(dxfile,
|
|
417
685
|
rows=3, # rows
|
418
686
|
cols=2, # cols
|
419
687
|
num=3) # start num
|
688
|
+
machine.delete_tiny_elements(mindist)
|
420
689
|
|
421
690
|
if da > 0.0 or dy > 0.0:
|
422
691
|
if inner:
|
@@ -435,45 +704,55 @@ def convert(dxfile,
|
|
435
704
|
if part:
|
436
705
|
if part[0] == 'stator':
|
437
706
|
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()
|
707
|
+
machine.set_inner_or_outer(part[1])
|
708
|
+
machine.search_stator_subregions(single=True)
|
709
|
+
machine = build_machine_stator(machine, inner, mindist, p, single=True)
|
449
710
|
|
450
711
|
params = create_femag_parameters_stator(machine,
|
451
712
|
part[1])
|
452
713
|
else:
|
453
714
|
machine.geom.set_rotor()
|
454
|
-
machine.
|
455
|
-
machine.
|
456
|
-
|
457
|
-
machine.rebuild_subregions()
|
715
|
+
machine.set_inner_or_outer(part[1])
|
716
|
+
machine.search_rotor_subregions(single=True)
|
717
|
+
machine = build_machine_rotor(machine, inner, mindist, p, single=True)
|
458
718
|
|
459
719
|
params = create_femag_parameters_rotor(machine,
|
460
720
|
part[1])
|
461
721
|
else:
|
462
|
-
machine.
|
722
|
+
machine.search_subregions(single=True)
|
463
723
|
|
464
|
-
machine.
|
465
|
-
|
466
|
-
logger.info("END of work: %s", basename)
|
724
|
+
machine.create_inner_corner_areas()
|
725
|
+
|
726
|
+
logger.info("***** END of work: %s *****", basename)
|
727
|
+
|
728
|
+
if machine.geom.is_rotor():
|
729
|
+
title = "Rotor"
|
730
|
+
else:
|
731
|
+
title = "Stator"
|
467
732
|
|
468
733
|
if show_plots:
|
469
734
|
p.render_elements(machine.geom, Shape,
|
470
|
-
draw_inside=True, title=
|
735
|
+
draw_inside=True, title=title,
|
471
736
|
rows=3, cols=2, num=5, show=False,
|
472
737
|
with_corners=False,
|
473
738
|
with_nodes=False,
|
474
739
|
neighbors=False,
|
475
740
|
write_id=write_id,
|
741
|
+
draw_phi=True,
|
476
742
|
fill_areas=True)
|
743
|
+
elif small_plots:
|
744
|
+
#p.figure().suptitle(input_file.name, fontsize=16)
|
745
|
+
p.render_elements(machine.geom, Shape,
|
746
|
+
draw_inside=True, title=title,
|
747
|
+
rows=1, cols=1, num=1, show=False,
|
748
|
+
with_corners=False,
|
749
|
+
with_nodes=False,
|
750
|
+
neighbors=False,
|
751
|
+
write_id=write_id,
|
752
|
+
draw_phi=True,
|
753
|
+
fill_areas=True)
|
754
|
+
|
755
|
+
if show_plots or small_plots:
|
477
756
|
if write_png:
|
478
757
|
p.write_plot(basename)
|
479
758
|
else:
|
@@ -498,16 +777,19 @@ def convert(dxfile,
|
|
498
777
|
|
499
778
|
fslrenderer = FslRenderer(basename)
|
500
779
|
conv['fsl'] = fslrenderer.render(machine, inner, outer)
|
501
|
-
if params:
|
502
|
-
conv.update(params)
|
503
780
|
|
781
|
+
if params is not None:
|
782
|
+
conv.update(params)
|
504
783
|
conv['name'] = basename
|
505
|
-
timer.stop("-- all done in %0.4f seconds --")
|
784
|
+
t = timer.stop("-- all done in %0.4f seconds --", info=True)
|
785
|
+
journal.put('time_total', t)
|
786
|
+
journal.set('success', True)
|
506
787
|
return conv
|
507
788
|
|
508
789
|
|
509
790
|
def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
510
791
|
if not (m_inner and m_outer):
|
792
|
+
logger.warning("inner %s outer %s", m_inner, m_outer)
|
511
793
|
return {}
|
512
794
|
|
513
795
|
params = {}
|
@@ -518,14 +800,14 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
518
800
|
parts_outer = int(m_outer.get_symmetry_part())
|
519
801
|
|
520
802
|
if parts_inner > parts_outer:
|
521
|
-
num_slots = parts_inner
|
522
|
-
num_poles = parts_outer
|
803
|
+
num_slots = int(parts_inner)
|
804
|
+
num_poles = int(parts_outer)
|
523
805
|
num_sl_gen = int(geom_inner.get_symmetry_copies()+1)
|
524
806
|
alfa_slot = geom_inner.get_alfa()
|
525
807
|
alfa_pole = geom_outer.get_alfa()
|
526
808
|
else:
|
527
|
-
num_slots = parts_outer
|
528
|
-
num_poles = parts_inner
|
809
|
+
num_slots = int(parts_outer)
|
810
|
+
num_poles = int(parts_inner)
|
529
811
|
num_sl_gen = int(geom_outer.get_symmetry_copies()+1)
|
530
812
|
alfa_slot = geom_outer.get_alfa()
|
531
813
|
alfa_pole = geom_inner.get_alfa()
|
@@ -534,14 +816,11 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
534
816
|
params['num_sl_gen'] = num_sl_gen
|
535
817
|
params['num_poles'] = num_poles
|
536
818
|
params['nodedist'] = nodedist
|
537
|
-
|
819
|
+
params['external_rotor'] = parts_inner > parts_outer
|
538
820
|
params['dy1'] = 2*geom_outer.max_radius
|
539
821
|
params['da1'] = 2*geom_outer.min_radius
|
540
822
|
params['da2'] = 2*geom_inner.max_radius
|
541
823
|
params['dy2'] = 2*geom_inner.min_radius
|
542
|
-
params['agndst'] = agndst(params['da1'], params['da2'],
|
543
|
-
num_slots, num_poles,
|
544
|
-
nodedist)
|
545
824
|
params['alfa_slot'] = alfa_slot
|
546
825
|
params['alfa_pole'] = alfa_pole
|
547
826
|
|
@@ -564,7 +843,7 @@ def create_femag_parameters(m_inner, m_outer, nodedist=1):
|
|
564
843
|
def create_femag_parameters_stator(motor, position):
|
565
844
|
params = {}
|
566
845
|
num_slots = motor.get_num_slots()
|
567
|
-
params['tot_num_slot'] = num_slots
|
846
|
+
params['tot_num_slot'] = int(num_slots)
|
568
847
|
if position == 'in':
|
569
848
|
params['da2'] = 2*motor.geom.max_radius
|
570
849
|
params['dy2'] = 2*motor.geom.min_radius
|
@@ -577,7 +856,7 @@ def create_femag_parameters_stator(motor, position):
|
|
577
856
|
def create_femag_parameters_rotor(motor, position):
|
578
857
|
params = {}
|
579
858
|
num_poles = motor.get_num_poles()
|
580
|
-
params['num_poles'] = num_poles
|
859
|
+
params['num_poles'] = int(num_poles)
|
581
860
|
if position == 'in':
|
582
861
|
params['da2'] = 2*motor.geom.max_radius
|
583
862
|
params['dy2'] = 2*motor.geom.min_radius
|