Computational Physics Question Card
1. RNG
-
What is Mersenne number? what is Mersenne prime number ?
, when is prime
-
What is the advantage and disadvantage of multiplicative RNG and additive RNG?
multiplicative simpler, faster, not good sequence
additive complex, slower, better sequence
-
How many RNG algorithm do you remember?
congruential, lagged fibonacci RNG
Congruential
-
What is Congruential RNG? Is it additive or Multiplicative?
, multiplicative
-
What’s the max period or congruential RNG? When achieve it?
, when is a Mersenne prime number ,
Lagged Fibonacci
-
What is Lagged Fibonacci RNG? Is it additive or Multiplicative?
, additive
-
How to generate the initial sequence before
use a congruential generator
-
What’s the max period?
-
What condition should the parameter satisfy? and the smallest number for it?
$T_{c,d}(z) = 1+z^c + z^d $ (Zieler Trinomial)cannot be factorized, (250,103)
How good is RNG?
-
What kind of method could be used to measure RNG?
square test, cube test, test, average value, spectral analysis, serial correlation test
-
What is square test?
, no cluster means good
-
What is cube test?
, should be distributed homogenously
-
What is test
the distribution around the mean value should behave like a Gaussian distribution
-
What is average test?
-
What is spectral analysis?
should correspond to a uniform distribution
Quasi Monte Carlo
-
What is quasi Monte Carlo approches?
use low-discrepancy sequence for Monte Carlo sampling
-
What is the error bounds in quasi-Monte Carlo? is the error bounds deterministic?
is the problem dimension, is number of sampling,yes
-
What is the error of Monte Carlo sampling? When quasi MC is better than MC?
, number of samples is large enough
-
What is the advantage of quasi MC?
quasi MC better convergence as increase, and error bounds is deterministic
Discrepancy and low-discrepancy sequence
-
What is D-star discrepancy?
for every subset of get the biggest difference between the volume and average points density.
-
How to judge if a sequence is a low discrepancy sequence?
Non Uniform Distribution
-
What are two method to perform transformation?
mapping, rejection method
-
How do mapping work for unit sphere from ?
-
How do mapping work for exponential distribution?
the exponential distribution is defined as
-
How do mapping work for gaussian? (Box-Muller transform)
the gaussian distribution is written as
-
What condition should transformation method satify?
integrability, invertibility
-
How to make rejection faster?
individual box(Riemann-integral)
Speedup
-
What is the Amdahl’s law?
, is the sequential part, is the speed up ratio
-
How many methods do you know in Julia for parallel programming?
asynchronous, multi-threading, distributed, gpu
2. Percolation
-
What is the main goal of percolation?
study the formation of clusters
-
What are two types of percolation?
site/bond percolation
-
What is percolated ?
as occupation rate go to some point, cluster size will go to infinite (phase transition)
Phase Transition
-
What name is the phase transition occuring in percolation?
second-order phase transition
-
What is the percolation strength, and it’s definition near at $p=1 $ and
infinite cluster , , , is percolation strength/order parameter, it strongly depends on the problem
-
which lattice has the highest 2d threshold site and bond ?
honeycomb
-
what is wrapping probability?
the probability system is percolated.
Cluster Size Distribution
-
What is cluster size distribution?
: occupation probability
: system’s side length
: number of clusters of size
-
What phenomenon will you find for cluster size distribution with different ?
, as , are higher
, straight line
, as , are lower
-
What do you observe in the test for the cluster size? ()
There is a spike near
Burning Method
-
What information can burning method provide?
a boolean feedback(yes or no percolated),
minimal path length
-
Write a short code for burning method
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15def burning_method(L=16):
lattice = np.random.randint(0, 2, (L, L)) # 0 empty 1 occupied
t = 2
lattice[0][lattice[0]==1] = t
while True:
cells = np.where(lattice == t)[0]
burn_neighbor = False
for cell in cells:
for neighbor in neighbors[cell]:
if neighbor == 1:
lattice[neighbor] = t+1
burn_neighbor = True
if not burn_neighbor
break
t += 1 -
How to count the largest cluster size of a random generated lattice?
similar to the burning algorithm but from another side.
Hoshen-Kopelmann Algorithm
-
What is the Hoshen-Kopelman used for?
know how the different clusters are distributed
-
What is the complexity of Hoshen-Kopelman Algorithm?
linear to the number of sites
-
Write a short code for Hoshen-Kopelmann algorithm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18def hoshen_kopelmann(L=16):
lattice = np.random.randint(0, 2, (L, L))
M = np.array([0,0]) # cluster counter
for i in range(L):
for j in range(L):
if lattice[i,j] == 1:
if no_left(i,j) and no_top(i,j): # no left and no top neighbor
lattice[i,j] = len(M);
M = np.append(M, 1)
elif no_left(i,j) ^ no_top(i,j): # either left or top neighbor
k0 = lattice[i-1,j] if no_left(i,j) else lattice[i, j-1]
lattice[i,j] = k0
M[k0] += 1
else: # has left and top neighbors
k1, k2 = lattice[i-1, j], lattice[i, j-1]
lattice[i,j] = k1
M[k1] = M[k1] + M[k2] + 1
M[k2] = -k1
3. Fractal
-
what is the fractal dimension?
for fractal dimension , if the length is stretched by factor of , it’s volume(mass) grows by
-
What is the fractal dimension of Sierpinski triangle?
Sandbox method
-
Write a short code for sandbox method
1
2
3
4
5
6
7def sandbox(lattice):
R_2s = np.arange(1,lattice.shape[0] // 2) # half size of R
NRs = np.zeros_like(R_2s)
Rs = R_2s * 2
for i,R_2 in enumerate(R_2s):
NRs[i] = lattice[R_2:-R_2,R_2:-R_2].sum()
plot_log_log(NRs, Rs)growing boxes from center
-
what is the slope of the log-log plot () of sandbox method
fractal dimension
Box counting method
-
write a short code for box counting method
1
2
3
4
5
6
7
8def box_counting(lattice):
epsilon = lattice.shape[0]
N_epsilons = []
epsilons = []
while epsilon >= 1:
N_epsilon = maxpool2d(lattice, epsilon).sum()
epsilon = epsilon // 2
plot_log_log(N_epsilons,epsilons) -
what is the slope of the log-log plot () of box counting algorithm
fractal dimension
Fractals & Percolation
-
What is the correlation function ? And what does the expression mean?
counts the filled sites within a dimension hyper shell of thick with radius and normalize by the surface area
-
What is the common relation for
decrease exponentially with , , is correlation length, propotional to the radius of a typical cluster
-
When is correlation singular?
is singular at , where
-
How does behave when is singular?
, where
-
What’s the relation between the fractal dimension and dimension ?
4. Cellular Automata
-
Illustrate the components defining a cellular automata
: lattice, : state of each site at time , update rules, : neighbors
-
What is the synchronous dynamics?
rules applied simultaneously to all sites
-
What’s the difference between Von Neumann neighborhood and Moore neighborhood?
Von Neumann: 4, Moore: 8
-
What’s the four types of boundaries?
periodic, fixed, adiabatic, reflection
Game of Life
-
What is the neighborhood for Game of Life?
Moore neighborhood
-
What’s the rule for Game of Life ?
neighbors action dead, because of isolation unchange birth dead, because of over population -
List some periodic pattern in Game of Life
pattern animation glider glider gun
Langton Ant
-
What’s the observation of the Langton Ant?
- chaotic phase of about 10000 steps
- form highway
- walk on highway
-
What’s the rule for Langton Ant?
cell state action white turn left, and paint the cell gray gray turn right, and paint the cell white
Traffic model
-
Consider one-dimension Cellular Automata with as nearest neighbors. What does mean?
which stands for rule
entries 111 110 101 100 011 010 001 000 0 1 1 0 0 1 0 1 -
In above setting, how many possible rules for 1 D Cellular Automata with ?
-
What phenomenon will you observe for number of moving cars when
when , traffic jam will happen
HPP model
-
What does the HPP lattice look like?
HPP lattice is defined on a 2d square lattice, also one could use hexagonal grid with two possible result
-
Describe the steps of HPP model.
- collision
- propagation/streaming
-
How many bits of information at each site are enough for HPP model ?
4, : three particles entering the site in direction 1,3,4
5. Monte Carlo
-
the main steps of a MC method?
-
random choose a new configuration in phase space,
-
accept or reject new configuration,
-
compute physical quantity and add it to the averaging procedure,
-
repeat
-
-
with is the error of MC? is it depend on the dimension?
, no
Buffon’s Needle
-
Suppose the length of the needle is and distance of grid is . What is the probability of the needle cross the line?
Integration
-
when simple sampling MC integration works well?
when is smooth
-
what’s the error of conventional integration(Trapezoidal Rule) ?
-
What’s the error in simple MC integration?
, it’s independent of the dimension
-
What’s the curcial points for MC method(MC more efficient than conventional method)?
-
Describe the steps for high dimension integration using MC.
- choose particle position
- make sure new sphere not overlap with pre-existing spheres. If it overlap, reject and sample again
-
Given a distribution better enclose the , describe the steps for sampling better
- if y > try again, else return
Importance Sampling
- Given the sampling from which is better enclose , how to integrate using Importance Sampling?
Control Variate
-
What is Control Variate?
-
If I want to use control variates, what condition should satisfy
- is known
Quasi Monte Carlo
-
What is Quasi Monte Carlo?
use low discrepancy generator to choose
-
What’s the theoretical error bound for Quasi Monte Carlo?
-
Does the convergence for Quasi Monte Carlo faster than theoretical?
yes
-
When does Quasi Monte Carlo better than the Monte Carlo?
Multi Level Monte Carlo
-
For a level MLMC, the cost/variance/ for each level is , what’s the cost/variance/sample number for MLMC?
6. Markov Chain
-
given the transition probability and acceptance probability , what’s the overall probability of a configuration?
-
What’s the master equation for the evolution of the probability ?
-
What’s the three condition a Markov Chain should satisfy?
- Ergodicitty:
- Normalization:
- Homogeneity:
-
What’s Detailed Balance ?
steady state of the Markov process
M(RT) Algorithm
-
What’s Metropolis algorithm?
-
What’s M(RT) algorithm?
- randomly choose configuration
- compute
if it will always accept
-
What’s the equilibrium distribution of the M(RT) algorithm ?
the Boltzmann distribution
Ising Model
-
Describe the Ising Model
: magnetization, a particle spin up else
: susceptibility,
: inverse temperature,
-
How to apply M(RT) algorithm to Ising Model
- randomly choose configuration
- compute
-
What is the critical temperature for Ising Model ?
6. Finite Difference
Error Estimation
-
How many kinds of errors can be categorized?
- input data error
- computational rounding error : float point
- truncation error : infinite term/linear approximation
- mathematical model error : flawless assumption
- human&machine error
-
Are mathematically equivalent formulas also numerically equivalent? why?
no, for example and
-
What is error propagation? How to compute it?
-
What is ill-conditioned and well-conditioned ?
ill-conditioned : small changes in the input data can result in large changes in the output data
well-conditioned : small changes in the input data only result in small changes in the output data
Discretization in Space and Time
- What’s the parabolic/hyperbolic/elliptic form?
- parabolic:
- hyperbolic:
- elliptic:
FTBS
-
What is Forward in Time, Backward in Space?
-
What is the order of accuracy for FTBS?
first order accuracy
-
Assume , when is FTBS stable and when is it unstable?
the Domain of Dependence(DoD) for FTBS is , within the DoD the domain is stable.
-
Solving the linear advection condition with FTBS, what is the in Von-Neumann Stability?
FTCS
-
What is Forward in Time Center in Space ?
-
Solving the linear advection condition with FTCS, what is the in Von-Neumann Stability? What’s different from FTCS?
CTCS
-
What is Centred in Time, Centred in Space ?
-
How to get the second term
use FTCS
-
Assume , when is CTCS stable and when is it unstable?
The DoD for CTCS is , within the DoD, it’s stable.
-
Solving the linear advection condition with CTCS, what is the in Von-Neumann Stability? What’s different from FTBS?
- The solution is stable and not damping since
- There are two solutions, one is spurious computational mode, one is the realistic solution
BTCS
-
What is Backward in Time, Centred in Space?
-
Is BTCS implicit?
yes
Numerical Analysis
-
What is Numerical diffusion and Numerical dispersion?
Numerical diffusion: smooth out sharp corners
Numerical dispersion: Fourier components travel at different speeds
-
What is Lax-Equivalence Theorem?
-
What is Courant-Friedrichs-Lewy(CFL) criterion? What’s the CFT condition for linear advection ?
-
What’s the typical for explicit method and implicit method?
for explicit method, for implicit method
-
What is Von-Neumann Stability Analysis?
condition behavior stable and damping neutral stable unstable and amplyfying
Phase velocity
-
What is the phase velocity in linear advection ?
since
-
What is the amplification factor of linear advection analytical solution?
-
What is the phase speed for amplification factor with wave number ?
-
What is the amplification factor of CTCS?
-
What is the phase speed in linear advection when using CTCS method? What phenomenon do you observe?
- There are two solutions, the positive one is the physical mode.
- The physical mode is close to the ground truth when and is very small.
Shallow water equation
-
What is the equation for incompressible navier stokes?
-
Assume the gravity only in direction, what PDE equation can we get from the incompressible navier stokes? How about 1D condition?
1 D condition
-
In 1 D wave condition, assume and , give the unstaggered(A-grid) and staggered(C-grid) formular of centered in space. Assume , what are the stable conditions for them?
A-grid
stable for
C-grid
stable for
better at high frequency
7. Time Integration
Error
-
What’s the difference between truncation error and round-off error?
Truncation error results from Taylor expansion
Roundoff error results from the float point computation
-
What is the round off error for explicit euler of timestep ?
where
-
What is the truncation error for explicit euler of timestep ?
-
What are the two main drawbacks of explicit euler compared to rounge kutta method?
- it’s numerical instable
- it has first order of truncation error which is lager then rounge kutta
-
Describe the picture below.
Conservation
-
What is Symplectic?
-
Given Hamitonian transformation that , what is the modified Hamitoninan transformation for the first order of ?
-
Describe the picture below from the conservation view.
8. Maxwell Equation
-
Give the general formula of Vlasov-Maxwell-Boltzmann equation describing the plasma distribution .
: advection in real space
: advection in velocity space
: lorentz force
:collision term, normally in Vlasov equation
particle in cell
-
Describe the Particle in Cell(PIC) method.
Boris Algorithm
-
Describe the Boris Algorithm.
-
Show what the absence of of the Boris algorithm conserves kinetic energy.
Yee-cell
-
Describe the Yee-Cell method.
-
How to determine the time step ?
where is dimension
-
How to minimize the error of by scaling ?
9. Nbody Problem
- List some algorithm to solve n-body problem numerically.
- PIC(Particle in Cell) : grid field solver
- P3M(Particle-particle Particle-Mesh) : split forces into short and long range
- Langevin : using Rosenbluth potentials
- SPH(Smooth Particle Hydrodynamics) : between finite sized
- FMM(Fast multipole method) : use center of force
- Tree Methods : mesh free
PIC(Particle In Cell)
P3M(Particle-Particle Particle-Mesh)
- Describe the general idea of P3M algorithm.
- nearby particles - nbody calculation
- fa away particles - PIC algorithm