An ideal 1 dimension random walk with probability of
Learn More →
Following three successive figures show different
Learn More →
Learn More →
Learn More →
And next we show the relation between
Learn More →
The probability of
where
Learn More →
Learn More →
Learn More →
Learn More →
Learn More →
Learn More →
For two dimension RW, we need two consider the extra dimension we can randomly walk on. Similar to one dimension, we first plot the first 1000 and 10 million steps of random walk which shows a beautiful pattern.
Learn More →
Learn More →
Similar to 1 dimension, the probability
Learn More →
Learn More →
And finally I calculate
Learn More →
Learn More →
program rw1
implicit none
integer, parameter :: N=10, NP=100000
integer :: x(NP)=0, i, j
double precision :: p=0.6d0, pp, xa, xb
call random_seed()
! open(66, file='1d06.dat', status='unknown')
open(66, file='6gau10.dat', status='unknown')
do i = 1, N
xa = 0.d0
do j = 1, NP
call random_number(pp)
! p is the prob. of right
if (pp.lt.p) then
x(j) = x(j) + 1
xa = xa + dble(x(j))
else
x(j) = x(j) - 1
xa = xa + dble(x(j))
end if
end do
! <x>
xa = xa / dble(NP)
xb = 0.d0
do j = 1, NP
xb = xb + (dble(x(j)) - xa) * (dble(x(j)) - xa)
end do
xb = xb / dble(NP)
! write(66, '(I6, 2f25.17)') i, xa, xb
end do
write(66, '(100000I5)') x
end program rw1
program rw2
implicit none
integer, parameter :: N=1000, NP=100000
integer :: x(NP)=0, y(NP)=0, i, j
double precision :: p=0.25d0, pp, xa, xb, R
call random_seed()
open(66, file='2dstd.dat', status='unknown')
do i = 1, N
xa = 0.d0
xb = 0.d0
do j = 1, NP
call random_number(pp)
! p is the prob. of right
if (pp.lt.p) then
x(j) = x(j) + 1
else if ((pp.gt.p).and.(pp.le.2.d0*p)) then
x(j) = x(j) - 1
else if ((pp.gt.2.d0*p).and.(pp.le.3.d0*p)) then
y(j) = y(j) + 1
else
y(j) = y(j) - 1
end if
R = dsqrt(dble(x(j))*dble(x(j))+dble(y(j))*dble(y(j)))
xa = xa + R
xb = xb + R * R
end do
! traj
! write(66, '(2I5)') x(1), y(1)
! <x>
xa = xa / dble(NP)
! <x^2>
xb = xb / dble(NP)
write(66, '(I6, 2f25.17)') i, xa, xb
end do
! write(66, '(100000I5)') x
! write(66, '(100000I5)') y
end program rw2
Ising model on square lattice are L \times L spin that can take 2 values, either S_i=+1 or S_i=-1. Each spin interact with neighbors and with external field. The Hamiltonian of the system is\begin{equation} H = -\sum_{<ij>} J_{ij}S_iS_j - \sum_i H_iS_i \end{equation}A particular solution for no external field are obtained by Lars Onsager where the second-order phase transition is happened at\dfrac{J}{k_BT_c} = \dfrac{ln(1+\sqrt{2})}{2}. With this in mind, we can use Metropolis algorithm to simulate Ising model with good accuracy. Following four figures show different MC steps, the spin of a 100 \times 100 system with blue represent spin up and red represent spin down. Since the temperature happened around the critical temperature, the magnetization taken very long time to come to equilibrium.
Mar 16, 2023Non-reversal random walk are randomly walk except it cannot reverse it's previous step. Following two figures show different steps of NRRW, compare to previous figure it can walk further since it cannot go reverse its previous step.
Mar 16, 2023To generate two independent Gaussian random variables x and y we use these equation\begin{equation} x = \sigma \sqrt{-2ln\xi_1}\cos(2\pi \xi_2) \quad,\quad y = \sigma \sqrt{-2ln\xi_1}\sin(2\pi \xi_2) \end{equation}This figure show total number N=10^5 Gaussian random numbers.
Mar 15, 2023Poisson equation has the form of\begin{equation} \dfrac{\partial^2 u}{\partial x^2}+\dfrac{\partial^2 u}{\partial y^2} = -\dfrac{q}{K} \tag{1} \end{equation}In this particular case u is the steady-state temperature. Given the boundary condition we can apply finite difference into this PDE and solve it numerically. The finite difference has the following relation.\begin{equation} w_{ij} = \dfrac{1}{2+2\left( \dfrac{h}{j}\right)^2} \left[ w_{i+1,j} + w_{i-1,j} + (\dfrac{h}{k})^2(w_{i,j+1}+w_{i,j-1}) -h^2f_{ij} \right] \tag{2} \end{equation}Instead of solving this linear equation, we were using relaxation method to solve it which is let the solution iterate until it reach a desired tolerance. Follow figure show the temperature distribution in x-y plane with line represent the isotherm area. The area around x and y axis is what we expected that the center are the hottest and gradually cool down to another two boundary.
Mar 15, 2023or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up