Skip to content

Commit

Permalink
removed a couple of lines that were causing AET and wetting front the…
Browse files Browse the repository at this point in the history
…ta issues in the unit test. Unit test values should now be correct. Added precision to unit test benchmark values. Also fixed a bug where GetValuePtr should now work for field capacity and max ponded head.
Peter La Follette authored and Peter La Follette committed Apr 12, 2024
1 parent 17f6441 commit 93b4283
Showing 3 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/all.hxx
Original file line number Diff line number Diff line change
@@ -192,8 +192,8 @@ struct lgar_calib_parameters
double *vg_n; // Van Genuchten n [-]
double *vg_alpha; // Van Genuchten alpha [1/cm]
double *Ksat; // Hydraulic conductivity [cm/hr]
double field_capacity_psi; // field capacity in capillary head [cm]
double ponded_depth_max; // maximum ponded depth of surface water [cm]
double *field_capacity_psi; // field capacity in capillary head [cm]
double *ponded_depth_max; // maximum ponded depth of surface water [cm]

};

6 changes: 2 additions & 4 deletions src/bmi_lgar.cxx
Original file line number Diff line number Diff line change
@@ -535,8 +535,6 @@ update_calibratable_parameters()
state->soil_properties[soil].vg_m = 1.0 - 1.0/state->soil_properties[soil].vg_n;
state->soil_properties[soil].vg_alpha_per_cm = state->lgar_calib_params.vg_alpha[layer_num-1];
state->soil_properties[soil].Ksat_cm_per_h = state->lgar_calib_params.Ksat[layer_num-1];
state->lgar_bmi_params.field_capacity_psi_cm = state->lgar_calib_params.field_capacity_psi;
state->lgar_bmi_params.ponded_depth_max_cm = state->lgar_calib_params.ponded_depth_max;

current->theta = calc_theta_from_h(current->psi_cm, state->soil_properties[soil].vg_alpha_per_cm,
state->soil_properties[soil].vg_m, state->soil_properties[soil].vg_n,
@@ -820,9 +818,9 @@ GetValuePtr (std::string name)
else if (name.compare("hydraulic_conductivity") == 0)
return (void*)this->state->lgar_calib_params.Ksat;
else if (name.compare("ponded_depth_max") == 0)
return (void*)&this->state->lgar_calib_params.ponded_depth_max;
return (void*)(&state->lgar_bmi_params.ponded_depth_max_cm);
else if (name.compare("field_capacity") == 0)
return (void*)&this->state->lgar_calib_params.field_capacity_psi;
return (void*)(&state->lgar_bmi_params.field_capacity_psi_cm);
else {
std::stringstream errMsg;
errMsg << "variable "<< name << " does not exist";
11 changes: 5 additions & 6 deletions tests/main_unit_test_bmi.cxx
Original file line number Diff line number Diff line change
@@ -453,8 +453,8 @@ int main(int argc, char *argv[])

// Benchmark values of wetting fronts depth and moisture (b is for benchmark)
//std::vector<double> depth_wf_b = {1.873813, 44.00,175.0, 200.0}; // in cm
std::vector<double> depth_wf_b = {4.55332255489760840, 44.00,175.0, 200.0}; // in cm
std::vector<double> theta_wf_b = {0.21414942004659104, 0.172703948143618, 0.252113867764474, 0.179593529195751};
std::vector<double> depth_wf_b = {4.55355239489608365, 44.00,175.0, 200.0}; // in cm
std::vector<double> theta_wf_b = {0.21371581122514613, 0.17270389607163267, 0.25211383152603861, 0.17959348005962811};

int m_to_cm = 100;
int m_to_mm = 1000;
@@ -518,7 +518,7 @@ int main(int argc, char *argv[])

// check total infiltration, AET, and PET.
double infiltration_check_mm = 1.896; // in mm
double AET_check_mm = 0.00922002885520525; // in mm
double AET_check_mm = 0.02980092620558239; // in mm
double PET_check_mm = 0.104; // in mm
double infiltration_computed = 0.0;
double PET_computed = 0.0;
@@ -528,7 +528,6 @@ int main(int argc, char *argv[])
model.GetValue("potential_evapotranspiration", &PET_computed);
model.GetValue("actual_evapotranspiration", &AET_computed);


std::cout<<GREEN<<"\n";
std::cout<<"| *************************************** \n";
std::cout<<"| All BMI Tests passed? "<< passed <<"\n";
@@ -589,8 +588,8 @@ int main(int argc, char *argv[])
double vg_n_set[] = {1.44260592334, 1.14965918354, 1.39051695249};
double vg_alpha_set[] = {0.0021297, 0.0073272, 0.0027454};
double Ksat_set[] = {0.446, 0.0743, 0.415};
double field_capacity_set = 340.9;
double ponded_depth_max_set = 0.0;
double field_capacity_set = 103.3;
double ponded_depth_max_set = 1.0;

// Get the initial values set through the config file
model_calib.GetValue("smcmax", &smcmax[0]);

0 comments on commit 93b4283

Please sign in to comment.