Ice Sheet System Model  4.18
Code documentation
ODE1.cpp
Go to the documentation of this file.
1 #include <math.h>
2 #include "./types.h"
3 #include "../Exceptions/exceptions.h"
4 
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 }
IssmDouble
double IssmDouble
Definition: types.h:37
types.h
prototypes for types.h
alpha
IssmDouble alpha(IssmDouble x, IssmDouble y, IssmDouble z, int testid)
Definition: fsanalyticals.cpp:221
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
ODE1
IssmDouble ODE1(IssmDouble alpha, IssmDouble beta, IssmDouble Si, IssmDouble dt, int method)
Definition: ODE1.cpp:5