femagtools 1.8.12__py3-none-any.whl → 1.8.13__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/machine/sm.py CHANGED
@@ -42,8 +42,8 @@ def parident(workdir, engine, machine,
42
42
 
43
43
  optional arguments:
44
44
  num_cur_steps: number of current steps (default 5)
45
- num_beta_steps: number of current steps (default 13)
46
- num_exc_steps: number of excitation current (default 7)
45
+ num_beta_steps: number of beta steps (default 13)
46
+ num_exc_steps: number of excitation current (default 6)
47
47
  speed: rotor speed in 1/s (default 160/p)
48
48
  i1_max: maximum current in A rms (default approx 3*i1nom)
49
49
  beta_min: minimal current angle (default -180°)
@@ -79,9 +79,14 @@ def parident(workdir, engine, machine,
79
79
  exc_logspace = True
80
80
  ifmin, ifmax = ifnom/4, 1.4*ifnom
81
81
  if exc_logspace:
82
- excur = np.logspace(np.log(ifmin), np.log(ifmax),
82
+ """excur = np.logspace(np.log(ifmin), np.log(ifmax),
83
83
  kwargs.get("num_exc_steps", 6),
84
- base=np.exp(1)).tolist()
84
+ base=np.exp(1)).tolist()"""
85
+ # create a data grid always contains ifnom
86
+ excur = np.logspace(np.log(ifmin), np.log(ifnom),
87
+ kwargs.get("num_exc_steps", 6) - 2,
88
+ base=np.exp(1), endpoint=False).tolist()
89
+ excur.extend([ifnom, ifmax])
85
90
  else:
86
91
  excur = np.linspace(ifmin, ifmax,
87
92
  kwargs.get("num_exc_steps", 6))
@@ -440,10 +445,6 @@ class SynchronousMachine(object):
440
445
 
441
446
  with warnings.catch_warnings():
442
447
  warnings.simplefilter("ignore")
443
- def sqrtculoss(iqde):
444
- pcu = self.culoss(iqde)
445
- return pcu
446
-
447
448
  res = so.minimize(
448
449
  self.culoss, startvals, method='SLSQP', # trust-constr
449
450
  bounds=self.bounds,
@@ -469,10 +470,6 @@ class SynchronousMachine(object):
469
470
 
470
471
  with warnings.catch_warnings():
471
472
  warnings.simplefilter("ignore")
472
- def sqrtculoss(iqde):
473
- pcu = self.culoss(iqde)
474
- #logger.info("iqde %s --> pcu %f", iqde, pcu)
475
- return pcu
476
473
  res = so.minimize(
477
474
  self.culoss, startvals, method='SLSQP', # trust-constr
478
475
  bounds=self.bounds,
@@ -513,42 +510,38 @@ class SynchronousMachine(object):
513
510
  with minimal losses at max voltage"""
514
511
  iqde = self.iqd_tmech(torque, w1/2/np.pi/self.p)
515
512
  if np.linalg.norm(
516
- self.uqd(w1, *iqde)) <= u1max*np.sqrt(2):
513
+ self.uqd(w1, *iqde)) <= u1max*np.sqrt(2):
517
514
  if log:
518
515
  log(iqde)
519
516
  return (*iqde, torque)
520
- #beta, i1 = betai1(iqde[0], iqde[1])
521
- #iex = iqde[2]
522
-
523
- #beta = 0 if torque>0 else np.pi
524
- io = iqde[0], 0, iqde[2] #*iqd(beta, i1), iex
517
+ beta, i1 = betai1(iqde[0], iqde[1])
518
+ iex = iqde[2]
519
+ def ubeta(b):
520
+ return np.sqrt(2)*u1max - np.linalg.norm(
521
+ self.uqd(w1, *iqd(b, i1), iex))
522
+ beta = -np.pi/4 if torque>0 else -3*np.pi/4
523
+ io = *iqd(beta, i1), iex
525
524
 
526
525
  # logger.debug("--- torque %g io %s", torque, io)
527
- with warnings.catch_warnings():
528
- warnings.simplefilter("ignore")
529
- n = w1/2/np.pi/self.p
530
- def sqrtculoss(iqde):
531
- pcu = self.culoss(iqde)
532
- #logger.info("iqde %s pcu %g", iqde, pcu)
533
- return pcu
534
-
535
- res = so.minimize(
536
- self.culoss, io, method='SLSQP', # trust-constr
537
- bounds=self.bounds,
538
- constraints=[
539
- {'type': 'eq',
540
- 'fun': lambda iqd: torque - self.tmech_iqd(*iqd, n)},
541
- {'type': 'eq',
542
- 'fun': lambda iqd: u1max*np.sqrt(2)
543
- - np.linalg.norm(self.uqd(w1, *iqd))}])
544
- #if res['success']:
545
- if log:
546
- log(res.x)
526
+ n = w1/2/np.pi/self.p
527
+ res = so.minimize(
528
+ self.culoss, io, method='SLSQP', # trust-constr
529
+ bounds=self.bounds,
530
+ constraints=[
531
+ {'type': 'eq',
532
+ 'fun': lambda iqd: self.tmech_iqd(*iqd, n) - torque},
533
+ {'type': 'eq',
534
+ 'fun': lambda iqd: np.linalg.norm(
535
+ self.uqd(w1, *iqd)) - u1max*np.sqrt(2)}])
536
+
537
+ if log:
538
+ log(res.x)
539
+ if res["success"]:
547
540
  return *res.x, self.tmech_iqd(*res.x, n)
548
- #logger.warning("%s: w1=%f torque=%f, u1max=%f, io=%s",
549
- # res['message'], w1, torque, u1max, io)
550
- #raise ValueError(res['message'])
551
- #return [float('nan')]*4
541
+
542
+ logger.warning("%s: w1=%f torque=%f, u1max=%f, io=%s",
543
+ res['message'], w1, torque, u1max, io)
544
+ raise ValueError(res['message'])
552
545
 
553
546
  def iqd_torque_umax(self, torque, w1, u1max,
554
547
  disp=False, maxiter=500, log=0, **kwargs):
@@ -559,33 +552,31 @@ class SynchronousMachine(object):
559
552
  if log:
560
553
  log(iqde)
561
554
  return (*iqde, torque)
562
- io = iqde[0], 0, iqde[2]
563
- # logger.debug("--- torque %g io %s", torque, io)
564
- with warnings.catch_warnings():
565
- warnings.simplefilter("ignore")
566
- def sqrtculoss(iqde):
567
- pcu = self.culoss(iqde)
568
- #logger.info("iqde %s pcu %g", iqde, pcu)
569
- return pcu
570
-
571
- res = so.minimize(
572
- self.culoss, io, method='SLSQP', # trust-constr
573
- bounds=self.bounds,
574
- #options={'disp': disp, 'maxiter': maxiter},
575
- # jac=gradient_respecting_bounds(self.bounds, self.culoss),
576
- constraints=[
577
- {'type': 'eq',
578
- 'fun': lambda iqd: self.torque_iqd(*iqd) - torque},
579
- {'type': 'eq',
580
- 'fun': lambda iqd: u1max*np.sqrt(2) - np.linalg.norm(
581
- self.uqd(w1, *iqd))}])
582
- #if res['success']:
583
- if log:
584
- log(res.x)
555
+ beta, i1 = betai1(iqde[0], iqde[1])
556
+ iex = iqde[2]
557
+ def ubeta(b):
558
+ return np.sqrt(2)*u1max - np.linalg.norm(
559
+ self.uqd(w1, *iqd(b, i1), iex))
560
+ beta = -np.pi/4 if torque>0 else -3*np.pi/4
561
+ io = *iqd(beta, i1), iex
562
+ res = so.minimize(
563
+ self.culoss, io, method='SLSQP', # trust-constr
564
+ bounds=self.bounds,
565
+ #options={'disp': disp, 'maxiter': maxiter},
566
+ # jac=gradient_respecting_bounds(self.bounds, self.culoss),
567
+ constraints=[
568
+ {'type': 'eq',
569
+ 'fun': lambda iqd: self.torque_iqd(*iqd) - torque},
570
+ {'type': 'eq',
571
+ 'fun': lambda iqd: u1max*np.sqrt(2) - np.linalg.norm(
572
+ self.uqd(w1, *iqd))}])
573
+ if log:
574
+ log(res.x)
575
+ if res['success']:
585
576
  return *res.x, self.torque_iqd(*res.x)
586
- #logger.warning("%s: w1=%f torque=%f, u1max=%f, io=%s",
587
- # res['message'], w1, torque, u1max, io)
588
- #raise ValueError(res['message'])
577
+ logger.warning("%s: w1=%f torque=%f, u1max=%f, io=%s",
578
+ res['message'], w1, torque, u1max, io)
579
+ raise ValueError(res['message'])
589
580
 
590
581
  def w1_imax_umax(self, i1max, u1max):
591
582
  """return frequency w1 and shaft torque at voltage u1max and current i1max
@@ -669,10 +660,12 @@ class SynchronousMachine(object):
669
660
 
670
661
  wmtab = []
671
662
  dw = 0
663
+ wmMax = 2*np.pi*n
664
+ '''
672
665
  wmMax = 5*wmType
673
666
  if n > 0:
674
667
  wmMax = min(wmMax, 2*np.pi*n)
675
-
668
+ '''
676
669
  if wmType > wmMax:
677
670
  wmrange = sorted([0, wmMax])
678
671
  wmtab = np.linspace(0, wmMax, nsamples).tolist()
@@ -793,6 +786,7 @@ class SynchronousMachinePsidq(SynchronousMachine):
793
786
  self.psiqf = ip.RegularGridInterpolator(
794
787
  (exc, iqx, idx), psiq,
795
788
  method='cubic', bounds_error=False, fill_value=None)
789
+ # excitation currents bounds should respect ifnom
796
790
  self.bounds = [(min(iq), max(iq)),
797
791
  (min(id), 0),
798
792
  (iexc[0], iexc[-1])]
@@ -909,6 +903,7 @@ class SynchronousMachineLdq(SynchronousMachine):
909
903
  method='cubic'
910
904
  , bounds_error=False, fill_value=None)
911
905
  i1max = np.sqrt(2)*(max(i1))
906
+ # excitation currents bounds should respect ifnom
912
907
  self.bounds = [(np.cos(min(beta))*i1max, i1max),
913
908
  (-i1max, 0),
914
909
  (iexc[0], iexc[-1])]
femagtools/parstudy.py CHANGED
@@ -140,7 +140,8 @@ class ParameterStudy(object):
140
140
 
141
141
  def __call__(self, opt, machine, simulation,
142
142
  engine, bchMapper=None,
143
- extra_files=[], num_samples=0):
143
+ extra_files=[], num_samples=0,
144
+ data_model_created=False):
144
145
  """calculate objective vars for all decision vars
145
146
  Args:
146
147
  opt: variation parameter dict (decision_vars, objective_vars)
@@ -150,6 +151,8 @@ class ParameterStudy(object):
150
151
  bchMapper: bch result transformation function
151
152
  extra_files: list of additional input file names to be copied
152
153
  num_samples: number of samples (ingored with Grid sampling)
154
+ data_model_created: model and complete data structur
155
+ was already created before calling this function
153
156
  """
154
157
 
155
158
  self.stop = False # make sure the calculation will start. thomas.maier/OSWALD
@@ -174,7 +177,8 @@ class ParameterStudy(object):
174
177
  workdir = pathlib.Path(self.femag.workdir)
175
178
  for d in workdir.glob('[0-9]*'):
176
179
  if re.search(r'^\d+$', d.name):
177
- shutil.rmtree(d)
180
+ if not data_model_created:
181
+ shutil.rmtree(d)
178
182
 
179
183
  extra_result_files = []
180
184
  if simulation.get('airgap_induc', False):
@@ -198,8 +202,7 @@ class ParameterStudy(object):
198
202
 
199
203
  prob = femagtools.moproblem.FemagMoProblem(decision_vars,
200
204
  objective_vars)
201
-
202
- if immutable_model:
205
+ if not data_model_created and immutable_model:
203
206
  modelfiles = self.setup_model(builder, model, recsin=fea.recsin,
204
207
  feloss=simulation.get('feloss', ''))
205
208
  logger.info("Files %s", modelfiles+extra_files)
@@ -282,7 +285,7 @@ class ParameterStudy(object):
282
285
  task = job.add_task(self.result_func)
283
286
  for fn in extra_files:
284
287
  task.add_file(fn)
285
- if immutable_model:
288
+ if not data_model_created and immutable_model:
286
289
  prob.prepare(x, [fea, self.femag.magnets])
287
290
  for m in modelfiles:
288
291
  task.add_file(m)
@@ -297,18 +300,21 @@ class ParameterStudy(object):
297
300
  else:
298
301
  prob.prepare(x, [model, fea, self.femag.magnets])
299
302
  logger.info("prepare %s", x)
300
- for mc in self.femag.copy_magnetizing_curves(
301
- model,
302
- dir=task.directory,
303
- recsin=fea.recsin,
304
- feloss=feloss):
305
- task.add_file(mc)
306
- set_magnet_properties(model, fea, self.femag.magnets)
303
+ if not data_model_created:
304
+ for mc in self.femag.copy_magnetizing_curves(
305
+ model,
306
+ dir=task.directory,
307
+ recsin=fea.recsin,
308
+ feloss=feloss):
309
+ task.add_file(mc)
310
+ set_magnet_properties(model, fea, self.femag.magnets)
307
311
  task.add_file(
308
312
  'femag.fsl',
309
- builder.create_model(model, self.femag.magnets) +
313
+ builder.create_model(model, self.femag.magnets) if not data_model_created else [] +
310
314
  builder.create_analysis(fea) +
311
- ['save_model("close")'])
315
+ ['save_model("close")'],
316
+ append=data_model_created # model already created, append fsl
317
+ )
312
318
 
313
319
  if hasattr(fea, 'poc'):
314
320
  task.add_file(fea.pocfilename,
femagtools/plot/bch.py CHANGED
@@ -559,7 +559,7 @@ def demagnetization(demag, ax=0):
559
559
  # arrowprops=dict(facecolor='green', edgecolor='green', shrink=0.05))
560
560
  ax.set_ylim([rrmin, 1.01])
561
561
  ax.set_ylabel('Rel. Remanence')
562
- ax.set_xlabel(f'Phase Current / {unit}')
562
+ ax.set_xlabel(f'Phase Current / {unit} (peak)')
563
563
  ax.grid()
564
564
 
565
565
 
@@ -112,12 +112,17 @@ def shortcircuit(femag, machine, bch, simulation, engine=0):
112
112
  for d in bchsc.demag if 'H_max' in d],
113
113
  'H_av': [d['H_av']
114
114
  for d in bchsc.demag if 'H_av' in d]}
115
- i1max = bchsc.scData['iks']
116
- if dd['displ']:
117
- phi = dd['displ'][0]/180*np.pi
115
+ x1 = bchsc.demag[0]['current_1']
116
+ x2 = bchsc.demag[0]['current_2']
117
+ def func(phi):
118
+ return x2*np.cos(phi) - x1*np.cos(phi-2*np.pi/3)
119
+ phi=so.fsolve(func, 0)[0]
120
+ i1max = x1/np.cos(phi)
121
+
122
+ phirot = dd['displ'][0]/180*np.pi
118
123
  bchsc.scData['demag'] = demag(
119
124
  femag, machine, simulation,
120
- i1max, phi, engine)
125
+ i1max, phirot, phi, engine)
121
126
  bchsc.scData['demag'].update(dd)
