From bd7e8682ae4d1f5d011880a6486615227b8fda71 Mon Sep 17 00:00:00 2001 From: avolta Date: Tue, 21 Jan 2025 14:32:41 +0100 Subject: [PATCH] aggiunta mappa temperature medie del mese precedente per hydrall --- agrolib/grapevine/grapevine.cpp | 2 +- agrolib/hydrall/hydrall.cpp | 39 +++++++++++++++++++++++++--- agrolib/hydrall/hydrall.h | 4 ++- bin/CRITERIA3D/criteria3DProject.cpp | 17 ++++++++++++ bin/CRITERIA3D/criteria3DProject.h | 2 ++ 5 files changed, 58 insertions(+), 6 deletions(-) diff --git a/agrolib/grapevine/grapevine.cpp b/agrolib/grapevine/grapevine.cpp index 83e04c5df..dd5ebd7f5 100644 --- a/agrolib/grapevine/grapevine.cpp +++ b/agrolib/grapevine/grapevine.cpp @@ -27,7 +27,7 @@ bool Vine3D_Grapevine::compute(bool computeDaily, int secondsPerStep, Crit3DMode { simulationStepInSeconds = double(secondsPerStep); isAmphystomatic = true; - myLeafWidth = 0.2; // [m] + myLeafWidth = 0.2; // [cm] // Stomatal conductance Adjust stom conductance-photosynth ratio for soil water (Pa) alphaLeuning = modelCase->cultivar->parameterWangLeuning.alpha; getFixSimulationParameters(); diff --git a/agrolib/hydrall/hydrall.cpp b/agrolib/hydrall/hydrall.cpp index bb6341d7f..5770584da 100644 --- a/agrolib/hydrall/hydrall.cpp +++ b/agrolib/hydrall/hydrall.cpp @@ -6,29 +6,45 @@ */ -#include +//#include #include #include "crit3dDate.h" #include "commonConstants.h" #include "hydrall.h" -bool computeHydrall(Crit3DDate myDate, double myTemperature, double myElevation) +bool computeHydrall(Crit3DDate myDate, double myTemperature, double myElevation, int secondPerStep) { getCO2(myDate, myTemperature, myElevation); + double actualLAI = getLAI(); + /* necessaria per ogni specie: + * il contenuto di clorofilla (g cm-2) il default è 500 + * lo spessore della foglia 0.2 cm default + * un booleano che indichi se la specie è anfistomatica oppure no + * parametro alpha del modello di Leuning + * + */ + // la temperatura del mese precedente arriva da fuori + + + return true; } double getCO2(Crit3DDate myDate, double myTemperature, double myElevation) { - double atmCO2 ; // fitting from data of Mauna Loa,Hawaii + double atmCO2 ; //https://www.eea.europa.eu/data-and-maps/daviz/atmospheric-concentration-of-carbon-dioxide-5/download.table + 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}; + 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}; + + // exponential fitting Mauna Loa if (myDate.year < 1990) { atmCO2= 280 * exp(0.0014876*(myDate.year -1840));//exponential change in CO2 concentration (ppm) } else { - atmCO2= 350 * exp(0.00630*(myDate.year - 1990)); + atmCO2= 353 * exp(0.00630*(myDate.year - 1990)); } atmCO2 += 3*cos(2*PI*getDoyFromDate(myDate)/365.0); // to consider the seasonal effects return atmCO2*getPressureFromElevation(myTemperature, myElevation)/1000000 ; // [Pa] in +- ppm/10 @@ -38,3 +54,18 @@ double getPressureFromElevation(double myTemperature, double myElevation) { return SEA_LEVEL_PRESSURE * exp((- GRAVITY * M_AIR * myElevation) / (R_GAS * myTemperature)); } + +double getLAI() +{ + // TODO + return 4; +} +/* +double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp) +{ + double newTemperature; + double monthFraction; + monthFraction = simulationStepInSeconds/(2592000.0); // seconds of 30 days + newTemperature = previousLastMonthTemp * (1 - monthFraction) + myInstantTemp * monthFraction ; + return newTemperature; +}*/ diff --git a/agrolib/hydrall/hydrall.h b/agrolib/hydrall/hydrall.h index 2882e1759..197266533 100644 --- a/agrolib/hydrall/hydrall.h +++ b/agrolib/hydrall/hydrall.h @@ -24,8 +24,10 @@ #define NOT_INITIALIZED_VINE -1 + bool computeHydrall(Crit3DDate myDate, double myTemperature, double myElevation, int secondPerStep); double getCO2(Crit3DDate myDate, double myTemperature, double myElevation); double getPressureFromElevation(double myTemperature, double myElevation); - + double getLAI(); + double meanLastMonthTemperature(double previousLastMonthTemp, double simulationStepInSeconds, double myInstantTemp); #endif // HYDRALL_H diff --git a/bin/CRITERIA3D/criteria3DProject.cpp b/bin/CRITERIA3D/criteria3DProject.cpp index 2f083458f..ce9015970 100644 --- a/bin/CRITERIA3D/criteria3DProject.cpp +++ b/bin/CRITERIA3D/criteria3DProject.cpp @@ -89,6 +89,7 @@ void Crit3DProject::clearCropMaps() degreeDaysMap.clear(); dailyTminMap.clear(); dailyTmaxMap.clear(); + lastMonthTavgMap.clear(); isCropInitialized = false; } @@ -110,6 +111,7 @@ bool Crit3DProject::initializeCropMaps() dailyTminMap.initializeGrid(*(DEM.header)); dailyTmaxMap.initializeGrid(*(DEM.header)); + lastMonthTavgMap.initializeGrid(*(DEM.header)); return true; } @@ -189,6 +191,7 @@ bool Crit3DProject::initializeCropWithClimateData() laiMap.value[row][col] = cropList[index].computeSimpleLAI(degreeDays, gisSettings.startLocation.latitude, currentDate.dayOfYear()); } } + lastMonthTavgMap.value[row][col]= 15; // initialize to 15°C } } @@ -1189,6 +1192,20 @@ bool Crit3DProject::computeSnowModel() return true; } +bool Crit3DProject::updateLast30DaysTavg() +{ + if (! dailyTminMap.isLoaded || ! dailyTmaxMap.isLoaded || ! hourlyMeteoMaps->mapHourlyTair->isLoaded) + return false; + + for (long row = 0; row < dailyTminMap.header->nrRows; row++) + { + for (long col = 0; col < dailyTminMap.header->nrCols; col++) + { + lastMonthTavgMap.value[row][col] = (29./30.)*lastMonthTavgMap.value[row][col] + (dailyTmaxMap.value[row][col] + dailyTminMap.value[row][col])/30; + } + } + return true; +} bool Crit3DProject::updateDailyTemperatures() { diff --git a/bin/CRITERIA3D/criteria3DProject.h b/bin/CRITERIA3D/criteria3DProject.h index a35de760f..f04fba99c 100644 --- a/bin/CRITERIA3D/criteria3DProject.h +++ b/bin/CRITERIA3D/criteria3DProject.h @@ -32,6 +32,7 @@ void clear3DProject(); bool check3DProject(); bool updateDailyTemperatures(); + bool updateLast30DaysTavg(); bool saveSnowModelState(const QString ¤tStatePath); bool saveSoilWaterState(const QString ¤tStatePath); @@ -47,6 +48,7 @@ gis::Crit3DRasterGrid degreeDaysMap; gis::Crit3DRasterGrid dailyTminMap; gis::Crit3DRasterGrid dailyTmaxMap; + gis::Crit3DRasterGrid lastMonthTavgMap; Crit3DSnow snowModel;