How do I solve this 2nd order ODE with time-dependent parameters?
Mostrar comentarios más antiguos
2nd ODE to solve
dx/dt*(a + f(t))* d2x/dt2 + 0.5*b*(dx/dt)^2 + k(t)*(dx/dt)^2 - g(t) = 0
Boundary condition: dx/dt(0) = v0
where
- 't' is the time,
- 'x' is the position
- 'dx/dt' is the velocity
- 'd2x/dt2' is the acceleration
- 'a', 'b', 'v0' are constants
- 'f(t)', 'k(t)' and 'h(t)' are KNOWN functions dependent on 't'
(I do now write them because they are quite big)
Since I am new in Matlab, I would like to know how to code this with ode45. Thank you in advance
1 comentario
Subrata Chakrabarti
el 6 de Jun. de 2020
I saw the reply from Torsten which was very nice indeed. I only have a small clarification to ask. What if the force term f(t), which is also a time dependent variable, is obtained from a separate algebraic expression which is running on a for loop with a counter similar to the time step.
Respuesta aceptada
Más respuestas (1)
Torsten
el 3 de En. de 2017
Try
syms t y
%%--- Initial conditions ---
phi = 12.5e-3;
v0 = 300;
e = 3e-3;
ro = 1580;
E = 43e9;
e_r = 0.01466;
B = 0.28e-3;
%%--- Intermediate calculations ---
v_T = sqrt(((1 + e_r) * 620e6) /E) - sqrt(E/ro) * e_r;
R_T = v_T * t;
m_acc = pi * e * ro *(R_T^2);
v_L = sqrt (E/ro);
R_L = v_L * t;
z = 2 * R_L;
E_TF_dt = B * ((e_r^2)* B * (0.9^(z/B)-1)) /(log(0.9));
E_ED = E * e * pi * e_r^2 * (-phi* (phi - 2*v_T*t)) /16;
E_DL = pi * R_T^2 * 10e9;
E_MC = pi * R_T^2 * 1e6 * e;
%%Resolution of the problem
g_t = -diff(E_ED + E_DL + E_MC, t);
f(t,y)=(g_t - (0.5*pi*v_T*e*ro + E_TF_dt) * y^2) /(y* (8.33e-3 + m_acc));
fun=matlabFunction(f);
[T,Y]=ode45(fun,[0 1], v0);
Best wishes
Torsten.
2 comentarios
Torsten
el 4 de En. de 2017
This might work, but I'm not sure:
syms t y(2)
%%--- Initial conditions ---
phi = 12.5e-3;
v0 = 300;
x0 = ...;
e = 3e-3;
ro = 1580;
E = 43e9;
e_r = 0.01466;
B = 0.28e-3;
%%--- Intermediate calculations ---
v_T = sqrt(((1 + e_r) * 620e6) /E) - sqrt(E/ro) * e_r;
R_T = v_T * t;
m_acc = pi * e * ro *(R_T^2);
v_L = sqrt (E/ro);
R_L = v_L * t;
z = 2 * R_L;
E_TF_dt = B * ((e_r^2)* B * (0.9^(z/B)-1)) /(log(0.9));
E_ED = E * e * pi * e_r^2 * (-phi* (phi - 2*v_T*t)) /16;
E_DL = pi * R_T^2 * 10e9;
E_MC = pi * R_T^2 * 1e6 * e;
%%Resolution of the problem
g_t = -diff(E_ED + E_DL + E_MC, t);
f(t,y)=[y(2) ; g_t - (0.5*pi*v_T*e*ro + E_TF_dt) * y(2)^2) /(y(2)* (8.33e-3 + m_acc))];
fun = matlabFunction(f);
[T,Y]=ode45(fun,[0 1], [x0 ; v0]);
Best wishes
Torsten.
Categorías
Más información sobre Numeric Solvers en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!