how to solve this coupled ODE problem using ode solvers ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Sravan Kumar Putta
el 19 de En. de 2021
Editada: Sravan Kumar Putta
el 20 de En. de 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 comentarios
Respuesta aceptada
Bjorn Gustavsson
el 20 de En. de 2021
Editada: Bjorn Gustavsson
el 20 de En. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Ordinary Differential Equations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!