femagtools 1.7.9__py3-none-any.whl → 1.8.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.
Files changed (42) hide show
  1. femagtools/__init__.py +1 -1
  2. femagtools/amela.py +2 -2
  3. femagtools/dxfsl/area.py +129 -25
  4. femagtools/dxfsl/conv.py +2 -9
  5. femagtools/dxfsl/converter.py +33 -10
  6. femagtools/dxfsl/fslrenderer.py +6 -12
  7. femagtools/dxfsl/geom.py +31 -9
  8. femagtools/dxfsl/journal.py +2 -2
  9. femagtools/dxfsl/machine.py +14 -13
  10. femagtools/dxfsl/shape.py +3 -0
  11. femagtools/ecloss.py +381 -2
  12. femagtools/femag.py +41 -0
  13. femagtools/fsl.py +31 -50
  14. femagtools/machine/pm.py +1 -1
  15. femagtools/machine/sm.py +14 -0
  16. femagtools/mcv.py +128 -124
  17. femagtools/me.py +13 -13
  18. femagtools/model.py +8 -2
  19. femagtools/plot/fieldlines.py +1 -1
  20. femagtools/plot/mcv.py +18 -0
  21. femagtools/plot/wdg.py +2 -2
  22. femagtools/svgfsl/converter.py +1 -1
  23. femagtools/templates/gen_hairpin_winding.mako +36 -45
  24. femagtools/templates/magnetIron.mako +1 -1
  25. femagtools/templates/magnetIron2.mako +1 -1
  26. femagtools/templates/magnetIron3.mako +1 -1
  27. femagtools/templates/magnetIron4.mako +1 -1
  28. femagtools/templates/magnetIron5.mako +1 -1
  29. femagtools/templates/magnetIronV.mako +1 -1
  30. femagtools/templates/magnetSector.mako +1 -1
  31. femagtools/templates/mesh-airgap.mako +12 -6
  32. femagtools/templates/prepare_thermal.mako +148 -13
  33. femagtools/windings.py +25 -20
  34. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/METADATA +20 -20
  35. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/RECORD +41 -42
  36. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/WHEEL +1 -1
  37. tests/test_mcv.py +106 -1
  38. tests/test_windings.py +5 -0
  39. tests/test_mcvwriter.py +0 -96
  40. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/LICENSE +0 -0
  41. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/entry_points.txt +0 -0
  42. {femagtools-1.7.9.dist-info → femagtools-1.8.0.dist-info}/top_level.txt +0 -0
femagtools/mcv.py CHANGED
@@ -103,6 +103,54 @@ def norm_pfe(B, pfe):
103
103
  for x in Bv[:n]] + [None]*(len(Bv)-n))
104
104
  return Bv.tolist(), m
105
105
 
106
+ def extrapol(crv, jsat=0, bmax=3):
107
+ """extends BH curve into saturation range"""
108
+ curve = copy.deepcopy(crv)
109
+ dh = curve['hi'][-1]-curve['hi'][-2]
110
+ db = curve['bi'][-1]-curve['bi'][-2]
111
+ mue_d = db/dh
112
+ mue = curve['bi'][-1]/curve['hi'][-1]
113
+ db = 3e-2*curve['bi'][-1]
114
+ b2 = 1.5
115
+
116
+ curve['muer'] = [b/MUE0/h if h>0 else float('nan')
117
+ for b, h in zip(curve['bi'],
118
+ curve['hi'])]
119
+
120
+ # extend bh-curve into saturation
121
+ while mue_d > 1.01*MUE0 and mue > 1.5*MUE0:
122
+ mue_d = MUE0 + (mue_d-MUE0)/np.sqrt(b2)
123
+ curve['bi'].append(curve['bi'][-1]+db)
124
+ curve['hi'].append(curve['hi'][-1]+db/mue_d)
125
+ curve['muer'].append(curve['bi'][-1]/MUE0/curve['hi'][-1])
126
+ b2 += 2
127
+ mue = curve['bi'][-1]/curve['hi'][-1]
128
+
129
+ # Fröhlich-Kennelly coefficients
130
+ if jsat:
131
+ hx = curve['hi'][-1]
132
+ bx = curve['bi'][-1]
133
+ fkb = 1./jsat
134
+ fka = (hx/(bx - MUE0*hx) - hx/jsat)
135
+ else:
136
+ Js1 = curve['bi'][-1] - MUE0*curve['hi'][-1]
137
+ Js0 = curve['bi'][-2] - MUE0*curve['hi'][-2]
138
+ fkb = ((curve['hi'][-1]/Js1 - curve['hi'][-2]/Js0)
139
+ /(curve['hi'][-1] - curve['hi'][-2]))
140
+ fka = curve['hi'][-1]/Js1 - fkb*curve['hi'][-1]
141
+ logger.debug("B values %d Fröhlich-Kennelly coeffs: a %f b %f",
142
+ len(curve['bi']), fka, fkb)
143
+ bstep = 0.15
144
+ bx = np.arange(curve['bi'][-1] + bstep, bmax, bstep)
145
+ # Fröhlich-Kennelly approximation
146
+ b = fkb * bx - MUE0*fka - 1
147
+ a = fkb * bx
148
+ c = MUE0*fka
149
+ nuer = (b + np.sqrt(b*b + 4*a*c))/2/a
150
+ curve['bi'] += bx.tolist()
151
+ curve['hi'] += (nuer*bx/MUE0).tolist()
152
+ return curve
153
+
106
154
 
