femagtools 1.7.7__py3-none-any.whl → 1.7.9__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 (38) hide show
  1. femagtools/__init__.py +1 -1
  2. femagtools/dxfsl/area.py +38 -9
  3. femagtools/dxfsl/converter.py +2 -1
  4. femagtools/dxfsl/fslrenderer.py +8 -1
  5. femagtools/dxfsl/geom.py +19 -8
  6. femagtools/dxfsl/svgparser.py +31 -4
  7. femagtools/femag.py +14 -0
  8. femagtools/fsl.py +74 -28
  9. femagtools/isa7.py +41 -0
  10. femagtools/job.py +2 -2
  11. femagtools/machine/afpm.py +5 -1
  12. femagtools/machine/utils.py +4 -3
  13. femagtools/model.py +7 -0
  14. femagtools/moo/population.py +9 -7
  15. femagtools/nc.py +12 -0
  16. femagtools/plot/__init__.py +1 -1
  17. femagtools/plot/nc.py +22 -5
  18. femagtools/plot/wdg.py +38 -5
  19. femagtools/svgfsl/converter.py +6 -0
  20. femagtools/templates/gen_winding.mako +10 -3
  21. femagtools/templates/magnetIron.mako +30 -46
  22. femagtools/templates/magnetIron2.mako +39 -0
  23. femagtools/templates/magnetIron3.mako +39 -0
  24. femagtools/templates/magnetIron4.mako +39 -0
  25. femagtools/templates/magnetIron5.mako +39 -0
  26. femagtools/templates/magnetIronV.mako +34 -54
  27. femagtools/templates/magnetSector.mako +32 -47
  28. femagtools/templates/prepare_thermal.mako +219 -0
  29. femagtools/templates/statorRotor3.mako +3 -22
  30. femagtools/windings.py +67 -39
  31. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/METADATA +3 -1
  32. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/RECORD +38 -37
  33. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/WHEEL +1 -1
  34. tests/test_fsl.py +1 -1
  35. tests/test_windings.py +13 -2
  36. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/LICENSE +0 -0
  37. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/entry_points.txt +0 -0
  38. {femagtools-1.7.7.dist-info → femagtools-1.7.9.dist-info}/top_level.txt +0 -0
femagtools/nc.py CHANGED
@@ -23,6 +23,7 @@ class Reader(object):
23
23
 
24
24
  def __init__(self, filename):
25
25
  ds = netCDF4.Dataset(filename)
26
+ node_temperature = None
26
27
  self.POINT_ISA_POINT_REC_PT_CO_X = []
27
28
  self.POINT_ISA_POINT_REC_PT_CO_Y = []
28
29
  self.LINE_ISA_LINE_REC_LN_PNT_1 = []
@@ -54,6 +55,11 @@ class Reader(object):
54
55
  grp.variables[k][:-1]
55
56
  for k in ('bnd_cnd', 'bnd_cnd', 'per_nod',
56
57
  'co_1', 'co_2', 'co_rad', 'co_phi', 'vp_re', 'vp_im')]
58
+ try:
59
+ node_temperature = grp.variables['temperature'][:-1]
60
+ except:
61
+ pass
62
+
57
63
  logger.debug('Nodes: %d', len(self.NODE_ISA_NODE_REC_ND_CO_1))
58
64
 
59
65
  grp = ds.groups['node_elements']
@@ -198,9 +204,15 @@ class Reader(object):
198
204
  self.poles_sim = int(grp.variables['poles_sim'].getValue().data)
199
205
  self.slots = int(grp.variables['num_slots'].getValue().data)
200
206
  self.arm_length = float(grp.variables['arm_length'].getValue().data)
207
+ self.state_of_problem = int(grp.variables['state_of_problem'].getValue().data)
201
208
  except:
202
209
  pass
203
210
 
211
+ if hasattr(self, 'state_of_problem'):
212
+ if self.state_of_problem == 5:
213
+ # th simulation
214
+ if node_temperature is not None:
215
+ self.NODE_ISA_NODE_REC_ND_VP_IM = node_temperature
204
216
  self.MAGN_TEMPERATURE = 20
