LandscapeDNDC 1.37.0
Loading...
Searching...
No Matches
ld_echy3d.h
1
8
9#ifndef LDNDC_KERNEL_ECHY3D_H_
10#define LDNDC_KERNEL_ECHY3D_H_
11
12#include "ld_kernel.h"
13#include "ld_shared.h"
14#include "ld_sinkinterface.h"
15#include "state/mbe_state.h"
16#include <map>
17
18namespace ldndc {
19
20struct EcHy3DNeighbor
21{
22 EcHy3DNeighbor( cbm::source_descriptor_t, double /* intersect */);
23
24 cbm::source_descriptor_t desc;
25 double intersect; // [m]
26 double water_flux; // [m3]
27 double so4_flux; // [kg S]
28 double no3_flux; // [kg N]
29 double nh4_flux; // [kg N]
30 double don_flux; // [kg N]
31 double doc_flux; // [kg C]
32
33 //entry of neighbor in parent EcHy3DCell vector
34 int cell_map;
35};
36
37class EcHy3DCell
38{
39
40public:
41
42 EcHy3DCell( int, int, double, double, double, double);
43 ~EcHy3DCell();
44
45 int setup_id;
46 int site_id;
47
48 double x; // [m]
49 double y; // [m]
50 double z; //height of soil surface [m]
51
52 bool outlet;
53 double river_output_potential; // downwards from the soil surface [m]
54 double river_length; // [m]
55 double river_elevation; // [m]
56
57 double area; // [m2]
58
59 cbm::string_t ecosystem_type; // {arable, forest, grassland, ...}
60
61 int nd_soil_layers; // number of soil layers
62
63 std::vector< EcHy3DNeighbor > neighbors;
64
65 lerr_t set_soil_layers( input_class_site_t *);
66
67 double sks_mean;
68 double sks_gw;
69 double sks_bottom;
70 double delta_groundwater_volume; // [m3:area]
71 double delta_surfacewater_volume;
72 double delta_riverwater_volume;
73 double delta_so4; // [kg S]
74 double delta_no3; // [kg N]
75 double delta_no3_gain_ecosystem_specific; // [kg N]
76 double delta_no3_loss_ecosystem_specific; // [kg N]
77 double delta_nh4; // [kg N]
78 double delta_don; // [kg N]
79 double delta_doc; // [kg C]
80 double delta_groundwater_gain_ecosystem_specific; // []
81 double delta_groundwater_loss_ecosystem_specific; // []
82 int sl_gw;
83
84 double scale_out;
85
86 double available_so4; // [kg S]
87 double available_no3; // [kg N]
88 double available_nh4; // [kg N]
89 double available_don; // [kg N]
90 double available_doc; // [kg C]
91
92 lerr_t reset();
93
94 double pressure_head; // [m]
95 lerr_t step_init( cbm::RunLevelArgs *);
96
97 lerr_t EcHy3DCell_update_soil_water_content( cbm::RunLevelArgs *);
98 lerr_t EcHy3DCell_update_surface_water_content( cbm::RunLevelArgs *);
99 lerr_t EcHy3DCell_update_river_water_content( cbm::RunLevelArgs *);
100 lerr_t EcHy3DCell_boundary_flows( cbm::RunLevelArgs *, int);
101
102 bool help;
103 lerr_t EcHy3DCell_update_nutrient_transport( double &_delta_val,
104 double &_accumulated_val,
105 lvector_t< double > &_val,
106 cbm::string_t _name);
107
108 double accumulated_precipitation;
109 double accumulated_throughfall;
110 lvector_t< double > accumulated_wateruptake_sl;
111 double accumulated_interceptionevaporation;
112 double accumulated_transpiration;
113 double accumulated_soilevaporation;
114 double accumulated_surfacewaterevaporation;
115 double accumulated_percolation;
116 double accumulated_infiltration;
117 double accumulated_groundwater_access; // [m3:m-2]
118 double accumulated_groundwater_loss; // [m3:m-2]
119 double accumulated_surfacewater_access; // [m3:m-2]
120 double accumulated_surfacewater_loss; // [m3:m-2]
121 double accumulated_outlet;
122 double accumulated_outflow_soil;
123 double accumulated_outflow_surface;
124
125 double accumulated_outflow_so4; // [kg S m-2]
126 double accumulated_outflow_no3; // [kg N m-2]
127 double accumulated_outflow_nh4; // [kg N m-2]
128 double accumulated_outflow_don; // [kg N m-2]
129 double accumulated_outflow_doc; // [kg C m-2]
130
131 double accumulated_precipitation_old;
132 double accumulated_throughfall_old;
133 double accumulated_transpiration_old;
134 double accumulated_wateruptake_old;
135 double accumulated_interceptionevaporation_old;
136 double accumulated_soilevaporation_old;
137 double accumulated_surfacewaterevaporation_old;
138 double accumulated_infiltration_old;
139 double accumulated_groundwater_access_old; // [m3:m-2]
140 double accumulated_groundwater_loss_old; // [m3:m-2]
141 double accumulated_surfacewater_access_old; // [m3:m-2]
142 double accumulated_surfacewater_loss_old; // [m3:m-2]
143 double accumulated_outlet_old;
144 double accumulated_outflow_soil_old;
145 double accumulated_outflow_surface_old;
146
147 double accumulated_outflow_so4_old; // [kg S m-2]
148 double accumulated_outflow_no3_old; // [kg N m-2]
149 double accumulated_outflow_nh4_old; // [kg N m-2]
150 double accumulated_outflow_don_old; // [kg N m-2]
151 double accumulated_outflow_doc_old; // [kg C m-2]
152
153 SubscribedField<double> AccumulatedPrecipitation;
154 SubscribedField<double> AccumulatedThroughfall;
155 SubscribedVectorField<double> AccumulatedWateruptake;
156 SubscribedField<double> AccumulatedTranspiration;
157 SubscribedField<double> AccumulatedInterceptionevaporation;
158 SubscribedField<double> AccumulatedSoilevaporation;
159 SubscribedField<double> AccumulatedSurfacewaterevaporation;
160 PublishedAndSubscribedField<double> AccumulatedRunoff;
161 PublishedAndSubscribedField<double> AccumulatedPercolation;
162 PublishedAndSubscribedField<double> AccumulatedInfiltration;
163 PublishedAndSubscribedField<double> AccumulatedGroundwaterAccess;
164 PublishedAndSubscribedField<double> AccumulatedGroundwaterLoss;
165
166 lvector_t< double > porosity_sl;
167 SubscribedVectorField<double> SoilPorosity;
168
169 double river_water; // [m]
170
171 double surface_snow;
172 PublishedAndSubscribedField<double> SurfaceSnow;
173
174 double surface_water; // [m]
175 PublishedAndSubscribedField<double> SurfaceWater;
176
177 lvector_t< double > wc_sl; // [m2:m-2]
178 PublishedAndSubscribedVectorField<double> VolumetricWaterContent;
179
180 lvector_t< double > sks_sl;
181 PublishedAndSubscribedVectorField<double> SaturatedHydraulicConductivity;
182
183 lvector_t< double > wc_fc_sl;
184 SubscribedVectorField<double> VolumetricFieldCapacity;
185
186 lvector_t< double > wc_sat_sl;
187 SubscribedVectorField<double> SaturatedWaterContent;
188
189 lvector_t< double > ice_sl;
190 SubscribedVectorField<double> IceContent;
191
192 lvector_t< double > height_sl; // [m]
193 lvector_t< double > depth_sl; // [m]
194 SubscribedVectorField<double> Soildepth;
195
196 lvector_t< double > so4_sl;
197 PublishedAndSubscribedVectorField<double> SoilSO4;
198
199 lvector_t< double > no3_sl;
200 PublishedAndSubscribedVectorField<double> SoilNO3;
201
202 lvector_t< double > nh4_sl;
203 PublishedAndSubscribedVectorField<double> SoilNH4;
204
205 lvector_t< double > don_sl;
206 PublishedAndSubscribedVectorField<double> SoilDON;
207
208 lvector_t< double > doc_sl;
209 PublishedAndSubscribedVectorField<double> SoilDOC;
210
211 PublishedAndSubscribedField<double> AccumulatedLeachingNO3;
212 PublishedAndSubscribedField<double> AccumulatedLeachingNH4;
213 PublishedAndSubscribedField<double> AccumulatedLeachingDON;
214 PublishedAndSubscribedField<double> AccumulatedLeachingDOC;
215
216 double
217 max_depth();
218
219 double
220 get_runoff();
221
222 double
223 get_ground_water_available();
224
225 double
226 get_ground_water();
227
228 double
229 get_soil_water();
230
231 double
232 get_total_water();
233
234 double
235 get_river_potential();
236
237 double
238 get_groundwater_share( lvector_t< double > &_source);
239
240 //Water volume only considered until field capacity
241 //Below field capacity, soil layer is no more accounted to the saturated zone
242 bool inline is_groundwater( int _sl){ return cbm::flt_greater( wc_sl[_sl], wc_fc_sl[_sl]); };
243};
244
245
246
247class LDNDC_API EcHy3D : public cbm::kernel_t
248{
249 LDNDC_KERNEL_OBJECT(EcHy3D,echy3d)
250
251public:
252 static double const WFPS_THRESHOLD;
253
254public:
255 EcHy3D();
256 ~EcHy3D();
257
258 lerr_t configure( cbm::RunLevelArgs *);
259 lerr_t initialize( cbm::RunLevelArgs *);
260
261 //we solve with read due to mobile communication
262 lerr_t read( cbm::RunLevelArgs *);
263 lerr_t write( cbm::RunLevelArgs *);
264
265 lerr_t finalize( cbm::RunLevelArgs *);
266
267private:
268
269 lerr_t EcHy3D_initialize_cells();
270 lerr_t EcHy3D_initialize_cell_communication( cbm::RunLevelArgs *);
271 lerr_t EcHy3D_initialize_sinks( cbm::RunLevelArgs *);
272
273 lerr_t EcHy3D_receive_state();
274 lerr_t EcHy3D_send_state( cbm::RunLevelArgs *);
275 lerr_t EcHy3D_write( cbm::RunLevelArgs *);
276
277
278 std::vector< EcHy3DCell > cells;
279
280 cbm::string_t data_file;
281 std::string data_file_content;
282
283 int kernel_setup_id;
284
285private:
286
287 lerr_t
288 collect_datarecord( ldndc_flt64_t * /* data buffer */);
289
290 lerr_t m_writerecord( ldndc_flt64_t *);
291 ldndc::sink_handle_t m_sink;
292 ldndc::SinkInterface m_sif;
293
298 EcHy3DCell *
299 get_cell( int /* cell id */);
300
301private:
302
303 /* hide these buggers for now */
304 EcHy3D( EcHy3D const &);
305 EcHy3D & operator=( EcHy3D const &);
306};
307} /* namespace ldndc */
308
309#endif /* !LDNDC_KERNEL_ECHY3D_H_ */
310
Spatially explicit groundwater model.
Definition airchemistryput.h:15