107
155
  def recalc_bsin(curve):
108
156
  """recalculates B-H curve (static problems) into effective
@@ -159,7 +207,7 @@ def recalc_hsin(curve):
159
207
  return ncurve
160
208
 
161
209
 
162
- def approx(db2, curve):
210
+ def approx(db2, curve, ctype):
163
211
  """return nuer, bi2, a, b approx for curve"""
164
212
  nuek0 = (curve['hi'][1] - curve['hi'][0]) / \
165
213
  (curve['bi'][1]-curve['bi'][0])
@@ -191,12 +239,22 @@ def approx(db2, curve):
191
239
  nuer.append(MUE0*nuek1)
192
240
  bi2.append(bk12)
193
241
 
194
- a.append(1.0)
195
- b.append(MUE0*curve['hi'][-1]-curve['bi'][-1])
242
+ if ctype in (DEMCRV, MAG_AC_CRV):
243
+ dhdbn = 0
244
+ k = len(bi2)-1
245
+ if curve['bi'][k] - curve['bi'][k-1] > 0:
246
+ dhdbn = ((curve['hi'][k] - curve['h'][k-1],KK)
247
+ /(curve['bi'][k] - curve['bi'][k-1]))
248
+ a.append(MUE0*dhdbn)
249
+ b.append(MUE0*curve['hi'][k] - dhdbn*curve['bi'][k])
250
+ else:
251
+ a.append(1.0)
252
+ b.append(MUE0*curve['hi'][-1]-curve['bi'][-1])
196
253
  return dict(nuer=nuer, a=a, b=b, bi2=bi2)
197
254
 
198
255
 
199
256
  def fe_sat_mag(curve):
257
+ """returns maximum polarization of all BH curves"""
200
258
  fesat = 0
201
259
  for c in curve:
202
260
  js2 = c['bi'][-1] - MUE0*c['hi'][-1]
@@ -219,7 +277,7 @@ def findNotNone(l):
219
277
 
220
278
 
221
279
  class Mcv(object):
222
- def __init__(self):
280
+ def __init__(self, data={}):
223
281
  # default values from file: mcv.par
224
282
  self.ACT_VERSION_MC_CURVE = 0
225
283
  self.ORIENTED_VERSION_MC_CURVE = 1
@@ -248,7 +306,6 @@ class Mcv(object):
248
306
  self.mc1_induction_factor = self.MC1_INDUCTION_FACTOR
249
307
  self.mc1_induction_beta_factor = self.MC1_INDUCTION_BETA_FACTOR
250
308
  self.mc1_fe_spez_weigth = self.MC1_FE_SPEZ_WEIGTH
251
- self.mc1_fe_sat_magnetization = self.MC1_FE_SAT_MAGNETIZATION
252
309
 
253
310
  self.mc1_title = ''
254
311
  self.version_mc_curve = self.ACT_VERSION_MC_CURVE
@@ -274,26 +331,18 @@ class Mcv(object):
274
331
 
275
332
  self.mc1_energy = [[0]*self.MCURVES_MAX]*self.MC1_NIMAX
276
333
 
277
- def rtrimValueList(self, vlist):
278
- """cut list at first 0"""
279
- le = len(vlist)
280
- for i in range(le-1, -1, -1):
281
- if vlist[i] != 0.:
282
- break
283
- return list(vlist[:i+1])
284
-
285
- def __getitem__(self, key):
286
- if key == 'ctype': # for compatibility purposes
287
- return self.mc1_type
288
- return getattr(self, key)
289
-
290
-
291
- class Writer(Mcv):
292
- def __init__(self, data=None):
293
- Mcv.__init__(self)
294
334
  if data:
295
335
  self.setData(data)
296
336
 
337
+ self.mc1_curves = len(self.curve)
338
+ if self.mc1_type == MAGCRV and self.mc1_curves > 1:
339
+ self.mc1_type = ORIENT_CRV
340
+ if self.mc1_type in (ORIENT_CRV, ORIENT_PM_CRV):
341
+ self.version_mc_curve = self.ORIENTED_VERSION_MC_CURVE
342
+ elif self.mc1_type == DEMCRV_BR:
343
+ self.version_mc_curve = self.PARAMETER_PM_CURVE
344
+
345
+
297
346
  def __setattr__(self, key, val):
298
347
  try:
299
348
  self.__dict__[key] = val
@@ -317,6 +366,24 @@ class Writer(Mcv):
317
366
  pass
318
367
  return
319
368
 
369
+ def rtrimValueList(self, vlist):
370
+ """cut list at first 0"""
371
+ le = len(vlist)
372
+ for i in range(le-1, -1, -1):
373
+ if vlist[i] != 0.:
374
+ break
375
+ return list(vlist[:i+1])
376
+
377
+ def __getitem__(self, key):
378
+ if key == 'ctype': # for compatibility purposes
379
+ return self.mc1_type
380
+ return getattr(self, key)
381
+
382
+
383
+ class Writer(Mcv):
384
+ def __init__(self, data=None):
385
+ Mcv.__init__(self, data)
386
+
320
387
  def getBlockLength(self, d):
321
388
  if isinstance(d, string_types) or isinstance(d, bytes):
322
389
  try:
@@ -374,11 +441,6 @@ class Writer(Mcv):
374
441
 
375
442
  def _prepare(self, fillfac, recsin):
376
443
  """prepare output format (internal use only)"""
377
- if self.mc1_type in (ORIENT_CRV, ORIENT_PM_CRV):
378
- self.version_mc_curve = self.ORIENTED_VERSION_MC_CURVE
379
- elif self.mc1_type == DEMCRV_BR:
380
- self.version_mc_curve = self.PARAMETER_PM_CURVE
381
-
382
444
  curve = copy.deepcopy(self.curve)
383
445
  if fillfac:
384
446
  alpha = fillfac/self.mc1_fillfac
@@ -392,17 +454,17 @@ class Writer(Mcv):
392
454
  if fillfac or recsin:
393
455
  if hasattr(self, 'mc1_fe_sat_magnetization'):
394
456
  self.mc1_fe_sat_magnetization = fe_sat_mag(curve)
395
- logger.info("%s Type: %d Num Curves %d",
457
+ logger.info("%s Type: %d (%s) Num Curves %d",
396
458
  self.name, self.version_mc_curve,
459
+ types[self.mc1_type],
397
460
  len(self.curve))
398
- self.mc1_curves = len(self.curve)
399
461
  self.mc1_ni = [min(len(c['hi']),
400
462
  len(c['bi']))
401
463
  for c in self.curve if 'hi' in c]
402
464
  self.mc1_db2 = [(c['bi'][-1]**2 - c['bi'][0]**2)/n
403
465
  for c, n in zip(curve, self.mc1_mi)]
404
466
  for db2, c in zip(self.mc1_db2, curve):
405
- c.update(approx(db2, c))
467
+ c.update(approx(db2, c, self.mc1_type))
406
468
  if not hasattr(self, 'mc1_fe_sat_magnetization'):
407
469
  self.mc1_fe_sat_magnetization = fe_sat_mag(curve)
408
470
  self.mc1_mi = [len(c['a'])
@@ -513,6 +575,7 @@ class Writer(Mcv):
513
575
  self.mc1_cw_factor = cw
514
576
  self.mc1_cw_freq_factor = beta
515
577
  self.mc1_induction_factor = gamma
578
+
516
579
  except AttributeError:
517
580
  pass
518
581
  self.writeBlock([float(self.mc1_base_frequency),
@@ -528,10 +591,10 @@ class Writer(Mcv):
528
591
  if not hasattr(self, 'losses') or not self.losses:
529
592
  # new variables: ce factor for bertotti losses
530
593
  # b_beta_coeff for modified steinmetz
531
- try:
532
- self.writeBlock([float(self.mc1_ce_factor),
594
+ try:
595
+ self.writeBlock([float(self.mc1_ce_factor),
533
596
  float(self.mc1_induction_beta_factor)])
534
- except:
597
+ except:
535
598
  pass
536
599
  return
537
600
 
@@ -599,7 +662,7 @@ class Writer(Mcv):
599
662
  logger.info('Losses n freq %d n ind %d', nfreq, nind)
600
663
  except Exception as e:
601
664
  logger.error("Exception %s", e, exc_info=True)
602
-
665
+
603
666
  def writeMcv(self, filename, fillfac=None, recsin=''):
604
667
  # windows needs this strip to remove '\r'
605
668
  filename = filename.strip()
@@ -612,7 +675,7 @@ class Writer(Mcv):
612
675
  else:
613
676
  binary = False
614
677
  self.fp = open(filename, "wb")
615
- logger.info("Write File %s, binary format %d", filename, binary)
678
+ logger.info("Write File %s, binary format", filename)
616
679
 
617
680
  self.writeBinaryFile(fillfac, recsin)
618
681
  self.fp.close()
@@ -737,8 +800,9 @@ class Reader(Mcv):
737
800
  if self.version_mc_curve == self.ORIENTED_VERSION_MC_CURVE or \
738
801
  self.version_mc_curve == self.PARAMETER_PM_CURVE:
739
802
  self.mc1_curves = int(line[4])
740
- logger.debug("MC file %s Version %s Curves %d",
741
- filename, self.version_mc_curve, self.mc1_curves)
803
+ logger.info("Read file %s %s Type: %d (%s) Num Curves %d",
804
+ filename, self.name, self.version_mc_curve,
805
+ types[self.mc1_type], self.mc1_curves)
742
806
  if self.mc1_type == DEMCRV_BR:
743
807
  self.mc1_angle[self.mc1_curves-1] = self.mc1_remz
744
808
 
@@ -873,7 +937,7 @@ class Reader(Mcv):
873
937
 
874
938
  self.ce = 0
875
939
  self.b_beta_coeff = 0
876
- try:
940
+ try:
877
941
  if not self.losses['f'][0]:
878
942
  self.fp.seek(-16, 1)
879
943
  res = self.readBlock([float]*2)
@@ -882,30 +946,33 @@ class Reader(Mcv):
882
946
  pass
883
947
 
884
948
  def get_results(self):
949
+ self.desc = self.mc1_title
950
+ self.fillfac = self.mc1_fillfac
951
+ #self.cversion = self.version_mc_curve
885
952
  result = {
886
- 'name': self.name,
887
- 'desc': self.mc1_title,
888
- 'cversion': self.version_mc_curve,
889
- 'ctype': self.mc1_type,
890
- 'recalc': self.mc1_recalc,
891
- 'remz': self.mc1_remz,
892
- 'bsat': self.mc1_bsat,
893
- 'bref': self.mc1_bref,
894
- 'fillfac': self.mc1_fillfac,
895
- 'fo': self.fo,
896
- 'Bo': self.Bo,
897
- 'ch': self.ch,
898
- 'ch_freq': self.ch_freq,
899
- 'cw': self.cw,
900
- 'ce': self.ce,
901
- 'b_beta_coeff': self.b_beta_coeff,
902
- 'cw_freq': self.cw_freq,
903
- 'b_coeff': self.b_coeff,
904
- 'rho': self.rho,
905
- 'fe_sat_mag': self.fe_sat_mag,
906
- 'curve': [{k: c[k] for k in ('hi', 'bi')}
907
- for c in self.curve]
908
- }
953
+ k: getattr(self, k) for k in (
954
+ 'name',
955
+ 'desc',
956
+ 'cversion',
957
+ 'ctype',
958
+ 'recalc',
959
+ 'remz',
960
+ 'bsat',
961
+ 'bref',
962
+ 'fillfac',
963
+ 'fo',
964
+ 'Bo',
965
+ 'ch',
966
+ 'ch_freq',
967
+ 'cw',
968
+ 'ce',
969
+ 'b_beta_coeff',
970
+ 'cw_freq',
971
+ 'b_coeff',
972
+ 'rho',
973
+ 'fe_sat_mag') if hasattr(self, k)}
974
+ result['curve'] = [{k: c[k] for k in ('hi', 'bi')}
975
+ for c in self.curve]
909
976
  try:
910
977
  if self.losses:
911
978
  result['losses'] = self.losses
@@ -1003,69 +1070,6 @@ class MagnetizingCurve(object):
1003
1070
  pass
1004
1071
  return None
1005
1072
 
1006
- def recalc(self):
1007
- for m in self.mcv:
1008
- curve = self.mcv[m]['curve'][0]
1009
- mi = MC1_MIMAX-2
1010
- dh = curve['hi'][-1]-curve['hi'][-2]
1011
- db = curve['bi'][-1]-curve['bi'][-2]
1012
- dmue_d = db/dh
1013
- dmue = curve['bi'][-1]/curve['hi'][-1]
1014
- db = 3e-2*curve['bi'][-1]
1015
- n3 = 1.5
1016
-
1017
- curve['muer'] = [b/MUE0/h
1018
- for b, h in zip(curve['bi'],
1019
- curve['hi'])]
1020
-
1021
- # extend bh-curve into saturation
1022
- while dmue_d > 1.01*MUE0 and dmue > 1.5*MUE0:
1023
- dmue_d = MUE0 + (dmue_d-MUE0)/np.sqrt(n3)
1024
- curve['bi'].append(curve['bi'][-1]+db)
1025
- curve['hi'].append(curve['hi'][-1]+db/dmue_d)
1026
- curve['muer'].append(curve['bi'][-1]/MUE0/curve['hi'][-1])
1027
- n3 += 0.2
1028
- dmue = curve['bi'][-1]/curve['hi'][-1]
1029
-
1030
- self.mcv[m]['db2'] = (curve['bi'][-1]**2 -
1031
- curve['bi'][0]**2)/(mi-1)
1032
- nuek0 = (curve['hi'][1] - curve['hi'][0]) / \
1033
- (curve['bi'][1]-curve['bi'][0])
1034
- for j1 in range(len(curve['bi'])):
1035
- bk02 = curve['bi'][j1]**2
1036
- if bk02 > 0:
1037
- break
1038
- curve['nuer'] = [MUE0*nuek0]
1039
- curve['bi2'] = [bk02]
1040
- curve['a'] = []
1041
- curve['b'] = []
1042
-
1043
- bk1 = 0.0
1044
- while bk1 <= curve['bi'][-1]:
1045
- bk12 = bk02 + self.mcv[m]['db2']
1046
- bk1 = np.sqrt(bk12)
1047
- j = 2
1048
- while j < len(curve['bi']) and bk1 <= curve['bi'][j]:
1049
- j += 1
1050
- j -= 1
1051
- bdel = curve['bi'][j] - curve['bi'][j1]
1052
- c1 = (curve['hi'][j] - curve['hi'][j1])/bdel
1053
- c2 = curve['hi'][j1] - c1*curve['bi'][j1]
1054
-
1055
- nuek1 = c1 + c2/bk1
1056
-
1057
- curve['a'].append(MUE0*(bk12*nuek0 -
1058
- bk02*nuek1)/self.mcv[m]['db2'])
1059
- curve['b'].append(MUE0*(nuek1 - nuek0)/self.mcv[m]['db2'])
1060
- nuek0 = nuek1
1061
- bk02 = bk12
1062
-
1063
- curve['nuer'].append(MUE0*nuek1)
1064
- curve['bi2'].append(bk12)
1065
-
1066
- curve['a'].append(1.0)
1067
- curve['b'].append(MUE0*curve['hi'][-1]-curve['bi'][-1])
1068
-
1069
1073
  def fix_name(self, name, fillfac=1.0):
1070
1074
  """return os compatible mcv name including fillfac"""
1071
1075
  if not self.find_by_name(name):
femagtools/me.py CHANGED
@@ -3,8 +3,8 @@ Postprocessing FEMAG-ME results
3
3
  """
