how to solve this coupled ODE problem using ode solvers ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sravan Kumar Putta
le 19 Jan 2021
Modifié(e) : Sravan Kumar Putta
le 20 Jan 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 commentaires
Réponse acceptée
Bjorn Gustavsson
le 20 Jan 2021
Modifié(e) : Bjorn Gustavsson
le 20 Jan 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!