205
217
  self.BR_TEMP_COEF = 0
206
218
  try:
@@ -16,5 +16,5 @@ from .nc import spel, mesh, demag, demag_pos, \
16
16
  airgap_flux_density_pos, loss_density
17
17
  from .mcv import mcv_hbj, mcv_muer, felosses
18
18
  from .phasor import i1beta_phasor, iqd_phasor, phasor
19
- from .wdg import mmf, mmf_fft, zoneplan, winding_factors, winding
19
+ from .wdg import mmf, mmf_fft, zoneplan, winding_factors, winding, currdist
20
20
  from .fieldlines import fieldlines
femagtools/plot/nc.py CHANGED
@@ -35,19 +35,19 @@ def spel(isa, superelements=[], with_axis=False, ax=0):
35
35
  color=isa.color[se.color], lw=0))
36
36
  try:
37
37
  # draw wire direction
38
- if se.subregion:
39
- if se.subregion.curdir != 0:
38
+ if se.subregion:
39
+ if se.subregion.curdir != 0:
40
40
  wkey = se.subregion.winding.key
41
- if se.subregion.curdir < 0:
41
+ if se.subregion.curdir < 0:
42
42
  label = str(se.subregion.curdir*wkey)
43
- else:
43
+ else:
44
44
  label = '+'+str(se.subregion.curdir*wkey)
45
45
 
46
46
  xy = np.array([n.xy
47
47
  for nc in se.nodechains
48
48
  for n in nc.nodes])
49
49
  cx, cy = np.mean(np.unique(xy[:, 0])), np.mean(np.unique(xy[:, -1]))
