how to solve this coupled ODE problem using ode solvers ?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Sravan Kumar Putta
il 19 Gen 2021
Modificato: Sravan Kumar Putta
il 20 Gen 2021
I have two ODEs within time interval [0 1] with initial conditions values for F_x and F_y are calculated from function
0 Commenti
Risposta accettata
Bjorn Gustavsson
il 20 Gen 2021
Modificato: Bjorn Gustavsson
il 20 Gen 2021
If you want to use the odeNN functions you need to rewrite your 2 2nd-order ODEs into 4 1st-order ODEs, something like this:
function dxdydvxdvydt = your_eqs_of_motion(t,xyvxvy,other,parameters)
x = xyvxvy(1); % If my ode-equations are complicated
y = xyvxvy(2); % I prefer to explicitly extract the
vx = xyvxvy(3); % variables into something that's
vy = xyvxvy(4); % easily human-readable
m = other;
Fx = force_functionx(t,x,y,vx,vy,other,parameters); % Adjust inputs as necessary
Fy = force_functiony(t,x,y,vx,vy,other,parameters);
% or possibly preferable:
% [Fx,Fy] = force_function_xny(t,x,y,vx,vy,other,parameters);
dxdydvxdvydt = [vx;vy;Fx/m;Fy/m];
end
Then you can integrate the equations of motion something like this:
m = 12; % you know what to set for this one
x0y0vx0vy0 = [1e-10,5.08e-5,0,0]; % Your initial conditions
t_span = [0,2*pi]; % a time-span of interest
[t_out,xyvxvy] = ode45(@(t,xyvxvy) your_eqs_of_motion(t,xyvxvy,m,[]),t_span,x0y0vx0vy0);
When integrating equations of motion you typically also have to carefully check that the constants of motion we know should be conserved (total energy, angular momentum, etc.) are reasonably conserved - the general ODE-integrating functions are not guaranteed to do this.
HTH
0 Commenti
Più risposte (0)
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!