54 double toReturn = 0.0;
61 vector <string> allProducts = priProducts;
62 allProducts.insert( allProducts.end(), secProducts.begin(), secProducts.end() );
63 for(uint i=0;i<allProducts.size();i++){
70 for(
int y=(initialYear-100);y<=currentYear;y++){
71 iiskey key(y,regId,allProducts[i]);
74 toReturn += remainingStock*coeff/1000;
81 for(uint i=0;i<fTypes.size();i++){
92 for(
int y=(initialYear-100);y<=currentYear;y++){
93 iiskey key(y,regId,fTypes[i]);
96 toReturn += remainingStock*coeff/1000;
107 for(uint i=0;i<fTypes.size();i++){
118 for(
int y=(initialYear-100);y<=currentYear;y++){
119 iiskey key(y,regId,fTypes[i]);
122 toReturn += remainingStock*coeff/1000;
160 for (uint i=0;i<regIds.size();i++){
161 pair<int,double> mypair(regIds[i],0.0);
176 for(uint i=0;i<fTypes.size();i++){
192 for(
int y=currentYear;y>currentYear-100;y--){
193 iiskey key(y,regId,fTypes[i]);
194 pair<iiskey,double> mypairInventory(key,deathByFt.at(i));
195 pair<iiskey,double> mypairExtra(key,deathByFt.at(i)*extraBiomass_ratio);
207 vector <string> allProducts = priProducts;
208 allProducts.insert( allProducts.end(), secProducts.begin(), secProducts.end() );
209 if(allProducts.size() != qByProduct.size()) {
msgOut(
MSG_CRITICAL_ERROR,
"allProducts and qByProduct have different lenght!");}
211 for(uint i=0;i<allProducts.size();i++){
214 for(
int y=currentYear;y>currentYear-100;y--){
215 iiskey key(y,regId,allProducts[i]);
216 pair<iiskey,double> mypair(key,qByProduct.at(i));
236 double newDeathBiomass = value*extraBiomass_ratio;
237 iiskey key(year,regId,fType);
245 iiskey key(year,regId,fType);
260 iiskey key(year,regId,productName);
261 pair<iiskey,double> mypair(key,value);
294 vector <string> allProducts = priProducts;
295 allProducts.insert( allProducts.end(), secProducts.begin(), secProducts.end() );
298 for (uint r=0;r<regIds.size();r++){
299 double regId = regIds[r];
300 for(uint i=0;i<allProducts.size();i++){
301 string pr = allProducts[i];
305 if(eol2e_share > 0 && subEnergyCoeff>0){
306 for(
int y=(initialYear-100);y<currentYear;y++){
309 double remainingStockLastYear =
getRemainingStock(originalStock,life,currentYear-y-1);
310 double remainingStockThisYear =
getRemainingStock(originalStock,life,currentYear-y);
311 double eofThisYear = remainingStockLastYear-remainingStockThisYear;
346 double k = log(2)/halfLife;
347 return initialValue*exp(-k*years);
map< int, double > cumEmittedForOper
Map that store emissions for forest operations, including transport, by l2_region [Mt CO2]...
void addSavedEmissions(const double &value, const int ®Id, const int &em_type)
Increases the value to the saved emissions for a given type and region.
map< iiskey, double > products
Map that register the production of a given product by year, l2_region and product [Mm^3 wood]...
The required data is for the current year.
Class to provide a simple integer-integer-string key in std maps.
void initialiseDeathBiomassStocks(const vector< double > &deathByFt, const int ®Id)
Initialises the stocks of death biomass for the avgLive_* years before the simulation starts...
int getIntSetting(const string &name_h, int position=0, int reg=WORLD) const
Do not actually output any message.
ThreadManager * MTHREAD
Pointer to the Thread manager.
ModelData * MD
the model data object
double getCumSavedEmissions(const int ®Id, const int &em_type) const
Returns the current cumulative saved emissions by type [Mt CO2].
double getStock(const int ®Id, const int &stock_type) const
Returns the current stock of carbon [Mt CO2].
map< int, double > cumSubstitutedMaterial
Map that store the cumulative CO2 substituted using less energivory material, by l2_region [Mt CO2]...
Scheduler * SCD
the scheduler object (simulation-loops scheduler)
void msgOut(const int &msgCode_h, const string &msg_h, const bool &refreshGUI_h=true) const
Overloaded function to print the output log.
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
void incrMapValue(map< K, V > &mymap, const K &key, const V &value, const int &error_level=MSG_CRITICAL_ERROR)
Increments a value stored in a map of the specified value, given the key.
vector< string > getStringVectorSetting(const string &name_h, int reg=WORLD) const
const double getProdData(const string &type_h, const int ®Id_h, const string &prodId_h, const int &year=DATA_NOW, const string &freeDim_h="")
void registerTransports(const double &distQ, const int ®Id)
Registers the quantities emitted by transport of wood FROM a given region.
Print an error message and stop the model.
void registerDeathBiomass(const double &value, const int ®Id, const string &fType)
Registers the "death" of a given amount of biomass, storing it in the deathBiomass map...
Flow from forest operations.
const double getForData(const string &type_h, const int ®Id_h, const string &forType_h, const string &freeDim_h, const int &year=DATA_NOW)
void initialiseProductsStocks(const vector< double > &qByProduct, const int ®Id)
Initialises the stocks of products for the avgLive_* years before the simulation starts.
Invetoried biomass (live and death tree logs)
Extra biomass (soils, branches..)
void registerHarvesting(const double &value, const int ®Id, const string &fType)
Registers the harvesting of trees increasing the value of cumEmittedForOper.
vector< string > getForTypeIds(bool all=false)
By default it doesn't return forTypes used only as input.
V findMap(const map< K, V > &mymap, const K &key, const int &error_level=MSG_CRITICAL_ERROR, const V ¬FoundValue=numeric_limits< V >::min()) const
Lookup a map for a value. Return the value starting from the key.
map< iiskey, double > deathBiomassInventory
Map that register the death of biomass by year, l2_region and forest type (inventoried)[Mm^3 wood]...
void incrOrAddMapValue(map< K, V > &mymap, const K &key, const V &value)
Increments a value stored in a map of the specified value, given the key.
void initialiseEmissionCounters()
Initialises the emission counters to zero.
Carbon(ThreadManager *MTHREAD_h)
Constructor.
vector< int > getRegionIds(int level_h, bool excludeResidual=true)
void HWP_eol2energy()
Computes the energy substitution for the quota of HWP that reachs end of life and doesn't go to landf...
double getDoubleSetting(const string &name_h, int position=0, int reg=WORLD) const
map< iiskey, double > deathBiomassExtra
Map that register the death of biomass by year, l2_region and forest type (non-inventoried biomass: b...
map< int, double > cumSubstitutedEnergy
Map that store the cumulative CO2 substituted for energy consumption, by l2_region [Mt CO2]...
double getRemainingStock(const double &initialValue, const double &halfLife, const double &years) const
Apply a single exponential decay model to retrieve the remining stock given the initial stock...
Biomass in forest products (sawns, pannels..)
#define DIAM_ALL
All diameter classes.
void registerProducts(const double &value, const int ®Id, const string &productName)
Registers the production of a given amount of products, storing it in the products maps...