Skip to content

Commit

Permalink
added nwm_ponded_depth as bmi output for parity with NWM surface pond…
Browse files Browse the repository at this point in the history
…ed depth, updated Kinf_nash_surface default value.
  • Loading branch information
ajkhattak committed Sep 10, 2024
1 parent c462707 commit 8cc8c44
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Example configuration files are provided in this directory. To build and run the
| K_nash_surface<sup>1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | Nash Config param for surface runoff |
| nash_storage_surface<sup>1</sup> | 1D array (*double*) | | meters [m] | parameter_adjustable | surface runoff | Nash Config param; reservoir surface storage; default is zero storage |
| nsubsteps_nash_surface<sup>1</sup> | *int* | | | parameter_adjustable | surface runoff | optional (default = 10); number of subtimstep for Nash runoff |
| Kinf_nash_surface<sup>*,1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | optional (default = 0.05); storage fraction per hour that moves from reservoirs to soil |
| Kinf_nash_surface<sup>*,1</sup> | *double* | | 1/hour [h^-1] | parameter_adjustable | surface runoff | optional (default = 0.001); storage fraction per hour that moves from reservoirs to soil |
| retention_depth_nash_surface<sup>*,1</sup> | *double* | | m | parameter_adjustable | surface runoff | optional (default = 0.001); water retention depth threshold (only applied to the first reservoir) |
| a_Xinanjiang_inflection_point_parameter<sup>*</sup> | *double* | | | parameter_adjustable | infiltration excess runoff | when `surface_water_partitioning_scheme=Xinanjiang` |
| b_Xinanjiang_shape_parameter<sup>*</sup> | *double* | | | parameter_adjustable | infiltration excess runoff | when `surface_water_partitioning_scheme=Xinanjiang` |
Expand Down
1 change: 1 addition & 0 deletions include/bmi_cfe.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ struct cfe_state_struct {

int surface_runoff_scheme; // options: giuh-based runoff and nash cascade-based runoff

double nwm_ponded_depth_m;
// ***********************************************************
// ******************* Dynamic allocations *******************
// ***********************************************************
Expand Down
28 changes: 23 additions & 5 deletions src/bmi_cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define INPUT_VAR_NAME_COUNT 5
#define OUTPUT_VAR_NAME_COUNT 14

#define STATE_VAR_NAME_COUNT 94 // must match var_info array size
#define STATE_VAR_NAME_COUNT 95 // must match var_info array size


#define PARAM_VAR_NAME_COUNT 18
Expand Down Expand Up @@ -178,8 +178,10 @@ Variable var_info[] = {
// -------------------------------------------
{ 91, "soil_moisture_profile", "double", 1},
{ 92, "soil_layer_depths_m", "double", 1},
{ 93, "max_rootzone_layer", "int", 1},
{ 93, "max_rootzone_layer", "int", 1},
//--------------------------------------------
{ 94, "nwm_ponded_depth", "double", 1},

};

int i = 0;
Expand Down Expand Up @@ -1141,9 +1143,9 @@ int read_init_config_cfe(const char* config_file, cfe_state_struct* model)
}
if (is_K_infiltration_nash_surface_set == FALSE) {
#if CFE_DEBUG >= 1
printf("Config param 'Kinf_nash_surface' not found in config file, default value is 0.05 [1/hr] \n");
printf("Config param 'Kinf_nash_surface' not found in config file, default value is 0.001 [1/hr] \n");
#endif
model->nash_surface_params.K_infiltration = 0.05; // used in the runon infiltration
model->nash_surface_params.K_infiltration = 0.001; // used in the runon infiltration
}
if (is_retention_depth_nash_surface_set == FALSE) {
#if CFE_DEBUG >= 1
Expand Down Expand Up @@ -1547,6 +1549,17 @@ static int Update (Bmi *self)
// Advance the model time
cfe_ptr->current_time_step += 1;

// compute NWM ponded depth, which is assumed to be the leftover water in the GIUH/NASH queue
cfe_ptr->nwm_ponded_depth_m = 0.0;
if (cfe_ptr->surface_runoff_scheme == GIUH) {
for(i=0;i<cfe_ptr->num_giuh_ordinates;i++)
cfe_ptr->nwm_ponded_depth_m += cfe_ptr->runoff_queue_m_per_timestep[i];
}
else if (cfe_ptr->surface_runoff_scheme == NASH_CASCADE) {
for(i=0;i<cfe_ptr->nash_surface_params.N_nash;i++)
cfe_ptr->nwm_ponded_depth_m += cfe_ptr->nash_surface_params.nash_storage[i];
}

return BMI_SUCCESS;
}

Expand Down Expand Up @@ -2050,7 +2063,12 @@ static int Get_value_ptr (Bmi *self, const char *name, void **dest)
return BMI_SUCCESS;
}


if (strcmp (name, "NWM_PONDED_DEPTH") == 0) {
cfe_state_struct *cfe_ptr;
cfe_ptr = (cfe_state_struct *) self->data;
*dest = (void*)&cfe_ptr->nwm_ponded_depth_m;
return BMI_SUCCESS;
}
/***********************************************************/
/*********** INPUT ***********************************/
/***********************************************************/
Expand Down

0 comments on commit 8cc8c44

Please sign in to comment.