Skip to content

Commit 8c09dba

Browse files
committed
Merge commit '3c36b0e92817ce4d282ca813b8991e9fa43c7d53'
2 parents c972415 + 3c36b0e commit 8c09dba

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

agrolib/hydrall/hydrall.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*!
2+
\name hydrall.cpp
3+
\brief
4+
\authors Antonio Volta, Caterina Toscano
5+
6+
*/
7+
8+
9+
#include <stdio.h>
10+
#include <math.h>
11+
#include "crit3dDate.h"
12+
#include "commonConstants.h"
13+
#include "hydrall.h"
14+
15+
16+
bool computeHydrall(Crit3DDate myDate, double myTemperature, double myElevation)
17+
{
18+
getCO2(myDate, myTemperature, myElevation);
19+
return true;
20+
}
21+
22+
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation)
23+
{
24+
double atmCO2 ; // fitting from data of Mauna Loa,Hawaii
25+
if (myDate.year < 1990)
26+
{
27+
atmCO2= 280 * exp(0.0014876*(myDate.year -1840));//exponential change in CO2 concentration (ppm)
28+
}
29+
else
30+
{
31+
atmCO2= 350 * exp(0.00630*(myDate.year - 1990));
32+
}
33+
atmCO2 += 3*cos(2*PI*getDoyFromDate(myDate)/365.0); // to consider the seasonal effects
34+
return atmCO2*getPressureFromElevation(myTemperature, myElevation)/1000000 ; // [Pa] in +- ppm/10
35+
}
36+
37+
double getPressureFromElevation(double myTemperature, double myElevation)
38+
{
39+
return SEA_LEVEL_PRESSURE * exp((- GRAVITY * M_AIR * myElevation) / (R_GAS * myTemperature));
40+
}

agrolib/hydrall/hydrall.h

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef HYDRALL_H
2+
#define HYDRALL_H
3+
4+
#ifndef COMMONCONSTANTS_H
5+
#include "commonConstants.h"
6+
#endif
7+
#ifndef CRIT3DDATE_H
8+
#include "crit3dDate.h"
9+
#endif
10+
11+
#define UPSCALINGFUNC(z,LAI) ((1.0 - exp(-(z)*(LAI))) / (z))
12+
13+
// Tree-plant properties
14+
#define FORM 0.5 // stem form factor
15+
#define RHOF 0.1 // [KgDM m-3] foliage density
16+
#define RHOS 750 // [KgDM m-3] wood-stem density
17+
18+
// Hydraulic properties
19+
#define H50 0.4 // height for 50% maturation of xylem cells (m) [not relevant]
20+
#define KR 4.0E-7 // root specific conductance (m3 MPa-1 s-1 kg-1) [not relevant]
21+
#define KSMAX 2.5E-3 // max. sapwood specific conductivity (m2 MPa-1 s-1) [not relevant]
22+
#define PSITHR -2.5 // water potential threshold for cavitation (MPa) [not relevant]
23+
24+
25+
#define NOT_INITIALIZED_VINE -1
26+
27+
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation);
28+
double getPressureFromElevation(double myTemperature, double myElevation);
29+
30+
31+
#endif // HYDRALL_H

agrolib/hydrall/hydrall.pro

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#---------------------------------------------------
2+
#
3+
# hydrall library
4+
# This project is part of CRITERIA3D distribution
5+
#
6+
#---------------------------------------------------
7+
8+
QT -= core gui
9+
10+
TEMPLATE = lib
11+
CONFIG += staticlib
12+
13+
CONFIG += debug_and_release
14+
CONFIG += c++11 c++14 c++17
15+
16+
#DEFINES += _CRT_SECURE_NO_WARNINGS
17+
18+
19+
unix:{
20+
CONFIG(debug, debug|release) {
21+
TARGET = debug/hydrall
22+
} else {
23+
TARGET = release/hydrall
24+
}
25+
}
26+
win32:{
27+
TARGET = hydrall
28+
}
29+
30+
INCLUDEPATH += ../crit3dDate ../mathFunctions ../soil ../crop
31+
32+
SOURCES += hydrall.cpp
33+
34+
35+
HEADERS += hydrall.h
36+

agrolib/mathFunctions/commonConstants.h

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@
159159
#define MO2 0.032
160160
// [kg mol-1] mass of molecular nitrogen (N2)
161161
#define MN2 0.028
162+
// [kg mol-1] mass of air
163+
#define M_AIR 0.029
162164
// [K] zero Celsius
163165
#define ZEROCELSIUS 273.15
164166
// [] ratio molecular weight of water vapour/dry air

0 commit comments

Comments
 (0)