In [1]:
using Plots
pyplot(size=(700,300),leg=false,
guidefont=font(9), titlefont=font(9));
R=40;L=1/pi*360E-2;C=1/(pi*360E+2);w=1/(sqrt(L*C))
fr=linspace(20,80,100)
ω=linspace(20,80,100)
y= abs(1 ./ (1+im*2π*ω*R*C-(2π*ω).^2*L*C))
#yi=abs(1 ./ (1+im*2π*ω*R*C-(2π*ω).^2*L*C))
m=plot(fr,y,title="Fréquence de résonance",
fill=(0,0.2,:red),bg=RGB(.2,.2,.2),
xlabel ="50Hz",ylabel = "Ω");
#m=plot!(fr,yi)
################################
q=linspace(0,2w)
p=abs(1./(1+im.*q.*R.*C-q.*q.*L.*C));
n=plot(q,p,title="Pulsation de résonance",
fill=(0,0.2,:yellow),
bg=RGB(.2,.2,.2),
xlabel = "314 Rad/s",
ylabel = "Ω")
################################
plot(m,n,layout=2)


INFO: Recompiling stale cache file /home/pi/.julia/lib/v0.4/Plots.ji for module Plots.
[Plots.jl] Initializing backend: pyplot
Out[1]:

In [2]:
#r=40;l=1/pi*360E-2;l=1/(pi*360E+2);
#w=1/(sqrt(l*c));

In [3]:
using ODE,Plots
pyplot(size=(300,200),leg=false,
guidefont=font(7), titlefont=font(7));
function oscillator(t, y)
    y[2] = - 3* + y[1] - y[2] / 10
end
oscillator(t, y) = [y[2], - 3* + y[1] - y[2] / 10]


Out[3]:
oscillator (generic function with 1 method)

In [4]:
initial = [1.0,0.0];                   # Initial conditions
t = float([0:0.01:50]);   
t,y = ode45(oscillator, initial, t)
# Time steps for solution
#xv = Sundials.cvode(oscillator, initial, t);
#xv[1:5,:]
y=hcat(y...);
plot(t,y,title="Mouvement",
bg=RGB(.2,.2,.2),
xlabel ="Temps",ylabel = "Vitesse")


WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at ./deprecated.jl:73
while loading In[4], in expression starting on line 2
Out[4]:

In [5]:
#listet=initial
vₓ=xv[:,1]
vᵥ=xv[:,2]
plot(vₓ,vᵥ,title="Mouvement",
bg=RGB(.2,.2,.2),
xlabel ="Temps",ylabel = "Vitesse")


LoadError: UndefVarError: xv not defined
while loading In[5], in expression starting on line 3

In [6]:
function pendulum(t, y)
    Y = [
    6 * (2 * y[3] - 3 * cos(y[1] - y[2]) * y[4]) / (16 - 9 * cos(y[1] - y[2])^2);
    6 * (8 * y[4] - 3 * cos(y[1] - y[2]) * y[3]) / (16 - 9 * cos(y[1] - y[2])^2)
    ]
    [
    Y[1];
    Y[2];
    - (Y[1] * Y[2] * sin(y[1] - y[2]) + 3 * sin(y[1])) / 2;
    - (sin(y[2]) - Y[1] * Y[2] * sin(y[1] - y[2])) / 2;
    ]
end
initial = [3/4 * pi, pi, 0, 0];         # Initial conditions -> chaotic behaviour
# initial = [pi / 4, 0, 0, 0];          # Initial conditions -> deterministic behaviour

T, xv = ode23(pendulum, initial, [0.; 40]);
xv = hcat(xv...).';

In [7]:
vₓ=xv[:,1]
vᵥ=xv[:,2]
plot(vₓ,vᵥ,title="Espace de phase 2 pendules",bg=RGB(.2,.2,.2),
xlabel ="P1",ylabel = "P2")


Out[7]:

In [8]:
using Plots
x = linspace(0.0,5*pi,100); y = sin(x);
plot(x, y,title="sinus",
bg=RGB(.2,.2,.2),
xlabel ="Temps",ylabel = "Vitesse")


Out[8]:

In [9]:
using Sundials,ODE,Plots
pyplot(size=(700,300),leg=false,
guidefont=font(9), titlefont=font(9));
function oscillator(t, y, ydot)
    ydot[1] = y[2]
    ydot[2] = - 3* + y[1] - y[2] / 10
end
initial = [1.0,0.0];                   # Initial conditions
t = float([0:0.01:50]);                # Time steps for solution
xv = Sundials.cvode(oscillator, initial, t);
xv[1:5,:]
pq=plot(t,xv[:,1],title="Oscillateur",
bg=RGB(.2,.2,.2),
xlabel ="Temps",ylabel = "Vitesse")
#---phase----
vₓ=xv[:,1]
vᵥ=xv[:,2]
qp=plot(vₓ,vᵥ,title="portrait de phase",
bg=RGB(.2,.2,.2),
xlabel ="Temps",ylabel = "Vitesse")
#------subplot----
plot(pq,qp,layout=2)


WARNING: [a] concatenation is deprecated; use collect(a) instead
 in depwarn at ./deprecated.jl:73
while loading In[9], in expression starting on line 9
Out[9]:

xv = Sundials.cvode(oscillator, initial, t); xv[1:5,:] pq=plot(t,xv[:,1],title="Oscillateur", bg=RGB(.2,.2,.2), xlabel ="Temps",ylabel = "Vitesse")

---phase----

vₓ=xv[:,1] vᵥ=xv[:,2] qp=plot(vₓ,vᵥ,title="portrait de phase", bg=RGB(.2,.2,.2), xlabel ="Temps",ylabel = "Vitesse")

------subplot----

plot(pq,qp,layout=2)