ornstein_uhlenbeck_process.hpp 1.85 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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 <unordered_map>
#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;

        field<rnumber,be,THREE> *ou_field;
25
        field<rnumber,be,THREE> *ou_field_vort;
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
        field<rnumber,be,THREExTHREE> *B;
        // field<rnumber,be,ONE> *number_of_modes;
        kspace<be,SMOOTH> *kk;
        // std::unordered_map<double,double> map_n_kabs;

        std::random_device rd{};
        std::mt19937 gen{rd()};
        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);
        inline double gamma(double ksqu)
        {
            return this->ou_energy_amplitude * pow(ksqu,1./3.);
        }
        void initialize_B(void);
55

56
57
        void let_converge(void);

58
59
60
61
62
        void add_to_field_gaussian(
          field<rnumber,be,THREE> *src, double param);
        void add_to_field_sharp(
          field<rnumber,be,THREE> *src);
        void add_to_field_replace(
63
          field<rnumber,be,THREE> *src, std::string uv);
64

sniklas142's avatar
sniklas142 committed
65
66
67
        void strip_from_field(
          field<rnumber, be, THREE> *src);

68
69
        void calc_ou_vorticity(void);

70
71
72
73
74

};


#endif