Examples » Walker: Integrating the Ornstein-Uhlenbeck SDE

This example runs Walker to integrate the Ornstein-Uhlenbeck SDE (see DiffEq/OrnsteinUhlenbeck.h) using constant coefficients.

Control file

title "Example problem"

walker

  #nstep 1      # Max number of time steps
  term  5.0     # Max time
  dt    0.001   # Time step size
  npar  1000000 # Number of particles (this many only to have a reasonably
                #   smooth bivariated PDF
  ttyi  1000    # TTY output interval

  rngs
    mkl_mrg32k3a seed 0 end
  end

  ornstein-uhlenbeck
    depvar r
    init raw
    coeff const
    ncomp 3
    theta 1.0 2.0 3.0 end
    mu 0.0 0.5 1.0 end

    # Upper triangle of the square of the diffusion matrix 'sigma-square'.
    # Must be symmetric positive semi-definite.
    sigmasq
      4.0  2.5   1.1
          32.0   5.6
                23.0
    end

    rng mkl_mrg32k3a
  end

  statistics
    interval 2
    <R> <rr> <R2> <r2r2> <R3> <r3r3> <r1r2> <r1r3> <r2r3>
  end

  pdfs
    interval          1000
    filetype          gmshbin
    policy            overwrite
    centering         node
    #format            scientific
    #precision         4
    f2( r1 r2 : 2.0e-1 2.0e-1 ) #; -2 2 -2 2 )
  end
end

Example run on 4 CPUs

./charmrun +p4 Main/walker -v -c ../../tmp/ou.q -u 0.9

Estimated moments

Left – time evolution of the means and the means of the invariant distribution, right – time evolution of the components of the covariance matrix and those of the invariant.

Image
Image

Gnuplot commands to reproduce the above plots:

plot "stat.txt" u 2:3 w l t "<R1>", "stat.txt" u 2:4 w l t "<R2>", "stat.txt" u 2:5 w l t "<R3>", 0 lt 1, 0.5 lt 2, 1.0 lt 3
plot "stat.txt" u 2:6 w l t "<r1r1>", "stat.txt" u 2:7 w l t "<r1r2>", "stat.txt" u 2:8 w l t "<r1r3>", "stat.txt" u 2:9 w l t "<r2r2>", "stat.txt" u 2:10 w l t "<r2r3>", "stat.txt" u 2:11 w l t "<r3r3>", 4.0/2 lt 1, 2.5/3 lt 2, 1.1/4 lt 3, 32.0/4 lt 4, 5.6/5 lt 5, 23.0/6 lt 6

Estimated bivariate PDF

Example visualization of the estimated bivariate PDF at the final time step using gmsh.

Image