py3c01 part a: computational methods2.pdf · solution to physical models newtons laws of motion or...
TRANSCRIPT
PY3C01 Part a: Computational methods
Lecturer:Dr Thomas ArcherOffice: Lloyd 221Phone: 8455E-mail: [email protected]
http://www.tcd.ie/Physics/people/Tom/Archer/teaching
If there are computer problems please E-mail [email protected]
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
● Other systems without symmetry more computationally intensive
● Sale ~N3
Bulk Al
● 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 behttp://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 directory3. Go to the root directory (/). Inspect its contents4. 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 pathnames2. 7. ii. Using relative pathnames
6. Go back to your home directory7. Create a directory anynameyoulike and change into it8. 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 less10. Copy the file to anothername.txt11. Edit the new file and save it.12. Go back to your home directory13. Go into the directory anynameyoulike14. Print the contents of yourfavoritename.txt and then redirect its content to another file ofyourchoice.txt15. Inspect the content of ofyourchoice.txt16. Create a process in the foreground using “sleep 1000”17. Suspend the foreground process18. Resume the suspended process in the foreground19. Terminate the process20. Kill the sleep process21. Check whether the sleep process was really killed