-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants.c
77 lines (52 loc) · 2.07 KB
/
constants.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "constants.h"
PetscErrorCode FundamentalConstantsSet( FundamentalConstants FC, ScalingConstants const SC )
{
/* fundamental physical and chemical constants are all here, and should
always be accessed from this struct to avoid duplication */
PetscFunctionBeginUser;
FC->AVOGADRO = 6.02214076E23; /* 1/mol */
FC->GAS = 8.3144598; /* J/K/mol */
FC->GAS *= SC->TEMP / SC->ENERGY; /* 1/mol */
/* BOLTZMANN is 1.380649E-23 J/K */
/* note that BOLTZMANN is also GAS constant per particle */
FC->BOLTZMANN = FC->GAS / FC->AVOGADRO;
FC->GRAVITATIONAL = 6.67408E-11; /* m^3/kg/s^2 */
FC->GRAVITATIONAL *= SC->DENSITY * PetscPowScalar( SC->TIME, 2.0 );
FC->STEFAN_BOLTZMANN = 5.670367e-08; /* W/m^2/K^4 */
FC->STEFAN_BOLTZMANN /= SC->SIGMA;
/* this is not really a fundamental constant, but is close
enough for our global modelling purposes */
/* computed from 1.385185824553049e+21 / 0.01801528 */
FC->OCEAN_MOLES = 7.68894973907177e+22; /* moles of H2O (or H2) in ocean */
PetscFunctionReturn(0);
}
PetscErrorCode ScalingConstantsCreate( ScalingConstants* scaling_constants_ptr )
{
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = PetscMalloc1(1,scaling_constants_ptr);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
PetscErrorCode ScalingConstantsDestroy( ScalingConstants* scaling_constants_ptr )
{
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = PetscFree(*scaling_constants_ptr);CHKERRQ(ierr);
*scaling_constants_ptr = NULL;
PetscFunctionReturn(0);
}
PetscErrorCode FundamentalConstantsCreate( FundamentalConstants* fundamental_constants_ptr )
{
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = PetscMalloc1(1,fundamental_constants_ptr);CHKERRQ(ierr);
PetscFunctionReturn(0);
}
PetscErrorCode FundamentalConstantsDestroy( FundamentalConstants* fundamental_constants_ptr )
{
PetscErrorCode ierr;
PetscFunctionBeginUser;
ierr = PetscFree(*fundamental_constants_ptr);CHKERRQ(ierr);
*fundamental_constants_ptr = NULL;
PetscFunctionReturn(0);
}