Solving coupled differential equations.

7 visualizzazioni (ultimi 30 giorni)
Jose Aroca
Jose Aroca il 15 Set 2021
Commentato: Bjorn Gustavsson il 15 Set 2021
I am tryng to solce the following coupled diferrential equations., , where and . I have developed a code to solve a single and simpler euqation of this form using the finite difference algorithm, but I am unsure how to extend this to solve these coupled equations. The code is as follows:
close all
Omega = 0.3;
dt = 0.1;
Ns = 1000;
ds = dt/Ns;
t = 0:dt:10;
N = numel(t);
c = zeros(1,N);
c(1) = 1;
v = 0;
for n = 1:N-1 % Outer loop; c is updated each iteration of this loop
% Inner loop: c is taken to be constant through this loop, the same
% approximation as is made in section 5.2.1 of the pdf.
for nn = 1:Ns
v = v - (1i*Omega*v + c(n))*ds; %insert f(t,s) here
end
c(n+1) = c(n) + v*dt;
end
plot(t,real(c),'.'),grid
xlabel('t'),ylabel('real(c)')

Risposte (1)

Bjorn Gustavsson
Bjorn Gustavsson il 15 Set 2021
The first trick to try with these coupled integro-differential equations is to try to "differentiate away the integrals":
which becomes:
which simplifies to:
This now have become a second order ode, to my brief look it seems as if the second ode also should be convertable in the same way. Then you just have to convert the 2 second-order odes to 4 first order odes, but that I assume is standard to you.
HTH
  2 Commenti
Jose Aroca
Jose Aroca il 15 Set 2021
First of all, thank you for your answer. I see what you mean, but I am not sure it will work with these equations. The functions g1(2) and f1(2) depend on both t and s, so you cannot differentiate the integrals with respect to t. That is why I was trying to use the finite difference algorithm.
Bjorn Gustavsson
Bjorn Gustavsson il 15 Set 2021
Ops, I missed that. But I still think you can use that trick, it will not simplify that nicely, but you will still get some kind of simplification if you split up the integral from 0 to t+dt into the sum of two integrals, from 0 to t and from t to t+dt, then you can combine the integrals from 0 to t and slog through a couple of more steps, swap order of differentiation and integration by parts?

Accedi per commentare.

Categorie

Scopri di più su Programming in Help Center e File Exchange

Prodotti


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by