Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added_NWM_ponded depth #134

Merged
merged 2 commits into from
Sep 12, 2024
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
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
3 changes: 2 additions & 1 deletion realizations/realization_cfe_pet_surfgiuh.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Q_OUT",
"POTENTIAL_ET",
"ACTUAL_ET",
"SOIL_STORAGE"
"SOIL_STORAGE",
"NWM_PONDED_DEPTH"
],
"modules": [
{
Expand Down
3 changes: 2 additions & 1 deletion realizations/realization_cfe_pet_surfnash.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"Q_OUT",
"POTENTIAL_ET",
"ACTUAL_ET",
"SOIL_STORAGE"
"SOIL_STORAGE",
"NWM_PONDED_DEPTH"
],
"modules": [
{
Expand Down
44 changes: 34 additions & 10 deletions src/bmi_cfe.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#define CFE_DEBUG 0

#define INPUT_VAR_NAME_COUNT 5
#define OUTPUT_VAR_NAME_COUNT 14
#define OUTPUT_VAR_NAME_COUNT 15

#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 All @@ -200,7 +202,8 @@ static const char *output_var_names[OUTPUT_VAR_NAME_COUNT] = {
"GW_STORAGE",
"SOIL_STORAGE",
"SOIL_STORAGE_CHANGE",
"SURF_RUNOFF_SCHEME"
"SURF_RUNOFF_SCHEME",
"NWM_PONDED_DEPTH"
};

static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
Expand All @@ -217,7 +220,8 @@ static const char *output_var_types[OUTPUT_VAR_NAME_COUNT] = {
"double",
"double",
"double",
"int"
"int",
"double"
};

static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] = {
Expand All @@ -234,6 +238,7 @@ static const int output_var_item_count[OUTPUT_VAR_NAME_COUNT] = {
1,
1,
1,
1,
1
};

Expand All @@ -251,7 +256,8 @@ static const char *output_var_units[OUTPUT_VAR_NAME_COUNT] = {
"m",
"m",
"m",
"none"
"none",
"m"
};

static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] = {
Expand All @@ -268,6 +274,7 @@ static const int output_var_grids[OUTPUT_VAR_NAME_COUNT] = {
0,
0,
0,
0,
0
};

Expand All @@ -285,7 +292,8 @@ static const char *output_var_locations[OUTPUT_VAR_NAME_COUNT] = {
"node",
"node",
"node",
"none"
"none",
"node"
};

// Don't forget to update Get_value/Get_value_at_indices (and setter) implementation if these are adjusted
Expand Down Expand Up @@ -1141,9 +1149,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 +1555,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 +2069,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
Loading