30
Numerické limity SPICE

Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Numerické limity SPICE

Page 2: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Numerické limity SPICE

IEEE 754 double-precision binary floating-point format: binary64

Machine epsilon = Eps = 2-52≈2.22 × 10-16 ..horní hranice relativní chyby při

zaokrouhlování

Dynamický rozsah od 2-1022 do 21023 ~10-308 do 10308

Binary 64 se používá pro reprezentaci V, I, TIME

v SPICE.

Další limity- PSpice:

max. napětí 1010 V a proudy 1010 A,

max. derivace 1014,

min. kladné nenulové číslo = 10-30.

Pozor při práci s “malými” veličinami

(nanometry..) nebo s “velkými” veličinami

(behavioral modeling). Používej normování.

Page 3: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Numerické limity SPICE

.subckt MLMCS plus minus params:

+ d=100n del=66.6n Su=100u er=5 Uev=0.33

*****************************************************

.param

+ e0=8.854p m=9.109e-31 e=1.602e-19 h=6.626e-34

.param C0={e0*er*Su/d} C1={C0/(1-del/d)} C2={C0*d/del}

*Use this below line for LTSpice

*.param a={Su*e**2/(4*pi*h*Uev*del**2)}

+ b={4*pi*del*sqrt(m*e)*pwr(Uev,1.5)/h} loga={log(a)}

*Use this below line for OrCAD PSpice

.param a=2.10572e5 b=91.4682096 loga={log(a)}

.func I12(V1)=

+ {V1*abs(V1)*exp(LIMIT(loga-b/MAX(abs(V1),1n),-20,20))}

*****************************************************

*model of memcapacitive port

C1 plus c {C1}

C2 c minus {C2}

GQ c minus value={I12(V(c,minus))}

Rshunt c 0 100meg

*end of the model of memcapacitive port

*****************************************************

.ends MLMCS

Pod 10-30, tudíž zdroj skrytých fatálních chyb v PSpice a také v HSPICE

I12 se mění mezi 10-127 a 101, překračuje SPICE limity. Prevence numerického podtečení:

Výpočet log, umělá limitace, výpočet antilog

Behaviorální modelování moderních nanosoučástek – problémy s malými a velkými čísly

Page 4: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Příklady behaviorálního modelování systémů s elektrickými i neelektrickými veličinami v SPICE - memristory

Page 5: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

* Memristor crossbar arrays

* Bio-inspired electronics

* Massively-parallel analog computations

– náročné simulace extrémně rozsáhlých systémů (miliony součástek)

Page 6: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

TiO2 memristor, HP laboratoře, 2008

Pt Pt

D

TiO2- TiO2

v(t)

w(t)

i(t)

0,1w

xD

1mem on off offR x R x R x R Rx

onoff RRR

dxki

dt 4 1 110k A s

10nmD

Page 7: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

TiO2 memristor, HP laboratoře, 2008

0,1w

xD

1mem on off offR x R x R x R Rx

onoff RRR

dxki

dt 4 1 110k A s

10nmD

x

IC= x 0

Raux

1G

k*i(E)

C=1F

E -deltaR*v(x)*i(E)

G int

Roff

plus

minus

RM

+

i(E)

Roff*i(E)

Rmem*i(E)

Page 8: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

TiO2 memristor, HP laboratoře, 2008

x

IC= x 0

Raux

1G

k*i(E)

C=1F

E -deltaR*v(x)*i(E)

G int

Roff

plus

minus

RM

+

i(E)

Roff*i(E)

Rmem*i(E)

.subckt memristor plus minus params:

+ Ron=100 Roff=100k x0=0.5

.param k=10k deltaR={Roff-Ron}

Roff plus a {Roff}

E a minus value={-deltaR*V(x)*I(E)}

Gint 0 x value={k*I(E)}

C x 0 1 IC={x0}

Raux x 0 1G

.ends memristor

Page 9: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

TiO2 memristor, HP laboratoře, 2008

50u

00 0.1 0.3 0.4flux [Vs]

charge[As]

200u

-200u-1 0 1Vmem [V]

2

-2

Vmem[V]

0 1 2 3time [s]

0 1 2 3time [s]

x[-]

0

1

200u

-200u

Imem[A]

Imem[A]

2

[V]

100u

0

charge[As]

200u

-200u

Imem[A]

Vmem

-2

200u

-200u

Imem[A]

x[-]

0

1

flux [Vs]0 1.20.4 0.8

Vmem [V]0-1.5 1.5

0 1 2 3time [s]

0 1 2 3time [s]

0 0.6flux [Vs]

-2 0 2Vmem [V]

2 3 4 5time [s]

2 3 4 5time [s]

7m

5m

charge[As]

20m

-20m

Imem[A]

2

-2

Vmem[V]

x[-]

0

1

20m

-20m

Imem[A]

-0.5

0.2 1.0 0.2

1.0-1.0 -0.5 -1