122
127
  scdata = bchsc.scData
123
128
  #for w in bch.flux:
@@ -310,7 +315,7 @@ def shortcircuit_2phase(femag, machine, simulation, engine=0):
310
315
 
311
316
  # rotor position at maximum current:
312
317
  trot = min(iav[0], iap[0])
313
- phi = wm*trot + phi0
318
+ phirot = wm*trot + phi0
314
319
  logger.info("phi %.1f")
315
320
 
316
321
  scData = {
@@ -330,10 +335,10 @@ def shortcircuit_2phase(femag, machine, simulation, engine=0):
330
335
  if simulation.get('sim_demagn', 0):
331
336
  i1max = iap[1] if iap[1] > abs(iav[1]) else iav[1]
332
337
  scData['demag'] = demag(femag, machine, simulation,
333
- i1max, phi, engine)
338
+ i1max, phirot, 0, engine)
334
339
  return scData
335
340
 
336
- def demag(femag, machine, simulation, i1max, phi, engine=0):
341
+ def demag(femag, machine, simulation, i1max, phirot, phi, engine=0):
337
342
  """demag simulation using psi-torq-rem-rot"""
338
343
  logger.info("Demagnetization processing")
339
344
  i1min = simulation.get('i1min', abs(i1max/3))
@@ -345,7 +350,8 @@ def demag(femag, machine, simulation, i1max, phi, engine=0):
345
350
  i1tab = b*(a+np.log(xtab))
