Skip to content

Commit b21cc64

Browse files
Merge branch 'master' of https://github.com/ARPA-SIMC/PRAGA
2 parents 48b061a + dda97cb commit b21cc64

File tree

13 files changed

+205
-7
lines changed

13 files changed

+205
-7
lines changed

agrolib/grapevine/grapevine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool Vine3D_Grapevine::compute(bool computeDaily, int secondsPerStep, Crit3DMode
2727
{
2828
simulationStepInSeconds = double(secondsPerStep);
2929
isAmphystomatic = true;
30-
myLeafWidth = 0.2; // [m]
30+
myLeafWidth = 0.2; // [cm]
3131
// Stomatal conductance Adjust stom conductance-photosynth ratio for soil water (Pa)
3232
alphaLeuning = modelCase->cultivar->parameterWangLeuning.alpha;
3333
getFixSimulationParameters();

agrolib/hydrall/hydrall.cpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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, int secondPerStep)
17+
{
18+
getCO2(myDate, myTemperature, myElevation);
19+
double actualLAI = getLAI();
20+
/* necessaria per ogni specie:
21+
* il contenuto di clorofilla (g cm-2) il default è 500
22+
* lo spessore della foglia 0.2 cm default
23+
* un booleano che indichi se la specie è anfistomatica oppure no
24+
* parametro alpha del modello di Leuning
25+
*
26+
*/
27+
// la temperatura del mese precedente arriva da fuori
28+
29+
30+
31+
return true;
32+
}
33+
34+
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation)
35+
{
36+
double atmCO2 ; //https://www.eea.europa.eu/data-and-maps/daviz/atmospheric-concentration-of-carbon-dioxide-5/download.table
37+
double year[24] = {1750,1800,1850,1900,1910,1920,1930,1940,1950,1960,1970,1980,1990,2000,2010,2020,2030,2040,2050,2060,2070,2080,2090,2100};
38+
double valueCO2[24] = {278,283,285,296,300,303,307,310,311,317,325,339,354,369,389,413,443,473,503,530,550,565,570,575};
39+
40+
// exponential fitting Mauna Loa
41+
if (myDate.year < 1990)
42+
{
43+
atmCO2= 280 * exp(0.0014876*(myDate.year -1840));//exponential change in CO2 concentration (ppm)
44+
}
45+
else
46+
{
47+
atmCO2= 353 * exp(0.00630*(myDate.year - 1990));
48+
}
49+
atmCO2 += 3*cos(2*PI*getDoyFromDate(myDate)/365.0); // to consider the seasonal effects
50+
return atmCO2*getPressureFromElevation(myTemperature, myElevation)/1000000 ; // [Pa] in +- ppm/10
51+
}
52+
53+
double getPressureFromElevation(double myTemperature, double myElevation)
54+
{
55+
return SEA_LEVEL_PRESSURE * exp((- GRAVITY * M_AIR * myElevation) / (R_GAS * myTemperature));
56+
}
57+
58+
double getLAI()
59+
{
60+
// TODO
61+
return 4;
62+
}
63+
/*
64+
double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp)
65+
{
66+
double newTemperature;
67+
double monthFraction;
68+
monthFraction = simulationStepInSeconds/(2592000.0); // seconds of 30 days
69+
newTemperature = previousLastMonthTemp * (1 - monthFraction) + myInstantTemp * monthFraction ;
70+
return newTemperature;
71+
}*/

agrolib/hydrall/hydrall.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
bool computeHydrall(Crit3DDate myDate, double myTemperature, double myElevation, int secondPerStep);
28+
double getCO2(Crit3DDate myDate, double myTemperature, double myElevation);
29+
double getPressureFromElevation(double myTemperature, double myElevation);
30+
double getLAI();
31+
double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp);
32+
33+
#endif // HYDRALL_H

agrolib/hydrall/hydrall.pro

Lines changed: 36 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

agrolib/pragaProject/pragaProject.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ void PragaProject::clearPragaProject()
7171
}
7272
}
7373

