femagtools 1.7.9__py3-none-any.whl → 1.8.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.
Files changed (43) hide show
  1. femagtools/__init__.py +1 -1
  2. femagtools/amela.py +2 -2
  3. femagtools/dxfsl/area.py +130 -26
  4. femagtools/dxfsl/conv.py +2 -14
  5. femagtools/dxfsl/converter.py +69 -12
  6. femagtools/dxfsl/fslrenderer.py +15 -13
  7. femagtools/dxfsl/geom.py +153 -82
  8. femagtools/dxfsl/journal.py +2 -2
  9. femagtools/dxfsl/machine.py +19 -15
  10. femagtools/dxfsl/shape.py +3 -0
  11. femagtools/ecloss.py +386 -2
  12. femagtools/femag.py +82 -9
  13. femagtools/fsl.py +52 -56
  14. femagtools/machine/pm.py +1 -1
  15. femagtools/machine/sm.py +16 -8
  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/afm_rotor.mako +4 -0
  24. femagtools/templates/gen_hairpin_winding.mako +36 -45
  25. femagtools/templates/magnetIron.mako +1 -1
  26. femagtools/templates/magnetIron2.mako +1 -1
  27. femagtools/templates/magnetIron3.mako +1 -1
  28. femagtools/templates/magnetIron4.mako +1 -1
  29. femagtools/templates/magnetIron5.mako +1 -1
  30. femagtools/templates/magnetIronV.mako +1 -1
  31. femagtools/templates/magnetSector.mako +1 -1
  32. femagtools/templates/mesh-airgap.mako +12 -6
  33. femagtools/templates/prepare_thermal.mako +199 -61
  34. femagtools/windings.py +25 -20
  35. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/METADATA +20 -20
  36. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/RECORD +42 -43
  37. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/WHEEL +1 -1
  38. tests/test_mcv.py +106 -1
  39. tests/test_windings.py +5 -0
  40. tests/test_mcvwriter.py +0 -96
  41. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/LICENSE +0 -0
  42. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/entry_points.txt +0 -0
  43. {femagtools-1.7.9.dist-info → femagtools-1.8.1.dist-info}/top_level.txt +0 -0
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,
@@ -91,7 +91,11 @@ m.nodedist = ${model.get('nodedist', 1)}
91
91
  x,y = (P22.x+P32.x)/2,(P21.y+P22.y)/2
92
92
  if m.remanenc == nil then
93
93
  m.remanenc = 1.2
94
+ end
95
+ if m.relperm == nil then
94
96
  m.relperm = 1.05
97
+ end
98
+ if m.rlen == nil then
95
99
  m.rlen = 100
96
100
  end
97
101
  for i = 1,m.npols_gen do
@@ -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)}
@@ -49,7 +49,7 @@ end
49
49
  beta = math.pi/m.num_poles
50
50
  rotor_thcond = ${model['thcond']}
51
51
  rotor_thcap = ${model['thcap']}
52
- rotor_density = ${model.get('density')*1e3}
52
+ rotor_density = ${model.get('density')}
53
53
 
54
54
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
55
55
  if m.shaft_rad < m.yoke_rad then
@@ -51,7 +51,7 @@ end
51
51
  beta = math.pi/m.num_poles
52
52
  rotor_thcond = ${model['thcond']}
53
53
  rotor_thcap = ${model['thcap']}
54
- rotor_density = ${model.get('density')*1e3}
54
+ rotor_density = ${model.get('density')}
55
55
 
56
56
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
57
57
  if m.shaft_rad < m.yoke_rad then
@@ -75,7 +75,7 @@ end
75
75
  beta = math.pi/m.num_poles
76
76
  rotor_thcond = ${model['thcond']}
77
77
  rotor_thcap = ${model['thcap']}
78
- rotor_density = ${model.get('density')*1e3}
78
+ rotor_density = ${model.get('density')}
79
79
 
80
80
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
81
81
  if m.shaft_rad < m.yoke_rad then
@@ -50,7 +50,7 @@ end
50
50
  beta = math.pi/m.num_poles
51
51
  rotor_thcond = ${model['thcond']}
52
52
  rotor_thcap = ${model['thcap']}
53
- rotor_density = ${model.get('density')*1e3}
53
+ rotor_density = ${model.get('density')}
54
54
 
55
55
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0) and model.get('density', 0):
56
56
  if m.shaft_rad < m.yoke_rad then
@@ -50,7 +50,7 @@ end
50
50
  beta = math.pi/m.num_poles
51
51
  rotor_thcond = ${model['thcond']}
52
52
  rotor_thcap = ${model['thcap']}
53
- rotor_density = ${model.get('density')*1e3}
53
+ rotor_density = ${model.get('density')}
54
54
 
55
55
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
56
56
  if m.shaft_rad < m.yoke_rad then
@@ -78,7 +78,7 @@ end
78
78
  beta = math.pi/m.num_poles
79
79
  rotor_thcond = ${model['thcond']}
80
80
  rotor_thcap = ${model['thcap']}
81
- rotor_density = ${model.get('density')*1e3}
81
+ rotor_density = ${model.get('density')}
82
82
 
83
83
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
84
84
  if m.shaft_rad < m.yoke_rad then
@@ -78,7 +78,7 @@ end
78
78
  beta = math.pi/m.num_poles
79
79
  rotor_thcond = ${model['thcond']}
80
80
  rotor_thcap = ${model['thcap']}
81
- rotor_density = ${model.get('density')*1e3}
81
+ rotor_density = ${model.get('density')}
82
82
 
83
83
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
84
84
  if m.shaft_rad < m.yoke_rad then
@@ -34,20 +34,26 @@ if not airgap_created then
34
34
  if inner_da_start == nil then
35
35
  inner_da_start = da2/2
36
36
  end
37
- nc_line(r1, 0.0, r2, 0.0, 2)
37
+ x1, y1 = pr2c(inner_da_start, 0.0)
38
+ nc_line(x1, y1, r1, 0.0, 0.0)
38
39
 
39
40
  if outer_da_start == nil then
40
41
  outer_da_start = da1/2
41
42
  end
42
- nc_line(r2, 0.0, outer_da_start, 0.0, 0)
43
+ x2, y2 = pr2c(outer_da_start, 0.0)
44
+ nc_line(r2, 0.0, x2, y2, 0.0)
43
45
 
44
46
  if m.tot_num_slot > m.num_sl_gen then
45
- x4, y4 = pr2c(outer_da_start, alfa)
46
- nc_line(x1, y1, x2, y2, 2)
47
- nc_line(x4, y4, x2, y2, 0)
47
+ x3, y3 = pr2c(inner_da_end, alfa)
48
+ x4, y4 = pr2c(r1, alfa)
49
+ nc_line(x3, y3, x4, y4, 0, 0)
50
+
51
+ x3, y3 = pr2c(outer_da_end, alfa)
52
+ x4, y4 = pr2c(r2, alfa)
53
+ nc_line(x3, y3, x4, y4, 0, 0)
48
54
  end
49
55
 
50
- x0, y0 = pr2c(r2-ag/6, alfa/2)
56
+ x0, y0 = pr2c(r1-ag/6, alfa/2)
51
57
  create_mesh_se(x0, y0)
52
58
  x0, y0 = pr2c(r2+ag/6, alfa/2)
53
59
  create_mesh_se(x0, y0)