Non-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.
Learn More โ
Learn More โ
Then I measure the probability
Learn More โ
Learn More โ
Learn More โ
Learn More โ
Then I measure
Learn More โ
Learn More โ
program rw2
implicit none
integer, parameter :: N=5000, NP=100000
integer :: x(NP)=0, y(NP)=0, pre(NP), i, j
double precision :: p=0.25d0, pp, xa, xb, R
call random_seed()
open(66, file='gauR.dat', status='unknown')
do i = 1, N
xa = 0.d0
xb = 0.d0
do j = 1, NP
! non-reversal
do
call random_number(pp)
! p is the prob. of right
if ((pp.lt.p).and.(pre(j).ne.1)) then
x(j) = x(j) + 1
pre(j) = 1
else if ((pp.gt.p).and.(pp.le.2.d0*p).and.(pre(j).ne.2)) then
x(j) = x(j) - 1
pre(j) = 2
else if ((pp.gt.2.d0*p).and.(pp.le.3.d0*p).and.(pre(j).ne.3)) then
y(j) = y(j) + 1
pre(j) = 3
else if ((pp.gt.3.d0*p).and.(pre(j).ne.4)) then
y(j) = y(j) - 1
pre(j) = 4
else
cycle
end if
exit
end do
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, '(2I8)') 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
! distribution
! write(66, '(100000I8)') x
! write(66, '(100000I8)') y
write(66, '(100000f25.17)') dsqrt(dble(x)*dble(x) + dble(y)*dble(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, 2023An ideal 1 dimension random walk with probability of p stepping to right and 1-p to the left are represented by below figure of numbers of particle of first 100 steps. From this we can clearly guess(see) that the probability P(x, N) at N step at location x are higher around the center and lower at the edge, just like a Gaussian distribution.
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