4
4
  __author__ = 'dapu zhang'
5
5
 
6
- import re
7
- import numpy as np
6
+ import re
7
+ import numpy as np
8
8
  import matplotlib.pyplot as plt
9
9
  import logging
10
10
 
@@ -16,33 +16,33 @@ def get_eigenvectors(filelist, psfiles):
16
16
  eigenvecs = {}
17
17
  eigenfreq = []
18
18
  ps_data = []
19
- temp = []
19
+ temp = []
20
20
  temp_arr = []
21
21
  read_fig = False
22
22
 
23
23
  if len(psfiles) > 0: read_fig = True
24
24
  if len(filelist) == 0: return []
25
-
26
- for k, kk in zip(filelist, range(len(filelist))):
25
+
26
+ for k, kk in zip(filelist, range(len(filelist))):
27
27
  # read ps file
28
28
  if read_fig: ps_data.append(plt.imread(psfiles[kk]))
29
29
  eigenvecs[str(kk)] = {}
30
- with open(k, 'r') as f:
30
+ with open(k, 'r') as f:
31
31
  data = f.read().split('\n')
32
- eigenval = float(re.split('\s+', data[0].strip())[2])
32
+ eigenval = float(re.split(r'\s+', data[0].strip())[2])
33
33
  eigenfreq.append(eigenval/2/np.pi)
