Most disciplines within physics require computational methods in some way. It is our intention to train students to apply computational methods to physics problems using Fortran or C code. We will provide a three-way balance between understanding the theory behind the methods, actually implementing the method to a specific problem (programming from scratch, using existing libraries), and becoming accustomed to doing so within a Unix-like environment (which might entail, for example, using scripts to manage data sets and program execution).

We will select a few methods that may include, but are not limited to, the following: numerical differentiation and integration; linear algebra, including solving systems of equations and finding the eigenvalues of a matrix (vibrational normal modes of a set of oscillators); ordinary differential equations (charged particles in an electromagnetic); partial differential equations (shallow water wave dynamics); Monte Carlo and molecular dynamics simulations (properties of condensed matter systems).

Classes Tuesdays and Thursdays 9am to 10:15am C3067

Lab: Fridays 2pm to 3:50pm (+ extra time after), C3057

Help Session (Office Hours): TBD

- L1 - Jan. 4, 2024
- General introduction
- Course Outline
- Computer Basics
- convert decimal fraction to binary
- gap notes
- notes from class
- Online textbook

- L2 - Jan. 9, 2024 -- Q1 from Assignment 1 is due
- Machine epsilon and error from substraction. Numerical derivatives.
- The IEEE 754 standard for floating point arithmetic
- machineEpsilon.c
- machineEpsilon-Single.c
- subtract.c
- machineEpsilon.f90
- gap notes
- notes from class

- L3 - Jan. 11, 2024
- cont. Num. Derivatives. Derivatives for non-uniform spacing, Richardson extrapolation, start Numerical integration (Trapezoid rule)
- gap notes
- notes from class

- L4 - Jan. 16, 2024
- Trapezoid and Simposon's rule
- gap notes
- notes from class

- L5 - Jan. 18, 2024
- Gaussian integration
- handout from Klein and Godunov here
- L05-GaussLegendre.ipynb
- L05-GaussLegendre.pdf
- gap notes
- notes from class

- Jan. 23, 2024
- Time given to work on Project 1 in C3057

- L6 - Jan. 25, 2024
- L7 - Jan. 30, 2024
- Runge-Kutta, Adaptive time step Euler, Adaptive RK4
- NR handout
- gap notes
- notes from class

- L8 - Feb. 1, 2024
- Fehlberg Method and going over Project 2
- gap notes
- notes from class

- L9 - Feb 6, 2024
- Stability, start Random Numbers
- gap notes
- notes from class

- L10 - Feb 8, 2024
- Random numbers cont'd, Start MC integration
- gap notes
- notes from class
- random_LCG.cpp
- illustration of correlation in LCG sequence
- Using gcc's built-in rand function use_rand.c
- Using NR's RNG RandomNR.cpp
- Using another NR RNG use_ranNR.c
- NR for F90 useNRrandomF90.f90
- Bitwise exclusive or xor.cpp
- Makefile
- filebundle.tgz

- L11 - Feb 13, 2024
- continue Monte Carlo integration, Metropolis Algorithm
- notes from class
- gap notes

- L12 - Feb 27, 2023. (return from break)
- Ising Model
- web demo of Ising model
- notes from class
- gap notes

- L13 Feb 29, 2024
- Discussion of Project 3: Ising model
- Project 3 description with added musings

- L14 March 5, 2024
- Matrices
- notes from class
- gap notes
- Example matrix add in Fortran InnerLoopROW.f90 InnerLoopCOL.f90 BuiltInAdd.f90 save.sh
- http://www.netlib.org/
- GSL: GNU Scientific Library
- MKL: Math Kernel Library
- Solving systems of linear equations
- sample LAPACK routine SGESV
- Sample solution using SGESV
testSGESV.f90
NotesSGESV.txt
Makefile for alfven
- Some files for C lapacke_mangling.h lapacke.h test-ROW.c test-COL.c

- File bundle

- L15 March 7, 2024 and March 12, 2024
- 1D Poisson Eqn, Eigenvalues
- notes from class
- gap notes
- scan of old notes with Jacobi Method
- Eigenvalues.nb.pdf -- Jacobi Method example

- L16 March 14, 2024
- PDEs, Time-Dependent Schrodinger Equation
- notes from class
- gap notes

- L17 March 2024 -- recorded lecture for independent study (from 2022)
- Discretization of Hyperbolic and Parabolic equations
- link to video Password: nYpVKV6W
- notes from class
- fill-in-the-blank notes for class
- Numerical Methods for Partial Differential Equations, by William F. Ames
- WaveEquationSepVar.nb.pdf

