LandscapeDNDC 1.37.0
plamox.h
1
11#ifndef LM_PHYSIOLOGY_PLAMOX_H_
12#define LM_PHYSIOLOGY_PLAMOX_H_
13
14#include "mbe_legacymodel.h"
15#include "state/mbe_state.h"
16#include "ld_shared.h"
17
18#include <input/remotesensing/remotesensing.h>
19
20#include "physiology/ld_plantfunctions.h"
21#include "physiology/ld_rootsystem.h"
22#include "physiology/ld_nitrogenfixation.h"
23#include "physiology/ld_transpiration.h"
24#include "physiology/ld_vernalization.h"
25#include "watercycle/ld_droughtstress.h"
26#include "physiology/ld_stomatalconductance.h"
27#include "physiology/photofarquhar/berryball.h"
28
29#include "eventhandler/graze/graze.h"
30#include "eventhandler/cut/cut.h"
31
32
33namespace ldndc {
34
35#define ON_ENTRY 1
36#define ON_EXIT 2
37
38extern cbm::logger_t * PhysiologyPlaMoxLogger;
39
40struct BaseRootSystemDNDC;
41class NitrogenFixation;
42
51class LDNDC_API PhysiologyPlaMox : public MBE_LegacyModel
52{
53 LMOD_EXPORT_MODULE_INFO(PhysiologyPlaMox,"physiology:plamox","Physiology PlaMox");
54
55 enum plant_life_cycle_e
56 {
57 ANNUAL = 0,
58 BIENNIAL,
59 PLURIENNIAL,
60 PERENNIAL
61 };
62
63public:
64
66 MoBiLE_State *,
67 cbm::io_kcomm_t *,
68 timemode_e);
69
75
76 lerr_t configure( ldndc::config_file_t const *);
77 lerr_t register_ports( cbm::io_kcomm_t *);
78 lerr_t initialize();
79
80 lerr_t solve();
81 lerr_t unregister_ports( cbm::io_kcomm_t *);
82 lerr_t finalize() { return LDNDC_ERR_OK; }
83
84 lerr_t sleep() { return LDNDC_ERR_OK; }
85 lerr_t wake() { return LDNDC_ERR_OK; }
86
87private:
88
89 MoBiLE_State * m_state;
90 cbm::io_kcomm_t * io_kcomm;
91
92 /* required input classes */
93 input_class_climate_t const & cl_;
94 input_class_setup_t const * m_setup;
95 input_class_soillayers_t const & sl_;
96 input_class_species_t const * m_species;
97 input_class_speciesparameters_t const * m_speciesparameters;
98 input_class_siteparameters_t const * m_siteparameters;
99 remotesensing::input_class_remotesensing_t const * rm_;
100
101 MoBiLE_PlantVegetation * m_veg;
102
103 /* required state components */
104 substate_airchemistry_t & ac_;
105 substate_microclimate_t & mc_;
106 substate_physiology_t & ph_;
107 substate_soilchemistry_t & sc_;
108 substate_watercycle_t & wc_;
109
110 /* management handling */
111 SubscribedEvent<LD_EventHandlerQueue> m_HarvestEvents;
112 SubscribedEvent<LD_EventHandlerQueue> m_PlantEvents;
113
114 PublishedField<double> aboveground_biomass;
115 PublishedField<double> maturity_status;
116 PublishedField<double> growing_degree_days_maturity;
117 PublishedField<double> dEmerg;
118
119 PublishedField<double> carbon_plant_biomass_total_exported_from_field;
120 PublishedField<double> carbon_plant_biomass_fruit_exported_from_field;
121 PublishedField<double> nitrogen_plant_biomass_total_exported_from_field;
122 PublishedField<double> nitrogen_plant_biomass_fruit_exported_from_field;
123
124 EventHandlerGraze m_eventgraze;
125 EventHandlerCut m_eventcut;
126
132
137 NitrogenFixation *plamox_nitrogen_fixation;
138
145 ldndc::growable_array < BaseRootSystemDNDC*, 1000, 1 > plamox_root_system;
146
151 LD_PlantFunctions m_pf;
152
153 lvector_t< double > no3_sl;
154 lvector_t< double > nh4_sl;
155 lvector_t< double > don_sl;
156
171 cbm::string_t droughtstress_method;
172
177 cbm::string_t::cbmstring_array_t plantfamilies;
178
184 double const FTS_TOT_;
185
186 /***********************************/
187 /* Mobile state exchange variables */
188 /***********************************/
189
190 lvector_t< long long int > seconds_crop_planting;
191
192 lvector_t< double > gdd_grain_filling;
193
194 lvector_t< double > hypoxia;
195
196 lvector_t< int > days_after_emergence;
197
198 lvector_t< std::string > location;
199 lvector_t< double > dw_retranslocation_stem;
200 lvector_t< double > dw_retranslocation_foliage;
201 lvector_t< double > dw_fol_old;
202 lvector_t< double > lai_dynamic;
203
204 /*************************/
205 /* PlaMox only variables */
206 /*************************/
207
208 std::map< std::string, double > gdd_target;
209
210 /*---------------*/
211 /* model options */
212
216 bool have_automatic_nitrogen;
217
221 double automatic_nitrogen_uptake;
222
223 /*-----------------------------*/
224 /* carbon and nitrogen balance */
225
226 double photoperiod_min;
227 double photoperiod_max;
228 double tot_c_;
229 double tot_n_;
230
231 double timestep_c_assi;
232
236 double n_at_planting;
237
238 /*-----------------*/
239 /* state variables */
240
244 lvector_t< double > transplanting_shock_vt;
245
249 lvector_t< int > yearly_cuts;
250
254 lvector_t< bool > reset_phenology;
255
259 lvector_t< double > n_plant;
260
265 lvector_t< double > allocation_factor_leafs;
266
271 lvector_t< double > allocation_factor_stems;
272
277 lvector_t< double > allocation_factor_fruit;
278
283 lvector_t< double > allocation_factor_roots;
284
290 lvector_t< double > lai_min;
291
296 lvector_t< double > fractional_cover;
297
302 lvector_t< double > chill_factor;
303
308 lvector_t< double > chill_units;
309
314 lvector_t< double > m_fruit_maximum;
315
320 lvector_t< double > spikelets_sterility;
321
326 lvector_t< double > nc_fol_opt;
327
332 lvector_t< unsigned int > root_q_vt_;
333
338 lvector_t< double > daytime_temperatures;
339
344 lvector_t< double > influence_heat_daily;
345
351
352
357
362 //double timing_heatshock;
367 //double duration_heatshock;
368
373 double Tcrit;
378 double Tzero;
379
380 double c_total_exported;
381 double c_fruit_exported;
382 double n_total_exported;
383 double n_fruit_exported;
384
385
386 /********************/
387 /* function members */
388 /********************/
389
394 lerr_t
395 PlaMox_step_init();
396
401 lerr_t
402 PlaMox_step_resize();
407 lerr_t
408 PlaMox_step_out();
409
414 lerr_t
415 PlaMox_management();
416
421 lerr_t
422 PlaMox_planting();
423
437 lerr_t
438 PlaMox_event_plant( MoBiLE_Plant *, EventAttributes const &);
439
444 lerr_t
445 PlaMox_harvest();
446
460 lerr_t
461 PlaMox_event_harvest( MoBiLE_Plant *, EventAttributes const &);
462
463 lerr_t
464 PlaMox_reset_phenology( MoBiLE_Plant * /* plant species */);
465
470 lerr_t
471 PlaMox_photosynthesis( MoBiLE_Plant * /* plant species */);
472
477 void
478 PlaMox_vernalization( MoBiLE_Plant * /* plant species */);
479
485 void
486 PlaMox_growing_degree_days( MoBiLE_Plant * /* plant species */);
487
492 void
493 PlaMox_heat_stress_limitation(MoBiLE_Plant* _vt /* plant species */);
494
499 void
500 PlaMox_plant_development_crop( MoBiLE_Plant * /* plant species */);
501
506 lerr_t
507 PlaMox_allocation_grass( MoBiLE_Plant * /* plant species */);
508
513 lerr_t
514 PlaMox_bud_burst( MoBiLE_Plant * /* plant species */);
515
520 lerr_t
521 PlaMox_redistribution( MoBiLE_Plant * /* plant species */);
522
527 void
528 PlaMox_respiration( MoBiLE_Plant * /* plant species */);
529
534 void
535 PlaMox_exsudation( MoBiLE_Plant * /* plant species */);
536
541 void
542 PlaMox_nitrogen_uptake( MoBiLE_Plant * /* plant species */);
543
548 lerr_t
549 PlaMox_nitrogen_fixation( MoBiLE_Plant * /* plant species */);
550
555 lerr_t
556 PlaMox_senescence( MoBiLE_Plant * /* plant species */);
557
558 /* senescence */
559 lerr_t
560 PlaMox_abscission( MoBiLE_Plant * /* plant species */);
561
566 void
567 PlaMox_drought( MoBiLE_Plant * /* plant species */);
568
573 void
574 PlaMox_transpiration( MoBiLE_Plant * /* plant species */);
575
583 void
585 double);
586
592 void
593 PlaMox_update_height( MoBiLE_Plant *);
594
600 void
602
612 void
613 PlaMox_update_foliage_structure( MoBiLE_Plant *);
614
621 void
622 PlaMox_update_specific_leaf_area( MoBiLE_Plant *);
623
629 void
630 PlaMox_update_nitrogen_concentrations( MoBiLE_Plant *);
631
637 double
638 PlaMox_get_nitrogen_deficiency( MoBiLE_Plant * /* plant species */);
639
645 double
646 PlaMox_get_biomass_induced_downregulation( MoBiLE_Plant *);
647
654 double
655 PlaMox_get_age_factor( MoBiLE_Plant * /* plant species */);
656
665 double
666 PlaMox_get_frost_factor( MoBiLE_Plant *,
667 double);
668
673 double
674 PlaMox_get_hypoxia_factor( MoBiLE_Plant * /* plant species */);
675
680 double
681 PlaMox_get_heat_factor( MoBiLE_Plant * /* plant species */);
682
687 double
688 PlaMox_get_foliage_nitrogen_concentration( MoBiLE_Plant * /* plant species */);
689
694 double
695 PlaMox_n_opt( MoBiLE_Plant * /* plant species */);
696
701 void
702 PlaMox_balance_check( int /*stage*/);
703
707 lerr_t PLAMOX_CHECK_FOR_NEGATIVE_VALUE( char const * /*name*/);
708
709
710 /*****************/
711 /* class members */
712 /*****************/
713
718 class PlaMoxIterator
719 {
720 public:
721
722 PlaMoxIterator(MoBiLE_PlantVegetation *_vg,
723 cbm::string_t::cbmstring_array_t &_f,
724 PlantIterator const &_it) :
725 vegetation( _vg),
726 plantfamilies( _f),
727 iterator( _it)
728 {
729 if ( this->vegetation && this->not_my_family())
730 {
731 this->find_next();
732 }
733 }
734 ~PlaMoxIterator(){}
735
736 private:
737
738 bool not_my_family()
739 {
740 if ( this->iterator != this->vegetation->end())
741 {
742 for (size_t i = 0; i < this->plantfamilies.size(); ++i)
743 {
744 cbm::string_t family = ":";
745 family << this->plantfamilies[i] <<":";
746 if ( this->vegetation->is_family( this->iterator, family.c_str()))
747 {
748 return false;
749 }
750 }
751 }
752 return true;
753 }
754
755 void find_next()
756 {
757 while ( ++this->iterator != this->vegetation->end() && not_my_family())
758 {}
759 }
760
761 public:
762
763 PlaMoxIterator operator++()
764 {
765 this->find_next();
766 return *this;
767 }
768
769 MoBiLE_Plant * operator*()
770 {
771 return this->iterator.operator*();
772 }
773
774 bool operator==(const PlaMoxIterator &_it) const
775 {
776 return this->iterator.operator==( _it.iterator);
777 }
778
779 bool operator!=(const PlaMoxIterator &_it) const
780 {
781 return this->iterator.operator!=( _it.iterator);
782 }
783
784 private:
785 MoBiLE_PlantVegetation *vegetation;
786 cbm::string_t::cbmstring_array_t plantfamilies;
787 PlantIterator iterator;
788 };
789
790 PlaMoxIterator begin();
791
792 PlaMoxIterator end();
793
794 plant_life_cycle_e
795 PlaMox_get_life_cycle( MoBiLE_Plant *);
796};
797} /*namespace ldndc*/
798
799#endif /* !LM_PHYSIOLOGY_PLAMOX_H_ */
Vegetation model PlaMox.
Definition: plamox.h:52
void PlaMox_nitrogen_uptake(MoBiLE_Plant *)
Calculates plant nitrogen uptake based on daily demand.
lvector_t< double > allocation_factor_stems
Allocation factor of daily assimilated carbon to stem growth [-].
Definition: plamox.h:271
double influence_heat_reduction_grainfilling
Resulting impact factor of the heat stress influence on grain yield.
Definition: plamox.h:350
void PlaMox_update_root_structure(MoBiLE_Plant *, double)
Updates all relevant root structural matters.
lvector_t< double > allocation_factor_fruit
Allocation factor of daily assimilated carbon to fruit growth [-].
Definition: plamox.h:277
BerryBall plamox_berryball
Photosynthesis.
Definition: plamox.h:131
ldndc::growable_array< BaseRootSystemDNDC *, 1000, 1 > plamox_root_system
Root system.
Definition: plamox.h:145
double const FTS_TOT_
Time resolution factor: .
Definition: plamox.h:184
double day_of_flowering
day after emergence where flowering is onset
Definition: plamox.h:356
void PlaMox_growing_degree_days(MoBiLE_Plant *)
Calculates growing degree days depending on daily average temperature.
lvector_t< double > influence_heat_daily
store daily impact factor of heat stress on grain yield;
Definition: plamox.h:344
lerr_t PlaMox_allocation_grass(MoBiLE_Plant *)
Allocation metrics for grass species.
lvector_t< double > daytime_temperatures
store daytime temperature for heat stress analysis
Definition: plamox.h:338
bool have_drought_stress
Consider drought stress yes/no.
Definition: plamox.h:161
void PlaMox_respiration(MoBiLE_Plant *)
Calculates maintenance/residual and growth respiration.
lvector_t< double > allocation_factor_roots
Allocation factor of daily assimilated carbon to root growth [-].
Definition: plamox.h:283
LD_PlantFunctions m_pf
All kind of plant related functions.
Definition: plamox.h:151
NitrogenFixation * plamox_nitrogen_fixation
Nitrogen fixation.
Definition: plamox.h:137
lvector_t< double > fractional_cover
Density of seeded plants with regard to optimum (full area) seeding (-).
Definition: plamox.h:296
bool have_heat_stress
Consider heat stress yes/no.
Definition: plamox.h:166
lvector_t< double > chill_factor
Factor that retards plant development if vernalization requirement is not fullfilled.
Definition: plamox.h:302
lvector_t< double > lai_min
Minimum value of üplamt leaf area index (m^2:m^-2). For crops, this value is fixed until between sowi...
Definition: plamox.h:290
lvector_t< double > allocation_factor_leafs
Allocation factor of daily assimilated carbon to leaf growth [-].
Definition: plamox.h:265
double Tzero
The temperature at which there is zero pod-set (°C)
Definition: plamox.h:378
lvector_t< unsigned int > root_q_vt_
Largest soil layer index where roots exist [-].
Definition: plamox.h:332
void PlaMox_update_height(MoBiLE_Plant *)
void PlaMox_vernalization(MoBiLE_Plant *)
Determines the growing degree days and the plant development stage based on if vernalization requirem...
void PlaMox_update_ground_cover(MoBiLE_Plant *)
cbm::string_t droughtstress_method
Transpiration method used by PlaMox.
Definition: plamox.h:171
cbm::string_t::cbmstring_array_t plantfamilies
Plant families that are considered by PlaMox.
Definition: plamox.h:177
double Tcrit
the timing of the episode of high temperatures relative to flowering
Definition: plamox.h:373
lerr_t PlaMox_nitrogen_fixation(MoBiLE_Plant *)
Calculates plant nitrogen fixation.
lvector_t< double > chill_units
Accumulated chilling units for vernalization;.
Definition: plamox.h:308
lerr_t PlaMox_senescence(MoBiLE_Plant *)
Calculates aboveground and belowground plant senecsence.
Spatially explicit groundwater model.
Definition: airchemistryput.h:15