34
-
35
- for i in range(len(data[1:-1])):
36
- for j in data[2+i].strip().split(' '):
34
+
35
+ for i in range(len(data[1:-1])):
36
+ for j in data[2+i].strip().split(' '):
37
37
  if j != '':
38
38
  temp.append(float(j))
39
39
 
40
40
  temp_arr = np.array(temp).reshape(-1, 5)
41
41
  idx_collect = []
42
42
  # remove the index, at which the dof equals zero
43
- for c in range(temp_arr.shape[0]):
43
+ for c in range(temp_arr.shape[0]):
44
44
  if np.abs(temp_arr[c, 1]) < 1e-15 and \
45
- np.abs(temp_arr[c, 2]) < 1e-15:
45
+ np.abs(temp_arr[c, 2]) < 1e-15:
46
46
  idx_collect.append(c)
47
47
  # prepare the data from the further calculation
48
48
  temp_arr = np.delete(temp_arr, np.array(idx_collect), axis=0)
@@ -52,4 +52,4 @@ def get_eigenvectors(filelist, psfiles):
52
52
  # return node position
53
53
  if kk == 0: eigenvecs.update({'node_pos': temp_arr[:, 4::]})
54
54
 
55
- return [ps_data, eigenfreq, eigenvecs]
55
+ return [ps_data, eigenfreq, eigenvecs]
femagtools/model.py CHANGED
@@ -392,7 +392,7 @@ class MachineModel(Model):
392
392
  for k in thkeys_shaft:
