Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Homework 3

Total points: 100.

Introduction to homework 3

This homework’s sets of classical pen and paper and computational exercises deal with the motion of different objects under the influence of various forces. The relevant reading background is

  1. chapter 2 of Taylor (there are many good examples there)

  2. chapters 5-7 of Malthe-Sørenssen.

In both textbooks there are many nice worked out examples. Malthe-Sørenssen’s text contains also several coding examples you may find useful.

There are several pedagogical aims we have in mind with these exercises:

  1. Get practice in setting up and analyzing a physical problem, finding the forces and the relevant equations to solve;

  2. Analyze the results and ask yourself whether they make sense or not;

  3. Find analytical solutions to problems when possible and compare them with numerical results. This also teaches us how to understand errors in numerical calculations;

  4. Being able to solve (in mechanics these are the most common types of equations) numerically ordinary differential equations and compare the solutions where possible with analytical solutions;

  5. Getting used to studying physical problems using all possible tools, from paper and pencil to numerical solutions;

  6. Analyze the results and ask yourself whether they make sense.

The above steps outline important elements of our understanding of the scientific method. Furthermore, there are also explicit coding skills we aim at such as setting up arrays, solving differential equations numerically and plotting your results. Coding practice is also an important aspect. The more we practice the better we get (hopefully). From a numerical mathematics point of view, we will solve the differential equations using Euler’s method (forward Euler).

The code we will develop can be reused as a basis for coming homeworks. We can also extend the numerical solver we write here to include other methods (later) like the modified Euler method (Euler-Cromer, midpoint Euler) and more advanced methods like the family of Runge-Kutta methods and the Velocity-Verlet method.

At the end of this course, we will thus have developed a larger code (or set of codes) which will allow us to study different numerical methods (integration and differential equations) as well as being able to study different physical systems. Combined with analytical skills, the hope is that this can allow us to explore interesting and realistic physics problems. By doing so, the hope is that can lead to deeper insights about the laws of motion which govern a system.

And hopefully you can reuse many of the above solvers in other courses (our ideal).

Practicalities about homeworks and projects

  1. You can work in groups (optimal groups are often 2-3 people) or by yourself. If you work as a group you can hand in one answer only if you wish. Remember to write your name(s)!

  2. Homeworks are available ten days before the deadline.

  3. Submission instructions: Submit the paper-and-pencil exercises as a single scanned PDF document. For this homework, this applies to exercises 1–5. Convert the Jupyter notebook to a PDF and attach it to the same PDF document.

Exercise 1 (20 pt), Electron moving into an electric field

An electron is sent through a varying electrical field. Initially, the electron is moving in the xx-direction with a velocity vx=100v_x = 100 m/s. The electron enters the field when it passes the origin. The field varies with time, causing an acceleration of the electron that varies in time

a⃗(t)=(−20m/s2−10m/s3t)e⃗y\vec{a}(t)=\left(-20\mathrm{m/s}^2-10\mathrm{m/s}^3t\right) \vec{e}_y

The field is only acting inside a box of length L=2mL = 2m.

Exercise 2 (10 pt), Drag force

We can observe that the models for linear and quadratic drag forces are given by:

flin=3πηDvfquad=κρAv2f_{lin} = 3\pi \eta D v \qquad f_{quad} = \kappa \rho A v^2

where DD is the “length scale” of the object (e.g., the diameter of the sphere), η\eta is the viscosity of the fluid, ρ\rho is the density of the fluid, AA is the cross-sectional area of the object, and κ\kappa is a constant of order unity (larger for flat and blunt bodies; smaller for streamlined bodies).

The two force laws scale differently with speed, as illustrated below for arbitrary parameter values.

<Figure size 600x450 with 1 Axes>

Exercise 3 (10 pt), Falling object

We have shown that an object that is dropped from rest and experiences linear drag force will reach a terminal velocity and do so exponentially:

vy(t)=vter(1−e−t/τ).v_y(t) = v_{ter}(1-e^{-t/\tau}).

Exercise 4 (10 pt), and now a theoretical exercise

Finding and exploring equations of motion is the central enterprise of classical mechanics. You will encounter (and derive) many equations you have not seen before, and you will need to explain them. Consider a hypothetical one-dimensional system where a mass mm has a speed of v0v_0 and coasts along the x-axis. The surrounding medium produces a drag force that is modeled using:

F(v)=−cv3/2.F(v) = -c v^{3/2}.

When the force is a pure function of velocity, using the technique called separation of variables on Newton’s 2nd Law, we can find the velocity as a function of time:

We can separate variables and write:

F(v)=ma=mdvdtF(v) = m a = m \dfrac{dv}{dt}

Divide both sides by F(v)F(v) and multiply both sides by dtdt:

dt=mF(v)dvdt = \dfrac{m}{F(v)}dv

And then, given starting (initial) conditions, we integrate both sides to find an expression for tt as a function of vv.

