Solving coupled second-order ODEs using ode45 (equations of motion)
Show older comments
Hello! I have browsed various threads on solving these types of problems and they've been very helpful. However, when I implemented the code, the answer makes no sense at all! I'm solving the equation
where
(Morse potential).
where Here is my code:
syms M x(t) z(t) Y alpha V_0 l h_0
V = V_0 * ((exp(-alpha * z) - 1)^2 - 1)
% z motion
eqz = diff(z, 2) == -diff(V, z)/M
% x motion
eqx = diff(x, 2) == 0
[VF, Subs] = odeToVectorField(eqz, eqx)
ftotal = matlabFunction(VF, 'Vars', {t, Y, V_0, alpha, M})
% Parameters
A = 1E-10; % Angstrom
eV = 1.6E-19; % electron volt
amu = 1.66E-27;
% Depth of well
V_0 = 88 * eV/1000;
% Softness
alpha = 2/A;
% Mass
M = 3 * amu;
ps = 1E-12;
theta_i = 45;
phi_i = 0;
E_i = 50 * eV/1000; % Incident energy (J)
E_z = E_i * (cos(theta_i))^2;
p_mag = sqrt(2 * M * E_i); % Magnitude of incident momentum
p_x_i = p_mag * sind(theta_i) * cosd(phi_i); % x-component of incident momentum
p_z_i = - p_mag * cosd(theta_i); % z-component of incident momentum
% initial conditions
ic = [20 * A; p_z_i/M; -10 * A; p_x_i/M];
tspan = [-2 * ps, 2 * ps];
[T,Y] = ode45(@(t,Y) ftotal(t, Y, V_0, alpha, M), tspan, ic)
% plot z against t
plot(T, Y(:, 1))
My problem is that the solution appears to just be a straight line, which doesn't make sense. Have I implemented ode45 in wrong?
Thanks for all the help!
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!