50
- ax.text(cx, cy, label, rotation=np.arctan2(cy, cx)/np.pi*180-90,
50
+ ax.text(cx, cy, label, rotation=np.arctan2(cy, cx)/np.pi*180-90,
51
51
  horizontalalignment='center', verticalalignment='center')
52
52
  except:
53
53
  pass
@@ -296,3 +296,20 @@ def loss_density(isa, subreg=[], cmap=DEFAULT_CMAP, ax=0):
296
296
  elements = [e for e in __elements_of_subreg(isa, subreg)]
297
297
  lossd = np.array([e.loss_density*1e-3 for e in elements])
298
298
  _contour(ax, 'Loss Density kW/m³', elements, lossd, '', cmap)
299
+
300
+ def temperature_distribution(isa, ax=0, cmap='plasma'):
301
+ """plot temperature distribution of NC/I7/ISA7 model
302
+
303
+ Args:
304
+ isa: Isa7/NC object
305
+ """
306
+ temp = []
307
+ elements = [e for e in isa.elements]
308
+ for e in isa.elements:
309
+ tmp = 0
310
+ ctr = 1
311
+ for n in e.vertices:
312
+ tmp += n.vpot[-1]
313
+ ctr = ctr + 1
314
+ temp.append(tmp/ctr)
315
+ _contour(ax, 'Temperature in K', elements, temp, '', cmap)
femagtools/plot/wdg.py CHANGED
@@ -9,14 +9,38 @@ import numpy as np
9
9
  import matplotlib.pyplot as plt
10
10
 
11
11
 
12
+ def currdist(wdg, title='', k='all', phi=0, ax=0):
13
+ """plot current distribution of winding
14
+ Arguments:
15
+ k: (int) winding key (all if 0 or 'all', default all)
16
+ phi: (float) current angle (default 0)
17
+ """
18
+ if ax == 0:
19
+ ax = plt.gca()
20
+ if title:
21
+ ax.set_title(title)
22
+ cdist = wdg.currdist(k=k, phi=phi)
23
+ taus = 360/wdg.Q
24
+ c = np.sum([cdist[j] for j in cdist], axis=0)
25
+ pos = np.arange(0, len(cdist[1]))*taus + taus/2
26
+ cbars = ax.bar(pos, c/np.max(c), width=taus/4)
27
+ ax.set_xlabel("Position / Deg")
28
+ ax.grid()
29
+ return cbars
30
+
31
+
12
32
  def mmf(f, title='', ax=0):
13
- """plot magnetomotive force (mmf) of winding"""
33
+ """plot magnetomotive force (mmf) of winding
34
+ Arguments
35
+ f: (dict) windings mmf
36
+ title: (str) plot title
37
+ """
14
38
  if ax == 0:
15
39
  ax = plt.gca()
16
40
  if title:
17
41
  ax.set_title(title)
18
- ax.plot(np.array(f['pos'])/np.pi*180, f['mmf'])
19
- ax.plot(np.array(f['pos_fft'])/np.pi*180, f['mmf_fft'])
42
+ yphi = ax.plot(np.array(f['pos'])/np.pi*180, f['mmf'])
43
+ yfft = ax.plot(np.array(f['pos_fft'])/np.pi*180, f['mmf_fft'])
20
44
  ax.set_xlabel('Position / Deg')
21
45
 
22
46
  phi = [f['alfa0']/np.pi*180, f['alfa0']/np.pi*180]
@@ -28,7 +52,7 @@ def mmf(f, title='', ax=0):
28
52
  ax.annotate(f"", xy=(phi[0], y[0]),
29
53
  xytext=(0, y[0]), arrowprops=dict(arrowstyle="->"))
30
54
  ax.grid()
31
-
55
+ return yphi, yfft
32
56
 
33
57
  def mmf_fft(f, title='', mmfmin=1e-2, ax=0):
34
58
  """plot winding mmf harmonics"""
@@ -37,7 +61,16 @@ def mmf_fft(f, title='', mmfmin=1e-2, ax=0):
37
61
  if title:
38
62
  ax.set_title(title)
39
63
  else:
40
- ax.set_title('MMF Harmonics (per phase)')
64
+ def single_phase(f):
65
+ try:
66
+ return len(f['currdens']) == 1
67
+ except KeyError:
68
+ return True
69
+ if single_phase(f):
70
+ ax.set_title('MMF Harmonics (single phase)')
71
+ else:
72
+ ax.set_title('MMF Harmonics')
73
+
41
74
  ax.grid(True)
42
75
  order, mmf = np.array([(n, m) for n, m in zip(f['nue'],
43
76
  f['mmf_nue']) if m > mmfmin]).T
@@ -20,6 +20,11 @@ def main():
20
20
  help='stator without airgap in/out',
21
21
  dest='stator',
22
22
  default='')
