Skip to main content
SciNet
  • Home
  • All Courses
  • Calendar
  • Certificates
  • SciNet
    Main Site Documentation my.SciNet
  • CCDB
  • More
Close
Toggle search input
English
English Français
You are currently using guest access
Log in
SciNet
Home All Courses Calendar Certificates SciNet Collapse Expand
Main Site Documentation my.SciNet
CCDB
Expand all Collapse all
  1. Dashboard
  2. PHY1610 - Winter 2025
  3. Assignment 4: Numerics and Teach Cluster

Assignment 4: Numerics and Teach Cluster

Completion requirements
Opened: Saturday, 8 February 2025, 12:00 AM
Due: Saturday, 15 February 2025, 11:59 PM

Model and data collection

Consider a marble thrown into a transparent container filled with a viscous liquid.  Data is collected by taking snapshots of its trajectory at regular time intervals to record a set of samples $$z_i = z(i\Delta t)$$ of its vertical position. Δt is the time interval between the samples.

Under the assumption that the friction force is linearly dependent on the marble's velocity, the (vertical) velocity and position have the following form: 

$$v_t = (v_0 + \frac{g}{\alpha}) e^{-\alpha t} - \frac{g}{\alpha}$$

$$z_t = z_0 + \frac{1}{\alpha} (v_0+\frac{g}{\alpha})(1-e^{-\alpha t}) - \frac{g}{\alpha} t$$

where \(z_0\) is the initial vertical position, \(v_0\) is the initial velocity in the vertical direction, \(g\) is the gravitation accelleration, and \(\alpha\) is the friction rate.

The friction rate α is the propery we are after here. The time between samples, Δt, is known but all other parameters should also be considered to be unknown.  (Note: you do not have to take any horizontal motion into account.)

Analysis method

Because the velocity decays exponentially, so does the acceleration, so ratio of the accellerations of subsequent points is equal to \(\exp(-\alpha\Delta t)\).  To gain accuracy, we can average this ratio over all the points to arrive at the following estimate for \(\alpha\):  

$$\alpha = \frac{1}{\Delta t}\ln \left[\frac{1}{n-2}\sum_{i=1}^{n-2} \frac{v_{i+1}-v_{i}}{v_{i+2}-v_{i+1}} \right]$$

Because this equation contains the velocities, a first step is to numerically differentiate the position time series.

Code

To perform this data analysis, you are given a module called "friction" that contains two functions:

 double frictionrate(double dt, const rvector<double>& v);
 rvector<double> numdiff(double dt, const rvector<double>& z);

The first function, frictionrate, computes the friction rate based on velocity samples v taken a time dt apart.

The second function, numdiff, estimates the velocities using finite differences of the position samples. 

So given a set of samples in an rvector z, the friction rate can be estimated with "rate = frictionrate(dt,numdiff(dt,z));".

This code for this module is available as a git repo on the teach cluster.  Once logged in, you can clone this repo with

$ git clone ~lcl_uotphy1610s1001/assignment4.git

In addition to the friction module, this repo also contains code for an application to generate sample data. Type "make testmodel.dat" to generate this data (with the following parameters: α=0.125, v0=10, z0=0, g=9.8, Δt=0.25, and t ranging from 0 and 16) and run "make analysis" will perform the data analysis.

Your assignment

For the assignment you should

  • Work on the Teach cluster. You should have been emailed instructions about your account and how to set the password.
  • Clone the git reposity for this assigment to your home directory on Teach.
  • Make sure you can compile and run the code.
  • Your first real task is to create documentation for both the friction module and the "testmodel" code, by adding comments to all of the code in doxygen style.
  • Also add a README.md to be included in the doxygen output. 
  • Add a 'doc'  target to the Makefile that generates the documentation, and make sure it runs.
  • Your second task is to write a job script that runs the data analysis.  Set it up to run in its own subdirectory (i.e., not the code directory). 
  • Submit the job and add its output to the repo, together with the job script.
  • This analysis method isn't particularly robust and can get ``nan''s or ``inf''s as output fairly easily.  Can you think of a way to modify the frictionrate function to be more robust?  Don't implement this, but add it to the README.md, so it becomes part of the documentation.

Use a makefile and git throughout your assignment. We expect to see several meaningful git commits.  Make sure to commit all necessary files to run the analysis. Upload all code, scripts, and the analysis output (but not the data in testmodel.dat) and also include a file with the output of "git log --stat".

The deadline is Saturday Feb 15th, 2025, at midnight.  FYI, there will be no assignment next week since we're coming up to reading week.

Contact site support
You are currently using guest access (Log in)
Data retention summary


All content on this website is made available under the Creative Commons Attribution 4.0 International licence, with the exception of all videos which are released under the Creative Commons Attribution-NoDerivatives 4.0 International licence.
Powered by Moodle