fluidsim.base.forcing.specific
Forcing schemes (fluidsim.base.forcing.specific
)
Provides:
- class fluidsim.base.forcing.specific.SpecificForcing(sim)[source]
Bases:
object
Base class for specific forcing
- class fluidsim.base.forcing.specific.SpecificForcingPseudoSpectralSimple(sim)[source]
Bases:
SpecificForcing
Specific forcing for pseudo-spectra solvers
- class fluidsim.base.forcing.specific.InScriptForcingPseudoSpectral(sim)[source]
Bases:
SpecificForcingPseudoSpectralSimple
Forcing maker for forcing defined by the user in the launching script
- class fluidsim.base.forcing.specific.SpecificForcingPseudoSpectralCoarse(sim)[source]
Bases:
SpecificForcing
Specific forcing for pseudo-spectra solvers
- static _check_forcing_shape(shape_forcing, shape)[source]
Check if shape of the forcing array exceeds the shape of the global array.
- Parameters:
- shape_forcing: array-like
A single-element array containing index of largest forcing wavenumber or a tuple indicating shape of the forcing array.
- shape: array-like
A tuple indicating the shape of an array or Operators instance.
- class fluidsim.base.forcing.specific.InScriptForcingPseudoSpectralCoarse(sim)[source]
Bases:
SpecificForcingPseudoSpectralCoarse
Forcing maker for forcing defined by the user in the launching script
- class fluidsim.base.forcing.specific.NormalizedForcing(sim)[source]
Bases:
SpecificForcingPseudoSpectralCoarse
Specific forcing normalized to keep constant injection
- classmethod _complete_params_with_default(params)[source]
This static method is used to complete the params container.
- normalize_forcingc_part_k(fvc_fft, vc_fft, key_forced=None)[source]
Modify the array fvc_fft to fixe the injection rate.
To be called only with proc 0.
- Parameters:
- fvc_fftndarray
The non-normalized forcing at the coarse resolution.
- vc_fftndarray
The forced variable at the coarse resolution.
- normalize_forcingc_2nd_degree_eq(fvc_fft, vc_fft, key_forced=None)[source]
Modify the array fvc_fft to fixe the injection rate.
To be called only with proc 0.
We consider that we force a variable \(\hat\alpha\) with a forcing \(\hat f\).
\[\partial_t \hat\alpha = \hat f\]We want to normalize the forcing \(\hat f\) such that the average over the time step of the injection of a quadratic quantity be equal to
self.forcing_rate
(\(P\)). Let’s consider that the time step starts at \(t=0\) and that the time increment is \(\delta t\).For simplicity, we first consider that the quadratic quantity is the quadratic quantity of the forced variable \(\hat\alpha\). Note that this function supports other quadratic quantities (for details, read the code). The average of the injection rate over the time step is:
\[P = \int_0^{\delta t} \frac{dt}{\delta t} \sum_{\mathbf k} \partial_t \frac{|\hat\alpha^2|}{2} = \int_0^{\delta t} \frac{dt}{\delta t} \sum_{\mathbf k} \hat\alpha^* \hat f\]We compute an approximation at first order in \(\delta t\) so that we can normalize the forcing such that the value given by this approximation is constant for all time steps. For each time step, the forcing \(\hat f\) is constant in time. At first order in \(\delta t\), we have during the time step:
\[\hat\alpha(t) \simeq \hat\alpha(0) + \hat f t\]and we get
\[P \simeq \hat f \int_0^{\delta t} \frac{dt}{\delta t} \sum_{\mathbf k} (\hat\alpha(0)^* + \hat f^* t) = \sum_{\mathbf k} \hat\alpha(0)^* \hat f + \sum_{\mathbf k} \frac{|\hat f|^2}{2} \delta t\]The final forcing \(\hat f\) is proportional to the “random” forcing \(\hat f_r\):
\[\hat f = R \hat f_r\]We solve a second-order equation to get the value of the coefficient \(R\):
\[\left(\sum_{\mathbf k} \frac{|\hat f_r|^2}{2} \delta t\right) R^2 + \left(\sum_{\mathbf k} \hat\alpha(0)^* \hat f_r\right) R - P = 0\]- Parameters:
- fvc_fftndarray
The non-normalized forcing at the coarse resolution.
- vc_fftndarray
The forced variable at the coarse resolution.
- coef_normalization_from_abc(a, b, c)[source]
Compute the roots of a quadratic equation
Compute the roots given the coefficients
a
,b
andc
. Then, select one of the roots based on a criteria and return it.Notes
Set params.forcing.normalized.which_root to choose the root with:
minabs
: minimum absolute valuefirst
: root with positive sign before discriminantsecond
: root with negative sign before discriminantpositive
: positive root
- class fluidsim.base.forcing.specific.Proportional(sim)[source]
Bases:
SpecificForcingPseudoSpectralCoarse
Specific forcing proportional to the forced variable
- class fluidsim.base.forcing.specific.RandomSimplePseudoSpectral(sim)[source]
Bases:
NormalizedForcing
Random normalized forcing
Bases:
RandomSimplePseudoSpectral
Time correlated random normalized forcing
This static method is used to complete the params container.
Return a coarse forcing as a linear combination of 2 random arrays
Compute the new random coarse forcing arrays when necessary.
Return a coarse forcing as a linear combination of 2 random arrays
Classes
Forcing maker for forcing defined by the user in the launching script |
|
Forcing maker for forcing defined by the user in the launching script |
|
|
Specific forcing normalized to keep constant injection |
|
Specific forcing proportional to the forced variable |
Random normalized forcing |
|
|
Base class for specific forcing |
Specific forcing for pseudo-spectra solvers |
|
Specific forcing for pseudo-spectra solvers |
|
Time correlated random normalized forcing |