Le serveur gitlab sera inaccessible le mercredi 19 février 2020 de 13h à 14h pour une intervention de maintenance programmée.

Adding the model of a node

parent 0816034c
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
"""
Éditeur de Spyder
"""
import numpy as np
import matplotlib.pyplot as plt
class RCnMOS:
def __init__(s,
dt = 10e-5,
wc = 5,
epsilon = 1e-4,
tol = 1e-9,
Vt = 0.5,
Kappa = 0.7,
Sigma = 0.05,
Ith = 5e-8,
Ut = 0.026,
Vr = 0.6,
Vdd = 2.5,
Vg = 0,
v0 = 0,
u0 = 0):
s.v0 = v0
s.u0 = u0
s.dt = dt
s.vr = Vr
s.vt = Vt
s.ut = Ut
s.kappa = Kappa
s.sigma = Sigma
s.vdd = Vdd
s.vg = Vg
s.wc = wc
s.ith = Ith
s.f = lambda U,t: (s.v0-U)*s.wc
s.tol = tol
s.epsilon = epsilon
def I_vg_vd_vs(s,vg,vd,vs):
return s.ith*(np.log(1+np.exp((s.kappa*(vg-s.vt)-vs+s.sigma*vd)/s.ut))**2-np.log(1+np.exp((s.kappa*(vg-s.vt)-vd+s.sigma*vs)/s.ut))**2)
def Vo(s,preactivation):
V = np.arange(s.vg,s.vdd,s.epsilon)
e = s.vdd - s.vg
mVo = 0
for vo in V:
I1 = s.I_vg_vd_vs(preactivation,s.vdd,vo)
I2 = s.I_vg_vd_vs(s.vr,vo,s.vg)
if abs(I1-I2) < s.tol:
return vo
elif abs(I1-I2) < e:
mVo = vo
e = abs(I1-I2)
return mVo
def activate(s,preactivation):
s.v0 = s.Vo(preactivation)
def evol(s,U,t=0):
s.activate(U)
k1 = s.f(s.u0,t)
k2 = s.f(s.u0+0.5*k1*s.dt,t+s.dt*0.5)
k3 = s.f(s.u0+0.5*k2*s.dt,t+s.dt*0.5)
k4 = s.f(s.u0+k1*s.dt,t+s.dt)
s.u0 = s.u0 + s.dt/6.*(k1 + 2*k2 + 2*k3 + k4)
def read(s):
return s.u0
# FilterOutp, Activation, Previous Activation, preactvation
xo = np.array([0,0,0,0])
print("start")
Node = RCnMOS()
print("Node")
xX = []
plt.figure()
k=1
VR = [0,0.5,0.55,0.6,1,1.25,1.5,2,2.5]
for vr in VR:
X = []
Node.vr = vr
for i in range(500):
Node.activate(i/500*2.5)
X.append(Node.v0)
xX.append(X)
plt.subplot(3,3,k)
plt.plot(np.linspace(0,2.5,500),X)
k+=1
'''
def van_der_pol(X,epsi,wo):
x = X[0]
xp = X[1]
return np.array([xp,
epsi*wo*(1.-x**2)*xp-(wo**2)*x]
)
f = lambda X,t: van_der_pol(X,5,1.)
vdp = dynamic(np.array([0.001,0.001]),f, 10e-4)
X = []
Y = []
for i in range(300000):
X.append(vdp.state[0])
Y.append(vdp.state[1])
vdp.evol(0)
plt.plot(Y,X)
'''
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment