PSSOH 2024, DOI: h ps://doi.o g/10.5281/zenodo.13892004
SWITCHED RELUCTANCE MOTOR
DRIVE SIMULATION USING
OPEN-SOURCE SOFTWARE
Bogdan B ko ić1, Milo an Majs o o ić1, Ma eja I ano ić1, Mladen Te zić1
1: Uni e si y o Belg ade, School o Elec ical Enginee ing, 11000 Belg ade, Se bia
e-mails: [email p o ec ed],[email p o ec ed],[email p o ec ed],
[email p o ec ed]
Abs ac
The swi ched eluc ance mo o is a iable magne - ee op ion o low and medium powe applica-
ions. Cu en challenges limi ing widesp ead applica ion a e he inhe en noise and ib a ion issues.
Mi iga ion o hese p oblems while e aining he equi ed pe o mance can be achie ed by imp o ing
he mo o design and con ol. The esea ch p esen ed in his pape is aimed a de eloping a de ailed
simula ion model o he swi ched eluc ance mo o d i e sys em. This p ocess includes: mo o pa am-
e e iden i ica ion based on ini e-elemen analysis, composi ion o he joined model o he mo o and
dedica ed powe con e e , au oma ic simula ion unning, ou pu da a logging, and p ocessing. The
en i e p ocedu e is conduc ed using open-sou ce so wa e pla o ms. The de eloped modelling and
simula ion app oach enables he de e mina ion o mo o and con e e pe o mance indica o s, includ-
ing a de ailed calcula ion o semiconduc o losses and empe a u e ise. Fu he mo e, his p o ides a
ounda ion o applying design and con ol op imiza ion algo i hms o achie e enhanced pe o mance
cha ac e is ics.
Keywo ds: swi ched eluc ance mo o , powe con e e , d i e, modelling, simula ion.
1 In oduc ion
The swi ched eluc ance mo o (SRM) is ecognized as a opology o in e es in low and medium
powe applica ions such as home appliances and small elec ic ehicles [1–4]. Compa ed o i s main
coun e pa , he pe manen magne synch onous machine (PMSM), he SRM has a dis inc ad an age
o being a magne - ee de ice. This ea u e makes he SRM mo e cos -e ec i e and eco- iendly,
conside ing he ola ili y o he pe manen magne ma ke and he de as a ing p ocedu e o a e-ea h
ma e ial ex ac ion. The majo d awbacks o he SRM a e noise and ib a ion inhe en ly ela ed o
he double-salien s uc u e [5]. To o e come hese challenges, imp o ed mo o and con e e design
and con ol app oaches a e equi ed.
The SRM design p ocedu e is based on analy ical calcula ions o ini e elemen analysis (FEA). The
wo app oaches can be combined o ake ad an age o he FEA accu acy and he ime-e iciency o
he analy ical app oach. This is commonly done by using FEA o ob ain lux and o que lookup ables
which a e hen used o compose he SRM dynamic model. This model can hen be used o simula e
SRM ope a ion unde a ious condi ions using any so wa e package equipped wi h s anda d non-
linea di e en ial equa ion sol e s.
1
The SRM can be supplied exclusi ely om a dedica ed powe con e e . Mul iple opologies ha e
been p oposed o e he yea s [6,7]. The mos commonly employed opology is he Asymme ic Hal -
B idge Con e e (AHBC), due o i s ela i ely low cos , con ol lexibili y, and simplici y.
A simula ion o he SRM d i e is equi ed in he de elopmen s age o assess he d i e pe o mance
unde a ious ope a ing modes. Bo h he mo o and con e e need o be simula ed in su icien de ail
wi hin a easonable ime ame. As p e iously s a ed, he mo o can be simula ed in g ea de ail using
FEA so wa e, howe e such simula ions a e by no means ime-e icien . On he o he hand, he e
is a wide a ay o ci cui simula ion so wa e packages. No ably, LTspice is a powe ul open-sou ce
simula ion ool inco po a ing ac ual de ice models [8]. This allows an accu a e p edic ion o con e e
pe o mance, mos no ably calcula ion o losses and dynamic beha iou . The e is only he ma e o
in e acing he con e e model o he SRM model. In his pape , a de ailed SRM model based on
lux and o que lookup ables is de eloped and implemen ed in he LTspice ci cui simula ion ool.
The lookup ables a e gene a ed using he FEA so wa e pla o m FEMM 4.2 [9] in combina ion wi h
GNU Oc a e [10]. To he bes o ou knowledge, no p e ious implemen a ions o an SRM model in
a ci cui analysis so wa e such as LTspice ha e been epo ed. Finally, he comple e d i e model is
assembled in LTspice. In e ac ion wi h he LTspice model (s a ing and s opping he model execu ion,
ou pu da a eco ding and p ocessing) is conduc ed en i ely using a dedica ed Py hon sc ip .
The pape is composed as ollows. Following he In oduc ion, undamen al in o ma ion ega ding
he applied SRM and AHBC a e gi en in sec ion 2. De ails ega ding he de elopmen and imple-
men a ion o he SRM d i e model using open-sou ce so wa e pla o ms a e gi en in sec ion 3. The
model esul s a e displayed in sec ion 4 and he conclusions and plans o u u e wo k a e p esen ed
in sec ion 5.
2 SRM d i e o e iew
The SRM unde in es iga ion has six s a o poles and en o o poles. Such a machine is ap ly e e ed
o as a 6/10 SRM. The machine c oss-sec ion is displayed in Figu e 1. The ope a ing p inciple is
ela i ely simple - when a gi en phase is ene gized a magne ic ield es ablished in he co esponding
s a o poles a ac s he nea es o o poles. By applying exci a ion in an app op ia e o de and wi h
sui able iming, high a e age o que wi h minimal oscilla ions is ob ained.
Typical SRM wa e o ms a e illus a ed in Figu e 2. The diag ams display he phase induc ance, ex-
ci a ion ol age and cu en , and elec omagne ic o que de eloped by a single phase. The a ia ion
o quan i ies is shown wi h espec o he o o angle. Cha ac e is ic posi ions o he o o wi h co e-
sponding quali a i e lux line dis ibu ions a e also displayed. Two cha ac e is ic o o posi ions a e
iden i ied: he unaligned posi ion, when he s a o pole is be ween wo o o poles and he induc ance
alue is minimal, and he aligned posi ion, when he axes o s a o and o o poles a e aligned and he
induc ance alue is maximal. The induc ance a ia ion be ween hese wo posi ions is app oxima ely
linea , dis ega ding magne ic sa u a ion. The phase is usually ene gized be o e he o e lap be ween
he s a o and o o poles begins and he cu en is quickly inc eased. P io o eaching ull alignmen ,
he ol age pola i y is e e sed and he cu en is educed back o ze o, a e which he ol age is
main ained a ze o alue un il he nex cycle. The ob ained elec omagne ic o que is mos ly posi i e,
howe e a sligh nega i e pulse canno be a oided p ac ically, due o he ini e cu en dec ease a e.
Posi i e o que is gene a ed when he induc ance is inc easing and ice e sa. No o que is gene a ed
when he induc ance is cons an . Wi hou di ing o deep in o he SRM model i sel , only he basic
2
Figu e 1: SRM c oss-sec ion
equa ions a e gi en as ollows [5]:
uξ=Rξiξ+dψξ
d =Rξiξ+Lξ(iξ, θ)diξ
d +∂Lξ(iξ, θ)
∂θ iξ,(1)
Teξ =1
2i2
ξ
∂Lξ(iξ, θ)
∂θ ,(2)
θ=∫Ωd . (3)
The a iables and pa ame e s in he p e ious exp essions a e de ined as:
•ξdeno es he obse ed phase (A, B, o C),
•uξ,iξ, and ψξa e he ol age, cu en , and lux linkage o he obse ed phase,
•θis he o o posi ion wi h espec o phase A,
•Ωis he o o angula speed,
•Teξ is he elec omagne ic o que gene a ed by he obse ed phase, and
•Rξand Lξa e he esis ance and induc ance o he obse ed phase.
I should be emphasized ha he induc ances a e dependen on cu en alues due o magne ic sa u-
a ion, which makes he SRM model highly non-linea . This non-linea i y will be accoun ed o by
modelling he SRM using lux and o que lookup ables ob ained om FEM simula ions, as elabo-
a ed in sec ion 3. The mo ion equa ion is excluded om he model, as he o o speed is conside ed
cons an in all upcoming analyses.
The SRM supply ol age ob iously needs o be a ied equen ly which can only be accomplished
by means o a powe con e e . Conside ing he equi ed ol age alues (+VDC,−VDC , and 0), a
wo-le el con e e such as an H-b idge would be sui able. Howe e , conside ing he ac ha he
3
10 20 30 40 50 60 70
0
Lmax
Angle (deg ees)
Induc ance (H)
∙×∙×∙×
010 20 30 40 50 60 70
VDC
Vol age (V)
−VDC
Angle (deg ees)
Cu en (A)
Lmin
Imax
010 20 30 40 50 60 70
To que (Nm)
Angle (deg ees)
Figu e 2: Example o SRM wa e o ms o a ypical ope a ing mode
SRM cu en is unidi ec ional, i is e y common in p ac ice o apply he asymme ic hal -b idge con-
e e (AHBC). The AHBC opology and i s connec ions o espec i e SRM phases is schema ically
displayed in Figu e 3. The AHBC s uc u ally esembles a s anda d H-b idge module, excep ha i
only employs wo swi ches (mos commonly MOSFET o IGBT) and wo diodes o each phase. As
p e iously s a ed, his is due o he ac ha he cu en is unidi ec ional, which e en elimina es he
need o e e se diodes in pa allel wi h he swi ches (e en hough hese a e inhe en ly p esen in mos
cases). Reducing he numbe o powe swi ches educes he o al componen cos , which makes he
AHBC a p e e ed op ion o SRM supply. Mo eo e , he con ol algo i hm is simple , as only wo
swi ches pe phase a e con olled, and he swi ching losses end o be lowe . The only d awback is
ha he con e e is composed o disc e e componen s which may inc ease manu ac u ing cos and
complexi y.
The con ol app oach will now be b ie ly explained o a ypical ope a ing mode. Example ol age
and cu en wa e o ms along wi h co esponding AHBC swi ching s a es a e shown in Figu e 4. Hys-
e esis cu en con ol is commonly applied in he ollowing manne :
• posi i e DC link ol age VDC is applied by u ning on he powe swi ches when he u n-on
angle (θon) is exceeded, which causes he cu en o inc ease;
4
LALBLC
VDC
QA+
QA-
DA+
DA-
QB+ DB+
QB-DB-
QC+
DC- QC-
DC+
Figu e 3: Schema ic display o SRM phases supplied om an AHBC
• when he cu en exceeds he alue I e + ∆I(I e is he e e ence and ∆I he hys e esis band),
he lowe swi ch is u ned o and app oxima ely ze o ol age is applied o he phase winding,
causing he cu en o g adually dec ease;
• when he cu en d ops o I e −∆I, he lowe swi ch is again u ned on and he cu en inc eases
due o posi i e DC link ol age;
• he p e ious wo s eps a e epea ed un il he u n-o angle (θo ) is eached, a e which bo h
swi ches a e u ned o and nega i e ol age −VDC is applied h ough he diodes;
• he nega i e ol age educes he cu en o ze o.
I should be no ed ha ei he o he wo swi ches can be manipula ed o achie e hys e esis con ol,
and no mally bo h a e used al e na ely o achie e an e en loss dis ibu ion. The selec ion o u n-on
and u n-o angles is c ucial o maximizing he a e age o que and minimizing he o que ipple.
Di e en alues o θon and θo should be applied o a ious speeds and loads o achie e op imal
ope a ing condi ions.
3 Model syn hesis and implemen a ion
The lowcha depic ing he model de elopmen and execu ion p ocedu e is shown in Figu e 5. The
applied so wa e ools a e indica ed and he key ou pu s a e highligh ed. The en i e p ocedu e can be
di ided in o h ee ou s eps:
(i) FEM model composi ion,
(ii) FEM model execu ion by means o Oc a e code,
(iii) LTspice model assembly, and
(i ) LTspice model execu ion by means Py hon code.
A e comple ing s eps (i) and (ii), lux and o que lookup ables a e gene a ed. Based on hese lookup
ables, he LTspice model is composed in s ep (iii). Finally, a Py hon sc ip o au oma iong he LTspice
simula ion execu ion and ou pu da a logging is de eloped in s ep (i ). The ob ained ou pu s a e he
SRM d i e pe o mance indica o s, such as cu en s, ol ages, powe swi ch losses, e c. Each o he
lis ed s eps is analysed in de ail in he ollowing subsec ions. Subsec ion 3.1 desc ibes s eps (i) and
(ii), whe eas subsec ion 3.2 is conce ned wi h s eps (iii) and (i ).
5
QA+
QA-
DA+
DA-
A
VDC
QA+
QA-
DA+
DA-
iA
A
VDC
QA+
QA-
DA+
DA-
iA
A
VDC
iA
1 2 3
(a) AHBC swi ching s a es
θ
1 31 22121
ΔI
iA
uA
θ
VDC
-VDC
I e
θon θo
(b) SRM ol age and cu en wa e o ms
Figu e 4: Illus a ion o SRM cu en con ol using AHBC
3.1 Flux and o que lookup able gene a ion (FEMM & Oc a e)
The FEM model is de eloped based on he cons uc ion da a o he 6/10 SRM displayed in Figu e 1.
The open-sou ce so wa e pla o m FEMM 4.2 o ini e elemen -based elec omagne ic calcula ions
is used. The SRM geome y is plo ed and app op ia e ma e ials a e assigned o di e en a eas. A e
his is comple ed, he machine geome y is di ided in o a g ea numbe o small ( ini e) iangula
elemen s. The ob ained ini e elemen mesh is displayed in Figu e 6a. When he mesh o app op ia e
densi y is o med, he calcula ion is conduc ed and he ield dis ibu ion wi hin he analysed domain
(machine) is ob ained. An example lux densi y dis ibu ion is displayed in Figu e 6b.
Manual model execu ion is gene ally incon enien , as many inpu pa ame e s need o be se p io o
each calcula ion. This becomes e y cumbe some and ime-consuming when a wide ange o ope a ing
modes needs o be analysed. In his pape , he FEM model was used o ob aining lux and o que
lookup ables (LUTs) wi h espec o winding cu en s and o o angula posi ion. As he accu acy o
he esul ing SRM model is di ec ly dependen on he esolu ion o hese LUTs, o e 2000 simula ions
o a ious cu en and o o angle combina ions a e equi ed. This p ocess is he e o e au oma ed
by in e acing FEMM wi h GNU Oc a e by means o he Oc a eFEMM oolbox [11]. This oolbox
allows Oc a e o modi y he model, un he simula ion, and access he ou pu alues.
The p ocess o gene a ing lux and o que LUTs is depic ed in he lowcha o Figu e 7a. No e ha
6
V1
36
D1
RBQ30NS45B
R1
0.2
V2
V=IF(V( he a)<18,5,0)
D3 RBQ30NS45B
BSC019N06NS_L0
M1
M2
BSC019N06NS_L0
L
1
MechTo que
0.5
Jm
0.002
To que
1
w
MechTo que 57.325
C1
1
MOD
IN OUT
X1
he aBu
1
w1
187500
C2
1
Flux
1
S a o Wind
1000
V4
V=IF(((V( he a)<18) & (V(Sch)>0.1)),5,0)
I1
24000
To que2DLookup
X
YZ
X2
Phi2DLookup
X
YZ
X3
R2
0.1
R3
0.1
S uja1
L 1
V ={V } Vh={Vh}
A1
R4
15k
R5
15k
he aBu 1
0.5
S uja2
L 1
R6
10
R7
10
C3
1n
C4
1n
B1
L 1
B2
V=IF(TIME<1us,V(S uja),ABS(V(S uja)))
B3
V=sgn(V(S uja))*V(Phi_abs)
C5
1e-11
R8
0.5e9
G1
A
AG1
B
L1
C
he a_0
he a_0
he a
s uja_0
he a Tem
Tem Phi
L1
G1_1
G1_1
s a1
Sch
he a
Phi_abs
S uja
Phi
S uja_abs
M1H
.lib i h5004pb .spi
. an 0 0.005s 1us 1e-6 uic
.lib SiR180DP_PS.LIB
.lib Op iMOS_60V_PSpice.lib
.pa am N=100
.ic V( he a_0)=0
.ic V(s uja_0)=0
.pa am Ns=116
.op ions abs ol=1e-10
.op ions el ol=0.001
.pa am V =12 Vh=0.2
Biblio eke:
RESULTS
FEMM 4.2 FLUX AND TORQUE
LOOKUP TABLES
Figu e 5: Flowcha o he model syn hesis, implemen a ion, and execu ion p ocedu e
M330-35A
M330-35A
Coppe
[I1:-58]
Coppe
[I1:58]
Coppe
[I2:58]
Coppe
[I2:-58]
Coppe
[I3:-58]
Coppe
[I3:58]
Coppe
[I1:58]
Coppe
[I1:-58]
Coppe
[I2:-58]
Coppe
[I2:58] Coppe
[I3:58]
Coppe
[I3:-58]
Ai
Ai
Ai
Ai
Ai
Ai
Ai
Ai
Ai
(a)
Densi y Plo : |B|, Tesla
1.284e+000 : >1.352e+000
1.216e+000 : 1.284e+000
1.149e+000 : 1.216e+000
1.081e+000 : 1.149e+000
1.014e+000 : 1.081e+000
9.461e-001 : 1.014e+000
8.785e-001 : 9.461e-001
8.110e-001 : 8.785e-001
7.434e-001 : 8.110e-001
6.758e-001 : 7.434e-001
6.082e-001 : 6.758e-001
5.407e-001 : 6.082e-001
4.731e-001 : 5.407e-001
4.055e-001 : 4.731e-001
3.379e-001 : 4.055e-001
2.704e-001 : 3.379e-001
2.028e-001 : 2.704e-001
1.352e-001 : 2.028e-001
6.763e-002 : 1.352e-001
<5.607e-005 : 6.763e-002
(b)
Figu e 6: SRM c oss-sec ion in FEMM 4.2 en i onmen : (a) ini e elemen mesh, (b) lux densi y
dis ibu ion ob ained a e calcula ion
7
he so wa e ools applied in each s age o he p ocedu e a e indica ed by app op ia e icons. The
model is gene a ed using only FEMM, al hough his s ep can also be ca ied ou using Oc a e. A e
he model is o med, inpu alues a e p o ided o Oc a e, speci ically he se o cu en s and o o
angles o LUT o ma ion. A loop is hen ini ia ed, whe ein FEMM calcula ions a e conduc ed o all
cu en and angle combina ions. This pa o he p ocess is au oma ed: Oc a e in okes he model, se s
he cu en and angle o he equi ed alues, uns he model, and ob ains he lux and o que alues.
Upon exi ing he loop, wo-dimensional lux and o que LUTs a e o med and expo ed o ex iles o
u he use in o ming he SRM nume ical model. Wi h a 1◦angle esolu ion and 1A cu en esolu ion,
he LUT con ains a o al o 2263 en ies. This ule o humb ensu es high modelling accu acy while
main aining he numbe o execu ed FEM simula ions and o al LUT gene a ion ime wi hin easonable
limi s. Addi ionally, inc easing he numbe o da a poin s in he LUT e en ually educes he simula ion
e iciency wi hou signi ican ly imp o ing he accu acy. The g aphical ep esen a ion o he lux and
o que LUTs in he o m o su ace diag ams is gi en in Figu e 7b.
SRM geome y
C ea e he FEMM
model
Vec o s o cu en alues
and o o angles
Se he cu en and
o o posi ion
Run he FEMM model
Flux and o que LUTs
Winding luxes and
elec omagne ic o que
YES
NO All simula ions
comple ed?
(a) (b)
Figu e 7: (a) Flux and o que LUT calcula ion lowcha , (b) lux and o que LUTs ep esen ed by
3D diag ams
8
3.2 SRM d i e model assembly and execu ion (LTspice & Py hon)
As indica ed in Figu e 5, he lux and o que LUTs a e used o o m an SRM model in he LTspice
en i onmen . While he con e e model is implemen ed in a s aigh o wa d manne , he SRM model
includes elec ical, magne ic, and mechanical quan i ies. The e o e, app op ia e elec ical equi alen s
need o be employed. Mo eo e , LUT implemen a ion in LTspice is qui e in ol ed. So wa e ools ha
enable a simple SRM model o mula ion a e a ailable, bu none o hem p o ides accu a e modelling
o powe swi ching de ice dynamics and losses. As he powe con e e is an in eg al and mos
sensi i e pa o he SRM d i e, a high- ideli y model is c ucial o p ope pe o mance p edic ion.
The comple e SRM d i e model implemen ed in LTspice is displayed in Figu e 8. The model can be
di ided in o se e al unc ional en i ies as designa ed in he igu e:
1. The main pa o he model – con e e ci cui connec ed o he phase winding e minals. The
phase winding is modelled as esis o connec ed in se ies wi h a dependen ol age sou ce co -
esponding o he winding elec omo i e o ce (EMF). When he EMF is calcula ed, he cu en
is ob ained simply as:
iA=uA−eA
RA
,(4)
whe e uAis he e minal ol age, eAis he EMF, and RAis he phase winding esis ance.
2. The EMF calcula ion ci cui based on di e en ia ing he winding lux. Fo his pu pose, he lux
alue is assigned o a ol age con olled cu en sou ce connec ed in se ies wi h an induc o . The
cu en alue co esponds o he lux and he induc ance co esponds o he numbe o u ns pe
phase, he eby essen ially ob aining he EMF alue as:
eA=Ns
dΦA(iA, θ)
d ,(5)
whe e Nsis he numbe o u ns pe phase (“induc ance”), and ΦAis he lux pe pole (“cu en ”).
No e ha a se ies RC snubbe is added in pa allel o a oid nume ical issues due o connec ing a
cu en sou ce in se ies wi h an induc o . The RC elemen il e s ou he high- equency noise
caused by he swi ching ac ions. The lux alue is ob ained om he LUT as a unc ion o
winding cu en iAand o o angle θ.
② ①⑥
⑤
③
④
V1
36
D1
RBQ30NS45B
R1
0.2
V=IF(V( he a)<18,5,0)
V2
D3 RBQ30NS45B
BSC019N06NS_L0
M1
M2
BSC019N06NS_L0
L
1
MechTo que
0.5
Jm
0.002
To que
1
w
MechTo que 57.325
C1
1
MOD
IN OUT
X1
he aBu
1
w1
187500
C2
1
Flux
1
S a o Wind
1000
V=IF(((V( he a)<18) & (V(Sch)>0.1)),5,0)
V4
I1
108000
To que2DLookup
X
YZ
X2
Phi2DLookup
X
YZ
X3
R2
0.1
R3
0.1
S uja1
L 1
V ={V } Vh={Vh}
A1
R4
15k
R5
15k
he aBu 1
0.5
S uja2
L 1
R6
10
R7
10
C3
1n
C4
1n
B1
L 1
B2
V=IF(TIME<1us,V(S uja),ABS(V(S uja)))
B3
V=sgn(V(S uja))*V(Phi_abs)
1e-10
C5
R8
1e9
C6
1e-12
GU
A
AGU
B
L1
C
he a_0
he a_0
he a
s uja_0
he a Tem
Tem
Phi
L1
GL
GL
s a1
Sch
he a
Phi_abs
S uja
Phi
S uja_abs
M1H
VTem
.lib i h5004pb .spi
. an 0 0.005s 1us 1e-6 uic
.lib SiR180DP_PS.LIB
.lib Op iMOS_60V_PSpice.lib
.pa am N=100
.ic V( he a_0)=0
.ic V(s uja_0)=0
.pa am Ns=116
.op ions abs ol=1e-10
.op ions el ol=0.001
.pa am V =12 Vh=0.2
Biblio eke:
Figu e 8: LTspice model o he SRM d i e: 1 – con e e ci cui , 2 – SRM phase winding model, 3 –
lux and o que calcula ion om LUTs, 4 – o o angle calcula ion, 5 – con ol ci cui s, 6 – model
inpu s (pa ame e s, lib a ies, ini ial condi ions) and simula ion se ings
9
ge -up-and- unning-wi h-l spice.h ml. Accessed: 2024-30-8.
[9] D. Meeke . Fini e elemen me hod magne ics e sion 4.2 use ’s manual, May 2020. A ailable a h p://www.
emm.in o/A chi es/doc/manual.pd .
[10] Gnu oc a e 9.2.0 manual, 2024. A ailable a h ps://docs.oc a e.o g/in e p e e /.
[11] D. Meeke . Fini e elemen me hod magne ics: Oc a e emm e sion 1.2 use ’s manual, Ma 2018. A ailable a
h p://www. emm.in o/A chi es/doc/oc a e emm.pd .
[12] Pyl spice 5.3.2 documen a ion, 2024. A ailable a h ps://pyl spice. ead hedocs.io/en/la es /
modules/modules.h ml.
Appendix
The Py hon code used o manipula e he LTspice model o he SRM d i e is gi en below. Pa s o
he code no speci ic o he Py hon–LTspice in e ace a e omi ed and eplace by e ical do s. Use
de ined unc ions ead_da a and calcVals dedica ed o eading, p ocessing, and plo ing ou pu
da a, a e gi en a e he main p og am.
Main p og am
1# Impo PyLTSpice modules
2 om PyLTSpice impo SimRunne
3 om PyLTSpice impo SpiceEdi o
4 om PyLTSpice impo LTSpiceLogReade
5 om PyLTSpice impo RawRead , T ace , RawW i e
6.
7.
8.
9# Impo use de ined unc ions
10 om unc ions impo *
11 .
12 .
13 .
14 # De ine ec o s o o a ing speeds and cu en s
15 nmeh_ ec = [2000, 4000, 8000, 12000, 18000] # o a ing speeds ( pm)
16 I e _ ec = [2, 4, 6, 8, 10, 12, 14] # e e ence cu en s (A)
17
18 # Run he simula ions o all speed and e . cu en alues
19 o I e in I e _ ec:
20 o nmeh in nmeh_ ec:
21
22 # Selec Spice model and gene a e ne lis
23 LTC = SimRunne (ou pu _ olde ='./ emp'+s (nmeh), imeou =6000.0)
24 LTC.c ea e_ne lis ('AHB.asc')
25 ne lis = SpiceEdi o ('AHB.ne ')
26
27 # Calcula e speed in (deg/s) and de ine he angula pe iod
28 ndegs = nmeh*360.0/60.0 # speed (deg/s)
29 he a_pe = 36.0 # angle co esponding o one elec ical pe iod (deg)
30 sim = 2.0* he a_pe /(nmeh*360.0/60.0) # simula ion leng h = wo pe iods
31 # ne lis .se _pa ame e s( es=0, cap=100e-6)
32
33 # Se he alues o ope a ing speed , e e ence cu en , and hys e esis band
34 ne lis .se _componen _ alue('I1',s (ndegs))
35 ne lis .se _pa ame e ('V ', I e )
36 ne lis .se _pa ame e ('Vh', 0.2)
37
38 # Simula ion se ings
39 ne lis .add_ins uc ions(
40 "; Simula ion se ings",
41 ";.pa am un = 0",
42 ". an 0 " +s ( sim) + " 0.1us 1e-6 uic" # makes a ansien simula ion
43 )
44 ne lis .se _pa ame e (' un', 0)
45
46 # Run he simula ion
47 p in ("simula ing es ")
48 LTC. un(ne lis , imeou =60.0)
49 ne lis . ese _ne lis ()
50
51 # Sim S a is ics
52 p in ('Success ul/To al Simula ions: ' +s (LTC.okSim) + '/' +s (LTC. unno))
53
16
54 # Read da a om he ou pu (*. aw) ile
55 ead_da a(" emp"+s (nmeh)+"/AHB_1. aw")
56
57 # Calcula e he a e age losses o swi ching de ices
58 gubici = calcVals(" emp"+s (nmeh)+"/AHB_1. aw")
59 p in (gubici)
Func ions
1##########################################################################
2# ead_da a --> eads and plo s he ol age , cu en , and o que wa e o ms
3de ead_da a( ilename):
4
5# Impo he RawRead module o eading ou pu aces
6 om PyLTSpice impo RawRead
7 om ma plo lib impo pyplo as pl
8
9# Read he ou pu aces
10 LTR = RawRead( ilename)
11 IR1 = LTR.ge _ ace("I(R1)")# Cu en
12 To que = LTR.ge _ ace("V(VTem)")# To que
13 VSRM = LTR.ge _ ace("V(L1)")# Vol age
14
15 x = LTR.ge _ ace(' ime')# Ge s he ime axis
16 s eps = LTR.ge _s eps()
17
18 # Plo he wa e o ms
19 o s ep in ange(len(s eps)):
20 # p in (s eps[s ep])
21 pl . igu e()
22 pl .plo (x.ge _wa e(s ep), -IR1.ge _wa e(s ep), label=s eps[s ep])
23 pl .g id()
24
25 pl . igu e()
26 pl .plo (x.ge _wa e(s ep), To que.ge _wa e(s ep), label=s eps[s ep])
27 pl .g id()
28
29 pl . igu e()
30 pl .plo (x.ge _wa e(s ep), VSRM.ge _wa e(s ep), label=s eps[s ep])
31 pl .g id()
32
33 pl .show()
34
35 ####################################################################################
36 # calcVals --> eads and plo s swi ching de ice losses and calcula es a e age losses
37 de calcVals( ilename):
38
39 # Impo he RawRead module o eading ou pu aces
40 om PyLTSpice impo RawRead
41 om ma plo lib impo pyplo as pl
42
43 # Read he ou pu aces
44 LTR = RawRead( ilename)
45 IM1 = LTR.ge _ ace("Ix(M1:DRAIN)")
46 IM2 = LTR.ge _ ace("Ix(M2:DRAIN)")
47 VM1H = LTR.ge _ ace("V(M1H)")
48 VM1L = LTR.ge _ ace("V(A)")
49 VM2 = LTR.ge _ ace("V(A)")
50
51 x = LTR.ge _ ace(' ime')# Ge s he ime axis
52 s eps = LTR.ge _s eps()
53
54 # MOSFET losses
55 # A ay ini ializa ion
56 PgM1 = []
57 PgM2 = []
58
59 # Loss calcula ion and da a plo ing
60 o s ep in ange(len(s eps)):
61 # Calcula e losses a he cu en ime s ep and add o a ay
62 PgM1.append ((VM1H.ge _wa e(s ep)-VM1L.ge _wa e(s ep)) * IM1.ge _wa e(s ep))
63 PgM2.append (VM2.ge _wa e(s ep) * IM2.ge _wa e(s ep))
64
65 # Plo he da a
66 pl . igu e()
67 pl .plo (x.ge _wa e(s ep), PgM1[s ep], label='Pg1')
17
68 pl .plo (x.ge _wa e(s ep), PgM2[s ep], label='Pg2')
69 pl .legend() # o de a legend
70 pl .g id()
71 pl .show()
72
73 # Calcula e he a e age losses o e he simula ion in e al
74 PgM1_a g = sum(PgM1[0])/len(PgM1[0])
75 PgM2_a g = sum(PgM2[0])/len(PgM2[0])
76
77 # Re u n he a e age alues o losses
78 e u n [PgM1_a g , PgM2_a g]
18