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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
# - id: include-what-you-use

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.3
rev: 0.30.0
hooks:
- id: check-github-workflows
- repo: meta
Expand Down
8 changes: 4 additions & 4 deletions src/DemandExpressionHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ bool CDemandOptimizer::ConvertToExpressionTerm(const string s, expressionTerm* t
//----------------------------------------------------------------------
else if (s[0]=='!') //decision variable e.g., !Q234, !I32, or !D.Matts_Brewery
{
if ((s[1] == 'Q') || (s[1] == 'h') || (s[1]=='I')) //Subbasin-indexed
if ((s[1] == 'Q') || (s[1] == 'h') || (s[1]=='I')) //Subbasin-indexed
{
int p=GetIndexFromDVString(s);
if (p == DOESNT_EXIST) {
Expand Down Expand Up @@ -707,7 +707,7 @@ bool CDemandOptimizer::ConvertToExpressionTerm(const string s, expressionTerm* t
//----------------------------------------------------------------------
else if (GetControlVariable(s,index) != RAV_BLANK_DATA) // control variable
{

term->type=TERM_CONTROL;
term->value=GetControlVariable(s,index);// initially zero
term->DV_ind=index;
Expand Down Expand Up @@ -760,7 +760,7 @@ expressionStruct *CDemandOptimizer::ParseExpression(const char **s,
{
strlen=to_string(s[i]).length();
type[i]=EXP;
if ((s[i][0]=='+') || ((strlen==1) && (s[i][0]=='-')) || (s[i][0]=='*') || (s[i][0]=='/') || (s[i][0]=='=') || (s[i][0]=='<') || (s[i][0]=='>')){
if ((s[i][0]=='+') || ((strlen==1) && (s[i][0]=='-')) || (s[i][0]=='*') || (s[i][0]=='/') || (s[i][0]=='=') || (s[i][0]=='<') || (s[i][0]=='>')){
type[i] = EXP_OP;
if ((i > 1) && (type[i - 1] == EXP_OP)) {
ExitGracefully("ParseExpression: cannot have consecutive math operators in an expression.",BAD_DATA_WARN);
Expand Down Expand Up @@ -1277,7 +1277,7 @@ double CDemandOptimizer::EvaluateTerm(expressionTerm **pTerms,const int k, const
int p=pT->p_index;
return _pModel->GetSubBasin(p)->GetAvgStateVar(i);
}
else if (pT->type == TERM_CONST)
else if (pT->type == TERM_CONST)
{
return pT->value;
}
Expand Down
22 changes: 11 additions & 11 deletions src/DemandOptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ int CDemandOptimizer::GetDemandIndexFromName(const string demand_tag) const
//////////////////////////////////////////////////////////////////
/// \brief gets demand from index
//
CDemand* CDemandOptimizer::GetWaterDemand(const int d)
CDemand* CDemandOptimizer::GetWaterDemand(const int d)
{
return _pDemands[d];
}
//////////////////////////////////////////////////////////////////
/// \brief gets number of enabled water demands
//
int CDemandOptimizer::GetNumWaterDemands() const
int CDemandOptimizer::GetNumWaterDemands() const
{
return _nDemands;
}
Expand Down Expand Up @@ -420,7 +420,7 @@ bool CDemandOptimizer::VariableNameExists(const string &name) const
for (int i = 0; i < _nUserConstants; i++) {
if (_aUserConstNames[i]==name){return true;}
}

if (GetUnitConversion(name)!=RAV_BLANK_DATA){return true;}

return false;
Expand Down Expand Up @@ -771,7 +771,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
{
// ASSUMES ALL EXPRESSIONS IN GOAL/CONSTRAINT ARE EITHER == or >/<, NEVER MIXED.
if (_pGoals[j]->is_goal) {
if (_pGoals[j]->pOperRegimes[0]->pExpression->compare == COMPARE_IS_EQUAL)
if (_pGoals[j]->pOperRegimes[0]->pExpression->compare == COMPARE_IS_EQUAL)
{
_pGoals[j]->slack_ind1=_nSlackVars;
pDV = new decision_var("SL+" + to_string(j), p, DV_SLACK,_nSlackVars);
Expand All @@ -790,7 +790,7 @@ void CDemandOptimizer::InitializePostRVMRead(CModel* pModel, const optStruct& Op
AddDecisionVar(pDV);
_nSlackVars++;
}
else
else
{
_pGoals[j]->slack_ind1=_nSlackVars;
pDV = new decision_var("SL+"+ to_string(j), p, DV_SLACK,_nSlackVars);
Expand Down Expand Up @@ -1782,7 +1782,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
retval = lp_lib::add_constraintex(pLinProg,3,row_val,col_ind,ROWTYPE_LE,RHS);
ExitGracefullyIf(retval==0,"SolveDemandProblem::Error adding stage discharge constraint F",RUNTIME_ERR);
IncrementAndSetRowName(pLinProg,rowcount,"reserv_Q_F"+to_string(pSB->GetID()));

}
else /* if (aDisableSDCurve[p])*/ //keep same rows - make inert equations
{
Expand All @@ -1798,7 +1798,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
IncrementAndSetRowName(pLinProg,rowcount,"reserv_Q_E"+to_string(pSB->GetID()));
retval = lp_lib::add_constraintex(pLinProg,1,row_val,col_ind,ROWTYPE_LE,RHS);
IncrementAndSetRowName(pLinProg,rowcount,"reserv_Q_F"+to_string(pSB->GetID()));

s+=2; //to ensure EnvMin counter is working
}
res_count++;
Expand Down Expand Up @@ -1887,7 +1887,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio

// ----------------------------------------------------------------
// ITERATIVELY SOLVE OPTIMIZATION PROBLEM WITH LP_SOLVE
// ----------------------------------------------------------------
// ----------------------------------------------------------------
const int NUM_ITERATIONS=5;

int ctyp;
Expand Down Expand Up @@ -1953,7 +1953,7 @@ void CDemandOptimizer::SolveDemandProblem(CModel *pModel, const optStruct &Optio
{
_aSolverRowNames [j]=to_string(lp_lib::get_row_name(pLinProg,j+1));
_aSolverResiduals[j]=constr[j]-lp_lib::get_rh(pLinProg,j+1); // LHS-RHS for each goal/constraint

ctyp=lp_lib::get_constr_type(pLinProg,j+1);
if (ctyp==LE){upperswap(_aSolverResiduals[j],0.0); }
if (ctyp==GE){lowerswap(_aSolverResiduals[j],0.0); _aSolverResiduals[j]*=-1; }
Expand Down Expand Up @@ -2211,8 +2211,8 @@ void CDemandOptimizer::WriteMinorOutput(const optStruct &Options,const time_stru

_GOALSAT<<tt.model_time <<","<<usedate<<","<<usehour;

//first slack terms are due to environmental flow constraints (_nEnviroFlowGoals)
//first slack terms are due to environmental flow constraints (_nEnviroFlowGoals)

int s=_nEnviroFlowGoals; //this is first index of user-specified slack variable

for (int i = 0; i < _nGoals; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/Diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ string CDiagnostic::GetName() const
case(DIAG_RSR): {return "DIAG_RSR";}
case(DIAG_R2): {return "DIAG_R2";}
case(DIAG_LOG_NASH): {return "DIAG_LOG_NASH";}
case(DIAG_KLING_GUPTA): {return "DIAG_KLING_GUPTA";}
case(DIAG_KLING_GUPTA): {return "DIAG_KLING_GUPTA";}
case(DIAG_KGE_PRIME): {return "DIAG_KGE_PRIME";}
case(DIAG_DAILY_KGE): {return "DIAG_DAILY_KGE";}
case(DIAG_NASH_SUTCLIFFE_DER):{return "DIAG_NASH_SUTCLIFFE_DER"; }
Expand Down
4 changes: 2 additions & 2 deletions src/EnergyTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ void CEnthalpyModel::Initialize(const optStruct& Options)
A=_pModel->GetSubBasin(p)->GetReferenceXSectArea();
tr=L*A/Q/SEC_PER_DAY;
if (tr<0.33*Options.timestep){_aMinResTime [p]=tr;}
else {_aMinResTime [p]=0.333*Options.timestep; }
else {_aMinResTime [p]=0.333*Options.timestep; }
}

// initialize stream temperatures if init_stream_temp is given
Expand Down Expand Up @@ -834,7 +834,7 @@ double CEnthalpyModel::GetEnergyLossesFromReach(const int p,double &Q_sens,doubl
Q_sens +=dA*hstar *(temp_air-Tbar_km); //[m2]*[MJ/m2/d/K]*[K]=[MJ/d]
Q_cond +=dA*kbed *(temp_bed-Tbar_km);
Q_lw_out +=dA*klin *(0.75*temp_lin-(Tbar_km+ZERO_CELSIUS)); //linearized - works except at T~0
Q_lateral+=dA*qlat *dbar/Ax*HCP_WATER*(temp_lat-Tbar_km);
Q_lateral+=dA*qlat *dbar/Ax*HCP_WATER*(temp_lat-Tbar_km);

temp_average+=dA/As*Tbar_km;
if (As == 0.0) {temp_average=0.0;}
Expand Down
2 changes: 1 addition & 1 deletion src/EnergyTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CEnthalpyModel :public CConstituentModel

//Manipulators (inherited from CConstitModel)
void Initialize (const optStruct& Options);

void PrepareForInCatchmentRouting(const int p);
void PrepareForRouting (const int p);
double ApplyInCatchmentRouting (const int p,
Expand Down
4 changes: 2 additions & 2 deletions src/FrozenLake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void CmvFrozenLake::GetParticipatingParamList(string *aP , class_type *aPC , in
}
else if (_type == LFREEZE_THERMAL)
{

}
else
{
Expand Down Expand Up @@ -105,7 +105,7 @@ void CmvFrozenLake::GetRatesOfChange( const double *state_vars,
const time_struct &tt,
double *rates) const
{
if ((pHRU->GetHRUType()!=HRU_LAKE) &&
if ((pHRU->GetHRUType()!=HRU_LAKE) &&
(pHRU->GetHRUType()!=HRU_WETLAND)){return;}//Lakes and wetlands only (includes reservoirs)

double ice_thick=state_vars[iFrom[0]];
Expand Down
10 changes: 5 additions & 5 deletions src/MassRouting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,14 @@ void CConstituentModel::PrepareForRouting(const int p) {
void CConstituentModel::PrepareForInCatchmentRouting(const int p) {
//does nothing - interesting in child classes
}
void CConstituentModel::InCatchmentRoute(const int p, double &Mlat_new, const optStruct &Options)
void CConstituentModel::InCatchmentRoute(const int p, double &Mlat_new, const optStruct &Options)
{
PrepareForInCatchmentRouting(p);

const double * aUnitHydro =_pModel->GetSubBasin(p)->GetUnitHydrograph();
const double * aQlatHist =_pModel->GetSubBasin(p)->GetLatHistory();
Mlat_new=ApplyInCatchmentRouting(p,aUnitHydro,aQlatHist,_aMlatHist[p],_nMlatHist[p], Options.timestep);

_aMlocLast[p] = _aMlocal[p];
_aMlocal [p] = Mlat_new;
}
Expand Down Expand Up @@ -266,7 +266,7 @@ void CConstituentModel::RouteMass(const int p, // SB index
//==============================================================
const double * aRouteHydro=_pModel->GetSubBasin(p)->GetRoutingHydrograph();
const double * aQinHist =_pModel->GetSubBasin(p)->GetInflowHistory();

int nSegments =_pModel->GetSubBasin(p)->GetNumSegments();
double seg_fraction=1.0/(double)(nSegments);

Expand All @@ -284,7 +284,7 @@ void CConstituentModel::RouteMass(const int p, // SB index
else {
ExitGracefully("Unrecognized or unsupported constiuent routing method (:Routing command must be ROUTE_NONE, ROUTE_PLUG_FLOW, or ROUTE_DIFFUSIVE_WAVE to support transport)",STUB);
}

//all fluxes from catchment are routed directly to basin outlet (unless handled in convolution routing as source term)
if ((!_lateral_via_convol) || (_pModel->GetSubBasin(p)->IsHeadwater())){
aMout_new[nSegments-1]+=Mlat_new;
Expand Down Expand Up @@ -436,7 +436,7 @@ void CConstituentModel::UpdateMassOutflows( const int p,
if (!_lateral_via_convol){//elsewise, in get net reach losses
dM+=0.5*(Mlat_new+_aMlat_last[p])*dt;
}

_channel_storage[p]+=dM;//[mg] or [MJ]

//Update rivulet storage
Expand Down
6 changes: 3 additions & 3 deletions src/ParseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ bool ParseInputFiles (CModel *&pModel,
}
ExitGracefully("Cannot find or read .rvi file",BAD_DATA);return false;
}
if (!Options.create_rvp_template) {//otherwise, jump right to parse rvp, where template is created
if (!Options.create_rvp_template) {//otherwise, jump right to parse rvp, where template is created
if (!ParseNetCDFRunInfoFile(pModel, Options, runname_overridden,runmode_overridden)){
ExitGracefully("Cannot find or read NetCDF runinfo file", BAD_DATA); return false;
}
Expand Down Expand Up @@ -3533,12 +3533,12 @@ bool ParseMainInputFile (CModel *&pModel,
} //end while (!end_of_file)
INPUT.close();

// Add TOTAL_SWE state variable if any snow is simulated
// Add TOTAL_SWE state variable if any snow is simulated
if (pModel->GetStateVarIndex(SNOW) != -1) {
tmpS[0] = TOTAL_SWE; tmpLev[0]=0; tmpN=1;
pModel->AddStateVariables(tmpS,tmpLev,tmpN);
}


//===============================================================================================
//Check input quality
Expand Down
24 changes: 12 additions & 12 deletions src/ParseManagementFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)

CDemand *pDemand=NULL;
int demand_ind=0;
long demandSBID;
long demandSBID;
int demand_ID;
string demand_name;

ifstream INPUT2; //For Secondary input
CParser *pMainParser=NULL; //for storage of main parser while reading secondary files
//ifstream INPUT3; //For tertiary input
//CParser *pSecondaryParser=NULL; //for storage of secondary parser while reading tertiary files
//ifstream INPUT3; //For tertiary input
//CParser *pSecondaryParser=NULL; //for storage of secondary parser while reading tertiary files

ifstream RVM;
RVM.open(Options.rvm_filename.c_str(),ios::binary);
Expand Down Expand Up @@ -176,8 +176,8 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
else if(!strcmp(s[0],":DemandExpression")) { code=62; }
//else if(!strcmp(s[0],":AnnualLicense")) { code=63; }
else if(!strcmp(s[0],":ReservoirWaterDemand")) { code=64; }
else if(!strcmp(s[0],":EndReservoirWaterDemand")) { code=65; }
else if(!strcmp(s[0],":IsUnrestricted")) { code=66; }
else if(!strcmp(s[0],":EndReservoirWaterDemand")) { code=65; }
else if(!strcmp(s[0],":IsUnrestricted")) { code=66; }

else if(!strcmp(s[0],":UserTimeSeries")) { code=70; }

Expand Down Expand Up @@ -209,14 +209,14 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
//if ((pMainParser != NULL) && (pSecondaryParser != NULL)){
// ExitGracefully("ParseEnsembleFile::nested :RedirectToFile commands are not allowed to be nested more than two levels (e.g., rvm file to rvm file to rvm file to rvm file)",BAD_DATA);
//}
//if (pMainParser != NULL) {
//if (pMainParser != NULL) {
// pSecondaryParser=pp
// pp=new CParser(INPUT3,filename,line);//open new parser
//} //from already redirected .rvm file
//else {
// pMainParser=pp;
//} //from already redirected .rvm file
//else {
// pMainParser=pp;
// pp=new CParser(INPUT2,filename,line);//open new parser
//} //from base .rvm file
//} //from base .rvm file
//

if (pMainParser != NULL) {
Expand Down Expand Up @@ -1077,7 +1077,7 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
break;
}
case (61): //--------------------------------------------
{/*:DemandLookupTable
{/*:DemandLookupTable
N
{Q_i D_i} x N
:EndDemandLookupTable
Expand Down Expand Up @@ -1266,4 +1266,4 @@ bool ParseManagementFile(CModel *&pModel,const optStruct &Options)
pp=NULL;

return true;
}
}
2 changes: 1 addition & 1 deletion src/PartitionPrecip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ void CmvPrecipitation::GetRatesOfChange(const double *state_vars,
rates[qSnLiqToDep]+=state_vars[iSnLiq]/Options.timestep;
}
}
else if (pHRU->GetHRUType() == HRU_WATER)
else if (pHRU->GetHRUType() == HRU_WATER)
{
rates[qSW] =snowthru + rainthru; //all water goes to surface water
}
Expand Down
2 changes: 1 addition & 1 deletion src/RavenProcessConnections.dat
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,4 @@ DFLOW_THRESHPOW DepressionOverflow DEPRESSION SURFACE_WATER
DFLOW_LINEAR DepressionOverflow DEPRESSION SURFACE_WATER
DFLOW_WEIR DepressionOverflow DEPRESSION SURFACE_WATER
SEEP_LINEAR Seepage DEPRESSION SOIL
LAKEREL_LINEAR LakeRelease LAKE SURFACE_WATER
LAKEREL_LINEAR LakeRelease LAKE SURFACE_WATER
2 changes: 1 addition & 1 deletion src/SnowBalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CmvSnowBalance::CmvSnowBalance(snowbal_type bal_type, CModelABC *pModel)
iSoil =pModel->GetStateVarIndex(SOIL,0);
iPond =pModel->GetStateVarIndex(PONDED_WATER);

CHydroProcessABC::DynamicSpecifyConnections(5);
CHydroProcessABC::DynamicSpecifyConnections(5);

iFrom[0]=iSnow; iTo[0]=iSnowLiq; //rates[0]: SNOW->SNOW_LIQ
iFrom[1]=iSnow; iTo[1]=iSoil; //rates[1]: SNOW->SOIL
Expand Down
10 changes: 5 additions & 5 deletions src/Solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ void MassEnergyBalance( CModel *pModel,
}//end for pp...
delete [] res_Qstruct;




//-----------------------------------------------------------------
Expand Down Expand Up @@ -658,7 +658,7 @@ void MassEnergyBalance( CModel *pModel,

pConstitModel->SetMassInflows (p,aMinnew[p]);
pConstitModel->SetLateralInfluxes(p,aRoutedMass[p]);

pConstitModel->InCatchmentRoute (p,Mlat_new,Options);//prepares, calculates, and updates Mlat_new
pConstitModel->PrepareForRouting (p);
pConstitModel->RouteMass (p,aMoutnew,Mlat_new,ResMass,ResSedMass,Options,tt); //Where everything happens!
Expand All @@ -676,21 +676,21 @@ void MassEnergyBalance( CModel *pModel,
//update state variable values=====================================
for (k=0;k<nHRUs;k++){
pHRU=pModel->GetHydroUnit(k);

if(pHRU->IsEnabled())
{
//update total SWE variable
if (iTotalSWE != DOESNT_EXIST) {
aPhinew[k][iTotalSWE] =0.0;
for (int i = 0; i < NS; i++)
for (int i = 0; i < NS; i++)
{
sv_type typ=pModel->GetStateVarType(i);
if ((typ == SNOW) || (typ == SNOW_LIQ)) {
aPhinew[k][iTotalSWE] += aPhinew[k][i];
}
}
}

for(i=0;i<NS;i++){
pHRU->SetStateVarValue(i,aPhinew[k][i]);
}
Expand Down
Loading
Loading