
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















Abstraction of Polymer
Radius
N = 200; imax = 100; jmax = 2; nframes = 20; % number of frames for movie rand('state', 0) % initialize i = 50; for kk = 1: 1000 rr = rand; if((rr >= 0 ) & ( rr < 0.5) ) i = i + 1; elseif((rr >= 0.5 ) & ( rr < 1.0) ) i = i - 1; end if i >= imax break end if i <= 1 break end plot(kk, i, 'r:.'); hold on F(kk) = getframe; kk end
Program: One- Dimensional Random Walk
Result: One- Dimensional Random Walk
Here we started with ith position = 50 for a grid of 100 mesh points and as a function of MC steps we see above the random walk.
Program: One- Dimensional Random Walk
Here r(rms) is the average (root-mean-squared) step size. Notice that that the same result obtains for a three-dimensional walk. According to above equation, even though the total distance walked after N steps is Nr(rms), on average, the radial distance from the starting point is only sqrt(N) x r(rms).
When walk is random, the particle is equally likely to in any direction in each step. On average, for a large number of random steps, all the cross terms will vanish and we will be left with
A Random Walk
Simple Unbiased Random Walk
For simple,random walks(RW) the walker may cross the walk an infinite number of times with no cost. In d dimensions the end-to-end distance diverges with the number of steps N according to
A simulation of the simple random walk can be carried out by picking a starting point and generating a random number to determine the direction of each subsequent, additional step. After each step the end-to-end distance is computed.
The result is like above figure.
A Picture is Worth a Thousand Words
2D Walk^ 3D Walk
Self-avoiding walks (SAW)
Self-avoiding Random Walk
Self-avoiding Random
Walk Algorithm
#include <iostream.h> #include <stdlib.h> #include <math.h>
void do_walk (int maxstep, int& nstep, double& rsquared ){ const int MAXSTEP=20; int map[ MAXSTEP2][MAXSTEP2]={0};**
*// start point int completed=0; int x = MAXSTEP; int y = MAXSTEP; int npoint = 1; map[x][y] = npoint; do { int xnew=x; int ynew=y; switch ( (int)( (double)rand()/(RAND_MAX+1.0)) ) { case 0: xnew-= 1; break; case 1: xnew+= 1; break; case 2: ynew-= 1; break; case 3: ynew+= 1; break; } if ( map[xnew][ynew] == 0 ){ npoint++; map[xnew][ynew] = npoint; x = xnew; y = ynew; if ( npoint == maxstep+1 )completed=1; } else if ( map[xnew][ynew] != npoint-1 ) { completed=1; } } while ( !completed );
// Print window centred on map for ( int i=5; i<2MAXSTEP-5; i++ ){ for ( int j=5; j < 2MAXSTEP-5; j++ ){ cout.width(3); cout << map[i][j]; } cout << endl; } nstep = npoint-1; rsquared = pow( x-MAXSTEP,2.0) + pow( y- MAXSTEP, 2.0 ); } int main(){ int maxstep=20,nstep; double rsquared; srand(987654321); for (int i=1; i<10; i++ ){ do_walk(maxstep,nstep,rsquared); cout << endl << "Nsteps: " <<nstep << " Rsquared: " <<rsquared<<endl; } return 0; }**
docsity.com