(a) (b) (c)

Page 10: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

Pickettův model, HP laboratoře, 2009

gII

vewB

gIwB

Ig

M eveew

jvi

2

)sgn(

2

Aej

mB

24

01

2.1

ww

gvewww

243

2.91

0

12

12 www

)(

)(ln

15.1

2 21

12210

www

www

w

w

w

wwve gI

0forexpsinh

0forexpsinh

Mc

b

i

w

wa

on

Mon

Mc

b

i

w

aw

off

Moff

iw

we

i

if

iw

we

i

if

dt

dw

c

on

c

off

w

e

r 0

2

8

)2ln(

Page 11: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

Pickettův model, HP laboratoře, 2009

gII

vewB

gIwB

Ig

M eveew

jvi

2

)sgn(

2

Aej

mB

24

01

2.1

ww

gvewww

243

2.91

0

12

12 www

)(

)(ln

15.1

2 21

12210

www

www

w

w

w

wwve gI

0forexpsinh

0forexpsinh

Mc

b

i

w

wa

on

Mon

Mc

b

i

w

aw

off

Moff

iw

we

i

if

iw

we

i

if

dt

dw

c

on

c

off

w

e

r 0

2

8

)2ln(

pod 10-30

w není normováno (nanometer size)

“exp(exp)”

..potenciální over(under)flowing

dělení uzlovým napětím

abs není hladká funkce

Chyby a nešikovnosti

Page 12: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

Pickettův model - optimalizace

gII

vewB

gIwB

Ig

M eveew

jvi

2

)sgn(

2

Aej

mB

24

01

2.1

ww

gvewww

243

2.91

0

12

12 www

)(

)(ln

15.1

2 21

12210

www

www

w

w

w

wwve gI

w

e

r 0

2

8

)2ln(

1)expl()(sinhl)sgn( 654321 gg

w

gM vkkvwkkkkvi

LLL

L

xxxxx

xxxx

for)1)(exp(

for)exp()expl(

RS

vg

iM

vM

10-2

10-1

100

101

10-4

10-2

100

102

w = 1.2 nm

w = 1.5 nm

w = 1.8 nm

v (V)

i (m

A)

Original model

Approximation

Page 13: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

Pickettův model - optimalizace

RS

vg

iM

vM

HSPICE code

.SUBCKT TiO2mem p m IC=1.5

.param foff=3.5u ioff=115u aoff=1.2 fon=40u

+ ion=8.9u aon=1.8 b=500u wc=107m k1=11.3153

+ k2=44.6944u k3=1.34192 k4=3.0364 k5=11.4919n

+ k6=24.1384 Rs=232

+ expL(x,L)='(x<=L) ? exp(x): exp(L)*(1+x-L)' sinhL(x,L)= '0.5*(expL(x,L)-expL(-x,L))'

+ stp(x)='(1+sgn(x))/2'

*Port Equation

GM p int value='sgn(v(p,int))*k1*k2**v(w)*(sinhL((k3+k4*v(w))*abs(v(p,int)),10)

+ +k5*(expL(k6*abs(v(p,int)),30)-1))'

Rsh p int 1G

Rs int m 'Rs‘

*State Equation

Ec c 0 value='(V(int)-V(m))/Rs'

C1 w 0 1n IC='IC'

R w 0 100T

Goff 0 w value='foff/2*stp(V(c))*expL(abs(V(c))/ioff-expL((V(w)-aoff)/wc-abs(V(c))/b,10)-

+ V(w)/wc,13)*(1-exp(-2*abs(V(c))/ioff))'

Gon w 0 value='fon/2* stp(-V(c))*expL(abs(V(c))/ion-expL((aon-V(w))/wc-abs(V(c))/b,10)-

+ V(w)/wc,11)*(1-exp(-2*abs(V(c))/ion))'

.ENDS TiO2mem

Page 14: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

* Benchmark circuits:

1 2 3 M

1

2

3

N

in

Počet uzlů: (M+1)(N+1) = 1.002.001 Počet memristorů: 2MN+M+N= 2.002.000 Počet vnitřních uzlů v každém memristoru: A = 1 Celkový počet uzlů n , matice (n,n): n = (M+1)(N+1)+A(2MN+M+N) = 3.004.001

Složitost lze nastavit pomocí M, N Příklad: M=N=1000

Page 15: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

* Benchmark circuits:

1 2 3 M

1

2

3

N

in

Složitost lze nastavit pomocí M, N

MATLAB

netlist_generator.m

Výsledky analýzy transient

HSPICE

netlist.sp

Jak generovat netlist pro sítě s miliony součástek?

Page 16: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

* Benchmark circuits:

1 2 3 M

1

2

3

N

in

Složitost lze nastavit pomocí M, N

Vin, start

Vin, stop

Page 17: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování memristorů

* Simulation time vs number of memristors:

number of memristors

100 1k 10k 100k 1M 10M 10m

