0% found this document useful (0 votes)
11 views50 pages

CP01 1preface

Uploaded by

g04086244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views50 pages

CP01 1preface

Uploaded by

g04086244
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

计算物理

Computational Physics
Chapter 1 (1)
Preface

Chen Changjun
Tel: 13554152594
Email: cjchen@[Link]
2
Total scores:

Usual performance
(homework, attendance, …) 20%

Presentation 10%

Final exam 70%

3
Text Book

《数值计算理论与实现》

陈长军

华中科技大学出版社,2014

4
Text Book

《An Introduction to
Computer Simulation
Methods: Application to
Physical Systems》 (3rd)
Harver Gould,
Jan Tobochnik
Wolfgang Christian.

Pearson Education Inc. 2006

5
Reference book:

《计算方法》

张诚坚 何南忠
高等教育出版社 2008

7
Reference book:

(1) An Introduction to Computational Physics. (2ed)


Tao Pang. Cambridge University Press, 2006

(2) Computational Physics: Simulation of Classical


and Quantum Systems.
Philipp O. J. Scherer. Springer 2010

(3) A survey of computational physics: introductory


computational science.
Rubin H. Landau, Manuel José Páez, Cristian C.
Bordeianu. Princeton University Press. 2008
8
What is the computational physics?

Theoretical
Physics

Computational
Physics

Experimental
Physics
9
Title: Methods in Computational Physics
Author: B. J. Alder
Publisher: New York Academic Press,
1963-1977 (17 vols)

von Neumann

1942
ENIAC 1946
Electronic Numerical Integrator and Calculator

11
Why we need computational physics?
Some experiments are too expensive, or even
impractical

 early universe
 high speed
 high or low temperature
 high pressure
 intense magnetic field
 …
12
Some theories are too complicated

Paul Dirac
1902~1984

13
14
Spinning Top
I11  23 ( I 2  I 3 )  N1
I 2 2  31 ( I 3  I1 )  N 2
I 3 3  12 ( I1  I 2 )  N 3

15
IBM 704

0 rd
uij (r )  
 rd

16
Curriculum Structure
18
Tools

 Hardware

曙光5000A
2008: top 500
230 tril
19
 Software

Programming Language

C/C++

Fortran Matlab

Mathematica
Java
Python
C#
20
Compiler
C/C++ Fortran Java

Turbo C MinGW JDK

VC6 Compaq JBuilder


Visual Fortran
VS .net Intel Fortran
Compiler

Python, Mathematica, Matlab, Tcl/tk


21
22
Performance comparison x=0.123456789
sin( x )* cos( x )* sqrt ( x )* 8* 20000* 20000

Fortran
Intel E7500 CPP (VC6) Matlab 6.5
(CVF6)
Time (s) 3.531 3.375 495.172

Cal (iter) 137418122.32 137418122.89 137420000.0

Ref (form) 137404372.22 137404375.58 137400000.0

Error 13750 13747 13750

23
n
r  1,i 2,i
( r
i 1
 r ) 2
C++ VS. Fortran
#include <iostream>
16 lines 7 lines
#include <cmath>
using namespace std; 387 characters 141 characters
int main() {
double r1[100], r2[100],size; program main
for (int i = 0; i < 100; i++) { real*8 :: r1(100),r2(100),size
r1[i] = i; r2[i] = 100 + i;
} r1 = [(i,i=1,100)]; r2 = r1 + 100
size = 0; size = sqrt(sum((r1(:)-r2(:))**2))
for (int i = 0; i < 100; i++) { print *,"size= ",size
size += (r1[i] - r2[i]) * (r1[i] - r2[i]); end program
}
size = sqrt(size);
cout << "size= " << size << endl;
}

24
n
r  1,i 2,i
( r
i 1
 r ) 2

Fortran VS. Python

program main import numpy as np


real*8 :: r1(100),r2(100),size
r1 = [Link]([i for i in range(1, 101)],
r1 = [(i,i=1,100)]; r2 = r1 + 100 dtype=np.float64)
size = sqrt(sum((r1(:)-r2(:))**2)) r2 = r1 + 100
print *,"size= ",size size = [Link]([Link]((r1 - r2) ** 2))
end program print("size= ", size)

