|
| 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 | +}*/ |
0 commit comments