FFSM++  1.1.0
French Forest Sector Model ++
Carbon.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2015 by Laboratoire d'Economie Forestière *
3  * http://ffsm-project.org *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version, given the compliance with the *
9  * exceptions listed in the file COPYING that is distribued together *
10  * with this file. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program; if not, write to the *
19  * Free Software Foundation, Inc., *
20  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  ***************************************************************************/
22 #ifndef CARBON_H
23 #define CARBON_H
24 
25 // Core C++ headers
26 #include <string>
27 #include <vector>
28 #include <map>
29 #include <stdexcept>
30 #include <iostream>
31 #include <sstream>
32 #include <time.h>
33 
34 //regmas headers
35 #include "BaseClass.h"
36 
37 /// Class responsable to keep the logbook of the Carbon Balance
38 /**
39 @author Antonello Lobianco
40 
41 A single istance of this class exists and is available trought the global MTHREAD->CBAL pointer.
42 
43 It consits of functions to track a carbon-related event and store the information in STL maps that either register the events (for the stocks) or contain the cumulated carbon (for emission flows).
44 
45 Carbon pools are stored as Mm^3 wood while and emission cumulated counters are directly in Mt CO2.
46 
47 getStock() and getCumSavedEmissions() are then used to report the current levels of carbon in the stock or emitted/substituted.
48 */
49 
50 class Carbon: public BaseClass{
51 public:
52  Carbon(ThreadManager* MTHREAD_h); ///< Constructor
53  ~Carbon();
54 
55 
56  double getStock(const int & regId, const int & stock_type) const; ///< Returns the current stock of carbon [Mt CO2]
57  double getCumSavedEmissions(const int & regId, const int & em_type) const; ///< Returns the current cumulative saved emissions by type [Mt CO2]
58 
59  void registerHarvesting(const double & value, const int & regId, const string &fType); ///< Registers the harvesting of trees increasing the value of cumEmittedForOper
60  void registerDeathBiomass(const double &value, const int & regId, const string &fType); ///< Registers the "death" of a given amount of biomass, storing it in the deathBiomass map
61  void registerProducts(const double &value, const int & regId, const string &productName);///< Registers the production of a given amount of products, storing it in the products maps. Also increase material substitution.
62  void registerTransports(const double &distQ, const int & regId); ///< Registers the quantities emitted by transport of wood FROM a given region
63  void initialiseDeathBiomassStocks(const vector<double> & deathByFt, const int & regId); ///< Initialises the stocks of death biomass for the avgLive_* years before the simulation starts
64  void initialiseProductsStocks(const vector<double> & qByProduct, const int &regId); ///< Initialises the stocks of products for the avgLive_* years before the simulation starts
65  void initialiseEmissionCounters(); ///< Initialises the emission counters to zero.
66  void HWP_eol2energy(); ///< Computes the energy substitution for the quota of HWP that reachs end of life and doesn't go to landfill
67 
68 
69 private:
70  void addSavedEmissions(const double & value, const int & regId, const int & em_type); ///< Increases the value to the saved emissions for a given type and region
71  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, the half life and the time passed from stock formation.
72 
73  map<iiskey, double > deathBiomassInventory; ///< Map that register the death of biomass by year, l2_region and forest type (inventoried)[Mm^3 wood]
74  map<iiskey, double > deathBiomassExtra; ///< Map that register the death of biomass by year, l2_region and forest type (non-inventoried biomass: branches, roots..) [Mm^3 wood]
75  map<iiskey, double > products; ///< Map that register the production of a given product by year, l2_region and product [Mm^3 wood]
76  map<int,double> cumSubstitutedEnergy; ///< Map that store the cumulative CO2 substituted for energy consumption, by l2_region [Mt CO2]
77  map<int,double> cumSubstitutedMaterial; ///< Map that store the cumulative CO2 substituted using less energivory material, by l2_region [Mt CO2]
78  map<int,double> cumEmittedForOper; ///< Map that store emissions for forest operations, including transport, by l2_region [Mt CO2]
79 
80 
81 
82 };
83 
84 #endif // CARBON_H
map< int, double > cumEmittedForOper
Map that store emissions for forest operations, including transport, by l2_region [Mt CO2]...
Definition: Carbon.h:78
void addSavedEmissions(const double &value, const int &regId, const int &em_type)
Increases the value to the saved emissions for a given type and region.
Definition: Carbon.cpp:324
map< iiskey, double > products
Map that register the production of a given product by year, l2_region and product [Mm^3 wood]...
Definition: Carbon.h:75
void initialiseDeathBiomassStocks(const vector< double > &deathByFt, const int &regId)
Initialises the stocks of death biomass for the avgLive_* years before the simulation starts...
Definition: Carbon.cpp:169
~Carbon()
Definition: Carbon.cpp:36
double getCumSavedEmissions(const int &regId, const int &em_type) const
Returns the current cumulative saved emissions by type [Mt CO2].
Definition: Carbon.cpp:138
double getStock(const int &regId, const int &stock_type) const
Returns the current stock of carbon [Mt CO2].
Definition: Carbon.cpp:53
map< int, double > cumSubstitutedMaterial
Map that store the cumulative CO2 substituted using less energivory material, by l2_region [Mt CO2]...
Definition: Carbon.h:77
Thread manager. Responsable to manage the main thread and "speak" with the GUI.
Definition: ThreadManager.h:65
void registerTransports(const double &distQ, const int &regId)
Registers the quantities emitted by transport of wood FROM a given region.
Definition: Carbon.cpp:277
void registerDeathBiomass(const double &value, const int &regId, const string &fType)
Registers the "death" of a given amount of biomass, storing it in the deathBiomass map...
Definition: Carbon.cpp:243
void initialiseProductsStocks(const vector< double > &qByProduct, const int &regId)
Initialises the stocks of products for the avgLive_* years before the simulation starts.
Definition: Carbon.cpp:203
void registerHarvesting(const double &value, const int &regId, const string &fType)
Registers the harvesting of trees increasing the value of cumEmittedForOper.
Definition: Carbon.cpp:225
Base class for the regmas application.
Definition: BaseClass.h:239
map< iiskey, double > deathBiomassInventory
Map that register the death of biomass by year, l2_region and forest type (inventoried)[Mm^3 wood]...
Definition: Carbon.h:73
void initialiseEmissionCounters()
Initialises the emission counters to zero.
Definition: Carbon.cpp:158
Carbon(ThreadManager *MTHREAD_h)
Constructor.
Definition: Carbon.cpp:32
Class responsable to keep the logbook of the Carbon Balance.
Definition: Carbon.h:50
void HWP_eol2energy()
Computes the energy substitution for the quota of HWP that reachs end of life and doesn&#39;t go to landf...
Definition: Carbon.cpp:288
map< iiskey, double > deathBiomassExtra
Map that register the death of biomass by year, l2_region and forest type (non-inventoried biomass: b...
Definition: Carbon.h:74
map< int, double > cumSubstitutedEnergy
Map that store the cumulative CO2 substituted for energy consumption, by l2_region [Mt CO2]...
Definition: Carbon.h:76
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...
Definition: Carbon.cpp:341
This file is the header of BaseClass and it is included by ALL compiled code.
void registerProducts(const double &value, const int &regId, const string &productName)
Registers the production of a given amount of products, storing it in the products maps...
Definition: Carbon.cpp:257