LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
ld_vegetation_period.h
1
7
8#ifndef LDNDC_KERNEL_FARMSYSTEM_DYNAMICVEGETATION_H_
9#define LDNDC_KERNEL_FARMSYSTEM_DYNAMICVEGETATION_H_
10
11#include "ld_kernel.h"
12#include "ld_eventqueue.h"
13#include <containers/lvector.h>
14#include <json/cbm_json.h>
15#include "farmsystem/ld_stores.h"
16
17namespace ldndc {
18
19class source_t;
20
21class VegetationPeriod
22{
23private:
24
25 static int nd_vegetation_periods;
26
27public:
28
29 struct tilling_t
30 {
31 tilling_t();
32 int day_of_application;
33 int days_of_application_after_harvest;
34 double depth;
35 };
36
37 struct irrigation_t
38 {
39 irrigation_t();
40 int day_of_application;
41 double irrigation_height;
42 double fraction_dvs_min_of_application;
43 double fraction_dvs_max_of_application;
44 double fraction_field_capacity;
45 bool is_reservoir;
46 std::vector< int > years;
47 };
48
49 enum event_status_e
50 {
51 RECEIVABLE,
52 APPOINTED,
53 INITIALIZED,
54 STARTED,
55 CONTINUING,
56 FINALIZED,
57 DONE
58 };
59
60 struct flooding_t
61 {
62 flooding_t();
63 int start_static;
64 int end_static;
65 double start_dynamic;
66 double end_dynamic;
67 double irrigation_height;
68 double watertable;
69 double bundheight;
70 double percolation_rate;
71 bool drainage;
72 bool unlimited_water;
73 double saturation_level;
74 double soil_depth;
75 event_status_e status;
76 };
77
78 struct fertilizer_t
79 {
80 fertilizer_t();
81 int day_of_application;
82 int days_of_application_after_harvest;
83 double fraction_dvs_min_of_application;
84 double fraction_dvs_max_of_application;
85 double fraction_field_capacity;
86 cbm::string_t name;
87 double c_amount;
88 double n_amount;
89 double depth;
90 int store_id;
91 cbm::string_t water_management;
92 double irrigation_height;
93 std::vector< int > years;
94 event_status_e status;
95 };
96
97 struct planting_t
98 {
99 int day_of_application;
100 cbm::string_t name;
101 cbm::string_t type_base;
102 cbm::string_t type_extension;
103 cbm::string_t group;
104 inline cbm::string_t plant_type() { return type_base + type_extension; };
105 inline cbm::string_t plant_name() { return name; };
106 double initialbiomass;
107 bool covercrop;
108 cbm::string_t method;
109 double height;
110 double remains_relative;
111 bool mulching;
112 int days_to_maturity;
113 int days_to_earliest_harvest;
114 int days_to_latest_harvest;
115 int days_on_field_after_maturity;
116 int gdd_min;
117 int gdd_max;
118
119 double residues_return_percentage;
120 cbm::string_t residues_return_schedule;
121 int residues_store_id;
122
123 std::vector< int > years;
124 };
125
126 struct cutting_t
127 {
128 cutting_t();
129 int day_of_application;
130 double remains_absolute;
131 double height;
132 double export_fruit;
133 double export_foliage;
134 double export_living_structural_tissue;
135 double export_dead_structural_tissue;
136 double export_root;
137 };
138
139public:
140
141 VegetationPeriod(
142 std::vector< int > const &,
143 size_t /* day of year of start */,
144 planting_t /* planting event */,
145 std::vector< tilling_t > const & /* tilling events */,
146 std::vector< fertilizer_t > const & /* fertilization events */,
147 std::vector< fertilizer_t > const & /* manure events */,
148 double /* irrigation reservoir */,
149 std::vector< irrigation_t > const & /* irrigation events */,
150 std::vector< flooding_t > const & /* flooding events */,
151 std::vector< cutting_t > const & /* cutting events */,
152 size_t /* dynamic parametrization */);
153
154 ~VegetationPeriod();
155
156 /* considered years for vegetation period */
157 std::vector< int > years;
158
160 size_t start;
161
162 planting_t planting_event;
163
164 std::vector< tilling_t > tilling_events;
165 std::vector< irrigation_t > irrigation_events;
166 std::vector< flooding_t > flooding_events;
167 std::vector< fertilizer_t > fertilization_events;
168 std::vector< fertilizer_t > manure_events;
169 std::vector< cutting_t > cutting_events;
170
171 /* */
172 long long int seconds_at_field_preparation;
173 int shorten_vegetation_period;
174
175 /* simulation time in seconds at planting event */
176 long long int seconds_at_planting;
177
178 /* simulation time in second at maturity */
179 long long int seconds_at_maturity;
180
181 /* simulation time in second at maturity */
182 long long int seconds_at_harvest;
183
184 double gdd_at_anticipated_maturity;
185
186 double gdd_target;
187 bool harvested;
188 bool residues_collected;
189
190 size_t executed_tilling_events;
191
192 double irrigation_reservoir;
193 double irrigation_reservoir_withdrawal;
194
195 size_t dynamic_parametrization;
196
197 int id_vegetation_period;
198
199public:
200
201 int inline id(){ return id_vegetation_period; };
202
203 inline bool not_initialized(){ return (seconds_at_field_preparation < 0); };
204
205 lerr_t
206 initialize( cbm::RunLevelArgs *);
207
208 lerr_t
209 assign_tilling_event( tilling_t*,
210 int /* current day */,
211 cbm::sclock_t const * /* clock */,
212 bool _pop = true);
213
214 lerr_t
215 assign_irrigation_event( irrigation_t*,
216 int /* current day */,
217 double /* maturity_status */,
218 double /* soil water content */,
219 double /* field capacity */,
220 bool _pop = true);
221
222 lerr_t
223 assign_flooding_event( std::vector< VegetationPeriod::flooding_t > &,
224 int /* current day */,
225 double /* maturity status */,
226 bool _pop = true);
227
228 lerr_t
229 assign_fertilization_event( fertilizer_t*,
230 size_t /* current day */,
231 size_t /* current year */,
232 double /* maturity status */,
233 double /* surface water */,
234 double /* soil water content */,
235 double /* field capacity */,
236 bool _pop = true);
237
238 lerr_t
239 assign_manuring_event( fertilizer_t*,
240 int /* current day */,
241 int /* current year */,
242 cbm::sclock_t const * /* clock */,
243 double /* maturity status */,
244 double /* surface water */,
245 double /* soil water content */,
246 double /* field capacity */,
247 double /* field size */,
248 std::vector< Store* > _stores,
249 bool _pop = true);
250
251 lerr_t
252 assign_cutting_event( cutting_t*,
253 int /* current day */,
254 bool _pop = true);
255
256 lerr_t
257 assign_planting_event( planting_t*,
258 int /* current day */,
259 long long int /* current second */);
260
261 lerr_t
262 assign_harvest_event( planting_t*,
263 int * /* vegetation period id */,
264 double * /* target of growing degree days for harvest */,
265 cbm::sclock_t const * /* clock */,
266 double /* growing degree days */,
267 double /* maturity status */);
268
269 lerr_t
270 collect_residues( cbm::RunLevelArgs *,
271 Store * /* carbon */,
272 source_t * /* source */);
273
274 /* returns days calculated from seconds */
275 size_t
276 days_since( long long int /* seconds */,
277 cbm::sclock_t const * /* clock */);
278};
279
280
281} /* namespace ldndc */
282
283#endif /* !LDNDC_KERNEL_FARMSYSTEM_DYNAMICVEGETATION_H_ */
Spatially explicit groundwater model.
Definition airchemistryput.h:15