7 lines 6 lines
141 characters 149 characters
25
量子化学软件中的编程语言

26
Interface for data input and output
Command line

MFC

Java

Tcl/tk

Matlab
27
Visualization

gnuplot

origin

28
29
Open GL

DirectX Java 3D

30
Python

Matplotlib: data plot

VPython: 3-D animations

Tkinter: graphical user interface (GUI)

31
Some program skills you may need

 Software Architecture (black box, module,…)


 Microsoft Foundation Class (MFC)
 Multi-thread
 3D computer graphics

32
First learn computer science and all the theory.
Next develop a programming style. Then forget
all that and just hack.

首先学会计算机科学和所有的理论。然后发展出一
个编程风格。之后便要忘掉所有这些,以自由的方
式探索。

—— George Carrette

33
There are two ways of constructing a software
design. One way is to make it so simple that there
are obviously no deficiencies. And the other way
is to make it so complicated that there are no
obvious deficiencies.

有两种生成一个软件设计方案的途径。一个是把它做
得如此简单,以致于明显不会有漏洞存在。另一个是
把它做的如此复杂,以致于不会有明显的漏洞存在。

—— C.A.R. Hoare
What we will learn in this course?
 Algorithms
x 2
3

df ( x )
P ( x i )  yi
dx

 f ( x )dx Ax  b

dy
Ax   x  2x
dx 35
Why not use Matlab or Mathematica or netlib?
 Small
Matlab 6.5 700M, Mathematica 219 M
 Simple

SUBROUTINE DBCG (N, B, X, NELT, IA,


JA, A, ISYM, MATVEC, MTTVEC,
MSOLVE, MTSOLV, ITOL, TOL, ITMAX,
ITER, ERR, IERR, IUNIT, R, Z, P, RR, ZZ,
PP, DZ, RWORK, IWORK)
36
 Convergence problem

 Efficiency

speed accuracy

 Extensible

37
Basic ideas in numerical methods:

Difference A   Ai

Iteration xk  f ( xk )  xk 1
Low-order approximation
f ( x0 ) 2
f ( x )  f ( x 0 )  f ( x 0 )  x   x 
2
38
 Application:

Monte Carlo

39
Molecular Dynamics

  2
d r
f m 2
dt

40
Quantum Mechanics
 ( x , t )    2 2

i    V ( x , t )  ( x , t )
t  2 m x
2

41
Finite Difference

    

42
Finite Element

    

43
How to study this course:

 Preview the textbook


 Understand some basic ideas
 Be familiar with programming
 Spend enough time on computer
 Cooperate with classmates

44
作业要求
 文件格式:pdf
 文件名: 物理1101_张三_M201070001
 章节目录
 问题描述
 使用的公式
 流程图 execute begin
or end
 源代码
 运算结果 determine
 图例 45
Presentation

 Brief talk about 5 minutes.


 Select the topic in the ppt or the reference book
description of the problem
program idea, input/output format, how to run
results (data, figures)

 Be ready for any questions


 This will improve your score
Example
For integration  f ( x )dx
y
 ( y  L / 2)2
L ve

x
initial pos (0, 0) initial vel (0, v0)
final pos? final vel?
Two ways: analytic calculation, numerical
calculation. 47
For Eigenvector Ax   x
Find the principal axis!

    momentum of
L   r  pdV   I    inertia tensor

diagonalize I principal axis


48
     
L   r  pdV   r     r  dm
     
     r  r  -r  r     dm


 e1   x (y  z )-xy y  xz z dm  
2 2

 (y 2  z 2 )dm  
    xydm   xzdm
 x 
    xydm  (x
2
 z )dm
2
  yzdm    y 
  
  xzdm   z 
   yzdm  
2 2
 (x y )dm 
49
Available Topics
Project1: Monte Carlo integration in
high dimensional space
Project2: Simulate the particle
system (molecule, planet)
Project3: Electrostatic field calculation
(FFT or FD)
Project4: Heat Flow
Project5: Quantum mechanics (Schrodinger
equation)
50

You might also like