Skip to content

Commit 73b4735

Browse files
James CraigJames Craig
authored andcommitted
v508 [BENCHMARKED] - (assim + management); :RevertToSDCurve
support for flow and stage assimilation working with water management (DemandOptimization.cpp/.h) -replaces mass balance constraints with assimilation constraints -moved to +/- delta h representation as primary DVs in LP problem -new routine CModel::GetObservedFlow -CREservoir::GetObsStage() support for RevertToSDCurve (DemandExpressionHandling.cpp; ParseManagementFile.cpp) reservoir stage asssimilation now REQUIRES :AssimilateReservoirStage command in .rvt file [BACKWARD COMPATIBILTY] -changes to Assimilate.cpp/ParseTimeSeriesFile.cpp/Reservoir.cpp adjustments to CModel::UpdateDiagnostics() so that invalid data streams just get ignored (Model.cpp;ModelInitialize.cpp) (allows you to comment out reservoirs with data without breaking model) minor bug fixes - - use of dry stage rather than min stage for setting stage bounds in man model - forece positive storage in SOILEVAP_HBV (SoilEvaporation.cpp) - mistake in writing SubbasinProperties_Auto (StandardOutput.cpp)
1 parent e56c5f9 commit 73b4735

15 files changed

+503
-205
lines changed

src/Assimilate.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,6 @@ void CModel::InitializeDataAssimilation(const optStruct &Options)
5757
}
5858
}
5959

60-
//Connect Lake assimilation observations
61-
if(Options.assimilate_stage)
62-
{
63-
for(int i=0;i<_nObservedTS;i++) {
64-
if((!strcmp(_pObservedTS[i]->GetName().c_str(),"RESERVOIR_STAGE")) && (_pObservedTS[i]->GetType() == CTimeSeriesABC::TS_REGULAR)) {
65-
CSubBasin *pBasin=GetSubBasinByID(_pObservedTS[i]->GetLocID());
66-
CReservoir *pRes=pBasin->GetReservoir();
67-
if(pRes!=NULL) {
68-
pRes->TurnOnAssimilation(_pObservedTS[i]);
69-
}
70-
else {
71-
ExitGracefully("Reservoir stage observations assigned to basin without lake or reservoir. Data cannot be assimilated",BAD_DATA_WARN);
72-
}
73-
}
74-
}
75-
WriteAdvisory("Lake stage data assimilation will lead to mass balance error estimates in the WatershedStorage output file. This is a natural side effect of assimilation.",Options.noisy);
76-
}
77-
7860
}
7961
/////////////////////////////////////////////////////////////////
8062
/// \brief Overrides flows with observations at gauges and propagates adjustments upstream of gauges
@@ -99,9 +81,7 @@ void CModel::AssimilationOverride(const int p,const optStruct& Options,const tim
9981
Qmodlast= _pSubBasins[p]->GetLastOutflowRate();
10082
if(Qmod>PRETTY_SMALL) {
10183
_aDAscale [p]=1.0+alpha*((Qobs-Qmod)/Qmod); //if alpha = 1, Q=Qobs in observation basin
102-
//_aDAQadjust[p]=alpha*(Qobs-Qmod);//Option A: instantaneous flow (should set second argument to AdjustAllFlows() to true)
10384
_aDAQadjust[p]=0.5*alpha*(2.0*Qobs-Qmodlast-Qmod);//Option B: mean flow
104-
//_aDAQadjust[p]=1.0;//TMP DEBUG - TESTING
10585
}
10686
else {
10787
_aDAscale [p]=1.0;

src/DemandExpressionHandling.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ string DVTypeToString(dv_type t)
288288
if (t==DV_QOUTRES ){return "DV_QOUTRES"; }
289289
if (t==DV_STAGE ){return "DV_STAGE"; }
290290
if (t==DV_DSTAGE ){return "DV_DSTAGE"; }
291+
if (t==DV_DSTAGE2 ){return "DV_DSTAGE2"; }
291292
if (t==DV_BINRES ){return "DV_BINRES"; }
292293
if (t==DV_DELIVERY){return "DV_DELIVERY"; }
293294
if (t==DV_RETURN ){return "DV_RETURN"; }
@@ -1319,6 +1320,17 @@ void CDemandOptimizer::AddConstraintToLP(const int ii, const int kk, lp_lib::lpr
13191320
{
13201321
pE= pC->pOperRegimes[kk]->pExpression; //active expression
13211322

1323+
if (pE->nGroups == 0) {
1324+
// special case - revert to SD curve - blank row
1325+
row_val[0]=0.0;
1326+
col_ind[0]=0;
1327+
RHS=0.0;
1328+
retval = lp_lib::set_rowex(pLinProg,lpgoalrow,1,row_val,col_ind);
1329+
ExitGracefullyIf(retval==0,"AddConstraintToLP::Error updating user-specified constraint/goal",RUNTIME_ERR);
1330+
retval = lp_lib::set_rh(pLinProg,lpgoalrow,RHS);
1331+
return;
1332+
}
1333+
13221334
RHS=0.0;
13231335
for (int j = 0; j < pE->nGroups; j++)
13241336
{

0 commit comments

Comments
 (0)