Ian Jauslin
summaryrefslogtreecommitdiff
blob: fb58eaa18832304b06de37d783efaf979a41c8c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Nstrophy is a tool to solve the two-dimensional Navier-Stokes equation as well
as Gallavotti's reversible Navier-Stokes equation and compare them.

**Nstrophy is under active development**

# Building

Compile Nstrophy with
```bash
make
```
which will place a binary at `build/nstrophy`.

The syntax for the execution of Nstrophy is
```bash
./build/nstrophy [-p parameters] [-s savefile] <command>
```

Nstrophy is written in C. The Makefile uses the GNU C Compiler.

Nstrophy depends on `fftw`: [https://fftw.org]


# Commands

The available commands are

* `enstrophy`: to compute the enstrophy, the parameter alpha and
  alpha times the enstrophy. This command prints
  `step_index time average_alpha average_enstrophy average_alphaxenstrophy alpha enstrophy alphaxenstrophy`
  where the averages are running averages over `print_freq` steps.

* `uk`: to compute the Fourier transform of the solution.

* `quiet`: does not print anything, useful for debugging.


# Parameters

The parameters can be specified using the `-p` flag. The parameter string
should be a `;` sperated list of `key=value` pairs. The possible keys are

* `equation`: either `irreverisible` (default) or `reversible`.

* `K` (int, default 16): cutoff in momentum space: -K<=k_i<=K

* `K1` (int, default `K`): cutoff in momentum space for the x component:
  -K<=k_x<=K

* `K2` (int, default `K`): cutoff in momentum space for the y component:
  -K<=k_y<=K

* `N` (int, default smallest power of 2 that is larger than 3`K`): size of fft
  vectors: must be at least 3 times `K` to avoid aliasing.

* `N1` (int, default `N`): same as `N` but only for x component.

* `N2` (int, default `N`): same as `N` but only for y component.

* `nsteps` (long int, default 10000000): number of steps in the computation.
  Set to 0 to keep on going forever.

* `nu` (double, default 0.00048828125): viscosity.

* `delta` (double, default 0.0001220703125): step size.

* `L` (double, default 2pi): size of box.

* `print_freq` (long int, default 1000): only print every `print_freq` steps.

* `starting_time` (long int, default 0): start the computation at this step.

* `driving`: either `zero` for no driving, `test` (default) for a testing
  driving force or `file:<filename>` or `file_txt:<filename>` to read the
  driving force from a file. When using `file:<filename>` the file should be
  binary, whereas with `file_txt:<filename>` it should be plaintext. The binary
  file format is `(double)(double)` for each entry of the driving force,
  excluding kx<0 and kx=0&&ky<=0. The plaintext file format is
  `kx ky real_part imag_part`.

* `init`: either `random` for a random initialization, `gaussian` (default) for
  a Gaussian initial condition or `file:<filename>` or `file_txt:<filename>` to
  read the driving force from a file. When using `file:<filename>` the file
  should be binary, whereas with `file_txt:<filename>` it should be plaintext.
  The binary file format is `(double)(double)` for each entry of the driving
  force, excluding kx<0 and kx=0&&ky<=0. The plaintext file format is
  `kx ky real_part imag_part`.

* `init_en` (double, default 1.54511597324389e+02): initial value of the energy if
  `equation=irreversible` or of the enstrophy if `equation=reversible`.

* `random_seed` (int, default ): seed for random initialization.

* `algorithm`: either `RK4` for Runge-Kutta 4, or `RK2` for Runge-Kutta 2.


# Interrupting/resuming the computation

The computation can be interrupted by sending Nstrophy the `SIGINT` signal
(e.g. by pressing `Ctrl-C`.) When Nstrophy receives the `SIGINT` signal, it
finishes its current step and writes the value of uk, either to `savefile` if
such a file was specified on the command line (using the `-s` flag), or to
`stderr`. In addition, when a `savefile` is specified it writes the command
that needs to be used to resume the computation (which essentially just sets
the appropriate `starting_time` and `init:file:<savefile>` parameters. The data
written to the `savefile` is binary.


# License
Nstrophy is released under the Apache 2.0 license.

Copyright 2017-2023 Ian Jauslin