femagtools 1.8.6__py3-none-any.whl → 1.8.8__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/amela.py +18 -286
- femagtools/bch.py +11 -7
- femagtools/ecloss.py +121 -105
- femagtools/femag.py +13 -73
- femagtools/fsl.py +11 -8
- femagtools/isa7.py +174 -10
- femagtools/leakinduc.py +63 -0
- femagtools/losscoeffs.py +29 -3
- femagtools/machine/afpm.py +138 -60
- femagtools/machine/effloss.py +13 -1
- femagtools/mcv.py +173 -9
- femagtools/nc.py +16 -14
- femagtools/parstudy.py +3 -1
- femagtools/plot/bch.py +126 -44
- femagtools/plot/nc.py +13 -0
- femagtools/shortcircuit.py +378 -0
- femagtools/templates/psi-torq-rem-rot.mako +127 -0
- femagtools/templates/psi-torq-rot.mako +98 -0
- femagtools/tks.py +1 -1
- femagtools/windings.py +65 -0
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/METADATA +1 -1
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/RECORD +31 -27
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/WHEEL +1 -1
- tests/test_afpm.py +2 -2
- tests/test_amela.py +1 -3
- tests/test_fsl.py +4 -4
- tests/test_nc.py +10 -0
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/LICENSE +0 -0
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/entry_points.txt +0 -0
- {femagtools-1.8.6.dist-info → femagtools-1.8.8.dist-info}/top_level.txt +0 -0
femagtools/machine/afpm.py
CHANGED
@@ -11,6 +11,10 @@ from .. import model
|
|
11
11
|
from .. import utils
|
12
12
|
from .. import windings
|
13
13
|
from .. import femag
|
14
|
+
from .. import ecloss
|
15
|
+
from .. import nc
|
16
|
+
from .. import bch
|
17
|
+
|
14
18
|
from scipy.interpolate import make_interp_spline, RegularGridInterpolator, RectBivariateSpline
|
15
19
|
from scipy.integrate import quad
|
16
20
|
import copy
|
@@ -27,6 +31,49 @@ AFM_TYPES = (
|
|
27
31
|
"S2R1_all" # 2 stator, 1 rotor, all simulated
|
28
32
|
)
|
29
33
|
|
34
|
+
def stator_template_name(machine):
|
35
|
+
for k in machine['stator']:
|
36
|
+
if type(machine['stator'][k]) == dict:
|
37
|
+
return k
|
38
|
+
return ''
|
39
|
+
|
40
|
+
def magnet_template_name(machine):
|
41
|
+
for k in machine['magnet']:
|
42
|
+
if type(machine['magnet'][k]) == dict:
|
43
|
+
return k
|
44
|
+
return ''
|
45
|
+
|
46
|
+
def jsonify(v):
|
47
|
+
vtype = type(v)
|
48
|
+
if vtype == np.float32:
|
49
|
+
return float(v)
|
50
|
+
if vtype == np.ndarray:
|
51
|
+
return v.tolist()
|
52
|
+
if vtype == dict:
|
53
|
+
for k in v:
|
54
|
+
v[k] = jsonify(v[k])
|
55
|
+
return v
|
56
|
+
|
57
|
+
|
58
|
+
def get_magdata(task):
|
59
|
+
basedir = Path(task.directory)
|
60
|
+
bchfile_list = sorted(basedir.glob(
|
61
|
+
'*_[0-9][0-9][0-9].B*CH'))
|
62
|
+
if bchfile_list:
|
63
|
+
result = bch.Reader()
|
64
|
+
with open(bchfile_list[-1]) as f:
|
65
|
+
logger.debug("Reading %s",
|
66
|
+
bchfile_list[-1])
|
67
|
+
result.read(f)
|
68
|
+
fnc = list(basedir.glob('*.nc'))[0]
|
69
|
+
ibeta = len(result.linearForce)-1
|
70
|
+
ncmod = nc.read(fnc)
|
71
|
+
result.losses[0]['magnet_data'] = [jsonify(pm)
|
72
|
+
for pm in ncmod.get_magnet_data(
|
73
|
+
ibeta=ibeta)]
|
74
|
+
return result
|
75
|
+
|
76
|
+
|
30
77
|
def num_agnodes(Q, p, pw, ag):
|
31
78
|
"""return total number of nodes in airgap per pole
|
32
79
|
Args:
|
@@ -51,6 +98,7 @@ def num_agnodes(Q, p, pw, ag):
|
|
51
98
|
# TODO nodedist 0.5, 2, 4, 6
|
52
99
|
return nag
|
53
100
|
|
101
|
+
|
54
102
|
def _integrate(radius, pos, val):
|
55
103
|
interp = RegularGridInterpolator((radius, pos), val)
|
56
104
|
def func(x, y):
|
@@ -66,6 +114,7 @@ def _integrate1d(radius, val):
|
|
66
114
|
return interp((x))
|
67
115
|
return quad(func, radius[0], radius[-1], limit=100)[0]
|
68
116
|
|
117
|
+
|
69
118
|
def ld_interpol(i1, beta, v):
|
70
119
|
'''interpolate Ld at beta angle 0°, -180°'''
|
71
120
|
# ld
|
@@ -86,8 +135,9 @@ def ld_interpol(i1, beta, v):
|
|
86
135
|
bp = beta[0:-1] + \
|
87
136
|
[[dbeta for i in range(len(np.unique(i1)))]]
|
88
137
|
|
89
|
-
return RectBivariateSpline(np.unique(bp), np.unique(cur),
|
90
|
-
|
138
|
+
return RectBivariateSpline(np.unique(bp), np.unique(cur),
|
139
|
+
np.array(v)).ev(*[betad, i1]).tolist()
|
140
|
+
|
91
141
|
|
92
142
|
def lq_interpol(i1, beta, v):
|
93
143
|
'''interpolate Lq at beta -90°'''
|
@@ -111,6 +161,7 @@ def lq_interpol(i1, beta, v):
|
|
111
161
|
return RectBivariateSpline(np.unique(bp), np.unique(cur), \
|
112
162
|
np.array(v)).ev(*[betad, i1]).tolist()
|
113
163
|
|
164
|
+
|
114
165
|
def parident(workdir, engine, temp, machine,
|
115
166
|
magnetizingCurves, magnetMat=[], condMat=[],
|
116
167
|
**kwargs):
|
@@ -142,7 +193,7 @@ def parident(workdir, engine, temp, machine,
|
|
142
193
|
|
143
194
|
di = machine['inner_diam']
|
144
195
|
Q1 = machine['stator']['num_slots']
|
145
|
-
slotmodel =
|
196
|
+
slotmodel = stator_template_name(machine)
|
146
197
|
hs = machine['stator'][slotmodel]['slot_height']
|
147
198
|
wdgk = 'windings' if 'windings' in machine else 'winding'
|
148
199
|
N = machine[wdgk]['num_wires']
|
@@ -154,17 +205,19 @@ def parident(workdir, engine, temp, machine,
|
|
154
205
|
machine[wdgk].get('num_par_wdgs', 1))
|
155
206
|
|
156
207
|
p = machine['poles']
|
157
|
-
|
208
|
+
slotmodel = magnet_template_name(machine)
|
209
|
+
if np.isscalar(machine['magnet'][slotmodel]['rel_magn_width']):
|
158
210
|
num_slices = kwargs.get('num_slices', 3)
|
159
|
-
rmagw = num_slices*[machine['magnet'][
|
211
|
+
rmagw = num_slices*[machine['magnet'][slotmodel]['rel_magn_width']]
|
160
212
|
else:
|
161
|
-
rmagw = machine['magnet'][
|
213
|
+
rmagw = machine['magnet'][slotmodel]['rel_magn_width']
|
162
214
|
if len(rmagw) == 1:
|
163
215
|
num_slices = kwargs.get('num_slices', 3)
|
164
216
|
rmagw = num_slices*list(rmagw)
|
165
217
|
else:
|
166
218
|
num_slices = len(rmagw)
|
167
219
|
|
220
|
+
logger.info("num_slices %d rmagw %s", num_slices, rmagw)
|
168
221
|
lfe = get_arm_lengths(machine['outer_diam'],
|
169
222
|
machine['inner_diam'],
|
170
223
|
num_slices)
|
@@ -185,7 +238,7 @@ def parident(workdir, engine, temp, machine,
|
|
185
238
|
{"values": pole_width,
|
186
239
|
"name": "pole_width"},
|
187
240
|
{"values": rmagw,
|
188
|
-
"name": "magnet.
|
241
|
+
"name": f"magnet.{slotmodel}.rel_magn_width"},
|
189
242
|
{"values": lfe,
|
190
243
|
"name": "lfe"},
|
191
244
|
{"values": linspeed, "name": "speed"}
|
@@ -234,7 +287,7 @@ def parident(workdir, engine, temp, machine,
|
|
234
287
|
for pw, le, sp, rmw in zip(pole_width, lfe, linspeed, rmagw):
|
235
288
|
nlmachine = {k: machine[k] for k in machine}
|
236
289
|
nlmachine['pole_width'] = pw
|
237
|
-
nlmachine['magnet'][
|
290
|
+
nlmachine['magnet'][slotmodel]['rel_magn_width'] = rmw
|
238
291
|
nlmachine['lfe'] = le
|
239
292
|
nlcalc.update({"speed": sp})
|
240
293
|
nlsubdir = f'{workdir}/{i}'
|
@@ -242,9 +295,10 @@ def parident(workdir, engine, temp, machine,
|
|
242
295
|
if nlworkdir.exists():
|
243
296
|
shutil.rmtree(nlworkdir)
|
244
297
|
nlworkdir.mkdir(exist_ok=True)
|
245
|
-
noloadsim = femag.Femag(
|
246
|
-
|
247
|
-
|
298
|
+
noloadsim = femag.Femag(
|
299
|
+
nlworkdir, condMat=condMat, magnets=magnetMat,
|
300
|
+
magnetizingCurves=magnetizingCurves,
|
301
|
+
cmd=kwargs.get('cmd', None))
|
248
302
|
r = noloadsim(nlmachine, nlcalc)
|
249
303
|
nlresults['f'].append({k: v for k, v in r.items()})
|
250
304
|
i = i + 1
|
@@ -254,10 +308,10 @@ def parident(workdir, engine, temp, machine,
|
|
254
308
|
results = []
|
255
309
|
i = 0
|
256
310
|
for l, pw, rmw in zip(lfe, pole_width, rmagw):
|
257
|
-
mpart = {k: machine[k] for k in machine if k !=
|
311
|
+
mpart = {k: machine[k] for k in machine if k != slotmodel}
|
258
312
|
mpart['pole_width'] = pw
|
259
313
|
mpart['lfe'] = l
|
260
|
-
mpart['magnet'][
|
314
|
+
mpart['magnet'][slotmodel]['rel_magn_width'] = rmw
|
261
315
|
subdir = f"{workdir}/{i}"
|
262
316
|
|
263
317
|
simulation = dict(
|
@@ -265,8 +319,8 @@ def parident(workdir, engine, temp, machine,
|
|
265
319
|
wind_temp=20.0,
|
266
320
|
magn_temp=magtemp,
|
267
321
|
angl_i_up=0.0,
|
268
|
-
magn_height=machine['magnet'][
|
269
|
-
yoke_height=machine['magnet'][
|
322
|
+
magn_height=machine['magnet'][slotmodel]['magn_height'],
|
323
|
+
yoke_height=machine['magnet'][slotmodel].get(
|
270
324
|
'yoke_height', 0),
|
271
325
|
current=1,
|
272
326
|
poc=poc.Poc(999,
|
@@ -278,9 +332,10 @@ def parident(workdir, engine, temp, machine,
|
|
278
332
|
|
279
333
|
if kwargs.get('use_multiprocessing', True):
|
280
334
|
gpstudy = parstudy.Grid(
|
281
|
-
|
282
|
-
|
283
|
-
|
335
|
+
subdir, condMat=condMat, magnets=magnetMat,
|
336
|
+
magnetizingCurves=magnetizingCurves,
|
337
|
+
cmd=kwargs.get('cmd', None),
|
338
|
+
result_func=get_magdata)
|
284
339
|
lresults = gpstudy(parvardef, mpart, simulation, engine)
|
285
340
|
|
286
341
|
else:
|
@@ -299,9 +354,10 @@ def parident(workdir, engine, temp, machine,
|
|
299
354
|
if lworkdir.exists():
|
300
355
|
shutil.rmtree(lworkdir)
|
301
356
|
lworkdir.mkdir(exist_ok=True)
|
302
|
-
loadsim = femag.Femag(
|
303
|
-
|
304
|
-
|
357
|
+
loadsim = femag.Femag(
|
358
|
+
lworkdir, condMat=condMat, magnets=magnetMat,
|
359
|
+
magnetizingCurves=magnetizingCurves,
|
360
|
+
cmd=kwargs.get('cmd', None))
|
305
361
|
r = loadsim(mpart, simulation)
|
306
362
|
lresults['f'].append({k: v for k, v in r.items()})
|
307
363
|
|
@@ -371,7 +427,7 @@ def parident(workdir, engine, temp, machine,
|
|
371
427
|
losses.update({'speed': speed,
|
372
428
|
'hf': postp[0]['lossPar']['hf'],
|
373
429
|
'ef': postp[0]['lossPar']['ef'],
|
374
|
-
'magnet':np.flip(
|
430
|
+
'magnet': np.flip(
|
375
431
|
np.reshape([r['plmag'] for r in postp],
|
376
432
|
(-1, num_beta_steps)),
|
377
433
|
axis=1).T.tolist()})
|
@@ -416,8 +472,8 @@ def process(lfe, pole_width, machine, bch):
|
|
416
472
|
slots_gen = mmod.stator['num_slots_gen']
|
417
473
|
scale_factor = _get_scale_factor(model_type, num_slots, slots_gen)
|
418
474
|
endpos = [2*pw*1e3 for pw in pole_width]
|
419
|
-
displ = [[d for d in r['linearForce'][
|
420
|
-
if d < e*(1+1/len(r['linearForce'][
|
475
|
+
displ = [[d for d in r['linearForce'][-1]['displ']
|
476
|
+
if d < e*(1+1/len(r['linearForce'][-1]['displ']))]
|
421
477
|
for e, r in zip(endpos, bch)]
|
422
478
|
radius = [pw*machine['poles']/2/np.pi for pw in pole_width]
|
423
479
|
rotpos = [np.array(d)/r/1000 for r, d in zip(radius, displ)]
|
@@ -430,20 +486,20 @@ def process(lfe, pole_width, machine, bch):
|
|
430
486
|
if np.diff([len(d) for d in displ]).any():
|
431
487
|
raise ValueError(
|
432
488
|
f"inhomogenous number of steps: {[len(d) for d in displ]}")
|
433
|
-
lfx = [r['linearForce'][
|
489
|
+
lfx = [r['linearForce'][-1]['force_x'] for r in bch]
|
434
490
|
torque = _integrate(radius, rotpos[0], np.array(
|
435
491
|
[r*scale_factor*np.array(fx[:-1])/l
|
436
492
|
for l, r, fx in zip(lfe, radius, lfx)]))
|
437
493
|
|
438
494
|
voltage = {k: [scale_factor * np.array(ux[:-1])/l
|
439
|
-
for l, ux in zip(lfe, [r['flux'][k][
|
495
|
+
for l, ux in zip(lfe, [r['flux'][k][-1]['voltage_dpsi']
|
440
496
|
for r in bch])]
|
441
497
|
for k in bch[0]['flux']}
|
442
498
|
emf = [_integrate(radius, rotpos[0], np.array(voltage[k]))
|
443
499
|
for k in voltage]
|
444
500
|
|
445
501
|
fluxxy = {k: [scale_factor * np.array(flx[:-1])/l
|
446
|
-
for l, flx in zip(lfe, [r['flux'][k][
|
502
|
+
for l, flx in zip(lfe, [r['flux'][k][-1]['flux_k']
|
447
503
|
for r in bch])]
|
448
504
|
for k in bch[0]['flux']}
|
449
505
|
flux = [_integrate(radius, rotpos[0], np.array(fluxxy[k]))
|
@@ -451,57 +507,67 @@ def process(lfe, pole_width, machine, bch):
|
|
451
507
|
else:
|
452
508
|
r = radius[0]
|
453
509
|
torque = [r*scale_factor*fx
|
454
|
-
for fx in bch[0]['linearForce'][
|
510
|
+
for fx in bch[0]['linearForce'][-1]['force_x'][:-1]]
|
455
511
|
voltage = {k: [scale_factor * ux
|
456
|
-
for ux in bch[0]['flux'][k][
|
512
|
+
for ux in bch[0]['flux'][k][-1]['voltage_dpsi'][:-1]]
|
457
513
|
for k in bch[0]['flux']}
|
458
514
|
emf = [voltage[k][:n] for k in voltage]
|
459
515
|
fluxxy = {k: [scale_factor * np.array(flx)
|
460
|
-
for flx in bch[0]['flux'][k][
|
516
|
+
for flx in bch[0]['flux'][k][-1]['flux_k']]
|
461
517
|
for k in bch[0]['flux']}
|
462
518
|
flux = [fluxxy[k][:n] for k in fluxxy]
|
463
519
|
|
464
520
|
pos = (rotpos[0]/np.pi*180)
|
465
521
|
emffft = utils.fft(pos, emf[0])
|
466
522
|
|
523
|
+
scale_factor = 1 if model_type == 'S1R1' else 2
|
467
524
|
styoke = {}
|
468
|
-
stteeth = {'hyst':0, 'eddy':0}
|
525
|
+
stteeth = {'hyst': 0, 'eddy': 0}
|
469
526
|
rotor = {}
|
470
527
|
for k in ('hyst', 'eddy'):
|
471
528
|
if len(pole_width) > 1:
|
472
529
|
styoke[k] = _integrate1d(radius, scale_factor*np.array(
|
473
|
-
[sum(b['losses'][
|
530
|
+
[sum(b['losses'][-1]['stator']['stfe'][k])/l
|
474
531
|
for l, b in zip(lfe, bch)]))
|
475
532
|
rotor[k] = _integrate1d(radius, scale_factor*np.array(
|
476
|
-
[sum(b['losses'][
|
533
|
+
[sum(b['losses'][-1]['rotor']['----'][k])/l
|
477
534
|
for l, b in zip(lfe, bch)]))
|
478
535
|
else:
|
479
536
|
styoke[k] = scale_factor*sum(
|
480
|
-
bch[0]['losses'][
|
537
|
+
bch[0]['losses'][-1]['stator']['stfe'][k])
|
481
538
|
rotor[k] = scale_factor*sum(
|
482
|
-
bch[0]['losses'][
|
539
|
+
bch[0]['losses'][-1]['rotor']['----'][k])
|
483
540
|
|
484
|
-
if '
|
541
|
+
if 'magnet_data' in bch[0]['losses'][0]:
|
485
542
|
k = 'magnetH'
|
543
|
+
nsegx = machine['magnet'].get('num_segments', 1)
|
544
|
+
if type(nsegx) == int:
|
545
|
+
nsegx = [nsegx]*len(bch)
|
546
|
+
for nx, b in zip(nsegx, bch):
|
547
|
+
pm = b['losses'][0]['magnet_data']
|
548
|
+
magloss = ecloss.MagnLoss(magnet_data=[pm])
|
549
|
+
ml = magloss.calc_losses_ialh2(nsegx=nx)
|
550
|
+
b['losses'][-1][k] = ml[0]
|
486
551
|
else:
|
487
552
|
k = 'magnetJ'
|
488
553
|
if len(pole_width) > 1:
|
489
554
|
maglosses = _integrate1d(radius, scale_factor*np.array(
|
490
|
-
[b['losses'][
|
555
|
+
[b['losses'][-1][k]/lz
|
556
|
+
for lz, b in zip(lfe, bch)]))
|
491
557
|
else:
|
492
|
-
maglosses = scale_factor*bch[0]['losses'][
|
558
|
+
maglosses = scale_factor*bch[0]['losses'][-1][k]
|
493
559
|
|
494
|
-
freq = bch[0]['losses'][
|
560
|
+
freq = bch[0]['losses'][-1]['stator']['stfe']['freq'][0]
|
495
561
|
|
496
562
|
wdg = windings.Winding(
|
497
563
|
dict(Q=mmod.stator['num_slots'],
|
498
564
|
p=mmod.poles//2,
|
499
565
|
m=mmod.winding['num_phases'],
|
500
566
|
l=mmod.winding['num_layers']))
|
501
|
-
|
567
|
+
slotmodel = stator_template_name(machine)
|
502
568
|
cufill = mmod.winding.get('cufilfact', 0.4)
|
503
|
-
aw = (mmod.stator[
|
504
|
-
mmod.stator[
|
569
|
+
aw = (mmod.stator[slotmodel]['slot_width']*
|
570
|
+
mmod.stator[slotmodel]['slot_height']*
|
505
571
|
cufill/mmod.winding['num_wires']/mmod.winding['num_layers'])
|
506
572
|
r1 = wdg_resistance(wdg, mmod.winding['num_wires'],
|
507
573
|
mmod.winding['num_par_wdgs'],
|
@@ -687,9 +753,9 @@ def _draw_vertical_slots(ax,
|
|
687
753
|
beta0 = np.linspace(n*taus + taus/2+alpha[0], (n+1)*taus, 5)
|
688
754
|
beta1 = np.linspace(n*taus + taus/2+alpha[1], (n+1)*taus, 5)
|
689
755
|
xr = np.concatenate((
|
690
|
-
r[0]*np.cos(beta0), r[1]*np.cos(beta1[::-1])))
|
756
|
+
r[0]*np.cos(beta0), r[1]*np.cos(beta1[::-1])))+xoff
|
691
757
|
yr = np.concatenate((
|
692
|
-
r[0]*np.sin(beta0), r[1]*np.sin(beta1[::-1])))
|
758
|
+
r[0]*np.sin(beta0), r[1]*np.sin(beta1[::-1])))+yoff
|
693
759
|
ax.fill(xr, yr, color=color[0])
|
694
760
|
|
695
761
|
|
@@ -707,7 +773,10 @@ def vertical_plot(machine, ax):
|
|
707
773
|
model_type = machine['afmtype'][0:4]
|
708
774
|
dy1 = machine['outer_diam']*1e3
|
709
775
|
dy2 = machine['inner_diam']*1e3
|
710
|
-
|
776
|
+
try:
|
777
|
+
rel_magn_width = max(machine['magnet']['afm_rotor']['rel_magn_width'])
|
778
|
+
except TypeError:
|
779
|
+
rel_magn_width = machine['magnet']['afm_rotor']['rel_magn_width']
|
711
780
|
Q = machine['stator']['num_slots']
|
712
781
|
slot_width = machine['stator']['afm_stator']['slot_width']*1e3
|
713
782
|
poles = machine['poles']
|
@@ -856,7 +925,10 @@ def horizontal_plot(machine, ax):
|
|
856
925
|
model_type = machine['afmtype'][0:4]
|
857
926
|
dy1 = machine['outer_diam']*1e3
|
858
927
|
dy2 = machine['inner_diam']*1e3
|
859
|
-
|
928
|
+
try:
|
929
|
+
rel_magn_width = max(machine['magnet']['afm_rotor']['rel_magn_width'])
|
930
|
+
except TypeError:
|
931
|
+
rel_magn_width = machine['magnet']['afm_rotor']['rel_magn_width']
|
860
932
|
magn_height = machine['magnet']['afm_rotor']['magn_height']*1e3
|
861
933
|
magn_yoke_height = machine['magnet']['afm_rotor']['yoke_height']*1e3
|
862
934
|
|
@@ -948,15 +1020,15 @@ class AFPM:
|
|
948
1020
|
raise ValueError(f"invalid afm type {machine['afmtype']}")
|
949
1021
|
except KeyError:
|
950
1022
|
raise ValueError("missing key afmtype")
|
951
|
-
|
952
|
-
|
953
|
-
|
1023
|
+
slotmodel = magnet_template_name(machine)
|
1024
|
+
logger.info("num_slices %d rmagw %s", num_slices,
|
1025
|
+
machine['magnet'][slotmodel]['rel_magn_width'])
|
1026
|
+
if np.isscalar(machine['magnet'][slotmodel]['rel_magn_width']):
|
1027
|
+
rmagw = num_slices*[machine['magnet'][slotmodel]['rel_magn_width']]
|
954
1028
|
else:
|
955
|
-
rmagw = machine['magnet'][
|
956
|
-
|
957
|
-
|
958
|
-
elif num_slices != len(rmagw):
|
959
|
-
num_slices = len(rmagw)
|
1029
|
+
rmagw = machine['magnet'][slotmodel]['rel_magn_width']
|
1030
|
+
num_slices = len(rmagw)
|
1031
|
+
|
960
1032
|
lfe = get_arm_lengths(machine['outer_diam'],
|
961
1033
|
machine['inner_diam'],
|
962
1034
|
num_slices)
|
@@ -981,20 +1053,23 @@ class AFPM:
|
|
981
1053
|
{"values": lfe,
|
982
1054
|
"name": "lfe"},
|
983
1055
|
{"values": rmagw,
|
984
|
-
"name": "magnet.
|
1056
|
+
"name": f"magnet.{slotmodel}.rel_magn_width"},
|
985
1057
|
{"values": linspeed, "name": "speed"}
|
986
1058
|
]
|
987
1059
|
}
|
988
1060
|
|
989
1061
|
machine['pole_width'] = np.pi * machine['inner_diam']/machine['poles']
|
990
1062
|
machine['lfe'] = machine['outer_diam'] - machine['inner_diam']
|
991
|
-
|
992
|
-
machine['magnet'][
|
1063
|
+
try:
|
1064
|
+
machine['magnet'][slotmodel]['rel_magn_width'] = max(
|
1065
|
+
machine['magnet'][slotmodel]['rel_magn_width'])
|
1066
|
+
except TypeError:
|
1067
|
+
pass
|
993
1068
|
|
994
1069
|
simulation['skew_displ'] = (simulation.get('skew_angle', 0)/180 * np.pi
|
995
1070
|
* machine['inner_diam'])
|
996
1071
|
nlresults = {}
|
997
|
-
if (simulation['calculationMode']
|
1072
|
+
if (simulation['calculationMode'] == 'torq_calc'
|
998
1073
|
and 'poc' not in simulation):
|
999
1074
|
nlcalc = dict(
|
1000
1075
|
calculationMode="cogg_calc",
|
@@ -1017,10 +1092,13 @@ class AFPM:
|
|
1017
1092
|
parameters={
|
1018
1093
|
'phi_voltage_winding': current_angles})
|
1019
1094
|
logger.info("Current angles: %s", current_angles)
|
1020
|
-
|
1021
|
-
|
1095
|
+
simulation['calc_noload'] = 0
|
1096
|
+
|
1097
|
+
if 'poc' not in simulation:
|
1022
1098
|
simulation['poc'] = poc.Poc(machine['pole_width'])
|
1023
1099
|
|
1100
|
+
self.parstudy.result_func = get_magdata
|
1101
|
+
logger.info("Simulation %s", simulation['calculationMode'])
|
1024
1102
|
lresults = self.parstudy(
|
1025
1103
|
parvardef, machine, simulation, engine)
|
1026
1104
|
if lresults['status'].count('C') != len(lresults['status']):
|
femagtools/machine/effloss.py
CHANGED
@@ -327,11 +327,19 @@ def efficiency_losses_map(eecpars, u1, T, temp, n, npoints=(60, 40),
|
|
327
327
|
plcu1 = m.iqd_plcu1(iqd[0], iqd[1], 2*np.pi*f1)
|
328
328
|
plcu2 = m.iqd_plcu2(*iqd)
|
329
329
|
tfric = m.tfric
|
330
|
+
try:
|
331
|
+
plcu1_dc = m.iqd_plcu1(iqd[0], iqd[1],
|
332
|
+
np.array([0.0 for i in f1])).tolist()
|
333
|
+
plcu1_ac = [i-j for i, j in zip(plcu1.tolist(), plcu1_dc)]
|
334
|
+
except:
|
335
|
+
plcu1_dc, plcu1_ac = [], []
|
330
336
|
elif isinstance(m, SynchronousMachine):
|
331
337
|
plfe1 = m.kpfe*m.iqd_plfe1(*iqd, f1)
|
332
338
|
plfe2 = m.kpfe*m.iqd_plfe2(*iqd, f1)
|
333
339
|
plmag = np.zeros_like(plfe2)
|
334
340
|
plcu1 = m.iqd_plcu1(iqd[0], iqd[1], 2*np.pi*f1)
|
341
|
+
plcu1_dc = [] # reserved for winding (dc, ac) losses
|
342
|
+
plcu1_ac = []
|
335
343
|
plcu2 = m.iqd_plcu2(*iqd)
|
336
344
|
tfric = m.tfric
|
337
345
|
logger.info("Iex %f %f",
|
@@ -342,6 +350,8 @@ def efficiency_losses_map(eecpars, u1, T, temp, n, npoints=(60, 40),
|
|
342
350
|
plmag = np.zeros(ntmesh.shape[1])
|
343
351
|
plcu1 = np.array(r['plcu1'])
|
344
352
|
plcu2 = np.array(r['plcu2'])
|
353
|
+
plcu1_dc = [] # reserved for winding (dc, ac) losses
|
354
|
+
plcu1_ac = []
|
345
355
|
iqd = np.zeros(ntmesh.shape)
|
346
356
|
u1 = np.array(r['u1'])
|
347
357
|
i1 = np.array(r['i1'])
|
@@ -387,4 +397,6 @@ def efficiency_losses_map(eecpars, u1, T, temp, n, npoints=(60, 40),
|
|
387
397
|
plcu1=plcu1.tolist(),
|
388
398
|
plcu2=plcu2.tolist(),
|
389
399
|
plfric=plfric.tolist(),
|
390
|
-
losses=ploss.tolist()
|
400
|
+
losses=ploss.tolist(),
|
401
|
+
plcu1_dc=plcu1_dc,
|
402
|
+
plcu1_ac=plcu1_ac)
|