346
351
 
347
352
  if simulation.get('sc_type', 3) == 3:
348
- curvec = [[-a/2, a, -a/2] for a in i1tab]
353
+ curvec = [[a*np.cos(phi), a*np.cos(phi-2*np.pi/3),
354
+ a*np.cos(phi+2*np.pi/3)] for a in i1tab]
349
355
  else:
350
356
  if i1max > 0:
351
357
  curvec = [[a, -a, 0] for a in i1tab]
@@ -353,7 +359,7 @@ def demag(femag, machine, simulation, i1max, phi, engine=0):
353
359
  curvec = [[-a, a, 0] for a in i1tab]
354
360
  simulation.update({
355
361
  'calculationMode': 'psi-torq-rem',
356
- 'phi': phi,
362
+ 'phi': phirot,
357
363
  'magntemp': simulation['Tmag'],
358
364
  'curvec': curvec})
359
365
  _ = femag(machine, simulation)
@@ -6,7 +6,8 @@ muer = 1
6
6
  rel = 100
7
7
  cur = {1, 0}
8
8
  sigma1, sigma2 = get_dev_data( "cond_conduct" )
9
- rotorbar = def_new_bar(xb,yb, "green", "U", cur[1],cur[2], "wi",
9
+ --rotorbar = def_new_bar(xb,yb, "green", "U", cur[1],cur[2], "wi",
10
+ rotorbar = def_new_bar(xcoil,ycoil, "green", "U", cur[1],cur[2], "wi", -- xcoil and ycoil defined in rotor_winding_ks2.mako
10
11
  sigma2, muer, rel, "polar", 0, 0)
11
12
  Abar = get_sreg_data("area",rotorbar)
12
13
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  slot_div_angle = 360/m.tot_num_slot
4
4
 
5
- if m.xcoil_1 ~= nil and m.ycoil_1 ~= nil then
5
+ if m.xcoil_1 ~= nil and m.ycoil_1 ~= nil then
6
6
  rcoil, phi_coil = c2pd(m.xcoil_1, m.ycoil_1)
7
7
  else
8
8
  rcoil, phi_coil = da1/2 + m.slot_height/2, slot_div_angle/2
9
- end
9
+ end
10
10
 
11
11
  -- delete existing mesh in the slot
12
12
  for i = 1, m.num_sl_gen do
@@ -173,11 +173,11 @@ for i = 1, #winding do
173
173
  slot_nr = winding[i][2]
174
174
  layer = winding[i][3]
175
175
  direction = winding[i][4]
176
- if direction < 0 then
176
+ if direction < 0 then
177
177
  dir = 'wo'
178
178
  else
179
179
  dir = 'wi'
180
- end
180
+ end
181
181
  if i == 1 then
182
182
  if slot_nr <= m.num_sl_gen then
183
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)
@@ -188,7 +188,7 @@ for i = 1, #winding do
188
188
  if slot_nr <= m.num_sl_gen then
189
189
  add_to_wdg (wire_xy[slot_nr][layer].x, wire_xy[slot_nr][layer].y, "wsamekey", dir, "wser")
190
190
  end
191
-
191
+
192
192
  else
193
193
  if slot_nr <= m.num_sl_gen then
194
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)
@@ -197,4 +197,6 @@ for i = 1, #winding do
197
197
  end
