Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/bmi_lgar.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ extern "C" {
#include "../giuh/giuh.h"
}

#define NWM_PONDED_DEPTH_OUT_VAR "nwm_ponded_depth"

namespace bmi_lgar {
class NotImplemented : public std::logic_error {
public:
Expand Down Expand Up @@ -58,6 +60,7 @@ public:
this->output_var_names[12] = "percolation";
this->output_var_names[13] = "groundwater_to_stream_recharge";
this->output_var_names[14] = "mass_balance";
this->output_var_names[15] = NWM_PONDED_DEPTH_OUT_VAR;

/*
this->output_var_names[13] = "cum_precipitation";
Expand Down Expand Up @@ -142,7 +145,7 @@ private:
void realloc_soil();
struct model_state* state;
static const int input_var_name_count = 3;
static const int output_var_name_count = 15;
static const int output_var_name_count = 16;
static const int calib_var_name_count = 7;

std::string input_var_names[input_var_name_count];
Expand All @@ -166,6 +169,7 @@ private:
double volrech_timestep_m;
double volrunoff_timestep_m;
double volrunoff_giuh_timestep_m;
double volrunoff_giuh_ponded_m;
double volQ_timestep_m;
double volQ_gw_timestep_m;
double volPET_timestep_m;
Expand Down
17 changes: 14 additions & 3 deletions src/bmi_lgar.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Update()
bmi_unit_conv.volQ_gw_timestep_m = 0.0;
bmi_unit_conv.volPET_timestep_m = 0.0;
bmi_unit_conv.volrunoff_giuh_timestep_m = 0.0;
bmi_unit_conv.volrunoff_giuh_ponded_m = 0.0;

return;
}
Expand Down Expand Up @@ -153,6 +154,7 @@ Update()
double volrech_timestep_cm = 0.0;
double surface_runoff_timestep_cm = 0.0; // direct surface runoff
double volrunoff_giuh_timestep_cm = 0.0;
double volrunoff_giuh_ponded_cm = 0.0;
double volQ_timestep_cm = 0.0;
double volQ_gw_timestep_cm = 0.0;

Expand Down Expand Up @@ -523,6 +525,11 @@ Update()
// when groundwater component is added, it should probably happen inside of the subcycling loop.
volQ_timestep_cm = volrunoff_giuh_timestep_cm;

// calculate compounded runoff
for (int i = 0; i < num_giuh_ordinates; ++i) {
volrunoff_giuh_ponded_cm += giuh_runoff_queue[i];
}

/*----------------------------------------------------------------------*/
// Everything related to lgar state is done at this point, now time to update some dynamic variables

Expand Down Expand Up @@ -591,7 +598,7 @@ Update()
bmi_unit_conv.volQ_gw_timestep_m = volQ_gw_timestep_cm * state->units.cm_to_m;
bmi_unit_conv.volPET_timestep_m = PET_timestep_cm * state->units.cm_to_m;
bmi_unit_conv.volrunoff_giuh_timestep_m = volrunoff_giuh_timestep_cm * state->units.cm_to_m;

bmi_unit_conv.volrunoff_giuh_ponded_m = volrunoff_giuh_ponded_cm * state->units.cm_to_m;
}


Expand Down Expand Up @@ -765,6 +772,7 @@ GetVarGrid(std::string name)
|| name.compare("percolation") == 0
|| name.compare("groundwater_to_stream_recharge") == 0
|| name.compare("mass_balance") == 0
|| name.compare(NWM_PONDED_DEPTH_OUT_VAR) == 0
) // double
return 1;
else if (
Expand Down Expand Up @@ -845,7 +853,7 @@ GetVarUnits(std::string name)
|| name.compare("actual_evapotranspiration") == 0) // double
return "m";
else if (name.compare("surface_runoff") == 0 || name.compare("giuh_runoff") == 0
|| name.compare("soil_storage") == 0) // double
|| name.compare("soil_storage") == 0 || name.compare(NWM_PONDED_DEPTH_OUT_VAR) == 0) // double
return "m";
else if (name.compare("total_discharge") == 0 || name.compare("infiltration") == 0
|| name.compare("percolation") == 0) // double
Expand Down Expand Up @@ -884,7 +892,7 @@ GetVarLocation(std::string name)
|| name.compare("actual_evapotranspiration") == 0) // double
return "node";
else if (name.compare("surface_runoff") == 0 || name.compare("giuh_runoff") == 0
|| name.compare("soil_storage") == 0) // double
|| name.compare("soil_storage") == 0 || name.compare(NWM_PONDED_DEPTH_OUT_VAR)) // double
return "node";
else if (name.compare("total_discharge") == 0 || name.compare("infiltration") == 0
|| name.compare("percolation") == 0 || name.compare("groundwater_to_stream_recharge") == 0) // double
Expand Down Expand Up @@ -1001,6 +1009,8 @@ GetValuePtr (std::string name)
return (void*)(&bmi_unit_conv.volQ_gw_timestep_m);
else if (name.compare("mass_balance") == 0)
return (void*)(&bmi_unit_conv.mass_balance_m);
else if (name.compare(NWM_PONDED_DEPTH_OUT_VAR) == 0)
return (void*)(&this->bmi_unit_conv.volrunoff_giuh_ponded_m);
else if (name.compare("soil_depth_layers") == 0)
return (void*)this->state->lgar_bmi_params.cum_layer_thickness_cm; // this too and, if needed, change soil_moisture_layers to soil_thickness_layers
else if (name.compare("soil_moisture_wetting_fronts") == 0)
Expand Down Expand Up @@ -1316,6 +1326,7 @@ serialize(Archive& ar, const unsigned int version) {
ar & this->bmi_unit_conv.volQ_gw_timestep_m;
ar & this->bmi_unit_conv.mass_balance_m;
ar & this->bmi_unit_conv.volrunoff_timestep_m;
ar & this->bmi_unit_conv.volrunoff_giuh_ponded_m;
ar & state->lgar_bmi_params.num_wetting_fronts;
ar & state->lgar_calib_params.ponded_depth_max;
ar & state->lgar_calib_params.field_capacity_psi;
Expand Down