You are on page 1of 37

PY3C01 Part a:

Computational methods

Lecturer:
Dr Thomas Archer
Office: Lloyd 221
Phone: 8455
E-mail: archert@tcd.ie

http://www.tcd.ie/Physics/people/Tom/Archer/teaching

If there are computer problems please E-mail chris.smith@tcd.ie


Lecture 1
● Why computational modelling

● Where computational physics is now

● Where computational physics is going

● Coding grammar

● Development tools

– (re)Introduction to Linux
– Version control
Why computational modelling?
Physics now
Solution to physical models
● Newtons laws of motion or relativity
– Classical motion of objects

● Quantum mechanics
– describes atoms, molecules, all of chemistry, solids ….

We can write the equations to describe virtually


anything (black holes are still a little tricky) but how do
we solve them?
Classical mechanics Examples
● Weather

– chaotic

● Astrophysics

● Galaxy formation

Solar weather
● chaotic
● Usually classical mechanics but probably requires QM or relativity

● Finite element design

– Aerodynamics

– Optimization problems
Atomistic modelling
● Described almost exactly by quantum theory
– Solids
– Describes all chemistry
– Physical properties
– Optical properties
– Magnetic properties
– Biological processes
– Electronic transport
● Computationally expensive
– Small systems
– Numerical approximations
– Reduce complexity – periodicity in solid sate physics
– ~10,000 atoms possible as of 2013
Atomistic modelling examples
● Bulk materials – use periodicity - solid state physics

Bulk Al

● Other systems without symmetry more computationally intensive


● Sale ~N3
● Beyond simulations
– Simulate physical phenomena.
– Validate theoretical understanding.
– Data processing, data science
– Automation and control.
Where things are going

Time Magazine
What does more power allow us to do

● Reduce approximations
● Run more detailed calculations
● Study larger systems
● Study larger numbers of systems – High-throughput computing/big data
Growth of big data
● Available data rapidly
growing
● Not just an internet full of
selfies
● Scientific databases are
becoming readily
available
● How do we make sense
of it.
– Identifying trends leads to
new science
Physics future
Transferable skills
Coding Grammar

How many languages do


you know?
Flow charts
● Commands executed sequentially
Universal Grammar

● Grammar if you can write a flow chart you can turn it into a code
● Universal grammar - Common to all languages
● Syntax can always be quickly looked up

How many languages do you know?

ALL OF THEM!
Linux
Linux
● GNU licence – free to download change and redistribute.
● Safe/secure – no viruses.
● Most new developments are built on top of Linux/UNIX.
● You have total control and scripting is built in.
Linux modular design
Linux distributions

A good start would be


http://www.ubuntu.com/

You can boot from CD or


flash drive to avoid any
changes to your existing
OS
All you need in this course
Where are my files?
File permissions

Permission User Group Size Date Modified File name


Commands
Many Linux commands, some useful ones are given here:
http://www.tcd.ie/Physics/people/Tom.Archer/teaching/computational_methods/lectures/cheat_sheet.pdf
Commands
Commands
Commands
Commands
Arguments
● Many commands require specification of one or more arguments: arg1 [arg2]
● Most commands can be “fine-tuned” using options: command [-o] [--long-option]
● Sometimes options can also have arguments
Editors
● nano [file] - simple terminal based text editor
● gedit [file] - simple GUI editor
● emacs [file] - complex text editor
● vi [file] - the classical unix text editor

Many other programs available


Wildcards
Wildcards allow to handle many files with similar names simultaneously
* matches any string
ls *.jpg (list all files ending with '.jpg')
? matches any single character
ls file?.dat (matches file1.dat, files.dat, but not file10.dat)
[abcde] exactly one of the listed characters
ls data[137] (matches data1, data7, but not data13 or data5)
[2-7] exactly one character in the given range
ls file[a-e] (matches filea, filee, but not filez or fileaa)
{xy,linux,unix} exactly any of the given strings
Combining commands
ls | wc -l
- counts number of files/directories
cat text.txt | grep Linux | wc -l
- counts number of lines in text.txt that contain the word “Linux”
cat word_list | sort | uniq > unique_word_list
- alphabetically sorts all lines (words) in word_list, removes duplicate lines, and
writes the resulting list into file unique_word_list
echo 3*3 | bc
- calculates 3*3=9 (echo=writes the given string to stdout)
Working at home
● Cygwin
● Live cd/usb stick
● Virtualbox
Exercise
● Get familiar with the command line:
1. Go to your home directory. How many files of different type are there?
2. Go one level up and list the contents of that directory
3. Go to the root directory (/). Inspect its contents
4. Go to the /bin directory and list its contents. Do you recognize some of the filenames?
5. Inspect the contents of the /usr/bin directorty without changing to that directory
1. Using absolute pathnames
2. 7. ii. Using relative pathnames
6. Go back to your home directory
7. Create a directory anynameyoulike and change into it
8. Create a text file yourfavoritename.txt using an editor of your choice. Write something and save it.
9. Inspect your newly created file with cat, more, and less
10. Copy the file to anothername.txt
11. Edit the new file and save it.
12. Go back to your home directory
13. Go into the directory anynameyoulike
14. Print the contents of yourfavoritename.txt and then redirect its content to another file ofyourchoice.txt
15. Inspect the content of ofyourchoice.txt
16. Create a process in the foreground using “sleep 1000”
17. Suspend the foreground process
18. Resume the suspended process in the foreground
19. Terminate the process
20. Kill the sleep process
21. Check whether the sleep process was really killed

You might also like