gstools.field.generator.IncomprRandMeth
- class gstools.field.generator.IncomprRandMeth(model, mean_velocity=1.0, mode_no=1000, seed=None, verbose=False, sampling='auto', **kwargs)[source]
Bases:
RandMeth
RandMeth for incompressible random vector fields.
- Parameters
model (
CovModel
) – covariance modelmean_velocity (
float
, optional) – the mean velocity in x-directionmode_no (
int
, optional) – number of Fourier modes. Default:1000
seed (
int
orNone
, optional) – the seed of the random number generator. If “None”, a random seed is used. Default:None
verbose (
bool
, optional) – State if there should be output during the generation. Default:False
sampling (
str
, optional) –Sampling strategy. Either
“auto”: select best strategy depending on given model
“inversion”: use inversion method
“mcmc”: use mcmc sampling
**kwargs – Placeholder for keyword-args
Notes
The Randomization method is used to generate isotropic spatial incompressible random vector fields characterized by a given covariance model. The equation is [Kraichnan1970]:
where:
: mean velocity in direction
: fourier mode number
: random samples from a normal distribution
: samples from the spectral density distribution of the covariance model
: the projector ensuring the incompressibility
References
- Kraichnan1970
Kraichnan, R. H., “Diffusion by a random velocity field.”, The physics of fluids, 13(1), 22-31., (1970)
- Attributes
mode_no
int
: Number of modes in the randomization method.model
CovModel
: Covariance model of the spatial random field.name
str
: Name of the generator.sampling
str
: Sampling strategy.seed
int
: Seed of the master RNG.value_type
str
: Type of the field values (scalar, vector).verbose
bool
: Verbosity of the generator.
Methods
__call__
(pos[, add_nugget])Calculate the random modes for the randomization method.
get_nugget
(shape)Generate normal distributed values for the nugget simulation.
reset_seed
([seed])Recalculate the random amplitudes and wave numbers with the given seed.
update
([model, seed])Update the model and the seed.
- __call__(pos, add_nugget=True)[source]
Calculate the random modes for the randomization method.
This method calls the summate_incompr_* Cython methods, which are the heart of the randomization method. In this class the method contains a projector to ensure the incompressibility of the vector field.
- Parameters
pos ((d, n),
numpy.ndarray
) – the position tuple with d dimensions and n points.add_nugget (
bool
) – Whether to add nugget noise to the field.
- Returns
the random modes
- Return type
- get_nugget(shape)
Generate normal distributed values for the nugget simulation.
- Parameters
shape (
tuple
) – the shape of the summed modes- Returns
nugget – the nugget in the same shape as the summed modes
- Return type
- reset_seed(seed=nan)
Recalculate the random amplitudes and wave numbers with the given seed.
- Parameters
seed (
int
orNone
ornumpy.nan
, optional) – the seed of the random number generator. IfNone
, a random seed is used. Ifnumpy.nan
, the actual seed will be kept. Default:numpy.nan
Notes
Even if the given seed is the present one, modes will be recalculated.
- update(model=None, seed=nan)
Update the model and the seed.
If model and seed are not different, nothing will be done.
- property seed
Seed of the master RNG.
Notes
If a new seed is given, the setter property not only saves the new seed, but also creates new random modes with the new seed.
- Type