Exemple #1
0
def make_parameters_simulation(gamma, key_viscosity):
    """ Make parameters of the first simulation. """
    # Parameters simulation
    F = np.sin(pi / 4)
    sigma = 1

    # Create parameters
    params = Simul.create_default_params()

    # Operator parameters
    params.oper.nx = nx
    params.oper.ny = nz = nx // 4
    params.oper.Lx = Lx = 2 * pi
    params.oper.Ly = Lz = Lx * (nz / nx)
    params.oper.NO_SHEAR_MODES = True
    params.oper.coef_dealiasing = 0.6666

    # Forcing parameters
    params.forcing.enable = True
    params.forcing.type = "tcrandom_anisotropic"
    params.forcing.key_forced = "ap_fft"
    params.forcing.nkmax_forcing = nkmax_forcing = 8
    params.forcing.nkmin_forcing = nkmin_forcing = 4

    params.forcing.normalized.constant_rate_of = "energy"

    params.forcing.tcrandom_anisotropic.angle = np.arcsin(F)

    # Compute other parameters (Normalization by the energy..)
    tau_af = 1  # Forcing time equal to 1
    k_f = ((nkmax_forcing + nkmin_forcing) / 2) * max(2 * pi / Lx, 2 * pi / Lz)
    forcing_rate = (1 / tau_af**3) * ((2 * pi) / k_f)**2
    omega_af = 2 * pi / tau_af

    params.N = (gamma / F) * omega_af

    # Choose vis, key_viscosity=key_viscositycosity
    if key_viscosity == "nu_2":
        params.nu_2 = nu_2
    elif key_viscosity == "nu_8":
        params.nu_8 = nu_8
    else:
        raise ValueError(f"{key_viscosity} not known.")

    # Continuation on forcing...
    params.forcing.forcing_rate = forcing_rate
    params.forcing.tcrandom.time_correlation = sigma * (
        pi / (params.N * F))  # time_correlation = wave period

    # Time stepping parameters
    params.time_stepping.USE_CFL = True
    params.time_stepping.t_end = t_end

    # Initialization parameters
    params.init_fields.type = "noise"

    modify_parameters(params)

    return params
Exemple #2
0
def _create_object_params():
    params = Simul.create_default_params()
    try:
        params.N = 1.0
    except AttributeError:
        pass

    # Operator parameters
    params.oper.nx = params.oper.ny = 32
    params.oper.Lx = params.oper.Ly = 2 * pi

    # Forcing parameters
    params.forcing.enable = False
    params.forcing.type = 'tcrandom_anisotropic'

    try:
        params.forcing.tcrandom_anisotropic.angle = '45.0°'
    except AttributeError:
        pass

    params.forcing.nkmin_forcing = 8
    params.forcing.nkmax_forcing = 12

    # Compute \omega_l
    from math import radians
    if "°" in params.forcing.tcrandom_anisotropic.angle:
        angle = params.forcing.tcrandom_anisotropic.angle.split("°")
        angle = float(angle[0])
    else:
        raise ValueError("Angle should be contain the degrees symbol °.")
    omega_l = params.N * np.sin(radians(angle))
    params.forcing.tcrandom.time_correlation = 2 * pi / omega_l

    params.forcing.key_forced = 'ap_fft'

    # Time stepping parameters
    params.time_stepping.USE_CFL = True
    params.time_stepping.USE_T_END = True
    params.time_stepping.t_end = 2.

    # Output parameters
    params.output.HAS_TO_SAVE = False
    params.output.sub_directory = 'tests'

    return params
"""Script for a short simulation with the solver ns2d.strat

"""
import numpy as np
from math import pi

from fluiddyn.util import mpi

from fluidsim.solvers.ns2d.strat.solver import Simul

params = Simul.create_default_params()

gamma = 1.0
nb_wavelength = 2
nz = nb_wavelength * 30 * 2
nx = 6 * nz

params.time_stepping.t_end = 100.0

params.short_name_type_run = "quasi1d"

aspect_ratio = nz / nx
theta = np.arctan(aspect_ratio / nb_wavelength)
F = np.sin(theta)

kf = 2 * pi
omega_af = 2 * pi
forcing_rate = omega_af**3 / kf**2

Lx = 2 * pi / kf * np.sqrt(1 + (nb_wavelength / aspect_ratio)**2)
Lz = aspect_ratio * Lx
Exemple #4
0
def make_parameters_simulation(gamma,
                               F,
                               sigma,
                               nu_8,
                               t_end=10,
                               NO_SHEAR_MODES=False):

    ## Operator parameters
    anisotropy_domain = 4  # anisotropy_domain = nx / nz
    nx = 240
    nz = nx // anisotropy_domain
    Lx = 2 * pi
    Lz = Lx * (nz / nx)  # deltax = deltay

    coef_dealiasing = 0.6666

    # Time stepping parameters
    USE_CFL = True
    deltat0 = 0.0005
    # t_end = 5.

    ## Forcing parameters
    forcing_enable = True
    nkmax_forcing = 8
    nkmin_forcing = 4
    tau_af = 1  # Forcing time equal to 1

    ######################
    #######################

    # Create parameters
    params = Simul.create_default_params()

    # Operator parameters
    params.oper.nx = nx
    params.oper.ny = nz
    params.oper.Lx = Lx
    params.oper.Ly = Lz
    params.oper.NO_SHEAR_MODES = NO_SHEAR_MODES
    params.oper.coef_dealiasing = coef_dealiasing

    # Forcing parameters
    params.forcing.enable = forcing_enable
    params.forcing.type = 'tcrandom_anisotropic'
    params.forcing.key_forced = "ap_fft"
    params.forcing.nkmax_forcing = nkmax_forcing
    params.forcing.nkmin_forcing = nkmin_forcing

    params.forcing.tcrandom_anisotropic.angle = np.arcsin(F)

    # Compute other parameters
    k_f = ((nkmax_forcing + nkmin_forcing) / 2) * max(2 * pi / Lx, 2 * pi / Lz)
    forcing_rate = (1 / tau_af**7) * ((2 * pi) / k_f)**2
    omega_af = 2 * pi / tau_af
    params.N = (gamma / F) * omega_af
    params.nu_8 = nu_8

    # Continuation on forcing...
    params.forcing.forcing_rate = forcing_rate
    params.forcing.tcrandom.time_correlation = sigma * (
        pi / (params.N * F))  # time_correlation = wave period

    # Time stepping parameters
    params.time_stepping.USE_CFL = USE_CFL
    params.time_stepping.deltat0 = deltat0
    params.time_stepping.t_end = t_end

    # Initialization parameters
    params.init_fields.type = "noise"

    modify_parameters(params)

    return params