Computation for Physics

advertisement
Computation for
Physics
計算物理概論
什麼是計算及計算器
基本資料
• 教師:陳柏中 Pochung Chen
• 物理館 R521,理論中心 R510
• pcchen@phys.nthu.edu.tw
• http://qubit.phys.nthu.edu.tw/~pcchen (選 Teaching)
• 助教:張博勝
• phybd44@gmail.com
• 上課時間:R5R6R7 (1:20pm-16:40pm)
• 上課地點:物理館019 or 計中 2F 電一教室
評量方法
• 作業成績
• 期末報告或計畫
• 課堂表現
課程目標
• 了解電腦基本架構
• 學習使用程式語言 (Python)
• 學習使用應用軟體 (Sage Math)
• 學習使用電腦解決物理問題
課程大綱
• Introduction to computers
• Introduction to UNIX-like environment
• Introduction to programming languages
• Introduction to software
• Introduction to algorithms
• Introduction to computational physics
• Information society 資訊社
Weekly Schedule
• Week 1: 2/21 Lecture
• Week 9: 4/18 Lab-4+Lecture
• Week 2: 2/28 (No class)
• Week 10: 4/25 Lab-5+Lecture
• Week 3: 3/7 Lecture
• Week 11: 5/2 Lab-6+Lecture
• Week 4: 3/14 Lab-1
• Week 12: 5/9 Lab-7+Lecture
• Week 5: 3/21 Guest lecture:
• Week 13: 5/16 Lab-8+Lecture
• 李士傑「資訊與社會:什麼
• Week 14: 5/23 Lab-9+Lecture
是自由?」
• Week 6: 3:28 Lab-2+Lecture
• Week 15: 5/30 Lab-10+Lecture
• Week 7: 4/4 (No class)
• Week 16: 6/6 Lab-11+Lecture
• Week 8: 4/11 Lab-3+Lecture
• Week 17: 6/13 Lab-12+Lecture
• Week 18: 6/20 (Final week)
Experiment, Theory,
Simulation
Simulation
Experiment
Theory
What is Computation?
From Wikipedia
• Computation is any type of calculation or use of computing
technology in information processing.
• Computation is a process following a well-defined model understood
and expressed as, for example, an algorithm, or a protocol.
• Computational physics is the study and implementation of
numerical algorithms to solve problems in physics for which a
quantitative theory already exists. It is often regarded as a subdiscipline of theoretical physics but some consider it an intermediate
branch between theoretical and experimental physics.
• The study of the physics of computation relates to understanding the
fundamental physical limits of computers. This field has led to the
investigation of how thermodynamics limits information processing,
the understanding of chaos and dynamical systems, and a rapidly
growing effort to invent new quantum computers.
Introduction to
Computer
• A computer is a general
purpose device that can be
programmed to carry out a
finite set of arithmetic or
logical operations. Since a
sequence of operations can
be readily changed, the
computer can solve more
than one kind of problem
• The Zuse Z3, 1941,
considered the world's first
working programmable, fully
automatic computing
machine.
Computing Hardware
• Computing hardware evolved from machines that needed
separate manual action to perform each arithmetic
operation, to punched card machines, and then to storedprogram computers. The history of stored-program
computers relates first to computer architecture, that is, the
organization of the units to perform input and output, to
store data and to operate as an integrated mechanism.
算盤 Abacus
• As an aid to calculation
• No automation
Pascaline
• 1642-1645: Prototype period.
• First mechanical calculator that can perform
automatically the basic operations of arithmetic
http://www.youtube.com/watch?v=3h71HAJWnVU
Blaise Pascal 6/19/1623–8/19/1662
Arithmomètre
• Patented in France by Thomas de Colmar in 1820 and
manufactured from 1851 to 1915. It become the first
commercially successful mechanical calculator.
• Operations:
•
•
•
•
•
•
Sliding the Top Carriage
Addition
Multiplication
Subtraction
Integer division
Decimal division
• http://www.arithmometre.org/
http://www.youtube.com/watch?v=s2T_158Es
Ow
http://www.youtube.com/watch?v=v6niUVf0d
Difference engine
• A difference engine is an automatic
mechanical calculator designed to
tabulate polynomial functions. The
name derives from the method of
divided differences, a way to
interpolate or tabulate functions by
using a small set of polynomial
coefficients.
• Babbage's difference engine No. 2,
finally built in 1991, could hold 8
numbers of 31 decimal digits each
and could thus tabulate 7th degree
polynomials to that precision. The
best machines from Scheutz could
store 4 numbers with 15 digits each.
http://www.youtube.com/watch?v=0anIyVGe
Charles Babbage,
12/26/1791–
10/18/1871
Analytical engine
• Programmable mechanical general-purpose computer
• It incorporated an arithmetic logic unit, control flow in the
form of conditional branching and loops, and integrated
memory
• The input (programs and data) was to be provided to the
machine via punched cards
• For output, the machine would have a printer, a curve
plotter and a bell. The machine would also be able to punch
numbers onto cards to be read in later.
• There was to be a store (that is, a memory) capable of
holding 1,000 numbers of 40 decimal digits each (ca. 16.7
kB).
• Never built
Atanasoff–Berry
Computer 1942
• One of the first electronic digital
computing devices
• Not programmable
• Parallel processing
• Binary arithmetic
• Regenerative capacitor memory
• Separation of memory and
computing functions
http://www.youtube.com/watch?v=YyxGIbt
MS9E
Colossus computer 1944
• World's first electronic, digital, programmable, singlepurpose computer with variable coefficients.
Harvard Mark I 1944
• Electro-mechanical computer.
• Program-controlled by 24-channel punched paper tape.
ENIAC 1946
• Electronic Numerical Integrator And Computer
• First electronic general-purpose computer
• Turing-complete, digital, and re-programmable to
solve a full range of computing problems.
• ENIAC contained 17,468 vacuum tubes, 7,200 crystal
diodes, 1,500 relays, 70,000 resistors, 10,000 capacitors
and around 5 million hand-soldered joints. It weighed
more than 27 t, was roughly 2.4 m × 0.9 m × 30 m,
took up 167 m2, and consumed 150 kW of power.
• The need of a stored-program computer
Alan Turing
• Alan Mathison Turing, 6/23/1912 – 6/7/1954
• Universal Turing machine
• Algorithm
• Computation
• Criminal prosecution in 1952 due to his homosexuality
• British Prime Minister Gordon Brown made an official
public apology on behalf of the British government for
"the appalling way he was treated” in 2009.
Turing Machine
Turing Machine
• A tape divided into cells, one next to the other. Each cell contains a symbol from
some finite alphabet. The alphabet contains a special blank and one or more other
symbols. The tape is assumed to be arbitrarily extendable to the left and to the right.
Cells that have not been written to before are assumed to be filled with the blank
symbol.
• A head that can read and write symbols on the tape and move the tape left and right
one cell at a time.
• A state register that stores the state of the Turing machine, one of finitely many.
There is one special start state with which the state register is initialized.
• A finite table of instructions (usually 5-tuples : qiaj→qi1aj1dk) that, given the state(qi)
the machine is currently in and the symbol(aj) it is reading on the tape tells the
machine to do the following in sequence:
•
•
•
Either erase or write a symbol (replacing aj with aj1), and then
Move the head (which is described by dk='L’, 'R’, or 'N’), and then
Assume the same or a new state as prescribed (go to state qi1).
• Universal Turing machine=a Turing machine that can simulate an arbitrary Turing
machine on arbitrary input.
Von Nuemann Model
Generations
• 1st generation : Vacuum tubes
• 2nd generation : Transistor
• 3rd generation : Integrated Circuit (IC)
• 4th generation : Microprocessor + (LSI, VLSI)
How to program?
• Machine code:
• Instructions executed directly by CPU
• Loads the AL register with the data 01100001
• 10110000 01100001
• B0 61
• Assembly:
• Low-level programming language
• Statement (Assembler) Machine code instruction
• Loads the AL register with the data 01100001
• MOV AL, 61h
; Load AL with 97 decimal (61 hex)
High-level
programming
language
• Strong abstraction
• Natural language elements
• Interpreted language
• Compiled language
program helloworld
print *, "Hello, world."
end program helloworld
Operating System
• A collection of software that manages
computer hardware resources and
provides common services for
computer programs
• Acts as an intermediary between
programs and the computer hardware
UNIX
• A multitasking, multi-user
computer operating system
originally developed in 1969 by a
group of AT&T employees at Bell
Labs
• First developed in assembly
language
• By 1973 had been almost entirely
recoded in C
• X-Windows
Unix and UNIX-Like
Open Source/Free
• GNU and FSF
• Linux
• Free BSDs
GNU Project
• GNU’s Not Unix
• A free software, mass collaboration project, announced
on 27 September 1983, by Richard Stallman at MIT
General Public Licence
• GPL is the most widely used free software license,
which guarantees end users (individuals, organizations,
companies) the freedoms to use, study, share (copy),
and modify the software.
Linux
• The History of Linux began in
1991 with the commencement
of a personal project by a
Finnish student, Linus Torvalds,
to create a new free operating
system kernel.
Linux Distribution
Download