NS2D solver (fluidsim.solvers.ns2d.solver)

This module provides two classes defining the pseudo-spectral solver 2D incompressible Navier-Stokes equations (ns2d).

class fluidsim.solvers.ns2d.solver.InfoSolverNS2D(**kargs)[source]

Bases: fluidsim.base.solvers.pseudo_spect.InfoSolverPseudoSpectral

Contain the information on the solver ns2d.

Inheritance diagram of InfoSolverNS2D

Init. self by writing the information on the solver.

The function InfoSolverPseudoSpectral._init_root is called. We keep two classes listed by this function:

The other first-level classes for this solver are:

class fluidsim.solvers.ns2d.solver.Simul(params)[source]

Bases: fluidsim.base.solvers.pseudo_spect.SimulBasePseudoSpectral

Pseudo-spectral solver 2D incompressible Navier-Stokes equations.

Inheritance diagram of Simul

alias of InfoSolverNS2D

static _complete_params_with_default(params)[source]

Complete the params container (static method).

tendencies_nonlin(state_spect=None, old=None)[source]

Compute the nonlinear tendencies.



Array containing the state, i.e. the vorticity, in Fourier space. If state_spect, the variables vorticity and the velocity are computed from it, otherwise, they are taken from the global state of the simulation, self.state.

These two possibilities are used during the Runge-Kutta time-stepping.


An array containing the tendencies for the vorticity.


The 2D Navier-Stokes equation can be written as:

\[\partial_t \hat\zeta = \hat N(\zeta) - \sigma(k) \hat \zeta,\]

This function compute the nonlinear term (“tendencies”) \(N(\zeta) = - \mathbf{u}\cdot \mathbf{\nabla} \zeta\).

Default parameters

<params NEW_DIR_RESULTS="True" ONLY_COARSE_OPER="False" beta="0.0" nu_2="0.0"
        nu_4="0.0" nu_8="0.0" nu_m4="0.0" short_name_type_run="">
  <oper Lx="8" Ly="8" NO_SHEAR_MODES="False"
        coef_dealiasing="0.6666666666666666" nx="48" ny="48"
        truncation_shape="cubic" type_fft="default"/>  

  <time_stepping USE_CFL="True" USE_T_END="True" cfl_coef="None" deltat0="0.2"
                 deltat_max="0.2" it_end="10" max_elapsed="None" t_end="10.0"
    <phaseshift_random nb_pairs="1" nb_steps_compute_new_pair="None"/>  


  <init_fields available_types="['from_file', 'from_simul', 'in_script',
               'constant', 'noise', 'jet', 'dipole']" modif_after_init="False"
    <from_file path=""/>  

    <constant value="1.0"/>  

    <noise length="0.0" velo_max="1.0"/>  


  <forcing available_types="['in_script', 'in_script_coarse', 'pseudo_spectral',
           'proportional', 'tcrandom', 'tcrandom_anisotropic']" enable="False"
           forcing_rate="1.0" key_forced="None" nkmax_forcing="5"
           nkmin_forcing="4" type="">
    <milestone nx_max="None">
      <objects diameter="1.0" number="2" type="cylinders"

      <movement type="uniform">
        <uniform speed="1.0"/>  

        <sinusoidal length="1.0" period="1.0"/>  

        <periodic_uniform length="1.0" length_acc="1.0" speed="1.0"/>  



    <normalized constant_rate_of="None" type="2nd_degree_eq"

    <random only_positive="False"/>  

    <tcrandom time_correlation="based_on_forcing_rate"/>  

    <tcrandom_anisotropic angle="45°" kz_negative_enable="False"/>  


  <output HAS_TO_SAVE="True" ONLINE_PLOT_OK="True" period_refresh_plots="1"
    <periods_save increments="0" phys_fields="0" spatial_means="0"
                  spect_energy_budg="0" spectra="0" spectra_multidim="0"/>  

    <periods_print print_stdout="1.0"/>  

    <periods_plot phys_fields="0"/>  

    <phys_fields field_to_plot="rot" file_with_it="False"/>  

    <spectra HAS_TO_PLOT_SAVED="False"/>  

    <spectra_multidim HAS_TO_PLOT_SAVED="False"/>  

    <spatial_means HAS_TO_PLOT_SAVED="False"/>  

    <spect_energy_budg HAS_TO_PLOT_SAVED="False"/>  

    <increments HAS_TO_PLOT_SAVED="False"/>  


  <preprocess enable="False" forcing_const="1.0" forcing_scale="unity"
              init_field_const="1.0" init_field_scale="unity"
              viscosity_const="1.0" viscosity_scale="enstrophy_forcing"


