HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
Numa3DFunctions.c File Reference
#include <math.h>
#include <mathfunctions.h>
#include <physicalmodels/numa3d.h>

Go to the source code of this file.

Functions

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

Function Documentation

◆ Numa3DCalculateStandardAtmosphere_1()

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

Definition at line 5 of file Numa3DFunctions.c.

6 {
7  Numa3D *physics = (Numa3D*) 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 }
double Pref
Definition: numa3d.h:136
Definition: numa3d.h:128
double Tref
Definition: numa3d.h:136
double R
Definition: numa3d.h:130
double gamma
Definition: numa3d.h:129
double g
Definition: numa3d.h:132
#define raiseto(x, a)
Definition: math_ops.h:37

◆ Numa3DCalculateStandardAtmosphere_2()

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

Definition at line 30 of file Numa3DFunctions.c.

31 {
32  Numa3D *physics = (Numa3D*) 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 }
double Pref
Definition: numa3d.h:136
Definition: numa3d.h:128
double Tref
Definition: numa3d.h:136
double R
Definition: numa3d.h:130
double gamma
Definition: numa3d.h:129
double g
Definition: numa3d.h:132
#define raiseto(x, a)
Definition: math_ops.h:37