ornstein_uhlenbeck_process.hpp 1.82 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef ORNSTEIN_UHLENBECK_PROCESS_HPP
#define ORNSTEIN_UHLENBECK_PROCESS_HPP

#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "field.hpp"
#include <random>

extern int myrank, nprocs;

template <typename rnumber, field_backend be>
class ornstein_uhlenbeck_process{
    public:
        char name[256];

        int iteration;
        double ou_kmin_squ;
        double ou_kmax_squ;
        double ou_energy_amplitude;
22
        double ou_gamma_factor;
23
24
        double kolmogorov_constant = 2;
        double epsilon;
25
26

        field<rnumber,be,THREE> *ou_field;
27
        field<rnumber,be,THREE> *ou_field_vort;
28
29
        field<rnumber,be,THREExTHREE> *B;
        kspace<be,SMOOTH> *kk;
Niklas Schnierstein's avatar
Niklas Schnierstein committed
30

sniklas142's avatar
sniklas142 committed
31
        std::vector<std::mt19937_64> gen; 
32
33
34
35
36
37
38
39
40
41
        std::normal_distribution<double> d{0,1};

        ornstein_uhlenbeck_process(
            const char *NAME,
            int nx,
            int ny,
            int nz,
            double ou_kmin,
            double ou_kmax,
            double ou_energy_amplitude,
42
            double ou_gamma_factor,
43
44
45
46
47
48
49
            double DKX = 1.0,
            double DKY = 1.0,
            double DKZ = 1.0,
            unsigned FFTW_PLAN_RIGOR = FFTW_MEASURE);
        ~ornstein_uhlenbeck_process(void);

        void step(double dt);
50
        inline double energy(double kabs)
51
        {
52
            return this->ou_energy_amplitude * pow(kabs,-5./3);
53
        }
54
55
56

        inline double gamma(double kabs)
        {
57
            return this->ou_gamma_factor*pow(kabs,2./3.)*sqrt(this->ou_energy_amplitude);
58
59
60
        }
        

61
        void initialize_B(void);
62

63
64
        void let_converge(void);

65
        void add_to_field_replace(
66
          field<rnumber,be,THREE> *src, std::string uv);
67

sniklas142's avatar
sniklas142 committed
68
69
70
        void strip_from_field(
          field<rnumber, be, THREE> *src);

71
72
        void calc_ou_vorticity(void);

73
74
75
76
77

};


#endif