Documentation for params

short_name_type_run: str

A short name of the simulation used to create the directory name.


To be used only when loading a simulation. If True (default), a new directory is created to contain the results of the simulation. If False, the results of the simulation are appended in the old directory.


To be used only when loading a simulation. If True (not default), the operator is created with a very small resolution. It is very fast but then it can not be used to process data.

nu_2: float (default = 0.)

Viscosity coefficient. Used in particular in the method fluidsim.base.solvers.pseudo_spect.SimulBasePseudoSpectral.compute_freq_diss()).

nu_8: float

Hyper-viscous coefficient of order 8. Also used in the method compute_freq_diss.

nu_4: float

Hyper-viscous coefficient of order 4.

nu_m4: float

Hypo-viscous coefficient of order -4. Hypo-viscosity affect more the large scales.

Documentation for params.oper

Documentation for params.time_stepping

See fluidsim.base.time_stepping.base.

USE_T_END: bool (default True)

If True, time step until t > t_end. If False, time step until it >= it_end.

t_end: float

See documentation USE_T_END.

it_end: int

If USE_T_END is False, number of time steps.

USE_CFL: bool (default False)

If True, use an adaptive time step computed in particular with a Courant-Friedrichs-Lewy (CFL) condition.

type_time_scheme: str (default “RK4”)

Type of time scheme. Can be in (“RK2”, “RK4”).

deltat0: float (default 0.2)

If USE_CFL is False, value of the time step.

deltat_max: float (default 0.2)

Maximum value of the time step (useful when USE_CFL is True).

cfl_coef: float (default None)

If not None, clf_coef used in the CFL condition. If None, the value is choosen taking into account the time scheme.

max_elapsed: number or str (default None)

If not None, the computation stops when the elapsed time becomes larger than max_elapsed. Can be a number (in seconds) or a string (formated as “%H:%M:%S”).

Documentation for params.time_stepping.phaseshift_random

Documentation for params.init_fields

See fluidsim.base.init_fields.

type: str (default constant)

Name of the initialization method.

available_types: list

Actually not a parameter; just a hint to set type.

modif_after_init: bool (default False)

Used internally when reloading some simulations.

Documentation for params.init_fields.from_file

path: str

Documentation for params.init_fields.constant

value: float (default 1.)

Documentation for params.init_fields.noise

velo_max: float (default 1.)

Maximum velocity.

length: float (default 0.)

The smallest (cutoff) scale in the noise.

Documentation for params.forcing

How the forcing is normalized

Documentation for params.forcing.milestone

Documentation for params.forcing.milestone.objects
Documentation for params.forcing.milestone.movement
Documentation for params.forcing.milestone.movement.uniform
Documentation for params.forcing.milestone.movement.sinusoidal
Documentation for params.forcing.milestone.movement.periodic_uniform

Documentation for params.forcing.normalized

Documentation for params.forcing.random

Documentation for params.forcing.tcrandom

Documentation for params.forcing.tcrandom_anisotropic

Documentation for params.output

See fluidsim.output.base

ONLINE_PLOT_OK: bool (default: True)

If True, the online plots are enabled.

period_refresh_plots: float (default: 1)

Period of refreshment of the online plots.

HAS_TO_SAVE: bool (default: True)

If False, nothing new is saved in the directory of the simulation.

sub_directory: str (default: “”)

A name of a subdirectory where the directory of the simulation is saved.

Documentation for params.output.periods_save

Periods (float, in equation time) to set when the specific outputs are saved.

Documentation for params.output.periods_print

Periods (float, in equation time) to set when the printing specific outputs are called.

Documentation for params.output.periods_plot

Periods (float, in equation time) to set when the plots of the specific outputs are called.

Documentation for params.output.phys_fields

Documentation for params.output.spectra

Documentation for params.output.spectra_multidim

Documentation for params.output.spatial_means

Documentation for params.output.spect_energy_budg

Documentation for params.output.increments

Documentation for params.preprocess



Contain the information on the solver ns2d.


Pseudo-spectral solver 2D incompressible Navier-Stokes equations.