View
216
Download
0
Category
Preview:
Citation preview
7/24/2019 cnc_hw2
1/6
1)a)
For a linear equation as follows:
dy
dx=f(x , y )
dy
dx+p (x )y=q (x )
General solution for the differential equation is as follows:
y= u (x ) q (x ) dx+C
u(x)
Where
u (x)=ep(x)dx
The given differential equation is:
mdv
dt=v+RI(t)
Given thatI( t)=I
0 and
0
v
and re ordering differential equation:
dv
dt+
v
m=
R I0
m
Therefore;
q (x )=R I0m
p (x )=1
m
y=v
We replace the variables to general solution
u (x)=e 1
mdx
=ex
m
7/24/2019 cnc_hw2
2/6
v=e
x
mR I
0
mdx+C
e
x
m
=R I0 e
x
m+C
e
x
m
=R I0+C e
xm
With given initial condition
0
v
0=R I0+C e
0
m
C=R I0
As a result:
v (t)=R I0+C e
tm
b)
We can represent differential equation as follows:
m v
t=v+R I
0
More prisiel! we can appro"i#ate v$%) as follows:
v(k)=R I0m
v ( k)v (k1 ) t
&r;
v(k1 )=R I0m
v(k)v(k1 )t
Appro"i#ation does not #atter if t is s#all enough'
% initializationsR =1e3; % resistor 1kI=2e-3; % I_0 currentTm = 10e-3; % time constantt_last= 100e-3; % 100ms simulation timen=1001; % number of points to simulate larger it is less ifference bet!een anal"tican numeric solutionst= 0#t_last$n-1t_last; % time 'ector
( = R)*I-R)*I)*e+p-t)$Tm&;
(p = zeros1,n&;(p1&=0; % initial conition for 'oltage
7/24/2019 cnc_hw2
3/6
t =t_last$n-1&;
fork=2#n (pk&=R*I*tTm*(pk-1&&$t Tm&;% numeric representation of t.e ifferentiale/uation %(pk&=t_last$n-1&$Tm * R*I-(pk-1&&(pk-1&;en
% plot t.e resultsplott,(,t,(p&titleumeric 's) nal"tic olutions&+labeltime&"label'&legennal"tic,umeric&gri
Figure 1: Analytic vs. Numeric Solution for the given differential equation
c)
(ow we put a threshold to reset the voltage' We are able to see the spi%es'
n_fire=0; % 'ariable to store number of firest.eta = 1; % t.res.ol 'aluefork=2#n
(pk&=R*I*tTm*(pk-1&&$t Tm&; % numeric calculation if(pk& 4= t.eta (pk&=0; n_fire=n_fire1; % number of fires passing t.e t.res.ol
enenn_fire % number of firesfigureplott,(p&titleumeric olution !it. t.res.ol&
7/24/2019 cnc_hw2
4/6
+labeltime&"label'&legenumeric&gri
Figure 2: Numeric solution for t= 100ms with threshold value of 1
nfire *
1+
d)
,f we put the calculation for the nu#ber of shoots in other loop and #a%eI0 variable- we can obtain the
effect of the current vs nu#ber of shoots'
n_cur= 5; % number of current 'alue samples;I_last=10e-3; %en 'alue of t.e currentI_first= 2e-3; %start 'alue of t.e currentI_0 = I_first#I_last-I_first&$n_cur-1I_last; % 6urrent arra"n_fires=zeros1,n_cur&; %number of fires initialization for eac. current le'elt.eta = 1; % t.res.ol 'alue
% !e s!eep t.e loop for eac. current 'alue an e+tract t.e number of fires% kno!legeform=1#n_cur (p = zeros1,n&; (p1&=0; % initial conition for 'oltage
% In orer fork=2#n
(pk&=R*I_0m&*tTm*(pk-1&&$t Tm&; % numeric calculation
7/24/2019 cnc_hw2
5/6
if(pk& 4= t.eta (pk&=0; n_firesm&=n_firesm&1; % number of fires passing t.e t.res.ol en en
en
figure
plotI_0,n_fires&title6urrent 's umber of fires&+label6urrent I_0&"labelumber of fires&legen7ires&gri
Figure ! "urrent "hange vs. Num#er of Fire
e)
The onl! difference between part d is current sweep #ethod' ,nstead of linearl! sweeping- we rando#l!
pic%ed the current values for a given #ean and standard value' The result should be co#pletel! correlated'
,n Figure +!ou can clearl! see the result' While Gaussian distribution #a! select negative values- it is
possible to see that there is no firing below so#e current value'
% 8e take t.e results of t.e part to s.o! t.e correlation bet!een ranom% s!eep an linear s!eepfigureplotI_0,n_fires&
n_cur= 100; % number of current 'alue samples;I_mean=2e-3; %9ean 'alue of t.e currentI_st= :e-3; %tanar e'iation of t.e currentI_0 = I_mean I_st)*rannn_cur,1&; % 6urrent arra"n_fires=zeros1,n_cur&; %number of fires initialization for eac. current le'el
7/24/2019 cnc_hw2
6/6
t.eta = 1; % t.res.ol 'alue
% !e s!eep t.e loop for eac. current 'alue an e+tract t.e number of fires% kno!legeform=1#n_cur (p = zeros1,n&; (p1&=0; % initial conition for 'oltage
% In orer fork=2#n
(pk&=R*I_0m&*tTm*(pk-1&&$t Tm&; % numeric calculation if(pk& 4= t.eta (pk&=0; n_firesm&=n_firesm&1; % number of fires passing t.e t.res.ol en en
en
.ol onscatterI_0,n_fires, r& % scatter plot is more reasonable to s.o!title6urrent 's umber of fires&+label6urrent I_0&
"labelumber of fires&legen
Recommended