-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrownian_motion_simulation_prb.f
95 lines (85 loc) · 2.19 KB
/
brownian_motion_simulation_prb.f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
program main
c*********************************************************************72
c
cc MAIN is the main program for BROWNIAN_MOTION_SIMULATION_PRB.
c
c Discussion:
c
c BROWNIAN_MOTION_SIMULATION_PRB tests the BROWNIAN_MOTION_SIMULATION library.
c
c Licensing:
c
c This code is distributed under the GNU LGPL license.
c
c Modified:
c
c 30 September 2012
c
c Author:
c
c John Burkardt
c
implicit none
integer k
parameter ( k = 40 )
integer m_max
parameter ( m_max = 3 )
integer n
parameter ( n = 1001 )
double precision d
double precision dsq(k,n)
character * ( 80 ) header
integer m
integer seed
double precision t
double precision x(m_max,n)
call timestamp ( )
write ( *, '(a)' ) ''
write ( *, '(a)' ) 'BROWNIAN_MOTION_SIMULATION_PRB'
write ( *, '(a)' ) ' FORTRAN77 version'
write ( *, '(a)' )
& ' Test the BROWNIAN_MOTION_SIMULATION library.'
c
c Compute the path of a particle undergoing Brownian motion.
c
do m = 1, 2
d = 10.0D+00
t = 1.0D+00
seed = 123456789
call brownian_motion_simulation ( m, n, d, t, seed, x )
if ( m .eq. 1 ) then
header = 'motion_1d'
else if ( m .eq. 2 ) then
header = 'motion_2d'
end if
call brownian_motion_display ( m, n, x, header )
end do
c
c Estimate the average displacement of the particle from the origin
c as a function of time.
c
do m = 1, 3
d = 10.0D+00
t = 1.0D+00
seed = 123456789
call brownian_displacement_simulation ( k, n, m, d, t, seed,
& dsq )
if ( m .eq. 1 ) then
header = 'displacement_1d'
else if ( m .eq. 2 ) then
header = 'displacement_2d'
else if ( m .eq. 3 ) then
header = 'displacement_3d'
end if
call brownian_displacement_display ( k, n, d, t, dsq, header )
end do
c
c Terminate.
c
write ( *, '(a)' ) ''
write ( *, '(a)' ) 'BROWNIAN_MOTION_SIMULATION_PRB'
write ( *, '(a)' ) ' Normal end of execution.'
write ( *, '(a)' ) ''
call timestamp ( );
return
end