23
+ argparser.add_argument('--EESM',
24
+ help='Electric Excited Synchronous Motor',
25
+ dest='EESM',
26
+ action="store_true",
27
+ default=False)
23
28
  argparser.add_argument('-p', '--plot',
24
29
  help='show plots',
25
30
  dest='show_plots',
@@ -61,6 +66,7 @@ def main():
61
66
 
62
67
  res = convert(args.svgfile, # SVG-Filename
63
68
  part=part,
69
+ EESM=EESM,
64
70
  view_only=args.view,
65
71
  show_plots=args.show_plots,
66
72
  show_areas=args.show_areas,
@@ -88,6 +88,12 @@ m.num_poles = ${model.poles}
88
88
 
89
89
  % if 'thcap' in model.winding:
90
90
  -- Thermal Material properties
91
+
92
+ conductor_density = ${model.winding['spmaweight']*1e3}
93
+ conductor_thcond = ${model.winding['thcond']}
94
+ conductor_thcap = ${model.winding['thcap']}
95
+
96
+ --[[
91
97
  if m.slot_height ~= nil then
92
98
  -- FEMAG slot model
93
99
  -- TODO: slot model from user
@@ -100,9 +106,9 @@ if m.slot_height ~= nil then
100
106
  dr = 1
101
107
  end
102
108
 
103
- density = ${model.windings['spmaweight']*1e3}
104
- lam = ${model.windings['thcond']}
105
- cap = ${model.windings['thcap']}
109
+ density = ${model.winding['spmaweight']*1e3}
110
+ lam = ${model.winding['thcond']}
111
+ cap = ${model.winding['thcap']}
106
112
 
107
113
  for i=1,m.num_sl_gen do
108
114
  a = (2*i-1)*math.pi/m.tot_num_sl + m.zeroangl/180*math.pi
@@ -114,4 +120,5 @@ if m.slot_height ~= nil then
114
120
  end
115
121
  end
116
122
  end
123
+ ]]--
117
124
  %endif
@@ -1,4 +1,3 @@
1
-
2
1
  m.magn_rad = da2/2
3
2
  m.yoke_rad = dy2/2
4
3
 
@@ -39,58 +38,43 @@ for i = 0, m.npols_gen-1 do
39
38
  end
40
39
  end
41
40
  %endif
42
- %if model.get('thcond', 0) and model.get('thcap', 0):
41
+
42
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
43
+ if m.shaft_rad == nil then
44
+ m.shaft_rad = dy2/2
45
+ end
46
+ if m.shaft_rad > dy2/2 then
47
+ m.shaft_rad = dy2/2
48
+ end
43
49
  beta = math.pi/m.num_poles
44
- xrb,yrb = pr2c(m.yoke_rad+0.1, beta) -- rotor lamination
45
- thcond = ${model['thcond']}
46
- thcap = ${model['thcap']}
47
- density = ${model.get('density')*1e3}
48
- def_mat_therm(xrb,yrb,'blue',density,thcond,thcap,1)
50
+ rotor_thcond = ${model['thcond']}
51
+ rotor_thcap = ${model['thcap']}
52
+ rotor_density = ${model.get('density')*1e3}
49
53
 
50
54
  %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
51
55
  if m.shaft_rad < m.yoke_rad then
52
- thcond = ${model['thcond_shaft']}
53
- thcap = ${model['thcap_shaft']}
54
- density = ${model['spmaweight_shaft']*1e3}
55
- def_mat_therm(m.yoke_rad/2,0.1,'blue',density,thcond,thcap,1) -- Shaft
56
+ shaft_thcond = ${model['thcond_shaft']}
57
+ shaft_thcap = ${model['thcap_shaft']}
58
+ shaft_density = ${model['spmaweight_shaft']*1e3}
59
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
60
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
56
61
  end
57
62
  %endif
58
- rm = m.magn_rad*math.cos(beta)
59
- density = ${model['spmaweight_magnet']*1e3}
60
- thcond = ${model.get('thcond_magnet', 8)}
61
- thcap = ${model.get('thcap_magnet', 440)}
62
- for i = 1,m.npols_gen do -- Magnete
63
- alfa = (2*i-1) * beta
64
- xmx,ymx = pr2c(rm,alfa)
65
- def_mat_therm(xmx,ymx,darkgreen-i%2,density,thcond,thcap,1)
66
- end
67
-
68
- if m.air_triangle > 0 then
69
- rs = math.sqrt(rm^2 + m.magn_width^2/4)
70
- gam = math.atan(m.magn_width/2, rm)
71
- for i = 1,m.npols_gen do -- air triangle
72
- alfa = (2*i-1) * beta
73
- xsx,ysx = pr2c(rs,alfa + gam + 1e-2)
74
- def_mat_therm(xsx,ysx,skyblue,1.12,0.026,1007,1)
75
- xsx,ysx = pr2c(rs,alfa - gam - 1e-2)
76
- def_mat_therm(xsx,ysx,skyblue,1.12,0.026,1007,1)
77
- end
78
- end
79
-
80
63
 
81
- -- add air layer (inside) for heat transfer
82
- h = 3.8
83
- beta = 360*m.npols_gen/m.num_poles
64
+ if x0_shaft == nil then
65
+ -- add air layer (inside) for heat transfer
66
+ h = 3.8
67
+ beta = 360*m.npols_gen/m.num_poles
84
68
 
85
-
86
- x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
87
- x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
88
- x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
89
- x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
90
- nc_line(x0, y0, x1, y1, 0)
91
- nc_circle(x1, y1, x2, y2, 0)
92
- nc_line(x2, y2, x3, y3, 0)
93
- x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
94
- create_mesh_se(x0, y0)
69
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
70
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
71
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
72
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
73
+ nc_line(x0, y0, x1, y1, 0)
74
+ nc_circle(x1, y1, x2, y2, 0)
75
+ nc_line(x2, y2, x3, y3, 0)
76
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
77
+ create_mesh_se(x0, y0)
78
+ end
95
79
 
96
80
  %endif
@@ -41,3 +41,42 @@ for i = 0, m.npols_gen-1 do
41
41
  end
42
42
  end
43
43
  %endif
44
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
45
+ if m.shaft_rad == nil then
46
+ m.shaft_rad = dy2/2
47
+ end
48
+ if m.shaft_rad > dy2/2 then
49
+ m.shaft_rad = dy2/2
50
+ end
51
+ beta = math.pi/m.num_poles
52
+ rotor_thcond = ${model['thcond']}
53
+ rotor_thcap = ${model['thcap']}
54
+ rotor_density = ${model.get('density')*1e3}
55
+
56
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
57
+ if m.shaft_rad < m.yoke_rad then
58
+ shaft_thcond = ${model['thcond_shaft']}
59
+ shaft_thcap = ${model['thcap_shaft']}
60
+ shaft_density = ${model['spmaweight_shaft']*1e3}
61
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
62
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
63
+ end
64
+ %endif
65
+
66
+ if x0_shaft == nil then
67
+ -- add air layer (inside) for heat transfer
68
+ h = 3.8
69
+ beta = 360*m.npols_gen/m.num_poles
70
+
71
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
72
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
73
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
74
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
75
+ nc_line(x0, y0, x1, y1, 0)
76
+ nc_circle(x1, y1, x2, y2, 0)
77
+ nc_line(x2, y2, x3, y3, 0)
78
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
79
+ create_mesh_se(x0, y0)
80
+ end
81
+
82
+ %endif
@@ -65,3 +65,42 @@ end
65
65
  end
66
66
 
67
67
  %endif
68
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
69
+ if m.shaft_rad == nil then
70
+ m.shaft_rad = dy2/2
71
+ end
72
+ if m.shaft_rad > dy2/2 then
73
+ m.shaft_rad = dy2/2
74
+ end
75
+ beta = math.pi/m.num_poles
76
+ rotor_thcond = ${model['thcond']}
77
+ rotor_thcap = ${model['thcap']}
78
+ rotor_density = ${model.get('density')*1e3}
79
+
80
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
81
+ if m.shaft_rad < m.yoke_rad then
82
+ shaft_thcond = ${model['thcond_shaft']}
83
+ shaft_thcap = ${model['thcap_shaft']}
84
+ shaft_density = ${model['spmaweight_shaft']*1e3}
85
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
86
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
87
+ end
88
+ %endif
89
+
90
+ if x0_shaft == nil then
91
+ -- add air layer (inside) for heat transfer
92
+ h = 3.8
93
+ beta = 360*m.npols_gen/m.num_poles
94
+
95
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
96
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
97
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
98
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
99
+ nc_line(x0, y0, x1, y1, 0)
100
+ nc_circle(x1, y1, x2, y2, 0)
101
+ nc_line(x2, y2, x3, y3, 0)
102
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
103
+ create_mesh_se(x0, y0)
104
+ end
105
+
106
+ %endif
@@ -40,3 +40,42 @@ for i = 0, m.npols_gen-1 do
40
40
  end
41
41
  end
42
42
  %endif
43
+ %if model.get('thcond', 0) and model.get('thcap', 0):
44
+ if m.shaft_rad == nil then
45
+ m.shaft_rad = dy2/2
46
+ end
47
+ if m.shaft_rad > dy2/2 then
48
+ m.shaft_rad = dy2/2
49
+ end
50
+ beta = math.pi/m.num_poles
51
+ rotor_thcond = ${model['thcond']}
52
+ rotor_thcap = ${model['thcap']}
53
+ rotor_density = ${model.get('density')*1e3}
54
+
55
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0) and model.get('density', 0):
56
+ if m.shaft_rad < m.yoke_rad then
57
+ shaft_thcond = ${model['thcond_shaft']}
58
+ shaft_thcap = ${model['thcap_shaft']}
59
+ shaft_density = ${model['spmaweight_shaft']*1e3}
60
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
61
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
62
+ end
63
+ %endif
64
+
65
+ if x0_shaft == nil then
66
+ -- add air layer (inside) for heat transfer
67
+ h = 3.8
68
+ beta = 360*m.npols_gen/m.num_poles
69
+
70
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
71
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
72
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
73
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
74
+ nc_line(x0, y0, x1, y1, 0)
75
+ nc_circle(x1, y1, x2, y2, 0)
76
+ nc_line(x2, y2, x3, y3, 0)
77
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
78
+ create_mesh_se(x0, y0)
79
+ end
80
+
81
+ %endif
@@ -40,3 +40,42 @@ for i = 0, m.npols_gen-1 do
40
40
  end
41
41
  end
42
42
  %endif
43
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
44
+ if m.shaft_rad == nil then
45
+ m.shaft_rad = dy2/2
46
+ end
47
+ if m.shaft_rad > dy2/2 then
48
+ m.shaft_rad = dy2/2
49
+ end
50
+ beta = math.pi/m.num_poles
51
+ rotor_thcond = ${model['thcond']}
52
+ rotor_thcap = ${model['thcap']}
53
+ rotor_density = ${model.get('density')*1e3}
54
+
55
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
56
+ if m.shaft_rad < m.yoke_rad then
57
+ shaft_thcond = ${model['thcond_shaft']}
58
+ shaft_thcap = ${model['thcap_shaft']}
59
+ shaft_density = ${model['spmaweight_shaft']*1e3}
60
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
61
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
62
+ end
63
+ %endif
64
+
65
+ if x0_shaft == nil then
66
+ -- add air layer (inside) for heat transfer
67
+ h = 3.8
68
+ beta = 360*m.npols_gen/m.num_poles
69
+
70
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
71
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
72
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
73
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
74
+ nc_line(x0, y0, x1, y1, 0)
75
+ nc_circle(x1, y1, x2, y2, 0)
76
+ nc_line(x2, y2, x3, y3, 0)
77
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
78
+ create_mesh_se(x0, y0)
79
+ end
80
+
81
+ %endif
@@ -68,62 +68,42 @@ for i = 0, m.npols_gen-1 do
68
68
  end
69
69
  %endif
70
70
 
71
- %if model.get('thcond', 0) and model.get('thcap', 0):
72
- beta = math.pi/m.num_poles + m.zeroangl/180*math.pi
73
- xrb,yrb = pr2c(m.yoke_rad+0.1, beta) -- rotor lamination
74
- thcond = ${model['thcond']}
75
- thcap = ${model['thcap']}
76
- def_mat_therm(xrb,yrb,'blue',7700,thcond,thcap,1)
77
- --def_mat_therm(m.yoke_rad/2,0.1,'blue',7700,thcond,thcap,1) -- Shaft
78
-
79
- gam = m.magn_angle/2/180*math.pi
80
- y = m.rotor_rad*math.sin(beta)
81
- x = m.rotor_rad*math.cos(beta)
82
- rr = y/math.sin(gam)
83
- xx = x - math.sqrt(rr^2 - y^2)
84
- rm = xx/(math.cos(beta/2) - math.sin(beta/2)/math.tan(gam))
85
- thcon = 8
86
- thcap = 440
87
- for i = 1,m.npols_gen do -- Magnets
88
- alfa = (2*i-1) * beta
89
- xmx,ymx = pr2c(rm,alfa-beta/2)
90
- def_mat_therm(xmx,ymx,darkgreen-i%2,7500,thcond,thcap,1)
91
- xmx,ymx = pr2c(rm,alfa+beta/2)
92
- def_mat_therm(xmx,ymx,darkgreen-i%2,7500,thcond,thcap,1)
71
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
72
+ if m.shaft_rad == nil then
73
+ m.shaft_rad = dy2/2
74
+ end
75
+ if m.shaft_rad > dy2/2 then
76
+ m.shaft_rad = dy2/2
77
+ end
78
+ beta = math.pi/m.num_poles
79
+ rotor_thcond = ${model['thcond']}
80
+ rotor_thcap = ${model['thcap']}
81
+ rotor_density = ${model.get('density')*1e3}
82
+
83
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
84
+ if m.shaft_rad < m.yoke_rad then
85
+ shaft_thcond = ${model['thcond_shaft']}
86
+ shaft_thcap = ${model['thcap_shaft']}
87
+ shaft_density = ${model['spmaweight_shaft']*1e3}
88
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
89
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
93
90
  end
91
+ %endif
94
92
 
95
- thcond = 0.026 -- air
96
- thcap = 1007
97
- get_spel_keys("sekeys") -- Get all subregions of the model
98
- for i=1, #sekeys do
99
- srkey = get_spel_data("srkey", sekeys[i])
100
- if srkey > 0 then
101
- srname = get_sreg_data("name",srkey)
102
- if srname == ' ' then
103
- srkey = 0
104
- end
105
- end
106
- if srkey == 0 then
107
- elkeys = get_spel_data("elkeys", sekeys[i])
108
- Ex, Ey = get_elem_data("xycp", elkeys[1])
109
- r, phi = c2pr(Ex, Ey)
110
- if r < m.rotor_rad then -- rotor only
111
- def_mat_therm(Ex,Ey,'skyblue',1.12,thcond,thcap,1)
112
- end
113
- end
93
+ if x0_shaft == nil then
94
+ -- add air layer (inside) for heat transfer
95
+ h = 3.8
96
+ beta = 360*m.npols_gen/m.num_poles
97
+
98
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
99
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
100
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
101
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
102
+ nc_line(x0, y0, x1, y1, 0)
103
+ nc_circle(x1, y1, x2, y2, 0)
104
+ nc_line(x2, y2, x3, y3, 0)
105
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
106
+ create_mesh_se(x0, y0)
114
107
  end
115
108
 
116
- -- add air layer (inside) for heat transfer
117
- h = 3.8
118
- beta = 360*m.npols_gen/m.num_poles
119
- x0, y0 = pd2c(dy2/2, m.zeroangl)
120
- x1, y1 = pd2c(dy2/2-h, m.zeroangl)
121
- x2, y2 = pd2c(dy2/2-h, beta+m.zeroangl)
122
- x3, y3 = pd2c(dy2/2, beta+m.zeroangl)
123
- nc_line(x0, y0, x1, y1, 0)
124
- nc_circle(x1, y1, x2, y2, 0)
125
- nc_line(x2, y2, x3, y3, 0)
126
- x0, y0 = pd2c(dy2/2-h/2, beta/2+m.zeroangl)
127
- create_mesh_se(x0, y0)
128
-
129
109
  %endif
@@ -68,55 +68,40 @@ for i = 0, m.npols_gen-1 do
68
68
  end
69
69
  end
70
70
  %endif
71
- %if model.get('thcond', 0) and model.get('thcap', 0):
72
- beta = math.pi/m.num_poles + m.zeroangl/180*math.pi
73
- xrb,yrb = pr2c(m.yoke_rad+0.1, beta) -- rotor lamination
74
- thcond = 24 -- ${model['thcond']}
75
- thcap = 480 -- ${model['thcap']}
76
- def_mat_therm(xrb,yrb,'blue',7700,thcond,thcap,1)
77
- --def_mat_therm(m.yoke_rad/2,0.1,'blue',7700,thcond,thcap,1) -- Shaft
71
+ %if model.get('thcond', 0) and model.get('thcap', 0) and model.get('density', 0):
72
+ if m.shaft_rad == nil then
73
+ m.shaft_rad = m.condshaft_r
74
+ end
75
+ if m.shaft_rad > dy2/2 then
76
+ m.shaft_rad = dy2/2
77
+ end
78
+ beta = math.pi/m.num_poles
79
+ rotor_thcond = ${model['thcond']}
80
+ rotor_thcap = ${model['thcap']}
81
+ rotor_density = ${model.get('density')*1e3}
78
82
 
79
- rm = m.rotor_rad - m.magn_height/2
80
- thcond = 8
81
- thcap = 440
82
- for i = 1,m.npols_gen do -- Magnets
83
- alfa = (2*i-1) * beta
84
- xmx,ymx = pr2c(rm,alfa-beta/2)
85
- def_mat_therm(xmx,ymx,darkgreen-i%2,7500,thcond,thcap,1)
83
+ %if model.get('thcond_shaft', 0) and model.get('thcap_shaft', 0):
84
+ if m.shaft_rad < m.yoke_rad then
85
+ shaft_thcond = ${model['thcond_shaft']}
86
+ shaft_thcap = ${model['thcap_shaft']}
87
+ shaft_density = ${model['spmaweight_shaft']*1e3}
88
+ r_shaft = (m.shaft_rad + m.yoke_rad)/2
89
+ x0_shaft, y0_shaft = pd2c(r_shaft, beta/2)
86
90
  end
91
+ %endif
92
+ if x0_shaft == nil then
93
+ -- add air layer (inside) for heat transfer
94
+ h = 3.8
95
+ beta = 360*m.npols_gen/m.num_poles
87
96
 
88
- thcond = 0.026 -- air
89
- thcap = 1007
90
- get_spel_keys("sekeys") -- Get all subregions of the model
91
- for i=1, #sekeys do
92
- srkey = get_spel_data("srkey", sekeys[i])
93
- if srkey > 0 then
94
- srname = get_sreg_data("name",srkey)
95
- if srname == ' ' then
96
- srkey = 0
97
- end
98
- end
99
- if srkey == 0 then
100
- elkeys = get_spel_data("elkeys", sekeys[i])
101
- Ex, Ey = get_elem_data("xycp", elkeys[1])
102
- r, phi = c2pr(Ex, Ey)
103
- if r < m.rotor_rad then -- rotor only
104
- def_mat_therm(Ex,Ey,'skyblue',1.12,thcond,thcap,1)
105
- end
106
- end
97
+ x0, y0 = pd2c(m.shaft_rad, m.zeroangl)
98
+ x1, y1 = pd2c(m.shaft_rad-h, m.zeroangl)
99
+ x2, y2 = pd2c(m.shaft_rad-h, beta+m.zeroangl)
100
+ x3, y3 = pd2c(m.shaft_rad, beta+m.zeroangl)
101
+ nc_line(x0, y0, x1, y1, 0)
102
+ nc_circle(x1, y1, x2, y2, 0)
103
+ nc_line(x2, y2, x3, y3, 0)
104
+ x0, y0 = pd2c(m.shaft_rad-h/2, beta/2+m.zeroangl)
105
+ create_mesh_se(x0, y0)
107
106
  end
108
- --[[
109
- -- add air layer (inside) for heat transfer
110
- h = 3.8
111
- beta = 360*m.npols_gen/m.num_poles
112
- x0, y0 = pd2c(dy2/2, m.zeroangl)
113
- x1, y1 = pd2c(dy2/2-h, m.zeroangl)
114
- x2, y2 = pd2c(dy2/2-h, beta+m.zeroangl)
115
- x3, y3 = pd2c(dy2/2, beta+m.zeroangl)
116
- nc_line(x0, y0, x1, y1, 0)
117
- nc_circle(x1, y1, x2, y2, 0)
118
- nc_line(x2, y2, x3, y3, 0)
119
- x0, y0 = pd2c(dy2/2-h/2, beta/2+m.zeroangl)
120
- create_mesh_se(x0, y0)
121
- --]]
122
107
  %endif