This quiz is designed to take approximately 20 minutes to complete (you will be given 60 Minutes).
Please read the following instructions before starting the quiz.
This is an open Internet quiz. Feel free to use anything on the Internet with one important exception...
- DO NOT communicate live with other people during the quiz (either verbally or on-line). The goal here is to find answers to problems as you would in the real world.
You will be given 60 minutes to complete this quiz. Use your time wisely.
HINTS:
- Neatness and grammar is important. We will ignore all notes or code we can not read or understand.
- Read the entire quiz from beginning to end before starting. Not all questions are equal in points vs. time so plan your time accordingly.
- Some of the information provided my be a distraction. Do not assume you need to understand everything written to answer the questions.
- Spaces for answers are provided. Delete the prompting text such as "Put your answer to the above question here" and replace it with your answer. Do not leave the prompting text with your answer.
- Do not assume that the answer must be in the same format of the cell provided. Feel free to change the cell formatting (e.g., markdown to code, and vice versa) or add additional cells as needed to provide your answer.
- When a question asks for an answer "in your own words" it is still okay to search the Internet for the answer as a reminder. However, we would like you to do more than cut and paste. Make the answer your own.
- If you get stuck, try not to leave an answer blank. It is better to include some notes or stub functions so we have an idea about your thinking process so we can give you partial credit.
- Always provid links to any references you find helpful.
- Feel free to delete the provided check marks (✅) as a way to keep track of which questions you have successfully completed.
Honor Code
I, agree to neither give nor receive any help on this quiz from other people. I also understand that providing answers to questions on this quiz to other students is also an academic misconduct violation as is live communication or receiving answers to questions on this quiz from other people. It is important to me to be a person of integrity and that means that ALL ANSWERS on this quiz are my answers.
✅ DO THIS: Include your name in the line below to acknowledge the above statement:
Put your name here.
A simple hydrodynamical model for traffic flow is the so called Lighthill-Whitham-Richards (LWR) model. This model describes the density of cars, $\rho = \rho(x,t)$ as a function of space and time. The conservation law describing this is
$$ \frac{\partial \rho}{\partial t} + \frac{\partial f(\rho)}{\partial x} = 0, $$where $f(\rho) = \rho v(\rho)$ and $v(\rho) = (1-\rho)$ is the velocity of the cars.
From one of the development nodes, clone the repository traffic
This repository contains a program that uses a pseudospectral method to simulate the above equation on $x \in [0,10]$ with initial data $\rho = 1$ if $ 3 \le x \le 5$ and $\rho = 1/2$ otherwise.
References: [1.] M. J. Lighthill and G. B. Whitham. On kinematic waves. II. A theory of traffic flow on long crowded roads. Proc. Roy. Soc. London Ser. A, 229:317–346, 1955.
[2.] P. I. Richards. Shock waves on the highway. Operations Research, 4:42–51, 1956.
The repository contains a file traffic.f90
and your first task is to compile and run this program.
module purge
. The code ca be compiled into an executable named a.out
by the command
gfortran traffic.f90 -I${EBROOTFFTW}/include -L${EBROOTFFTW}/lib -lfftw3
But this will not work right away as the complier does not know where to find the file fftw3.f
. This file is part of the include files that come with the library fftw3
(The fastest Fourier transform in the west, www.fftw.org).
✅ Question 1: (2 points) What are the module commands you use to get access to fftw3?
Put your answer here
✅ Question 2: (1 point) How can you use module
to find out what EBROOTFFTW
is?
Put your answer here
✅ Question 3: (1 point) In bash
how would you find out what EBROOTFFTW
is?
Put your answer here
✅ Question 4: (2 points) Write a bash script that purges all modules and then loads fftw, compiles and runs the traffic program. The script should also make a data.tgz
file that uses tar with the -zcf
flag to compress all data*.txt
files into a the data.tgz
file. Finally the script should remove all files ending with .txt
.
Make sure you test the script.
Put your answer to the above question here
The data files data000000.txt
, data000020.txt
,..., data002540.txt
are plain text files where the first column contanins the $x$ coordinates and the second column $\rho$ at these $x$ values. The number in the filename is related to the time (from 0 to 5).
Note that if you were not able to complie and run the file the data files are also in the repository.
✅ Question 5: (3 points) Make a movie or gif of how $\rho$ changes in time.
Put the name of the movie file here (upload it to D2L).
Use your favourite editor to change the value of nmod
(around line 112 in traffic.f90) to 20000 (this prevents writing the soluiton to file) and recompile as described above.
Use the command time ./a.out
and report the average user time
for 10 tries.
Now use the intel compiler to do the same timing:
module purge
module load intel
ifort -mkl traffic.f90
time ./a.out
Again report the average user time
for 10 tries.
✅ Question 7: (1 point) What are the user times for the gfortran and ifort compilers?
put your answer to the above question here.
You are done with your quiz. Please save the file and upload the jupyter notebook to the D2L dropbox. Also upload the movie.
Written by Daniel Appelö, Michigan State University
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.