Cyclops Base¶
Library of miscellaneous helper functions for Cyclops init/admin tasks.
Functions¶
- read_ICs : Read initial conditions from the Polvani experiments
- geopotential_transform : Transform the height field from (u,v,h) to skew-Hermitian (u,v,phi)
- inv_geopotential_transform : Transform the height field from skew-Hermitian (u,v,phi) to (u,v,h)
- compute_L_2_error : Compute the L_2 error between two vectors
- compute_L_infty_error : Compute the L_infty (sup-norm) error between two vectors
- h_init : Generate an initially stationary Gaussian height field for testing
-
cyclops_base.compute_L_2_error(U_hat_ref, U_hat_approx, st)[source]¶ Computes and returns the L_2 error.
The L_2 error is defined as:
\[L_{2} = \frac{\sqrt{\sum e^{2}}}{\sqrt{\sum u_{ref}^{2}}}\]where e is the absolute error.
The errors are computed in Fourier space but returned in real space. The returned error is the L_2 error of all three variables together.
The reference solution will generally be the solution at the previous iteration, which is used for measuring convergence.
Parameters
- U_hat_ref : the solution at the previous timestep (or a reference solution)
- U_hat_approx : the solution at the current timestep
- st : spectral toolbox object
Returns
- error : The computed L_2 error
-
cyclops_base.compute_L_infty_error(U_hat_ref, U_hat_approx, st)[source]¶ Compute the L_infty error at a given timestep.
The L_infty error is defined as:
\[L_{\infty} = \max\left|\frac{U_{new}-U_{old}}{U_{old}}\right|\]The errors are computed in Fourier space but returned in real space. The returned error is the greatest of the errors computed for both velocities and the height.
The reference solution will generally be the solution at the previous iteration, which is used for measuring convergence.
Parameters
- U_hat_ref : the solution at the previous timestep (or a reference solution)
- U_hat_approx : the solution at the current timestep
- st : spectral toolbox object
Returns
- error : The computed L_infty error
-
cyclops_base.geopotential_transform(control, h)[source]¶ Transforms the height field from perturbation height to geopotential height (phi) defined as
\[\phi = \frac{gh}{\sqrt{gH_{0}}}.\]This permits a skew-Hermitian formulation for the linear operator.
Parameters
- control : control object
- h : the height field (np.array of size (Nx, Nx))
Returns
- h_out : the geopotential height (np.array of size (Nx, Nx))
-
cyclops_base.h_init(control)[source]¶ This function sets up a Gaussian initial condition for the height field. Initial flow is stationary.
Parameters
- control : control object
Returns
- XX : x-coordinate matrix from the x-coord vector
- YY : y-coordinate matrix from the y-coord vector
- U : initial condition in realspace, sized (3, Nx, Nx) with (u, v, {h || phi}) along the first rank
-
cyclops_base.inv_geopotential_transform(control, h)[source]¶ Inverts the geopotential transform to give the height field in terms of perturbation height.
Parameters
- control : control object
- h : the perturbation geopotential height (np.array(Nx, Nx))
Returns
- h_out : The perturbation height field (np.array(Nx, Nx))
See Also
-geopotential_transform
-
cyclops_base.read_ICs(control, filename, perturbation=True)[source]¶ Read and return initial conditions for the Polvani experiments as provided by Beth Wingate’s code.
Parameters
- control : a control object
- filename : the filename to be read <string>
- perturbation : flag if ICs are not in geopotential perturbation coordinates
Returns
- XX : x-coordinate matrix from the x-coord vector
- YY : y-coordinate matrix from the y-coord vector
- U : initial condition in realspace, sized (3, Nx, Nx) with (u, v, {h || phi}) along the first rank