198
198
  end
199
199
  end
200
- m.num_par_wdgs = ${model.get('num_par_wdgs', 1)}
200
+ m.num_par_wdgs = ${model.get('num_par_wdgs', 1)}
201
+
202
+ pre_models("gen_pocfile")
@@ -38,4 +38,4 @@ m.load_ex_cur = ${model.get('load_ex_cur',0)}
38
38
  run_models("ld_lq_f_cur")
39
39
  %else:
40
40
  run_models("ld_lq_fast")
41
- %endif
41
+ %endif
@@ -19,6 +19,7 @@ if not airgap_created then
19
19
  end
20
20
  x1, y1 = pr2c(r1, alfa)
21
21
  n = math.floor(m.fc_radius*alfa/agndst + 1.5)
22
+ n = n/10 -- Otherwise stacking mesh error TODO find a better formula
22
23
  nc_circle_m(r1, 0, x1, y1, 0.0, 0.0, n)
23
24
  if(m.npols_gen == m.num_poles) then
24
25
  nc_circle_m(x1, y1, r1, 0, 0.0, 0.0, n)
@@ -106,9 +106,13 @@ rotate({
106
106
  })
107
107
 
108
108
  file_psi = io.open("psi-rot-mag.dat","w")
109
+ value={}
110
+ temp={}
109
111
  for n=1,nrot+1 do
