SpECTRE  v2022.05.05
Burgers::AnalyticData::Sinusoid Class Reference

Analytic data (with an "exact" solution known) that is periodic over the interval \([0,2\pi]\). More...

#include <Sinusoid.hpp>

Public Types

using options = tmpl::list<>

Public Member Functions

 Sinusoid (const Sinusoid &)=default
Sinusoidoperator= (const Sinusoid &)=default
 Sinusoid (Sinusoid &&)=default
Sinusoidoperator= (Sinusoid &&)=default
template<typename T >
Scalar< T > u (const tnsr::I< T, 1 > &x) const
tuples::TaggedTuple< Tags::Uvariables (const tnsr::I< DataVector, 1 > &x, tmpl::list< Tags::U >) const
void pup (PUP::er &p)

Static Public Attributes

static constexpr Options::String help

Detailed Description

Analytic data (with an "exact" solution known) that is periodic over the interval \([0,2\pi]\).

The initial data is given by:

\begin{align} u(x, 0) = \sin(x) \end{align}

At future times the analytic solution can be found by solving the transcendental equation [61]

\begin{align} \label{eq:transcendental burgers periodic} \mathcal{F}=\sin\left(x-\mathcal{F}t\right) \end{align}

on the interval \(x\in(0,\pi)\). The solution from \(x\in(\pi,2\pi)\) is given by \(\mathcal{F}(x, t)=-\mathcal{F}(2\pi-x,t)\). The transcendental equation \((\ref{eq:transcendental burgers periodic})\) can be solved with a Newton-Raphson iterative scheme. Since this can be quite sensitive to the initial guess we implement this solution as analytic data. The python code below can be used to compute the analytic solution if desired.

At time \(1\) the solution develops a discontinuity at \(x=\pi\) followed by the amplitude of the solution decaying over time.

We have rescaled \(x\) and \(t\) by \(\pi\) compared to [61].
import numpy as np
from scipy.optimize import newton
# x_grid is a np.array of positions at which to evaluate the solution
def burgers_periodic(x_grid, time):
def opt_fun(F, x, t):
return np.sin((x - F * t)) - F
results = []
for i in range(len(x_grid)):
x = x_grid[i]
greater_than_pi = False
if x > np.pi:
x = x - np.pi
x = -x
x = x + np.pi
greater_than_pi = True
guess = 0.0
if len(results) > 0:
if results[-1] < 0.0:
guess = -results[-1]
guess = results[-1]
res = newton(lambda F: opt_fun(F, x, time), x0=guess)
if greater_than_pi:
return np.asarray(results)

Member Data Documentation

◆ help

constexpr Options::String Burgers::AnalyticData::Sinusoid::help
Initial value:
"A solution that is periodic over the interval [0,2pi]. The solution "
"starts as a sinusoid: u(x,0) = sin(x) and develops a "
"discontinuity at x=pi and t=1."}

The documentation for this class was generated from the following file: