Examples » Walker: Integrating the beta SDE

This example runs Walker to integrate the beta SDE (see DiffEq/Beta.h) using constant coefficients. For more detail on the beta SDE, see https://doi.org/10.1080/14685248.2010.510843.

Control file

title "Example problem"

walker

  #nstep 1      # Max number of time steps
  term  50.0    # Max time
  dt    0.005   # Time step size
  npar  100000  # Number of particles
  ttyi  1000    # TTY output interval

  rngs
    mkl_r250 end
  end

  beta
    depvar x
    ncomp 5
    init zero
    coeff const
    # alpha = Sb/kappa, beta = (1-S)b/kappa
    # S = 1/(1+\beta/alpha), delta = S/alpha = kappa/b
    kappa 2.0  0.76923  0.5  0.15873  0.5 end
    b     0.4  1.0      1.0  1.0      8.0 end
    S     0.5  0.53846  0.5  0.39683  0.5 end
    rng mkl_r250
  end

  statistics
    <X1> <X2> <X3> <X4> <X5>
    <x1x1> <x1x2> <x1x3> <x1x4> <x1x5>
           <x2x2> <x2x3> <x2x4> <x2x5>
                  <x3x3> <x3x4> <x3x5>
                         <x4x4> <x4x5>
                                <x5x5>
  end

  pdfs
    interval  1000
    filetype  txt
    policy    overwrite
    centering elem
    format    scientific
    precision 4
    p1( X1 : 2.0e-2 )
    p2( X2 : 2.0e-2 )
    p3( X3 : 2.0e-2 )
    p4( X4 : 2.0e-2 )
    p5( X5 : 2.0e-2 )
  end
end

Example run on 4 CPUs

./charmrun +p4 Main/walker -v -c ../../tmp/beta.q

Results

The left figure shows the time evolution of the means estimated from the numerical simulation together with those of the invariant distributions. The right figure shows the time evolution of the variances and those of the invariant. Both plots indicate convergence to the correct statistically stationary state.

Image
Image

Gnuplot commands to reproduce the above plots:

plot "stat.txt" u 2:3 w l t "<X1>", "stat.txt" u 2:4 w l t "<X2>", "stat.txt" u 2:5 w l t "<X3>", "stat.txt" u 2:6 w l t "<X4>", "stat.txt" u 2:7 w l t "<X5>", 0.5 lt 1, 0.53846 lt 2, 0.39683 lt 4
plot "stat.txt" u 2:8 w l t "<x1x1>", "stat.txt" u 2:13 w l t "<x2x2>", "stat.txt" u 2:17 w l t "<x3x3>", "stat.txt" u 2:20 w l t "<x4x4>", "stat.txt" u 2:22 w l t "<x5x5>", 0.20833 lt 1, 0.10805 lt 2, 0.083333 lt 3, 0.032788 lt 4, 0.014706 lt 5

The left figure shows the 5 estimated PDFs at the final step of the simulation together with the corresponding invariants. The right figure shows the time evolution of the estimated covariances indicating no correlations at all times corresponding to the statistically independent equations integrated.

Image
Image

Gnuplot commands to reproduce the above plots:

plot [0:1] [0:4] "pdf_p1.txt", "pdf_p2.txt", "pdf_p3.txt", "pdf_p4.txt", "pdf_p5.txt", x**(0.1-1.0)*(1.0-x)**(0.1-1.0)/19.715 lt 1 t "a=0.1, b=0.1", x**(0.7-1.0)*(1.0-x)**(0.6-1.0)/2.1539 lt 2 t "a=0.7, b=0.6", x**(1.0-1.0)*(1.0-x)**(1.0-1.0)/1.0 lt 3 t "a=1.0, b=1.0", x**(2.5-1.0)*(1.0-x)**(3.8-1.0)/0.03092 lt 4 t "a=2.5, b=3.8", x**(8.0-1.0)*(1.0-x)**(8.0-1.0)/1.9425e-05 lt 5 t "a=8.0, b=8.0"
plot [] [-0.003:0.003] "stat.txt" u 2:9 w l t "<x1x2>", "stat.txt" u 2:10 w l t "<x1x3>", "stat.txt" u 2:11 w l t "<x1x4>", "stat.txt" u 2:12 w l t "<x1x5>", "stat.txt" u 2:14 w l t "<x2x3>", "stat.txt" u 2:15 w l t "<x2x4>", "stat.txt" u 2:16 w l t "<x2x5>", "stat.txt" u 2:18 w l t "<x3x4>", "stat.txt" u 2:19 w l t "<x3x5>", "stat.txt" u 2:21 w l t "<x4x5>"