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

Output

Running on 4 processors:  Main/walker -v -c ../../tmp/ou.q -u 0.9
charmrun>  /usr/bin/setarch x86_64 -R  mpirun -np 4  Main/walker -v -c ../../tmp/ou.q -u 0.9
Charm++> Running on MPI version: 3.0
Charm++> level of thread support used: MPI_THREAD_SINGLE (desired: MPI_THREAD_SINGLE)
Charm++> Running in non-SMP mode: numPes 4
Converse/Charm++ Commit ID: b8b2735
CharmLB> Load balancer assumes all CPUs are same.
Charm++> Running on 1 unique compute nodes (4-way SMP).
Charm++> cpu topology info is gathered in 0.000 seconds.

      ,::,`                                                            `.
   .;;;'';;;:                                                          ;;#
  ;;;@+   +;;;  ;;;;;,   ;;;;. ;;;;;, ;;;;      ;;;;   `;;;;;;:        ;;;
 :;;@`     :;;' .;;;@,    ,;@, ,;;;@: .;;;'     .;+;. ;;;@#:';;;      ;;;;'
 ;;;#       ;;;: ;;;'      ;:   ;;;'   ;;;;;     ;#  ;;;@     ;;;     ;+;;'
.;;+        ;;;# ;;;'      ;:   ;;;'   ;#;;;`    ;#  ;;@      `;;+   .;#;;;.
;;;#        :;;' ;;;'      ;:   ;;;'   ;# ;;;    ;# ;;;@       ;;;   ;# ;;;+
;;;#        .;;; ;;;'      ;:   ;;;'   ;# ,;;;   ;# ;;;#       ;;;:  ;@  ;;;
;;;#        .;;' ;;;'      ;:   ;;;'   ;#  ;;;;  ;# ;;;'       ;;;+ ;',  ;;;@
;;;+        ,;;+ ;;;'      ;:   ;;;'   ;#   ;;;' ;# ;;;'       ;;;' ;':::;;;;
`;;;        ;;;@ ;;;'      ;:   ;;;'   ;#    ;;;';# ;;;@       ;;;:,;+++++;;;'
 ;;;;       ;;;@ ;;;#     .;.   ;;;'   ;#     ;;;;# `;;+       ;;# ;#     ;;;'
 .;;;      :;;@  ,;;+     ;+    ;;;'   ;#      ;;;#  ;;;      ;;;@ ;@      ;;;.
  ';;;    ;;;@,   ;;;;``.;;@    ;;;'   ;+      .;;#   ;;;    :;;@ ;;;      ;;;+
   :;;;;;;;[email protected]`     ';;;;;'@    ;;;;;, ;;;;      ;;+    +;;;;;;#@ ;;;;.   .;;;;;;
     .;;#@'         `#@@@:     ;::::; ;::::      ;@      '@@@+   ;:::;    ;::::::
    :;;;;;;.      __      __        .__   __
  .;@[email protected]';;;;;;'  /  \    /  \_____  |  | |  | __ ___________
    `     '#''@` \   \/\/   /\__  \ |  | |  |/ // __ \_  __ \
                  \        /  / __ \|  |_|    <\  ___/|  | \/
                   \__/\  /  (____  /____/__|_ \\___  >__|
                        \/        \/          \/    \/                       

                                 < ENVIRONMENT >                                
                                 ------ o ------                          

 * Build environment:
 --------------------
     Hostname                       : sprout
     Executable                     : walker
     Version                        : 0.1
     Release                        : LA-CC-XX-XXX
     Revision                       : e26d8f8514a11ade687ba460f42dfae5af53d4d6
     CMake build type               : DEBUG
     Asserts                        : on (turn off: CMAKE_BUILD_TYPE=RELEASE)
     Exception trace                : on (turn off: CMAKE_BUILD_TYPE=RELEASE)
     MPI C++ wrapper                : /opt/openmpi/1.8/clang/system/bin/mpicxx
     Underlying C++ compiler        : /usr/bin/clang++-3.5
     Build date                     : Fri Feb  6 06:39:01 MST 2015

 * Run-time environment:
 -----------------------
     Date, time                     : Sat Feb  7 11:58:53 2015
     Work directory                 : /home/jbakosi/code/quinoa/build/clang
     Executable (rel. to work dir)  : Main/walker
     Command line arguments         : '-v -c ../../tmp/ou.q -u 0.9'
     Output                         : verbose (quiet: omit -v)
     Control file                   : ../../tmp/ou.q
     Parsed control file            : success


                                   < FACTORY >                                  
                                   ---- o ----                            

 * Particle properties data layout policy (CMake: LAYOUT):
 ---------------------------------------------------------
     particle-major                

 * Registered differential equations:
 ------------------------------------
     Unique equation types          : 8
     With all policy combinations   : 18

     Legend: equation name : supported policies

     Policy codes:
      * i: initialization policy: R-raw, Z-zero
      * c: coefficients policy: C-const, J-jrrj

     Beta                           : i:RZ, c:CJ
     Diagonal Ornstein-Uhlenbeck    : i:RZ, c:C
     Dirichlet                      : i:RZ, c:C
     Gamma                          : i:RZ, c:C
     Generalized Dirichlet          : i:RZ, c:C
     Ornstein-Uhlenbeck             : i:RZ, c:C
     Skew-Normal                    : i:RZ, c:C
     Wright-Fisher                  : i:RZ, c:C


                                   < PROBLEM >                                  
                                   ---- o ----                            

 * Title: Example problem
 ------------------------

 * Differential equations integrated (1):
 ----------------------------------------
   < Ornstein-Uhlenbeck >
     kind                           : stochastic
     dependent variable             : r
     initialization policy          : R
     coefficients policy            : C
     start offset in particle array : 0
     number of components           : 3
     random number generator        : MKL MRG32K3A
     coeff sigmasq [6, upper tri]   : { 4 2.5 1.1 32 5.6 23 }
     coeff theta [3]                : { 1 2 3 }
     coeff mu [3]                   : { 0 0.5 1 }

 * Output filenames:
 -------------------
     Statistics                     : stat.txt
     PDF                            : pdf

 * Discretization parameters:
 ----------------------------
     Number of time steps           : 18446744073709551615
     Terminate time                 : 5
     Initial time step size         : 0.001

 * Output intervals:
 -------------------
     TTY                            : 1000
     Statistics                     : 2
     PDF                            : 1000

 * Statistical moments and distributions:
 ----------------------------------------
     Estimated statistical moments  : <R1> <R2> <R3> <r1r1> <r1r2> <r1r3> <r2r2> <r2r3> <r3r3> 
     PDFs                           : f2(r1,r2:0.2,0.2) 
     PDF output file type           : gmshbin
     PDF output file policy         : overwrite
     PDF output file centering      : node
     Text floating-point format     : default
     Text precision in digits       : 6

 * Load distribution:
 --------------------
     Virtualization [0.0...1.0]     : 0.9
     Load (number of particles)     : 1000000
     Number of processing elements  : 4
     Number of work units           : 40 (39*25000+25000)

 * Time integration: Differential equations testbed
 --------------------------------------------------
     Legend: it - iteration count
              t - time
             dt - time step size
            ETE - estimated time elapsed (h:m:s)
            ETA - estimated time for accomplishment (h:m:s)
            out - output-saved flags (S: statistics, P: PDFs)
     
      it             t            dt        ETE        ETA   out
 ---------------------------------------------------------------
    1000  1.000000e+00  1.000000e-03  000:04:16  000:17:04  SP
    2000  2.000000e+00  1.000000e-03  000:08:33  000:12:49  SP
    3000  3.000000e+00  1.000000e-03  000:12:51  000:08:34  SP
    4000  4.000000e+00  1.000000e-03  000:17:06  000:04:16  SP
    5000  5.000000e+00  1.000000e-03  000:21:19  000:00:00  SP

 Normal finish, maximum time reached: 5.000000

 * Timers (h:m:s):
 -----------------
     Initial conditions                                                : 0:0:0
     Migration of global-scope data                                    : 0:0:0
     Total runtime                                                     : 0:21:19


[Partition 0][Node 0] End of program

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