74+
75+
QString PragaProject::getVersion()
76+
{
77+
return "PRAGA V2.0.1 (2025)";
78+
}
79+
7480
void PragaProject::createPragaProject(QString path_, QString name_, QString description_)
7581
{
7682
createProject(path_, name_, description_);

agrolib/pragaProject/pragaProject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
void initializePragaProject();
9191
void clearPragaProject();
9292

93+
QString getVersion();
94+
9395
void createPragaProject(QString path_, QString name_, QString description_);
9496
void savePragaProject();
9597
void savePragaParameters();

agrolib/pragaProject/pragaShell.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ QList<QString> getPragaCommandList()
1313

1414
// praga commands
1515
cmdList.append("List | ListCommands");
16+
cmdList.append("Version | PragaVersion");
1617
cmdList.append("Proj | OpenProject");
1718
cmdList.append("Download | Download");
1819
cmdList.append("AggrOnZones | GridAggregationOnZones");
@@ -50,18 +51,31 @@ int cmdList(PragaProject* myProject)
5051
}
5152

5253

54+
int pragaVersion(PragaProject* myProject)
55+
{
56+
myProject->logInfo(myProject->getVersion());
57+
58+
return PRAGA_OK;
59+
}
60+
61+
5362
int PragaProject::executePragaCommand(QList<QString> argumentList, bool* isCommandFound)
5463
{
5564
*isCommandFound = false;
5665
if (argumentList.size() == 0) return PRAGA_INVALID_COMMAND;
5766

5867
QString command = argumentList[0].toUpper();
5968

60-
if (command == "?" || command == "LIST" || command == "LISTCOMMANDS")
69+
if (command == "?" || command == "LS" || command == "LIST" || command == "LISTCOMMANDS")
6170
{
6271
*isCommandFound = true;
6372
return cmdList(this);
6473
}
74+
if (command == "VERSION" || command == "PRAGAVERSION")
75+
{
76+
*isCommandFound = true;
77+
return pragaVersion(this);
78+
}
6579
else if (command == "PROJ" || command == "OPENPROJECT")
6680
{
6781
*isCommandFound = true;
@@ -900,7 +914,7 @@ int pragaBatch(PragaProject* myProject, QString scriptFileName)
900914
attachOutputToConsole();
901915
#endif
902916

903-
myProject->logInfo("\nPRAGA v2.0.0");
917+
myProject->logInfo(myProject->getVersion());
904918
myProject->logInfo("Execute script: " + scriptFileName);
905919

906920
if (scriptFileName == "")

agrolib/pragaProject/pragaShell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
QList<QString> getPragaCommandList();
99
int cmdList(PragaProject* myProject);
10+
int pragaVersion(PragaProject* myProject);
1011

1112
int executeCommand(QList<QString> argumentList, PragaProject* myProject);
1213
int pragaShell(PragaProject* myProject);

fedora/SPECS/PRAGA.spec

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
%{!?srcarchivename: %global srcarchivename PRAGA-%{version}}
33

44
Name: PRAGA
5-
Version: 2.0.0
6-
Release: 2%{?dist}
5+
Version: 2.0.1
6+
Release: 3%{?dist}
77
Summary: PRogram for AGrometeorological Analysis
88

99
URL: https://github.com/ARPA-SIMC/PRAGA
@@ -55,6 +55,15 @@ cp -a src/PRAGA %{buildroot}/%{_bindir}/
5555

5656

5757
%changelog
58+
* Tue Jan 21 2025 Fausto Tomei <ftomei@arpae.it> - 2.0.1-3
59+
- Release 2.0.1
60+
61+
* Tue Jan 21 2025 Fausto Tomei <ftomei@arpae.it> - 2.0.1-2
62+
- Release 2.0.1
63+
64+
* Fri Jan 17 2025 Fausto Tomei <ftomei@arpae.it> - 2.0.1-1
65+
- Release 2.0.1
66+
5867
* Tue Jan 14 2025 Fausto Tomei <ftomei@arpae.it> - 2.0.0-2
5968
- Release 2.0.0
6069

0 commit comments

Comments
 (0)