Examples » Walker: Integrating the diagonal Ornstein-Uhlenbeck SDE

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

Control file

title "Example problem"

walker

  term  10.0    # Max time
  dt    0.001   # Time step size
  npar  10000   # Number of particles
  ttyi  1000    # TTY output interval

  rngs
    mkl_mrg32k3a seed 0 end
  end

  diag_ou
    depvar o
    init raw
    coeff const
    ncomp 2
    sigmasq 0.25 1.0 end
    theta 1.0 1.0 end
    mu 0.0 1.5 end
    rng mkl_mrg32k3a
  end

  statistics
   interval 2
   <o1o1> <o2o2> <o1o2>
  end

  pdfs
    interval          500
    filetype          txt
    policy            overwrite
    centering         elem
    format            scientific
    precision         4
    f2( o1 o2 : 5.0e-2 5.0e-2 ) #; -2 2 -2 2 )
  end
end

Example run on 4 CPUs

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

Estimated moments

Left – time evolution of the means and the means of the invariant distribution, right – time evolution of the variances and those of the invariant as well as the zero correlation between the two independent equations integrated.

Image
Image

Gnuplot commands to reproduce the above plots:

plot "stat.txt" u 2:3 w l t "<O1>", "stat.txt" u 2:4 w l t "<O2>", 0.0 lt 1, 1.5 lt 2
plot "stat.txt" u 2:5 w l t "<o1o1>", "stat.txt" u 2:6 w l t "<o1o2>", "stat.txt" u 2:7 w l t "<o2o2>", 0.25/2 lt 1, 0.0 lt 2, 0.5 lt 3

Estimated bivariate PDF

Example ASCII bivariate PDF output.

# vim: filetype=sh:
#
# Joint bivariate PDF: f2(o1,o2)
# -----------------------------------------------
# Numeric precision: 4
# Bin sizes: 5.0000e-02, 5.0000e-02
# Number of bins estimated: 57 x 107
# Number of bins output: 57 x 107
# Sample space extents: [-1.2500e+00 : 1.5500e+00], [-2.4500e+00 : 2.8500e+00]
#
# Example step-by-step visualization with gnuplot
# -----------------------------------------------
# gnuplot> set grid
# gnuplot> unset key
# gnuplot> set xlabel "o1"
# gnuplot> set ylabel "o2"
# gnuplot> set zlabel "f2(o1,o2)"
# gnuplot> set dgrid3d 50,50,1
# gnuplot> set cntrparam levels 20
# gnuplot> set contour
# gnuplot> splot "pdf_f2.txt" with lines
#
# Gnuplot one-liner for quick copy-paste
# --------------------------------------
# set grid; unset key; set xlabel "o1"; set ylabel "o2"; set zlabel "f2(o1,o2)"; set dgrid3d 50,50,1; set cntrparam levels 20; set contour; splot "pdf_f2.txt" w l
#
# Data columns: o1, o2, f2(o1,o2)
# -----------------------------------------------
5.5000e-01  -1.6500e+00 4.0000e-02
1.0000e+00  -1.8000e+00 4.0000e-02
-9.5000e-01 1.7500e+00  4.0000e-02
-5.0000e-02 -2.4500e+00 4.0000e-02
8.0000e-01  2.3500e+00  4.0000e-02
-4.0000e-01 2.0500e+00  4.0000e-02
...

Example visualization of the estimated bivariate PDF with contour lines at the final time step using the command in the above input file.

Image