- L18 March 2024 -- recorded lecture for independent study (from 2022)
- Stability analysis, Elliptic equations
- link to video Password: nYpVKV6W
- notes from class
- fill-in-the-blank notes for class

## Labs/Tutorials and useful info

- Remember, you can download files from the web with., e.g.,

wget "http://www.physics.mun.ca/courses/p3800/PROJECTS/P1/Project1.tgz" - Setting up at home
- Lab 1 - Introduction to the command line - January 5 -- Snow day -- rescheduled to January 12.
- Lab exercises - we will go over these
- Time is devoted to help on the lab exercises.
- T01notes.txt sparse recollection of things covered in lab exercises
- For further study, you can check out this online tutorial on working with the shell.

- Lab 2 - xmgrace, make, LaTex, shell scripts - January 19.
- The quiz on D2L has the material built-in to the questions. Go to the quiz on D2L
- Text of material
- For further study, you can continue with this online tutorial on writing shell scripts.

- January 26, time on Project 1
- Lab 3 (Informal) - More linux stuff and time given to work on Project 1 - Feb. 2.
- T04notes.txt discussed a bit of Linux stuff
- Learn regular expressions at regexone.com

- Lab 4 - Makefiles, header files, modules - Feb. 9
- The quiz on D2L has the material built-in to the questions. Go to the quiz on D2L
- Text of material

- Feb. 16, time on projects and assignments
- March 1, Working on Assignment 3, projects
- Lab 5 - Libraries and LAPACK - March 8 - no quiz, just follow along -- NOPE, snow day!
Try again March 15 with focus on getting through A4.
- http://www.netlib.org/lapack/
- P3800_LAB_Libraries_LAPACK.pdf Writeup and tar package written by Kyle Hall, March 2018
- librarylab.tar

- Some programming links

## Projects

Your projects need to run properly on*alfven*, even if you've got them working on your own machine. If you've been working on your machine, you need to get the files on to*alfven*. For now, let's assume your files are on*alfven*. To submit a project, make sure everything needed for the project (Makefile, script to run the project, source code, latex file, pdf of writeup) is located in a single directory, called, e.g., Project1sol. This directory can have subdirectories if that's the way you structured it. Then, while in the parent directory of Project1sol, make an archive of the directory and copy it to the Submissions directory, via:tar -zcf project1sol-YOUR-NAME.tgz Project1sol cp project1sol-YOUR-NAME.tgz /home/Submissions

Now, if you've been working on your own machine, you need to copy your files over to*alfven*. To copy a file or directory from your machine to your home directory on*alfven*, execute (don't miss the colon at the end!)scp dirname username@alfven.physics.mun.ca:

To log on to alfven:ssh -X username@alfven.physics.mun.ca

(the -X is for forwarding X windows graphics)No. Due 1 Friday, Feb. 2, 2024 Summary Project Project Grading Scheme Website for Gaussian integration 2 Friday, Feb. 16. 2024 Summary Project Computational Physics notes by Professor A. MacKinnon, Imperial College London* 3 TBA Project description M vs T in thermodynamic limit Suscept. vs T near Tc in thermodynamic limit ChatGPT code Sample 10x10 Ising configuration gnuplot file for viewing the sample config 4 Presentations Friday April 5 Project description presentation marking guide (plain text)

*I gratefully acknowledge the author of "Computational Physics -- 3rd/4th Year Option", Emeritus Professor Angus MacKinnon of Imperial College London, for kindly permitting me to use and post his notes. -ISVGetting NR routines in C working for Project 2

If you are really only interested in the Fortran version, I still recommend watching the first five minutes or so of the C video before going on to the one for Fortran. Password for both is 3CpCZYZCU94.

Getting NR routines in Fortran 90 working for Project 2

## Assignments

No. Due 1 due January 23, 9am Assignment 1 2 due Thursday Feb 8 Assignment 2 3 TBD Assignment 3 starter code A3Q1.f90 Jupyter notebook A3.ipynb 4 In-class assignment Assignment 4 Q1: poisson-student.f90 Q2: sqwell-student.f90 Q3: sqwell-time-student.f90 movie.gnu notes.txt Q1 video Q2 video Q3 video (from 2022, where animation was done differently. Code now generates a single file processed by movie.gnu) Password: nYpVKV6W