t=m∫v0vdv′F(v′)t = m \int_{v_0}^v \dfrac{dv'}{F(v')}

Exercise 5 (10 pt), back to a falling ball and preparing for the numerical exercise

Useful material: Malthe-Sørenssen chapter 7.5 and Taylor chapter 2.4.

In this example we study the motion of an object subject to a constant force and a velocity dependent force. We will reuse the code we develop here in homework 4 for a position-dependent force.

Here we limit ourselves to a ball that is thrown from a height hh above the ground with an initial velocity v⃗0\vec{v}_0 at time t=t0t=t_0. We assume the air resistance is proportional to the square velocity. Together with the gravitational force these are the forces acting on our system.

In order to find an analytical solution we need to assume that the object is falling only in the yy-direction, with downward chosen as positive for this one-dimensional subproblem.

The position of the ball as function of time is r⃗(t)\vec{r}(t) where tt is time. The position is measured with respect to a coordinate system with origin at the floor.

We assume we have an initial position r⃗(t0)=he⃗y\vec{r}(t_0)=h\vec{e}_y and an initial velocity v⃗0=vx,0e⃗x+vy,0e⃗y\vec{v}_0=v_{x,0}\vec{e}_x+v_{y,0}\vec{e}_y.

In this exercise we assume the system is influenced by the gravitational force

F⃗grav=−mge⃗y\vec{F}_{grav}=-mg\vec{e}_y

and an air resistance given by a square law

F⃗drag=−Dvv⃗.\vec{F}_{drag} = -Dv\vec{v}.

The analytical expressions for velocity and position as functions of time will be used to compare with the numerical results in exercise 6.

We will use the above analytical results in our numerical calculations in exercise 6. The analytical solution in the yy-direction only will serve as a test for our numerical solution. We don’t often know the solutions to our problems exactly, so we have to check them against things we do know.

Exercise 6 (40pt), Numerical elements, solving exercise 5 numerically

This exercise should be handed in as a jupyter-notebook through the course submission system. Remember to write your name(s).

Previously, we:

  1. Gained more practice with plotting in Python

  2. Became familiar with arrays and representing vectors with such objects

In this homework, we will:

  1. Learn and utilize Euler’s Method to find the position and the velocity

  2. Compare analytical and computational solutions

  3. Add additional forces to our model

We will choose the following values

  1. mass m=0.2m=0.2 kg

  2. acceleration (gravity) g=9.81g=9.81 m/s2^{2}.

  3. initial position is the height h=2h=2 m

  4. initial velocities vx,0=vy,0=10v_{x,0}=v_{y,0}=10 m/s

Can you find a reasonable value for the drag coefficient DD? You need also to define an initial time and the step size Δt\Delta t. We can define the step size Δt\Delta t as the difference between any two neighboring values in time (time steps) that we analyze within some range. It can be determined by dividing the interval we are analyzing, which in our case is time tfinal−t0t_{\mathrm{final}}-t_0, by the number of steps we are taking (N)(N). This gives us a step size Δt=tfinal−t0N\Delta t = \dfrac{t_{\mathrm{final}}-t_0}{N}.

With these preliminaries we are now ready to plot our results from exercise 5.

We move now to the numerical solution of the differential equations as discussed in the lecture notes or Malthe-Sørenssen chapter 7.5. Let us remind ourselves about Euler’s Method.

Suppose we know f(t)f(t) and its derivative f′(t)f'(t). To find f(t+Δt)f(t+\Delta t) at the next step, t+Δtt+\Delta t, we can consider the Taylor expansion:

f(t+Δt)=f(t)+(Δt)f′(t)1!+(Δt)2f′′(t)2!+...f(t+\Delta t) = f(t) + \dfrac{(\Delta t)f'(t)}{1!} + \dfrac{(\Delta t)^2f''(t)}{2!} + ...

If we ignore the f′′f'' term and higher derivatives, we obtain

f(t+Δt)≈f(t)+(Δt)f′(t)f(t+\Delta t) \approx f(t) + (\Delta t)f'(t).

This approximation is the basis of Euler’s method, and the Taylor expansion shows that the local truncation error is O(Δt2)O(\Delta t^2), while the global error over a fixed interval is generally O(Δt)O(\Delta t). Thus, one would expect it to work better, the smaller the step size hh that you use. In our case the step size is Δt\Delta t.

In setting up our code we need to

  1. Define and obtain all initial values, constants, and time to be analyzed with step sizes as done above (you can use the same values)

  2. Calculate the velocity using vi+1=vi+(Δt)∗aiv_{i+1} = v_{i} + (\Delta t)*a_{i}

  3. Calculate the position using posi+1=ri+(Δt)∗vipos_{i+1} = r_{i} + (\Delta t)*v_{i}

  4. Calculate the new acceleration ai+1a_{i+1}.

  5. Repeat steps 2-4 for all time steps within a loop.