RandomGeostrophicSpectra#

class fridom.nonhydro.initial_conditions.geostrophic_spectra.RandomGeostrophicSpectra(mset: ~fridom.nonhydro.model_settings.ModelSettings, seed=12345, spectral_energy_density=<function geostrophic_energy_spectrum>)[source]#

Bases: State

Random geostrophic state with a given spectral energy density.

Parameters#

msetModelSettings

The model settings (need to be set up).

seedint

Seed for the random number generator (for the phase)

spectral_energy_densitycallable(kx, ky, kz)

Callable that returns the spectral energy density as a function of the wavenumbers kx, ky, and kz.

Examples#

import fridom.nonhydro as nh
# Set up the model settings
grid = nh.grid.cartesian.Grid(
    N=(128, 128, 32), L=(10, 10, 1), 
    periodic_bounds=(False, True, False))
mset = nh.ModelSettings(grid=grid, f0=1, N2=1.0, dsqr=0.2**2)
mset.time_stepper.dt = 0.1
mset.setup()
# Create the initial conditions
ic = nh.initial_conditions
def spectra(kx, ky, kz):
    return ic.geostrophic_energy_spectrum(kx, ky, kz, c=0.2, k0=1.4, d=7)
z = ic.RandomGeostrophicSpectra(mset, spectral_energy_density=spectra) * 0.1
# Create and run the model
model = nh.Model(mset)
model.z = z
model.run(runlen=200.0)
__init__(mset: ~fridom.nonhydro.model_settings.ModelSettings, seed=12345, spectral_energy_density=<function geostrophic_energy_spectrum>)[source]#

Methods

__init__(mset[, seed, spectral_energy_density])

dot(other)

Calculate the dot product of the state with another state.

fft([padding])

Calculate the Fourier transform of the state.

from_netcdf(mset, path)

Read the state from a NetCDF file.

has_nan()

Check if the state contains NaN values.

ifft([padding])

Calculate the inverse Fourier transform of the state.

norm_l2()

Calculate the L2 norm of the state.

norm_of_diff(other)

The norm of the difference between two states.

project(p_vec, q_vec)

Project the state on a (spectral) vector.

sync()

Synchronize the state.

to_netcdf(path)

Write the state to a NetCDF file.

Attributes

arr_dict

Return the dictionary of arrays (not FieldVariables).

b

Buoyancy

cfl

The CFL number.

ekin

The kinetic energy

epot

The potential energy

etot

The total energy

field_list

Return the list of fields.

grid

Return the grid of the model.

linear_pot_vort

Linearized potential vorticity

local_Ro

Local Rossby number

pot_vort

Scaled potential vorticity field.

rel_vort

The relative vorticity

rel_vort_x

X-component of the relative vorticity

rel_vort_y

Y-component of the relative vorticity

rel_vort_z

Z-component of the relative vorticity (Horizontal Vorticity)

u

Velocity in the x-direction.

v

Velocity in the y-direction.

w

Velocity in the z-direction.

xr

State as xarray dataset

xrs

State of sliced domain as xarray dataset