ornstein_uhlenbeck_process.hpp 1.97 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
23
        double kolmogorov_constant = 2;
        double epsilon;
24
25

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

sniklas142's avatar
sniklas142 committed
30
        std::vector<std::mt19937_64> gen; 
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
        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,
            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);
48
        inline double energy(double kabs)
49
        {
50
            return this->ou_energy_amplitude * pow(kabs,-5./3);
51
        }
52
53
54

        inline double gamma(double kabs)
        {
55
56
57
58
            //return this->kolmogorov_constant*sqrt(this->kolmogorov_constant/
             //               this->ou_energy_amplitude);
            return 10.*pow(kabs,2./3.)*this->kolmogorov_constant*sqrt(this->kolmogorov_constant/
                           this->ou_energy_amplitude); //TODO take out 10
59
60
61
        }
        

62
        void initialize_B(void);
63

64
65
        void let_converge(void);

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

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

72
73
        void calc_ou_vorticity(void);

74
75
76
77
78

};


#endif