393
393
  rotor[k+'_shaft'] = mshaft[k]
394
394
  rotor['spmaweight_shaft'] = rotor['rho_shaft']
395
-
395
+
396
396
  self.stator['mcvkey_shaft_name'] = mcv
397
397
  names.append((mcv, 1.0))
398
398
  else:
@@ -442,7 +442,7 @@ class MachineModel(Model):
442
442
 
443
443
  def is_complete(self):
444
444
  """check completeness of models"""
445
- if self.is_dxffile():
445
+ if self.is_dxffile() or self.is_svgfile():
446
446
  return True
447
447
  try:
448
448
  self.statortype()
@@ -460,6 +460,12 @@ class MachineModel(Model):
460
460
  return True
461
461
  return False
462
462
 
463
+ def is_svgfile(self):
464
+ if 'svgfile' in self.__dict__:
465
+ if isinstance(self.svgfile, dict):
466
+ return True
467
+ return False
468
+
463
469
  def has_magnet(self): # either rotor or magnet
464
470
  return hasattr(self, 'magnet')
465
471
 
@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
4
4
  import numpy as np
5
5
  import matplotlib.lines as mpl
6
6
 
7
- rgbpat = re.compile('rgb\((\d+),(\d+),(\d+)\)')
7
+ rgbpat = re.compile(r'rgb\((\d+),(\d+),(\d+)\)')
8
8
 