100m

1

10

100

1k

10k

sim

ula

tion t

ime

(s)

modified S-model

modified Pickett model

modified Bayat model

HW:

i7-4790K CPU @4.00GHz, 8 core

32 GB RAM

Windows 10

SW:

HSPICE

MultiThread 8

HPP Option (HSPICE Precision Parallel)

RUNLVL = 6

Page 18: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Příklad modelování mechanického systému v SPICE–

kyvadlo

Page 19: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

l

Modelování matematického kyvadla

sin 0g

l sin

g

l

X1 X2

sing

l

iniini

ini

Page 20: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování matematického kyvadla

sin 0g

l sin

g

l

X1 X2

sing

l

iniini

kyvadlo .param L=1 g=9.81 tt0=10 .subckt int 1 2 params:IC=0 Gint 0 2 value={v(1)} Cint 2 0 1 IC={IC} Raux 2 0 1G .ends X1 ttd tt int params: + IC={tt0*pi/180} X2 ttdd ttd int E ttdd 0 value={-g/L*sin(v(tt))} .tran 0 20 0 20m skipbp .probe .end

Page 21: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Modelování matematického kyvadla

Page 22: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Příklad behaviorálního modelování procesů neelektrické povahy –

stíhací křivka

Page 23: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes

0

h

y

x

pán

pes

pánv

pesv

pesv

t = 0

t > 0

pán

pes

pánv

Data: h = 100m, vpan = 5m/s, vpes = 10m/s

Page 24: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes

0

h

y

x

pán

pes

pánv

pesv

pesv

t = 0

t > 0

pán

pes

pánv

xpesv

ypesv

xpes xpán

ypes

ypán=h

Data: h = 100m, vpan = 5m/s, vpes = 10m/s

pes xpes

dx v

dt

pes ypes

dy v

dt

( )pes

pan pes

h ytg

x x

cos( )xpes pesv v

sin( )ypes pesv v

pan panx v t

Page 25: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Data: h = 100m, vpan = 5m/s, vpes = 10m/s

pes xpes

dx v

dt

pes ypes

dy v

dt

( )pes

pan pes

h ytg

x x

cos( )xpes pesv v

sin( )ypes pesv v

pan panx v t

vpan = 5m/s h = 100m

t

xpan

xpes vxpes

ypes vypes

(h, xpan,

xpes, ypes)

vpes = 10m/s

cos( )pesv

sin( )pesv

Page 26: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Data: h = 100m, vpan = 5m/s, vpes = 10m/s

vpan = 5m/s h = 100m

t

xpan

xpes vxpes

ypes vypes

(h, xpan,

xpes, ypes)

vpes = 10m/s

cos( )pesv

sin( )pesv

stihaci krivka

.param h=100 vpan=5 vpes=10

.subckt int in out params:IC=0

Gint 0 out value={v(in)}

Cint out 0 1 IC={IC}

Raux out 0 1T

.ends

Xint1 vxpes Xpes int

Xint2 vypes Ypes int

Expan xpan 0 value={vpan*time}

Ealfa alfa 0 value={atan2(h-v(Ypes),

+ v(xpan)-v(xpes))}

Exd vxpes 0 value={vpes*cos(v(alfa))}

Eyd vypes 0 value={vpes*sin(v(alfa))}

.tran 0 20 0 20m skipbp

.probe

.end

Page 27: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Data: h = 100m, vpan = 5m/s, vpes = 10m/s

Page 28: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Data: h = 100m, vpan = 5m/s, vpes = 10m/s

vpan = 5m/s h = 100m

t

xpan

xpes vxpes

ypes vypes

(h, xpan,

xpes, ypes)

vpes = 10m/s

cos( )pesv

sin( )pesv

stihaci krivka

.param h=100 vpan=5 vpes=10 del=0.1

*add subcircuit for the integrator

.subckt delay in out params:del=0.2

Edel out 0 LAPLACE {v(in)} {exp(-s*del)}

.ends

Xint1 XD Xpes int

Xint2 YD Ypes int

Expan xpan 0 value={vpan*time}

Ealfa alfa 0 value={atan2(h-v(Ypesd),

+ v(xpand)-v(xpesd))}

Exd XD 0 value={vpes*cos(v(alfa))}

Eyd YD 0 value={vpes*sin(v(alfa))}

Xxpand xpan xpand delay

Xxpesd xpes xpesd delay

Xypesd ypes ypesd delay

.tran 0 20 0 20m skipbp

.probe

.end

Modelování reakční doby psa del = 0.1s

delay

Page 29: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Modelování reakční doby psa del = 0.2s

Page 30: Numerické limity SPICE - unob.cz · 2019. 4. 16. · Numerické limity SPICE IEEE 754 double-precision binary floating-point format: binary64 Machine epsilon = Eps = 2-52≈2.22

Stíhací křivka – pán a pes Modelování reakční doby psa del = 1s