RSWE Direct

Module to handle the generic solvers for the RSWE. The point of access is through the solve function.

Functions

  • fine_propagator – computes the full (unaveraged) RSWE by Strang splitting
  • coarse_propagator – access point for averaged RSWE timestepping
  • dissipative_exponential – (hyper)viscosity operator
  • exp_L_exp_D – exponentiated sum of linear terms (advective and dissipative)
  • strang_splitting – generic strang splitting method
  • compute_nonlinear – computes the nonlinear terms for the perturbed RSWE
  • filter_kernel_exp – provides a normalised exponential kernel of integration
  • compute_average_force – computes the averaged nonlinearity (RHS)
  • solve – point of access for this library
Authors: Adam G. Peddle, Terry Haut
Version: 1.0
rswe_direct.compute_average_force(U_hat, control, st, expInt)[source]

This method computed the wave-averaged solution for use with the APinT coarse timestepping.

The equation solved by this method is a modified equation for a slowly-varying solution (see module header, above). The equation solved is:

\[\bar{N}(\bar{u}) = \sum \limits_{m=0}^{M-1} \rho(s/T_{0})e^{sL}N(e^{-sL}\bar{u}(t))\]

where \(\rho\) is the smoothing kernel (filter_kernel).

Parameters

  • U_hat : the known solution at the current timestep
  • control : control object
  • st : spectral toolbox object
  • expInt : exponential integrator for linear term

Returns

  • U_hat_averaged : The predicted averaged solution at the next timestep

Notes

The smooth kernel is chosen so that the length of the time window over which the averaging is performed is as small as possible and the error from the trapezoidal rule is as small as possible.

See Also

filter_kernel

rswe_direct.compute_nonlinear(U_hat, control, st, expInt=None)[source]

Function to compute the nonlinear terms of the RSWE. Calls through to some spectral toolbox methods to implement derivatives and nonlinear multiplication.

This function implements the simple solution to the problem, with none of the wave averaging.

Parameters

  • U_hat : the components of the unknown vector in Fourier space, ordered u, v, h
  • control : control object
  • st : spectral toolbox object
  • expInt : exponential integrator object

Returns

  • U_NL_hat : the result of the multiplication in Fourier space

See Also

compute_average_force

rswe_direct.dissipative_exponential(control, expInt, U_hat, t)[source]

Implements dissipation through a 4th-order hyperviscosity operator and matrix exponential.

Parameters

  • control : control object
  • expInt : exponential integrator for linear term
  • U_hat : the known solution at the current timestep
  • t : the timestep taken

Returns

  • U_hat_sp : The solution at the next timestep by dissipation
rswe_direct.exp_L_exp_D(control, expInt, U_hat, t)[source]

Call-through method for applying the linear solution and the dissipative term. (Both via exponential integrator)

Parameters

  • control : control object
  • expInt : exponential integrator for linear term
  • U_hat : the known solution at the current timestep
  • t : the timestep taken

Returns

  • U_hat_sp : The solution propagated by L and D
rswe_direct.filter_kernel_exp(M, s)[source]

Smooth integration kernel.

This kernel is used for the integration over the fast waves. It is formulated as:

\[\rho(s) \approx \exp(-50*(s-0.5)^{2})\]

and is normalised to have a total integral of unity. This method is used for the wave averaging, which is performed by self.compute_average_force.

Parameters

  • M : The interval over which the average is to be computed
  • s : The sample in the interval

Returns

The computed kernel value at s.

rswe_direct.solve(solver_name, control, st, expInt, u_init, invert_fft=True)[source]

Main point of access for the RSWE solver library. Handles either real-space input or Fourier-space input via the ivnert_fft flag.

Parameters

  • solver_name : string ‘fine_propagator’ or ‘coarse_propagator’ to
    toggle solvers
  • control : control object
  • st : spectral toolbox objecy
  • expInt : appropriate exponential integrator (contructed externally for speed)
  • u_init : the solution at the current timestep, i.e. initial condition
  • invert_fft : flag to switch on FFT-ing. True if u_init is in realspace

Returns

  • out_sols : the solution at the right-side of the time interval

Notes

u_init must be a numpy array of size (3, N_x, N_x) with solution fields along the first rank in the order (u, v, h).

rswe_direct.strang_splitting(U_hat, delta_t, control, expInt, st, linear, nonlinear)[source]

Propagates a solution for arbitrary linear and nonlinear operators over a timestep delta_t by using Strang Splitting.

Parameters

  • U_hat : The known solution at the current timestep, in Fourier space
  • delta_t : the timestep over which the solution is to be predicted
  • control : the control object
  • expInt : the exponential integrator (linear term)
  • st : spectral toolbox object
  • linear : the linear term. May be the same as expInt, but necessary
    for integration with exp_L_exp_D
  • nonlinear : the nonlinear operator being used, i.e. with or without wave averaging

Returns

  • U_hat_new : The computed U_hat at the next timestep