110
112
 
111
113
  pos, bag = calc_field(phi, curvec, file_psi)
114
+ value[n]=#pos
115
+ temp[n]=pos
112
116
  bags[n] = bag
113
117
  phi = n*dphi
114
118
  rotate({angle=phi, mode="absolute"})
@@ -116,16 +120,40 @@ end
116
120
  rotate({mode = "reset"}) -- restore the initial state (discard any changes)
117
121
  file_psi:close()
118
122
 
123
+ -- add otherwise nil value in bags[n][i][k]
124
+ for i=1, #value-1 do
125
+ if value[i]<value[i+1] then
126
+ num_pos=value[i]
127
+ end
128
+ end
129
+ -- end
130
+
131
+ --for i=1, #curvec do
132
+ -- bagfile = string.format("noloadbag-%d.dat", i)
133
+ -- file_bag = io.open(bagfile,"w")
134
+ -- for k = 1, num_pos do --#pos do -- add otherwise nil value in bags[n][i][k]
135
+ -- file_bag:write(string.format("%g ", pos[k]))
136
+ -- for n=1, nrot+1 do
137
+ -- file_bag:write(string.format("%g ",
138
+ -- bags[n][i][k])) -- Br, rotpos, cur, pos
139
+ -- end
140
+ -- file_bag:write("\n")
141
+ -- end
142
+ -- file_bag:close()
143
+ --end
144
+
145
+ -- add otherwise nil value in bags[n][i][k]
119
146
  for i=1, #curvec do
