Ice Sheet System Model  4.18
Code documentation
Functions
DrainageFunctionWaterfraction.cpp File Reference

: drain excess water fraction More...

#include <math.h>
#include "../Numerics/types.h"
#include "../Exceptions/exceptions.h"

Go to the source code of this file.

Functions

IssmDouble DrainageFunctionWaterfraction (IssmDouble waterfraction, IssmDouble dt=0.)
 

Detailed Description

: drain excess water fraction

Definition in file DrainageFunctionWaterfraction.cpp.

Function Documentation

◆ DrainageFunctionWaterfraction()

IssmDouble DrainageFunctionWaterfraction ( IssmDouble  waterfraction,
IssmDouble  dt = 0. 
)

Definition at line 9 of file DrainageFunctionWaterfraction.cpp.

9  {
10  /* DrainageFunctionWaterfraction returns how much of the waterfraction is drained per year */
11  _assert_(waterfraction>=0.);
12  _assert_(dt>=0.);
13 
14  IssmDouble w0=0.01, w1=0.02, w2=0.03;
15  IssmDouble yts=365.*24.*60.*60.;
16  IssmDouble Dret, D0=0., D1=0.005/yts, D2=0.05/yts;
17 
18  /*get drainage function value*/
19  if((w0==w1)||(w1==w2)||(w0==w2))
20  _error_("Error: equal ordinates in DrainageFunctionWaterfraction -> division by zero. Abort");
21 
22  if(waterfraction<=w0)
23  Dret=D0;
24  else if((waterfraction>w0) && (waterfraction<=w1))
25  Dret=(D1-D0)/(w1-w0)*(waterfraction-w0)+D0;
26  else if((waterfraction>w1) && (waterfraction<=w2))
27  Dret=(D2-D1)/(w2-w1)*(waterfraction-w1)+D1;
28  else
29  Dret=D2;
30 
31  /*drain only up to w0*/
32  if(dt==0.){
33  if(waterfraction>w0)
34  return waterfraction-w0;
35  else
36  return Dret;
37  }
38  else{
39  if((waterfraction>w0) && (waterfraction-dt*Dret<w0))
40  return (waterfraction-w0)/dt;
41  else
42  return Dret;
43  }
44 }
_assert_
#define _assert_(ignore)
Definition: exceptions.h:37
IssmDouble
double IssmDouble
Definition: types.h:37
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
bamg::D2
P2< double, double > D2
Definition: Metric.h:11