py3c01 part a: computational methods · solution to physical models newtons laws of motion or...
TRANSCRIPT
![Page 1: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/1.jpg)
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]
![Page 2: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/2.jpg)
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
![Page 3: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/3.jpg)
Why computational modelling?
![Page 4: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/4.jpg)
Physics now
![Page 5: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/5.jpg)
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?
![Page 6: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/6.jpg)
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
![Page 7: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/7.jpg)
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
![Page 8: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/8.jpg)
Atomistic modelling examples
● Bulk materials – use periodicity - solid state physics
● Other systems without symmetry more computationally intensive
● Sale ~N3
Bulk Al
![Page 9: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/9.jpg)
● Beyond simulations– Simulate physical phenomena.
– Validate theoretical understanding.
– Data processing, data science
– Automation and control.
![Page 10: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/10.jpg)
Where things are going
Time Magazine
![Page 11: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/11.jpg)
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
![Page 12: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/12.jpg)
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
![Page 13: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/13.jpg)
Physics future
![Page 14: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/14.jpg)
Transferable skills
![Page 15: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/15.jpg)
Coding Grammar
How many languages do you know?
![Page 16: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/16.jpg)
Flow charts
● Commands executed sequentially
![Page 17: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/17.jpg)
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!
![Page 18: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/18.jpg)
Linux
![Page 19: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/19.jpg)
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.
![Page 20: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/20.jpg)
Linux modular design
![Page 21: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/21.jpg)
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
![Page 22: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/22.jpg)
All you need in this course
![Page 23: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/23.jpg)
Where are my files?
![Page 24: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/24.jpg)
File permissions
Permission User Group Size Date Modified File name
![Page 25: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/25.jpg)
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
![Page 26: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/26.jpg)
Commands
![Page 27: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/27.jpg)
Commands
![Page 28: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/28.jpg)
Commands
![Page 29: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/29.jpg)
Commands
![Page 30: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/30.jpg)
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
![Page 31: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/31.jpg)
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
![Page 32: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/32.jpg)
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
![Page 33: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/33.jpg)
![Page 34: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/34.jpg)
![Page 35: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/35.jpg)
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)
![Page 36: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/36.jpg)
Working at home
● Cygwin● Live cd/usb stick● Virtualbox
![Page 37: PY3C01 Part a: Computational methods · Solution to physical models Newtons laws of motion or relativity – Classical motion of objects Quantum mechanics – describes atoms, molecules,](https://reader035.vdocuments.site/reader035/viewer/2022081522/5fbb80764bb3203b601743ae/html5/thumbnails/37.jpg)
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