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 double ni_amount;
91 double ui_amount;
92 int store_id;
93 cbm::string_t water_management;
94 double irrigation_height;
95 std::vector< int > years;
96 event_status_e status;
97 };
98
99 struct planting_t
100 {
101 int day_of_application;
102 cbm::string_t name;
103 cbm::string_t type_base;
104 cbm::string_t type_extension;
105 cbm::string_t group;
106 inline cbm::string_t plant_type() { return type_base + type_extension; };
107 inline cbm::string_t plant_name() { return name; };
108 double initialbiomass;
109 bool covercrop;
110 cbm::string_t method;
111 double height;
112 double remains_relative;
113 bool mulching;
114 int days_to_maturity;
115 int days_to_earliest_harvest;
116 int days_to_latest_harvest;
117 int days_on_field_after_maturity;
118 int gdd_min;
119 int gdd_max;
120
121 double residues_return_percentage;
122 cbm::string_t residues_return_schedule;
123 int residues_store_id;
124
125 std::vector< int > years;
126 };
127
128 struct cutting_t
129 {
130 cutting_t();
131 int day_of_application;
132 double remains_absolute;
133 double height;
134 double export_fruit;
135 double export_foliage;
136 double export_living_structural_tissue;
137 double export_dead_structural_tissue;
138 double export_root;
139 };
140
141public:
142
143 VegetationPeriod(
144 std::vector< int > const &,
145 size_t /* day of year of start */,
146 planting_t /* planting event */,
147 std::vector< tilling_t > const & /* tilling events */,
148 std::vector< fertilizer_t > const & /* fertilization events */,
149 std::vector< fertilizer_t > const & /* manure events */,
150 double /* irrigation reservoir */,
151 std::vector< irrigation_t > const & /* irrigation events */,
152 std::vector< flooding_t > const & /* flooding events */,
153 std::vector< cutting_t > const & /* cutting events */,
154 size_t /* dynamic parametrization */);
155
156 ~VegetationPeriod();
157
158 /* considered years for vegetation period */
159 std::vector< int > years;
160
162 size_t start;
163
164 planting_t planting_event;
165
166 std::vector< tilling_t > tilling_events;
167 std::vector< irrigation_t > irrigation_events;
168 std::vector< flooding_t > flooding_events;
169 std::vector< fertilizer_t > fertilization_events;
170 std::vector< fertilizer_t > manure_events;
171 std::vector< cutting_t > cutting_events;
172
173 /* */
174 long long int seconds_at_field_preparation;
175 int shorten_vegetation_period;
176
177 /* simulation time in seconds at planting event */
178 long long int seconds_at_planting;
179
180 /* simulation time in second at maturity */
181 long long int seconds_at_maturity;
182
183 /* simulation time in second at maturity */
184 long long int seconds_at_harvest;
185
186 double gdd_at_anticipated_maturity;
187
188 double gdd_target;
189 bool harvested;
190 bool residues_collected;
191
192 size_t executed_tilling_events;
193
194 double irrigation_reservoir;
195 double irrigation_reservoir_withdrawal;
196
197 size_t dynamic_parametrization;
198
199 int id_vegetation_period;
200
201public:
202
203 int inline id(){ return id_vegetation_period; };
204
205 inline bool not_initialized(){ return (seconds_at_field_preparation < 0); };
206
207 lerr_t
208 initialize( cbm::RunLevelArgs *);
209
210 lerr_t
211 assign_tilling_event( tilling_t*,
212 int /* current day */,
213 cbm::sclock_t const * /* clock */,
214 bool _pop = true);
215
216 lerr_t
217 assign_irrigation_event( irrigation_t*,
218 int /* current day */,
219 double /* maturity_status */,
220 double /* soil water content */,
221 double /* field capacity */,
222 bool _pop = true);
223
224 lerr_t
225 assign_flooding_event( std::vector< VegetationPeriod::flooding_t > &,
226 int /* current day */,
227 double /* maturity status */,
228 bool _pop = true);
229
230 lerr_t
231 assign_fertilization_event( fertilizer_t*,
232 size_t /* current day */,
233 size_t /* current year */,
234 double /* maturity status */,
235 double /* surface water */,
236 double /* soil water content */,
237 double /* field capacity */,
238 bool _pop = true);
239
240 lerr_t
241 assign_manuring_event( fertilizer_t*,
242 int /* current day */,
243 int /* current year */,
244 cbm::sclock_t const * /* clock */,
245 double /* maturity status */,
246 double /* surface water */,
247 double /* soil water content */,
248 double /* field capacity */,
249 double /* field size */,
250 std::vector< Store* > _stores,
251 bool _pop = true);
252
253 lerr_t
254 assign_cutting_event( cutting_t*,
255 int /* current day */,
256 bool _pop = true);
257
258 lerr_t
259 assign_planting_event( planting_t*,
260 int /* current day */,
261 long long int /* current second */);
262
263 lerr_t
264 assign_harvest_event( planting_t*,
265 int * /* vegetation period id */,
266 double * /* target of growing degree days for harvest */,
267 cbm::sclock_t const * /* clock */,
268 double /* growing degree days */,
269 double /* maturity status */);
270
271 lerr_t
272 collect_residues( cbm::RunLevelArgs *,
273 Store * /* carbon */,
274 source_t * /* source */);
275
276 /* returns days calculated from seconds */
277 size_t
278 days_since( long long int /* seconds */,
279 cbm::sclock_t const * /* clock */);
280};
281
282
283} /* namespace ldndc */
284
285#endif /* !LDNDC_KERNEL_FARMSYSTEM_DYNAMICVEGETATION_H_ */
Spatially explicit groundwater model.
Definition airchemistryput.h:15