120
147
  bagfile = string.format("noloadbag-%d.dat", i)
121
148
  file_bag = io.open(bagfile,"w")
122
- for k = 1, #pos do
123
- file_bag:write(string.format("%g ", pos[k]))
124
- for n=1, nrot+1 do
149
+ for n=1, nrot+1 do
150
+ for k = 1, value[n] do --#pos do
151
+ pos=temp[n]
152
+ file_bag:write(string.format("%g ", pos[k]))
125
153
  file_bag:write(string.format("%g ",
126
154
  bags[n][i][k])) -- Br, rotpos, cur, pos
127
155
  end
128
156
  file_bag:write("\n")
129
157
  end
130
158
  file_bag:close()
131
- end
159
+ end
@@ -0,0 +1,44 @@
1
+ -- Winding (ROTOR_KS2)
2
+
3
+ Q1 = m.tot_num_sl
4
+ Q2 = ${model['num_slots']}
5
+ m.tot_num_sl = Q2
6
+ % if model.get('num_slots_gen', 0):
7
+ m.num_sl_gen = ${model['num_slots_gen']}
8
+ % else:
9
+ m.num_sl_gen = Q2 * m.npols_gen/m.num_poles
10
+ % endif
11
+
12
+
13
+
14
+ m.zeroangl = ${model.get('zeroangl',0)}
15
+
16
+ m.mcvkey_yoke = mcvkey_yoke
17
+
18
+
19
+ dphi=1e-2
20
+
21
+ num_wires=1
22
+ dir = {'wi', 'wo'}
23
+
24
+ -- set subregions 'Bar'
25
+ r=da2/2 - m.slot_height/2
26
+ phi=180/Q2+m.zeroangl
27
+ xcoil, ycoil = pd2c(r,phi-dphi)
28
+ --delete_sreg(xcoil, ycoil)
29
+ --def_new_wdg(xcoil, ycoil, yellow, "Exc", num_wires, 10.0, dir[1])
30
+ def_currdens_se(xcoil, ycoil, 5)
31
+
32
+ for i=2, m.num_sl_gen do
33
+ phi=(2*i-1)*180/Q2 + m.zeroangl
34
+ xcoil, ycoil = pd2c(r,phi)
35
+ --delete_sreg(xcoil, ycoil)
36
+ pole_per_encoche = Q2 / m.num_poles
37
+ pole_num = i // pole_per_encoche
38
+
39
+ if pole_num % 2 == 0
40
+ then def_currdens_se(xcoil, ycoil, 5) --add_to_wdg(xcoil, ycoil, wsamekey, dir[1], 'wser')
41
+ else
42
+ def_currdens_se(xcoil, ycoil, -5) --add_to_wdg(xcoil, ycoil, wsamekey, dir[2], 'wser')
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ -- Winding (ROTOR_KS2)
2
+
3
+ Q1 = m.tot_num_sl
4
+ Q2 = ${model['num_slots']}
5
+ m.tot_num_sl = Q2
6
+ % if model.get('num_slots_gen', 0):
7
+ m.num_sl_gen = ${model['num_slots_gen']}
8
+ % else:
9
+ m.num_sl_gen = Q2 * m.npols_gen/m.num_poles
10
+ % endif
11
+
12
+
13
+
14
+ m.zeroangl = ${model.get('zeroangl',0)}
15
+
16
+ m.mcvkey_yoke = mcvkey_yoke
17
+
18
+
19
+ dphi=1e-2
20
+
21
+ num_wires=1
22
+ dir = {'wi', 'wo'}
23
+
24
+ -- set subregions 'Bar'
25
+ r=da2/2 - m.slot_height/2
26
+ phi=180/Q2+m.zeroangl
27
+ xcoil, ycoil = pd2c(r,phi-dphi)
28
+ --delete_sreg(xcoil, ycoil)
29
+ --def_new_wdg(xcoil, ycoil, yellow, "Exc", num_wires, 10.0, dir[1])
30
+ def_currdens_se(xcoil, ycoil, 5)
31
+
32
+ --for i=2, m.num_sl_gen do
33
+ -- phi=(2*i-1)*180/Q2 + m.zeroangl
34
+ -- xcoil, ycoil = pd2c(r,phi)
35
+ -- --delete_sreg(xcoil, ycoil)
36
+ -- pole_per_encoche = Q2 / m.num_poles
37
+ -- pole_num = i // pole_per_encoche
38
+
39
+ -- if pole_num % 2 == 0
40
+ -- then def_currdens_se(xcoil, ycoil, 5) --add_to_wdg(xcoil, ycoil, wsamekey, dir[1], 'wser')
41
+ -- else
42
+ -- def_currdens_se(xcoil, ycoil, -5) --add_to_wdg(xcoil, ycoil, wsamekey, dir[2], 'wser')
43
+ --end
44
+ --end
@@ -52,7 +52,7 @@ nc_circle_m(xw2, yw2, x8, y8, 0,0,0)
52
52
  nc_circle_m(x4, y4, xw3, yw3, 0,0,0)
53
53
  nc_circle_m(xw4, yw4, x7, y7, 0,0,0)
54
54
 
55
- x, y = (x4+x7)/2, (y4+y5)/2
55
+ x, y = (x7+x5)/2, (y4+y6)/2
56
56
  create_mesh_se(x, y)
57
57
 
58
58
  def_new_sreg(x, y, 'StZa', 'skyblue')