Physics problem help!

1 view (last 30 days)
Joe Worster
Joe Worster on 11 Apr 2018
Commented: Joe Worster on 12 Apr 2018
We were given a problem in my physics class that we are supposed to code, despite not being given much on how to use matlab. I've been at this for hours and I can't seem to figure it out and any type of help will be appreciated.
Problem 3: Oscillation of a Sodium atom in a Sodium-Chloride crystal
Problem: The Sodium-Chloride crystal is an example of a ionic crystal. It consists of alternating positively and negatively charged ions, the Sodium and Chloride atoms respectively. A Sodium atom moves subject to forces from the surrounding ions - and an analysis of the system shows that for small perturbations from the equilibrium configuration, a Sodium ion will experience an acceleration of a = −kx , where k = 0.17×1027s^−2 , where x is the position of the ion measured in meters. Assume that the ion starts at position x0 = 0 time t = 0 with a velocity v0 = 364m/s. (a) Find the time development of x(t). (b) Find the maximum value of x. (c) Find the oscillation time, that is the time it takes until the ion is in the same state as it started in.
  2 Comments
James Tursa
James Tursa on 11 Apr 2018
Supposed to code it how? Using your own written ordinary differential equation code, such as Euler method? Using a built-in integrator such as ode45? Symbolically in MATLAB? Solving by hand?
E.g., see this page for the close form solution:
Joe Worster
Joe Worster on 11 Apr 2018
Yes, such as the Euler method I believe

Sign in to comment.

Answers (1)

James Tursa
James Tursa on 11 Apr 2018
Edited: James Tursa on 11 Apr 2018
So, I will give you a start for an Euler scheme. You have two states to keep track of, the position and the velocity. Define two variables for this:
x is the position
v is the velocity
You are given two initial conditions for these states:
x0 = 0 m
v0 = 364 m/s
And a force constant
k = 0.17×10^27 s^2 <-- I assume this is 10^27 ???
For an arbitrary variable Y, the Euler method of propagating is
Y(t+dt) = Y(t) + (dY/dt) * dt;
So putting the pieces together here is an outline of your code:
% Initial conditions
x0 = 0; % m
v0 = 364; % m/s
k = 0.17e27; % s^−2
n = 1000; % Number of steps to integrate (you will have to experiment with this value)
dt = ________; % You will have to experiment with this value also
% Allocate states
x = zeros(1,n);
v = zeros(1,n);
t = zeros(1,n);
% Initialize first state
x(1) = x0;
v(1) = v0;
t(1) = 0;
% Loop for the integration
for i=1:n-1
x(i+1) = x(i) + ___________;
v(i+1) = v(i) + ___________;
t(i+1) = t(i) + ___________;
end
You need to figure out what goes in the blanks above. The x equation will be based on the derivative of x, which is velocity. The v equation will be based on the derivative of v, which is acceleration. The t equation is just to increment t by dt.
  9 Comments
James Tursa
James Tursa on 12 Apr 2018
@Jim Riggs: Yes, I noticed that. I first advised him to increase his total integration time hoping he would look at that himself, and the latest is I have actually given him appropriate integration times and step sizes to use. So, hopefully he can get everything fixed up now.
Joe Worster
Joe Worster on 12 Apr 2018
Thanks so much for the help!

Sign in to comment.

Categories

Find more on Programming 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!