I have three coupled differential equation and need help to solve them
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Captain Rituraj Singh
il 24 Giu 2022
Commentato: Captain Rituraj Singh
il 8 Lug 2022
Initial condition: x(0) = 0.5, y(0)=0.9, z(0) = 7.5.
The problem is, I don't know how to call in Eq. 1. To solve these equations I am using ode45.
Kindly help me to solve this issue.
Thank you
1 Commento
Star Strider
il 24 Giu 2022
Because of the presence of t in the denominator, the system is not defined (appoaches ∞) at .
The system likely has no finite solution.
Risposta accettata
Sam Chak
il 25 Giu 2022
The equations are rearranged. However, to simulate at , where division-by-zero occurs, I'm unable to comply.
syms x(t) y(t) z(t)
eqn1 = diff(x) == - (x/(4*t) + ((x^3)*z)/t + diff(z)) - y/t;
eqn2 = diff(y) == - (x*y/4 + (5*y/x)*diff(x)) - (x^4)/t;
eqn3 = diff(z) == - ((pi^2)/15)*(x/t + ((z^2)/x)*diff(x) - y/x);
eqns = [eqn1 eqn2 eqn3];
[V, S] = odeToVectorField(eqns) % convert to state equations for ode45 solver
Looking at the denominators, if , and , then singularities will occur at some points along this parabola of :
% Y1 = z(t), Y2 = x(t), Y3 = y(t)
sigma1 = @(x, z) 5926499560405365*z.^2 - 9007199254740992*x;
fimplicit(sigma1, [0 40 -8 8], 'LineWidth', 1.5)
grid on
xlabel({'$x(t)$'}, 'Interpreter', 'latex')
ylabel({'$z(t)$'}, 'Interpreter', 'latex')
Since the system cannot be simulated exactly at , and , then the initial sec is selected
odefcn = matlabFunction(V, 'vars', {'t', 'Y'})
tspan = [1e-2 1.5]; % time span of simulation
y0 = [7.5 0.5 0.9]; % initial values: assumes z(1) = 7.5, x(1) = 0.5, y(1) = 0.9
opt = odeset('RelTol', 1e-4, 'AbsTol', 1e-6);
[t, Y] = ode45(@(t, Y) odefcn(t, Y), tspan, y0);
plot(t, Y, 'LineWidth', 1.25), grid on,
xlabel({'$t$'}, 'Interpreter', 'latex')
3 Commenti
Sam Chak
il 8 Lug 2022
I have made some corrections to a few lines. Consider voting 👍 my Answer above as a small token of appreciation.
syms x(t) y(t) z(t)
a = 5.2037;
b = 8.0260;
c = 0.04829;
d = 16.46;
inv = 0.1973;
tau0 = 0.1; % initial condition for t
tauf = 10.0;
x0 = 0.50; % initial condition for x
s0 = c + (d*x0^3);
y0 = s0/(3*pi*tau0); % initial condition for y
z0 = 0.3; % initial condition for z
%-------------------------------------------------------------
% Constant A, B and C
%-------------------------------------------------------------
q1 = 0.1973*3*(x^2)*z*cosh((0.1973*z)/(2*x));
q2 = (0.1973*0.1973*(z^2)*x*sinh((0.1973*z)/(2*x)))/2;
A = q1 - q2;
q3 = (x.^3)*cosh((0.1973*z)/(2*x));
q4 = (0.1973*(x)*z*sinh((0.1973*z)/(2*x)))/2;
B = q3 + q4;
C = (12*a*x.^(3)) + (3*A/(2*(pi^2)));
w1 = (0.1973*2*(x^2)*z*cosh((0.1973*z)/(2*x)))/((pi^2)*(t));
w2 = 4*a*(x.^4)/t;
w3 = (3*B/(2*pi*pi))*0.1973*(diff(z));
w4 = 0.1973*y/t;
eqn1 = diff(x) == -(w1 + w2 + w3 - w4)/C;
f1 = 2*a*x*y/(0.1973*3*b);
f2 = y/(2*t);
f3 = ((5*y)/(2*x))*diff(x);
f4 = 8*a*(x.^4.0)/(0.1973*9*t);
eqn2 = diff(y) == -f1 - f2 + f3 + f4;
r1 = -(pi^2)/(2*0.1973*B);
r2 = (4*x/(3*t))*((c + d*(x.^3)) + (2*0.1973*(x^2)*z*cosh((0.1973*z)/(2*x))/(pi^2)) - ((0.1973*y)./x));
r3 = (c + d*(x.^3) + 3*d*(x.^3) + (2*A/(pi^2)))*diff(x);
eqn3 = diff(z) == r1*(r2 + r3);
eqns = [eqn1 eqn2 eqn3]; % Correction in this line 1
[V, S] = odeToVectorField(eqns)
odefcn = matlabFunction(V, 'vars', {'t', 'Y'}) % Correction in this line #2
tspan = [tau0 tauf];
D = [z0 x0 y0]; % Correction in this line #3
[t, Y] = ode45(@(t, Y) odefcn(t, Y), tspan, D); % Correction in this line #4
plot(t, Y), grid on, xlabel('t') % Plot the result
Più risposte (3)
Sam Chak
il 8 Lug 2022
After this line
[t, Y] = ode45(@(t, Y) odefcn(t, Y), tspan, D);
the ode45 solver will generate the solutions in the Y array with respect ro the time vector t. To extract the solutions in the form that you are familiar with, you can do this:
z = Y(:, 1); % because the odeToVectorField arranges them this way
x = Y(:, 2);
y = Y(:, 3);
and these solution vectors should appear on the Workspace. You can plot them if you wish
subplot(3,1,1)
plot(t, x)
subplot(3,1,2)
plot(t, y)
subplot(3,1,3)
plot(t, z)
If you want to keep and store the data {t, x, y, z} in a mat-file, where you can load and access it later, then delete the rest in the Workspace and enter this command:
save Captain.mat
If you want to load the data, enter this:
load Captain.mat
If you like the support, consider voting 👍 this Answer above as a small token of appreciation.
Sulaymon Eshkabilov
il 24 Giu 2022
Your given exercise is a type of implicitly defined ODEs and thus, you should employ ode15i - see this doc.
0 Commenti
Torsten
il 24 Giu 2022
You have a linear system of equations in dx/dt, dy/dt and dz/dt.
Solve it for these variables. Then you can write your system explicitly as
dx/dt = f1(t,x,y,z)
dy/dt = f2(t,x,y,z)
dz/dt = f3(t,x,y,z)
and use ode45 to solve (maybe by starting at t=1e-6 instead of t=0).
0 Commenti
Vedere anche
Categorie
Scopri di più su Ordinary Differential Equations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!