9
9
  def fieldlines(svgfilename, ax=0):
10
10
  """plot fieldlines from svg file"""
femagtools/plot/mcv.py CHANGED
@@ -37,10 +37,12 @@ def mcv_hbj(mcv, log=True, ax=0):
37
37
  label = 'Flux Density ({0}°)'.format(mcv.mc1_angle[k])
38
38
  if log:
39
39
  ax.semilogx(hi, bi, label=label)
40
+ ax.semilogx(hi, bi, 'k.')
40
41
  if ji:
41
42
  ax.semilogx(hi, ji, label='Polarisation')
42
43
  else:
43
44
  ax.plot(hi, bi, label=label)
45
+ ax.plot(hi, bi, 'k.')
44
46
  if ji:
45
47
  ax.plot(hi, ji, label='Polarisation')
46
48
  ax.set_xlabel('H / kA/m')
@@ -59,10 +61,26 @@ def mcv_muer(mcv, ax=0):
59
61
  if ax == 0:
60
62
  ax = plt.gca()
61
63
  ax.plot(bi, ur)
64
+ ax.plot(bi, ur, 'k.')
62
65
  ax.set_xlabel('B / T')
63
66
  ax.set_title('rel. Permeability')
64
67
  ax.grid()
65
68
 
69
+ def mcv_nuer(mcv, ax=0):
70
+ """plot rel. reluctivity vs. B of mcv dict"""
71
+ MUE0 = 4e-7*np.pi
72
+ bi, ur = zip(*[(bx, bx/hx/MUE0)
73
+ for bx, hx in zip(mcv['curve'][0]['bi'],
74
+ mcv['curve'][0]['hi']) if not hx == 0])
75
+ if ax == 0:
76
+ ax = plt.gca()
77
+ nuer = 1/np.array(ur)
78
+ ax.plot(bi, 1/np.array(ur))
79
+ ax.plot(bi, nuer, 'k.')
80
+ ax.set_xlabel('B / T')
81
+ ax.set_title('rel. Reluctivity')
82
+ ax.grid()
83
+
66
84
 
