2023-05-10 19:29:49 -04:00
|
|
|
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
|
2023-06-14 14:20:07 -04:00
|
|
|
./build/nstrophy [-p parameters] [-s savefile] [-u u_outfile] [-t nthreads] <command>
|
2023-05-10 19:29:49 -04:00
|
|
|
```
|
2023-06-14 14:19:27 -04:00
|
|
|
* `parameters` is a list of parameters for the computation, see
|
|
|
|
[Parameters](#parameters)
|
|
|
|
|
|
|
|
* `savefile` is a file where the last step of the computation is saved in
|
|
|
|
binary format so that the computation can be resumed after it has terminated,
|
|
|
|
see
|
|
|
|
[Interrupting and resuming the computation](#interrupting-and-resuming-the-computation).
|
|
|
|
|
|
|
|
* `u_outfile` is a file to which the final u is written in plain text format,
|
|
|
|
which can be used as an initial condition for a future computation.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2023-06-14 14:20:07 -04:00
|
|
|
* `nthreads` is the number of threads used to compute Fast Fourier Transforms.
|
|
|
|
|
2023-05-10 19:29:49 -04:00
|
|
|
Nstrophy is written in C. The Makefile uses the GNU C Compiler.
|
|
|
|
|
|
|
|
Nstrophy depends on `fftw`: [https://fftw.org]
|
|
|
|
|
|
|
|
|
|
|
|
# Commands
|
|
|
|
|
|
|
|
The available commands are
|
|
|
|
|
2023-05-10 19:37:48 -04:00
|
|
|
* `enstrophy`: to compute the enstrophy and various other observables. This
|
|
|
|
command prints
|
2024-10-15 11:45:28 -04:00
|
|
|
```step_index time average(alpha) average(energy) average(enstrophy) alpha energy enstrophy```
|
2023-05-16 00:07:38 -04:00
|
|
|
where the averages are running averages over `print_freq`. In addition, if
|
|
|
|
the algorithm has an adaptive step, an extra column is printed with `delta`.
|
2024-10-15 11:45:28 -04:00
|
|
|
In addition, if alpha has a negative value (even in between `print_freq`
|
|
|
|
intervals), a line is printed with the information.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2025-01-31 11:08:20 -05:00
|
|
|
* `lyapunov`: to compute the Lyapunov exponents. This command prints
|
|
|
|
```time instantaneous_lyapunov lyapunov```
|
|
|
|
where `instantaneous_lyapunov` is computed from the tangent flow only between
|
|
|
|
the given time and the previous one.
|
|
|
|
|
2023-05-10 19:29:49 -04:00
|
|
|
* `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.
|
|
|
|
|
2023-05-16 00:00:18 -04:00
|
|
|
* `final_time` (double, default 100000): time at which to end the computation.
|
|
|
|
Set to <0 to keep on going forever.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
|
|
|
* `nu` (double, default 0.00048828125): viscosity.
|
|
|
|
|
|
|
|
* `delta` (double, default 0.0001220703125): step size.
|
|
|
|
|
|
|
|
* `L` (double, default 2pi): size of box.
|
|
|
|
|
2023-05-16 00:00:18 -04:00
|
|
|
* `print_freq` (double, default 1): only print when time crosses integer
|
|
|
|
multiples of `print_freq`.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2023-05-16 00:00:18 -04:00
|
|
|
* `starting_time` (double, default 0): starting time.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
|
|
|
* `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`.
|
|
|
|
|
2024-12-11 15:48:11 -05:00
|
|
|
* `init_energy` (double, default is to not rescale the initial condition, is
|
|
|
|
incompatible with `init_enstrophy`): enforce a value for the energy of the
|
|
|
|
initial condition.
|
|
|
|
|
|
|
|
* `init_enstrophy` (double, default is to not rescale the initial condition, is
|
|
|
|
incompatible with `init_energy`): enforce a value for the enstrophy of the
|
|
|
|
initial condition.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
|
|
|
* `random_seed` (int, default ): seed for random initialization.
|
|
|
|
|
2023-05-17 17:41:00 -04:00
|
|
|
* `algorithm`: fixed step methods: `RK4` for Runge-Kutta 4, `RK2` for
|
|
|
|
Runge-Kutta 2.
|
|
|
|
adaptive step methods: `RKF45` for Runge-Kutta-Fehlberg (order
|
|
|
|
4), `RKDP54` for Runge-Kutta-Dormand-Prince (order 5), `RKBS32` for
|
|
|
|
Runge-Kutta-Bogacki-Shampine (order 3).
|
2023-05-15 20:29:06 -04:00
|
|
|
|
|
|
|
* `adaptive_tolerance` (double, default 1e-11): when using an adaptive step
|
|
|
|
method, this is the maximal allowed relative error.
|
|
|
|
|
|
|
|
* `adaptive_factor` (double, default 0.9): when using the RKF45 method, the
|
|
|
|
step gets adjusted by `factor*delta*(tolerance/error)^(1/5)`.
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2023-06-13 18:45:19 -04:00
|
|
|
* `max_delta` (double, default 1e-2): when using the adaptive step, do not
|
|
|
|
exceet `delta_max`.
|
|
|
|
|
2024-11-18 17:09:17 -05:00
|
|
|
* `adaptive_cost`: cost function to use to estimate the error of the adaptive
|
|
|
|
method: `L1` (default) for the normalized L1 norm, `k3` for the normalized L1
|
|
|
|
norm of f_k/|k|^3, `k32` for the normalized L1 norm, `enstrophy` for the
|
|
|
|
enstrophy, `alpha` for alpha.
|
2023-06-13 23:56:35 -04:00
|
|
|
|
2023-06-29 16:58:33 -04:00
|
|
|
* `keep_en_cst` (0 or 1, default 0): impose that the enstrophy is constant at
|
|
|
|
each step (only really useful for the reversible equation).
|
|
|
|
|
2024-11-07 14:39:03 -05:00
|
|
|
* `print_alpha` (0 or 1, default 0): if this is set to 1, then whenever alpha
|
|
|
|
is negative, its value is printed as a comment.
|
|
|
|
|
2025-01-31 11:08:20 -05:00
|
|
|
* `lyapunov_reset` (double, default: `print_freq`): if this is set, then, when
|
|
|
|
computing the Lyapnuov exponents, the tangent flow will renormalize itself at
|
|
|
|
times proportional to `lyapunov_reset`. This option is incompatible with
|
|
|
|
`lyapunov_maxu`.
|
|
|
|
|
|
|
|
* `lyapunov_maxu` (double, default: unset): if this is set, then, when
|
|
|
|
computing the Lyapnuov exponents, the tangent flow will renormalize itself
|
|
|
|
whenever the norm of the tangent flow exceeds `lyapunov_maxu`. This option
|
|
|
|
is incompatible with `lyapunov_reset`.
|
|
|
|
|
|
|
|
* `algorithm_lyapunov`: the algorithm used to integrate the tangent flow. Can
|
|
|
|
be `RK4` for Runge-Kutta 4 (default) or `RK2` for Runge-Kutta 2. Adaptive
|
|
|
|
step algorithms cannot be used for the tangent flow.
|
|
|
|
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2023-06-14 14:19:27 -04:00
|
|
|
# Interrupting and resuming the computation
|
2023-05-10 19:29:49 -04:00
|
|
|
|
2025-01-31 11:08:20 -05:00
|
|
|
The `enstrophy` 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
|
2023-05-10 19:29:49 -04:00
|
|
|
`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.
|
2023-05-10 19:33:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
# License
|
|
|
|
Nstrophy is released under the Apache 2.0 license.
|
|
|
|
|
2024-10-15 11:47:13 -04:00
|
|
|
Copyright 2017-2024 Ian Jauslin
|