HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Numa2DFunctions.c File Reference
#include <math.h>
#include <mathfunctions.h>
#include <physicalmodels/numa2d.h>

Go to the source code of this file.

Functions

int Numa2DCalculateStandardAtmosphere_1 (void *p, double z, double *ExnerP, double *P, double *rho, double *T)
 
int Numa2DCalculateStandardAtmosphere_2 (void *p, double z, double *ExnerP, double *P, double *rho, double *T)
 

Function Documentation

int Numa2DCalculateStandardAtmosphere_1 ( void *  p,
double  z,
double *  ExnerP,
double *  P,
double *  rho,
double *  T 
)

Definition at line 5 of file Numa2DFunctions.c.

6 {
7  Numa2D *physics = (Numa2D*) p;
8 
9  double R = physics->R;
10  double gamma = physics->gamma;
11  double g = physics->g;
12 
13  /* reference quantities at zero altitude */
14  double P0, T0;
15  P0 = physics->Pref;
16  T0 = physics->Tref;
17 
18  double inv_gamma_m1 = 1.0/(gamma-1.0);
19  double Cp = gamma * inv_gamma_m1 * R;
20 
21  double theta = T0;
22  *ExnerP = 1.0 - (g/(Cp*theta))*z;
23  *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1);
24  *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1);
25  *T = (*rho) * theta;
26 
27  return(0);
28 }
#define raiseto(x, a)
Definition: math_ops.h:37
double Pref
Definition: numa2d.h:117
double Tref
Definition: numa2d.h:117
Definition: numa2d.h:109
double R
Definition: numa2d.h:111
double gamma
Definition: numa2d.h:110
double g
Definition: numa2d.h:112
int Numa2DCalculateStandardAtmosphere_2 ( void *  p,
double  z,
double *  ExnerP,
double *  P,
double *  rho,
double *  T 
)

Definition at line 30 of file Numa2DFunctions.c.

31 {
32  Numa2D *physics = (Numa2D*) p;
33 
34  double R = physics->R;
35  double gamma = physics->gamma;
36  double g = physics->g;
37 
38  /* reference quantities at zero altitude */
39  double P0, T0;
40  P0 = physics->Pref;
41  T0 = physics->Tref;
42 
43  double BV = 0.01; /* Brunt-Vaisala frequency */
44  double inv_gamma_m1 = 1.0/(gamma-1.0);
45  double Cp = gamma * inv_gamma_m1 * R;
46 
47  double term = BV*BV*z/g;
48  double theta = T0 * exp(term);
49  *ExnerP = 1.0 + (g*g/(Cp*T0*BV*BV)) * (exp(-term) - 1.0);
50  *P = P0 * raiseto((*ExnerP),gamma*inv_gamma_m1);
51  *rho = (P0/(R*theta)) * raiseto((*ExnerP),inv_gamma_m1);
52  *T = (*rho) * theta;
53 
54  return(0);
55 }
#define raiseto(x, a)
Definition: math_ops.h:37
double Pref
Definition: numa2d.h:117
double Tref
Definition: numa2d.h:117
Definition: numa2d.h:109
double R
Definition: numa2d.h:111
double gamma
Definition: numa2d.h:110
double g
Definition: numa2d.h:112