implementations.problem_classes.Burgers module

class Burgers1D(N=64, epsilon=0.1, BCl=1, BCr=-1, f=0, mode='T2U', **kwargs)[source]

Bases: GenericSpectralLinear

See https://en.wikipedia.org/wiki/Burgers’_equation for the equation that is solved. Discretization is done with a Chebychev method, which requires a first order derivative formulation. Feel free to do a more efficient implementation using an ultraspherical method to avoid the first order business.

Parameters:
  • N (int) – Spatial resolution

  • epsilon (float) – viscosity

  • BCl (float) – Value at left boundary

  • BCr (float) – Value at right boundary

  • f (int) – Frequency of the initial conditions

  • mode (str) – ‘T2U’ or ‘T2T’. Use ‘T2U’ to get sparse differentiation matrices

dtype_f

alias of imex_mesh

dtype_u

alias of mesh

eval_f(u, *args, **kwargs)[source]

Abstract interface to RHS computation of the ODE

Parameters:
  • u (dtype_u) – Current values.

  • t (float) – Current time.

Returns:

f – The RHS values.

Return type:

dtype_f

get_fig()[source]

Get a figure suitable to plot the solution of this problem.

Returns:

self.fig

Return type:

matplotlib.pyplot.figure.Figure

plot(u, t=None, fig=None, comp='u')[source]

Plot the solution.

Parameters:
  • u (dtype_u) – Solution to be plotted

  • t (float) – Time to display at the top of the figure

  • fig (matplotlib.pyplot.figure.Figure, optional) – Figure with the same structure as a figure generated by self.get_fig. If none is supplied, a new figure will be generated.

Return type:

None

u_exact(t=0, *args, **kwargs)[source]
class Burgers2D(nx=64, nz=64, epsilon=0.1, fux=2, fuz=1, mode='T2U', **kwargs)[source]

Bases: GenericSpectralLinear

See https://en.wikipedia.org/wiki/Burgers’_equation for the equation that is solved. This implementation is discretized with FFTs in x and Chebychev in z.

Parameters:
  • nx (int) – Spatial resolution in x direction

  • nz (int) – Spatial resolution in z direction

  • epsilon (float) – viscosity

  • BCl (float) – Value at left boundary

  • BCr (float) – Value at right boundary

  • fux (int) – Frequency of the initial conditions in x-direction

  • fuz (int) – Frequency of the initial conditions in z-direction

  • mode (str) – ‘T2U’ or ‘T2T’. Use ‘T2U’ to get sparse differentiation matrices

compute_vorticity(u)[source]
dtype_f

alias of imex_mesh

dtype_u

alias of mesh

eval_f(u, *args, **kwargs)[source]

Abstract interface to RHS computation of the ODE

Parameters:
  • u (dtype_u) – Current values.

  • t (float) – Current time.

Returns:

f – The RHS values.

Return type:

dtype_f

get_fig()[source]

Get a figure suitable to plot the solution of this problem

Returns:

self.fig

Return type:

matplotlib.pyplot.figure.Figure

plot(u, t=None, fig=None, vmin=None, vmax=None)[source]

Plot the solution. Please supply a figure with the same structure as returned by self.get_fig.

Parameters:
  • u (dtype_u) – Solution to be plotted

  • t (float) – Time to display at the top of the figure

  • fig (matplotlib.pyplot.figure.Figure) – Figure with the correct structure

Return type:

None

u_exact(t=0, *args, noise_level=0, **kwargs)[source]