Tempus Version of the Day
Time Integration
Loading...
Searching...
No Matches
Example 0: Basic Problem

This example provides a minimal application code for integrating the van der Pol problem using a hand-written Forward Euler time loop. It does not yet use Tempus, Thyra, or other Trilinos abstractions for the state or time integration algorithm.

The purpose of this example is to establish the baseline structure used throughout the tutorial sequence. Later examples introduce Tempus and Trilinos capabilities one step at a time while preserving the same basic problem setup whenever possible.

van der Pol Problem

The scaled explicit first-order ODE is

\begin{eqnarray*}
  \dot{x}_0(t) & = & x_1(t) \\
  \dot{x}_1(t) & = & \left[(1-x_0^2)x_1-x_0\right]/\epsilon
\end{eqnarray*}

with initial conditions

\begin{eqnarray*}
  x_0(0) & = & 2 \\
  x_1(0) & = & 0.
\end{eqnarray*}

For the model definition and additional details, see Tempus_Test::VanDerPolModel and van der Pol Model.

Outline

This example demonstrates the basic structure of an application-level time integration loop:

  • declare the state and its time derivative
  • set the initial conditions
  • advance the solution from the initial time to the final time
    • select the timestep size
    • evaluate the right-hand side of the governing equations
    • apply the Forward Euler update
    • check a simple pass/fail criterion
    • accept the step and promote the solution

The regression check at the end of the run is secondary to the tutorial discussion and can be ignored on a first reading.

In this version:

  • the solution is stored in raw C++ arrays,
  • the right-hand side is evaluated directly in the application code,
  • timestep management is handled manually,
  • solution status is tracked with local scalar variables.

The next example replaces raw arrays with Thyra vectors while preserving the same overall algorithmic structure.

Tutorial Overview | Next Example →