Ice Sheet System Model  4.18
Code documentation
Functions
ODE1.cpp File Reference
#include <math.h>
#include "./types.h"
#include "../Exceptions/exceptions.h"

Go to the source code of this file.

Functions

IssmDouble ODE1 (IssmDouble alpha, IssmDouble beta, IssmDouble Si, IssmDouble dt, int method)
 

Function Documentation

◆ ODE1()

IssmDouble ODE1 ( IssmDouble  alpha,
IssmDouble  beta,
IssmDouble  Si,
IssmDouble  dt,
int  method 
)

Definition at line 5 of file ODE1.cpp.

5  {
6  /* solve the following equation:
7  *
8  * dS/dt = alpha S + beta
9  *
10  * method 0: Forward Euler (explicit)
11  * method 1: backward Euler (implicit)
12  * method 2: Crank Nicolson
13  *
14  * return S^{i+1} based on Si, dt, alpha and beta
15  */
16 
17  switch(method){
18  case 0: return Si*(1.+alpha*dt) + beta*dt;
19  case 1: return (Si+beta*dt)/(1.-alpha*dt);
20  case 2: return (Si*(1.+alpha*dt/2.) + beta*dt)/(1-alpha*dt/2.);
21  default: _error_("not supported yet");
22  }
23 }
alpha
IssmDouble alpha(IssmDouble x, IssmDouble y, IssmDouble z, int testid)
Definition: fsanalyticals.cpp:221
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49