next up previous contents
Next: Example Up: How to use Previous: Thorn writers   Contents


Evolution method writers

If you want to try adding a new evolution method to MoL the simplest way is to use the generic table option to specify it completely in the parameter file - no coding is required at all.

All the generic methods evolve the equation

\begin{displaymath}
\partial_t {\bf q} = {\bf L}({\bf q})
\end{displaymath} (part103)

using the following algorithm for an $N$-step method:
$\displaystyle {\bf q}^{(0)}$ $\textstyle =$ $\displaystyle {\bf q}^n,$  
$\displaystyle {\bf q}^{(i)}$ $\textstyle =$ $\displaystyle \sum_{k=0}^{i-1} \left( \alpha_{ik} {\bf
q}^{(k)} \right) + \Delta t \beta_{i-1} {\bf L} ( {\bf q}^{(i-1)} ),
\qquad i = 1, \dots, N,$ (part104)
$\displaystyle {\bf q}^{n+1}$ $\textstyle =$ $\displaystyle {\bf q}^{(N)}.$  

This method is completely specified by $N$ ( GenericIntermediateSteps) and the $\alpha$ ( GenericAlphaCoeffs) and $\beta$ (GenericBetaCoeffs) arrays. The names in parentheses give the keys in a table that MoL will use. This table is created from the string parameter Generic_Method_Descriptor.

As an example, the standard TVD RK2 method that is implemented both in optimized and generic form is written as

$\displaystyle {\bf q}^{(1)}$ $\textstyle =$ $\displaystyle {\bf q}^n + \Delta t {\bf L} ({\bf q}^n),$ (part105)
$\displaystyle {\bf q}^{n+1}$ $\textstyle =$ $\displaystyle \frac{1}{2} \left( {\bf q}^n + {\bf q}^{(1)} +
\Delta t {\bf L} ({\bf q}^{(1)}) \right).$ (part106)

To implement this using the generic table options, use
methodoflines::MoL_Intermediate_Steps = 2
methodoflines::MoL_Num_Scratch_Levels = 1
methodoflines::Generic_Method_Descriptor = \
           "GenericIntermediateSteps = 2 \
            GenericAlphaCoeffs = { 1.0 0.0 0.5 0.5 } \
            GenericBetaCoeffs = { 1.0 0.5 }"
The number of steps specified in the table must be the same as MoL_Intermediate_Steps, and the number of scratch levels should be at least MoL_Intermediate_Steps - 1.

The generic methods are somewhat inefficient for use in production runs, so it is frequently better to write an optimized version once you are happy with the method. To do this you should

  • write your code into a new file, called from the scheduler under the alias MoL_Add,
  • make certain that at each intermediate step the correct values of cctk_time and cctk_delta_time are set in SetTime.c for mesh refinement, boundary conditions and so on,
  • make certain that you check for the number of intermediate steps in ParamCheck.c.


next up previous contents
Next: Example Up: How to use Previous: Thorn writers   Contents