67
85
  def felosses(losses, coeffs, title='', log=True, ax=0):
68
86
  """plot iron losses with steinmetz or jordan approximation
femagtools/plot/wdg.py CHANGED
@@ -153,11 +153,11 @@ def winding_factors(wdg, n=8, ax=0):
153
153
  wdg.kwd(n),
154
154
  wdg.kw(n))]).T
155
155
  try:
156
- markerline1, stemlines1, _ = ax.stem(order-1, kwp,
156
+ markerline1, stemlines1, _ = ax.stem(order-0.5, kwp,
157
157
  'C1:', basefmt=" ",
158
158
  markerfmt='C1.',
159
159
  label='Pitch')
160
- markerline2, stemlines2, _ = ax.stem(order+1, kwd,
160
+ markerline2, stemlines2, _ = ax.stem(order+0.5, kwd,
161
161
  'C2:', basefmt=" ",
162
162
  markerfmt='C2.',
163
163
  label='Distribution')
@@ -66,7 +66,7 @@ def main():
66
66
 
67
67
  res = convert(args.svgfile, # SVG-Filename
68
68
  part=part,
69
- EESM=EESM,
69
+ EESM=args.EESM,
70
70
  view_only=args.view,
71
71
  show_plots=args.show_plots,
72
72
  show_areas=args.show_areas,
@@ -1,9 +1,13 @@
1
1
  -- hairpin winding template
2
2
 
3
- rcoil, phi_coil = c2pd(m.xcoil_1, m.ycoil_1)
4
-
5
3
  slot_div_angle = 360/m.tot_num_slot
6
4
 
5
+ if m.xcoil_1 ~= nil and m.ycoil_1 ~= nil then
6
+ rcoil, phi_coil = c2pd(m.xcoil_1, m.ycoil_1)
7
+ else
8
+ rcoil, phi_coil = da1/2 + m.slot_height/2, slot_div_angle/2
9
+ end
10
+
7
11
  -- delete existing mesh in the slot
8
12
  for i = 1, m.num_sl_gen do
9
13
  xc, yc = pd2c(rcoil, phi_coil+(i-1)*slot_div_angle)
@@ -12,7 +16,7 @@ end
12
16
  -- wire params
13
17
  wire_height = ${model['wire']["wire_height"]*1e3}
14
18
  wire_width = ${model['wire']["wire_width"]*1e3}
15
- wire_corner_r = ${model['wire']["corner_radius"]*1e3}
19
+ wire_corner_r = 0.0
16
20
  wire_gap = ${model['wire']["wire_separation"]*1e3}
17
21
  TH1 = ${model['wire']["wire_th1"]*1e3} -- distance to the bore radius
18
22
  nwires = ${model['wire']["num_layers"]}
@@ -128,7 +132,7 @@ for j = 1, m.num_sl_gen do
128
132
  end
129
133
  end
130
134
 
131
- ndt(agndst)
135
+ ndt(agndst*1.5)
132
136
  for j = 1, m.num_sl_gen do
133
137
  for i = 1, nwires do
134
138
  dx, dy = x0+(wire_gap+wire_height)*(i-1), y0
@@ -142,8 +146,8 @@ create_mesh()
142
146
 
143
147
  -- create winding
144
148
 
145
- widfile = io.open("wid.fsl", 'r')
146
-
149
+ --widfile = io.open("wid.fsl", 'r')
150
+ widfile = io.open("wid.txt", 'r')
147
151
  nrows = 1
148
152
  winding = {}
149
153
 
@@ -158,52 +162,39 @@ for i in widfile:lines() do
158
162
  end
159
163
 
160
164
  --[[
161
-
162
165
  winding table
163
-
164
- 1 slot_go pos_in_slot slot_ret pos_in_slot
165
-
166
+ key slot layer dir
166
167
  ]]--
167
168
  dir = 'wi'
168
169
  cols = {"green", "yellow", "cyan"}
169
170
  wk = 1
170
171
  for i = 1, #winding do
171
- idx = winding[i][2]
172
- idxp = winding[i][3]
173
- idy = winding[i][4]
174
- idyp = winding[i][5]
175
-
176
- if i == 1 then
177
- if idx <= m.num_sl_gen then
178
- wkey = def_new_wdg(wire_xy[idx][idxp].x, wire_xy[idx][idxp].y, cols[winding[i][1]], "Phase"..winding[i][1], 1, 0, 0, dir)
179
- end
180
-
181
- if math.abs(idy) <= m.num_sl_gen then
182
- add_to_wdg (wire_xy[math.abs(idy)][idyp].x, wire_xy[math.abs(idy)][idyp].y, "wsamekey", "wo", "wser")
183
- end
184
- else
185
- if winding[i][1] == winding[i-1][1] and winding[i][1] == wk then
186
- if idx <= m.num_sl_gen then
187
- add_to_wdg (wire_xy[idx][idxp].x, wire_xy[idx][idxp].y, "wsamekey", dir, "wser")
188
- end
189
- if math.abs(idy) <= m.num_sl_gen then
190
- add_to_wdg (wire_xy[math.abs(idy)][idyp].x, wire_xy[math.abs(idy)][idyp].y, "wsamekey", "wo", "wser")
191
- end
192
- else
193
- if idx <= m.num_sl_gen then
194
- wkey = def_new_wdg(wire_xy[idx][idxp].x, wire_xy[idx][idxp].y, cols[winding[i][1]], "Phase"..winding[i][1], 1, 0, 0, dir)
195
- wk = wk + 1
196
- end
197
- if math.abs(idy) <= m.num_sl_gen then
198
- if wk == winding[i][1] then
199
- add_to_wdg (wire_xy[math.abs(idy)][idyp].x, wire_xy[math.abs(idy)][idyp].y, "wsamekey", "wo", "wser")
200
- else
201
- wkey = def_new_wdg(wire_xy[math.abs(idy)][idyp].x, wire_xy[math.abs(idy)][idyp].y, cols[winding[i][1]], "Phase"..winding[i][1], 1, 0, 0, "wo")
172
+ windingskey = winding[i][1]
173
+ slot_nr = winding[i][2]
174
+ layer = winding[i][3]
175
+ direction = winding[i][4]
176
+ if direction < 0 then
177
+ dir = 'wo'
178
+ else
179
+ dir = 'wi'
180
+ end
181
+ if i == 1 then
182
+ if slot_nr <= m.num_sl_gen then
183
+ wkey = def_new_wdg(wire_xy[slot_nr][layer].x, wire_xy[slot_nr][layer].y, cols[winding[i][1]], "Phase"..winding[i][1], 1, 0, 0, dir)
184
+ end
185
+
186
+ else
187
+ if winding[i][1] == winding[i-1][1] and winding[i][1] == wk then
188
+ if slot_nr <= m.num_sl_gen then
189
+ add_to_wdg (wire_xy[slot_nr][layer].x, wire_xy[slot_nr][layer].y, "wsamekey", dir, "wser")
190
+ end
191
+
192
+ else
193
+ if slot_nr <= m.num_sl_gen then
194
+ wkey = def_new_wdg(wire_xy[slot_nr][layer].x, wire_xy[slot_nr][layer].y, cols[winding[i][1]], "Phase"..winding[i][1], 1, 0, 0, dir)
202
195
  wk = wk + 1
203
- end
204
- end
205
- end
196
+ end
197
+ end
206
198
  end
207
199
  end
208
-
209
200
  m.num_par_wdgs = ${model.get('num_par_wdgs', 1)}