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
52 changes: 26 additions & 26 deletions src/Abstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CmvAbstraction::CmvAbstraction(abstraction_type absttype, CModelABC *pModel)
//adjust minimum deficit
iFrom[2]=pModel->GetStateVarIndex(MIN_DEP_DEFICIT);
iTo [2]=pModel->GetStateVarIndex(MIN_DEP_DEFICIT);
}
}
else if (_type == ABST_HGDM) {
CHydroProcessABC::DynamicSpecifyConnections(4);
//abstraction (ponded-->large or small depressions or outflow)
Expand Down Expand Up @@ -170,34 +170,34 @@ void CmvAbstraction::GetParticipatingStateVarList(abstraction_type absttype, sv_
/// \param current_contrib_frac [in] current contributing fraction [0..1]
/// \param threshold [in] delta threshold for triggering zero contributing area [mm]
//
double HGDMcontrib_fraction(const double &current_storage,
const double &delta_storage,
const double &max_storage,
const double &current_contrib_frac,
const double &threshold = -0.01)
{
double HGDMcontrib_fraction(const double &current_storage,
const double &delta_storage,
const double &max_storage,
const double &current_contrib_frac,
const double &threshold = -0.01)
{
double vf1 = current_storage / max_storage; //[0..1]
double cf1 = current_contrib_frac; //[0..1]
double cf1 = current_contrib_frac; //[0..1]
double vf2,cf2;

if (delta_storage == 0.0)
if (delta_storage == 0.0)
{
return current_contrib_frac;
}
else
}
else
{
if (delta_storage < threshold)
if (delta_storage < threshold)
{
//vf2 = (current_storage + delta_storage) / max_storage; //never used
return 0.0;
}
else
}
else
{
vf2 = vf1 + (1.0 - cf1 ) * (delta_storage / max_storage);
if (vf1 < 0.999) {
cf2 = (((1.0 - cf1) * (vf2 - vf1)) / (1.0 - vf1)) + cf1;
cf2 = min(max(min(cf2, vf2), 0.0), 1.0);
}
}
else {
cf2 = 1.0;
}
Expand Down Expand Up @@ -373,22 +373,22 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars,
double Vs_max =pHRU->GetSurfaceProps()->dep_max;
double Vl_max =pHRU->GetSurfaceProps()->dep_max_large;
double f_s_to_l=pHRU->GetSurfaceProps()->small_to_large; //[0..1] fraction of depression landscape draining to large gatekeeper
double f_s_to_o=(1-f_s_to_l); //[0..1] fraction of depression landscape draining to outlet
double f_s_to_o=(1-f_s_to_l); //[0..1] fraction of depression landscape draining to outlet
double fsu =pHRU->GetSurfaceProps()->HGDM_frac_sm_dep; //[0..1] fraction of HRU covered in small depressions + contrib areas of depressions
double flu =pHRU->GetSurfaceProps()->HGDM_frac_lr_dep; //[0..1] fraction of HRU covered in large depression + contrib areas of depression
double fl =pHRU->GetSurfaceProps()->HGDM_frac_lr_are; //[0..1] fraction of HRU covered by maximum area of large depression
double p =pHRU->GetSurfaceProps()->HGDM_P;
double p_large =pHRU->GetSurfaceProps()->HGDM_P_LARGE;
//rules:

//rules:
// flu+fsu+fo=1.0
// fl < flu

double Atot =pHRU->GetArea()*M2_PER_KM2;
double Al_max=fl *Atot; //[km2] - maximum area of gatekeeper
double Asu =fsu*Atot; //[km2] - total contributing area + surface area of small depressions
double Alu =flu*Atot; //[km2] - total contributing area to large depression + surface area of large
double As; //[km2] - total water surface area of small and large depressions (As=A_w in Shook paper)
double As; //[km2] - total water surface area of small and large depressions (As=A_w in Shook paper)
double Al; //[km2] - surface area of large gatekeeper depression (<Al_max)

double ponded =state_vars[iPond];//[mm]
Expand All @@ -397,7 +397,7 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars,
double fsc_last=state_vars[iCFac];//[0..1] contributing fraction from previous time step

double overflow, to_large(0.0), to_outlet(0.0), to_dep_s(0.0), to_dep_l,excess;

//Small depressions ----------------------------------------------
//As=pow(Vsmall/Vs_max,2/(p+2));
//double dVs = runoff * (Asu - As) / Atot + ponded * (As/Atot);
Expand All @@ -408,7 +408,7 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars,
//AET=min(AET,Vsmall);
//Vsmall-=AET;
//double fsc=HGDMcontrib_fraction(Vsmall,dVs,Vs_max,fsc_last); //fsc is only used in next timestep

double fsc=HGDMcontrib_fraction(Vsmall,dVs,Vs_max,fsc_last); //fsc is only used in next timestep
if (dVs>0)
{
Expand All @@ -419,21 +419,21 @@ void CmvAbstraction::GetRatesOfChange( const double *state_vars,
to_large =(overflow+dVs*(fsc_last))*f_s_to_l; //total ponded->large
to_outlet =(overflow+dVs*(fsc_last))*f_s_to_o; //total ponded->outflow
}

//Large depression-----------------------------------------------
if (Vlarge <= 0.0 ){Al=0.0;}
else if (Vlarge >= Vl_max){Al=Al_max;}
else {Al=Al_max*pow((Vlarge / Vl_max),2.0/(p_large + 2.0));}

//double dVl=ponded*Al/Atot+to_large+runoff*(Alu-Al)/Atot+to_large;
double dVl=ponded*(Alu/Atot)+to_large; //any water in local contributing area, which includes Al_max (i.e., Alu>=Al_max, always)
Vlarge+=dVl;
excess=0.0;
if (Vlarge>Vl_max){
if (Vlarge>Vl_max){
excess= (Vlarge-Vl_max);
to_outlet+=excess;
to_outlet+=excess;
Vlarge=Vl_max;
}
}
to_dep_l=dVl-excess;

//No depression--------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/CustomOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,4 @@ CCustomOutput *CCustomOutput::ParseCustomOutputCommand(char *s[MAXINPUTITEMS], c
}

return pCustom;
}
}
2 changes: 1 addition & 1 deletion src/DemandExpressionHandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ exp_condition* CDemandOptimizer::ParseCondition(const char** s, const int Len, c
}
if (is_exp) {
pCond->pExp=this->ParseExpression((const char**)(s),Len,lineno,filename,Options);
if (pCond->pExp==NULL){return NULL;}//bad expression
if (pCond->pExp==NULL){return NULL;}//bad expression
return pCond;
}
else
Expand Down
12 changes: 6 additions & 6 deletions src/HydroUnits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,27 +555,27 @@ double CHydroUnit::GetStateVarMax(const int i,
double max_var=ALMOST_INF;
switch (_pModel->GetStateVarType(i))
{
case(SOIL):
case(SOIL):
{
max_var=GetSoilCapacity(_pModel->GetStateVarLayer(i)); break;
}
case(CANOPY):
case(CANOPY):
{
if(!ignorevar) { max_var=_VegVar.capacity; } break;
}
case(CANOPY_SNOW):
case(CANOPY_SNOW):
{
if(!ignorevar) { max_var=_VegVar.snow_capacity;} break;
}
case(GROUNDWATER):
case(GROUNDWATER):
{
if(Options.modeltype != MODELTYPE_SURFACE){} break; //GetAquiferHeadCapacity(0,HRUid);} //GWMIGRATE - HRUid k not accesible from here yet
}
case(DEPRESSION):
case(DEPRESSION):
{
if (_pSurface->dep_max>=0){max_var=_pSurface->dep_max;} break;
}
case(SNOW_COVER):
case(SNOW_COVER):
{
max_var=1.0; break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/LatConnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ double CLatConnect::GetWeight() const
/// \param tolerance [in] Acceptable deviation from 1.0 (default 0.05)
/// \return true if all HRU connection weights sum to approximately 1.0
//
bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[],
bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[],
const int nConnections,
const CModel* pModel,
const double tolerance)
Expand All @@ -100,7 +100,7 @@ bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[],
}

// Calculate the sum of weights for each source HRU
for (int i = 0; i < nConnections; i++)
for (int i = 0; i < nConnections; i++)
{
int sourceHRU = pModel->GetHRUByID(connections[i]->GetSourceHRUID())->GetGlobalIndex();
double weight = connections[i]->GetWeight();
Expand All @@ -127,4 +127,4 @@ bool CLatConnect::CheckConnectionWeights(const CLatConnect* const connections[],
delete[] hasConnections;

return allValid;
}
}
4 changes: 2 additions & 2 deletions src/LatConnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class CLatConnect
// Static methods to interact with the collection
static int GetNumLatConnections(const CModel *pModel);
static CLatConnect* GetLatConnection(const CModel *pModel, int index);
static bool CheckConnectionWeights (const CLatConnect* const connections[],
static bool CheckConnectionWeights (const CLatConnect* const connections[],
const int nConnections,
const CModel* pModel,
const double tolerance = 0.05);
};


#endif // LATCONNECT_H
#endif // LATCONNECT_H
6 changes: 3 additions & 3 deletions src/LatFlush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ void CmvLatFlush::Initialize()
if (toHRUGrp->IsInGroup(k2))
{
if (k1!=k2)
{
{
//dynamically allocate memory
int *tmpT=new int [q+1]; for (int i=0;i<q;i++){tmpT[i]= kTo [i];}delete [] kTo; kTo =tmpT; ExitGracefullyIf(kTo == NULL, "LatFLush::Initialize (1a)",OUT_OF_MEMORY);
int *tmpF=new int [q+1]; for (int i=0;i<q;i++){tmpF[i]= kFrom[i];}delete [] kFrom; kFrom=tmpF; ExitGracefullyIf(kFrom == NULL, "LatFLush::Initialize (1b)",OUT_OF_MEMORY);
double *tmpA=new double [q+1]; for (int i=0;i<q;i++){tmpA[i]=_aFrac[i];}delete [] _aFrac;_aFrac=tmpA; ExitGracefullyIf(_aFrac== NULL, "LatFLush::Initialize (1c)",OUT_OF_MEMORY);
area=_pModel->GetSubBasin(p)->GetHRU(ks2)->GetArea();
kFrom [q]=k1;
kTo [q]=k2;
kTo [q]=k2;
_aFrac[q]=area;
Asum+=area;//sum of recipient areas
nRecipients++;
Expand Down Expand Up @@ -146,7 +146,7 @@ void CmvLatFlush::Initialize()
int *tmpT=new int [q+1]; for (int i=0;i<q;i++){tmpT[i]= kTo [i];}delete [] kTo; kTo =tmpT; ExitGracefullyIf(kTo == NULL, "LatFLush::Initialize (1a)",OUT_OF_MEMORY);
int *tmpF=new int [q+1]; for (int i=0;i<q;i++){tmpF[i]= kFrom[i];}delete [] kFrom; kFrom=tmpF; ExitGracefullyIf(kFrom == NULL, "LatFLush::Initialize (1b)",OUT_OF_MEMORY);
double *tmpA=new double [q+1]; for (int i=0;i<q;i++){tmpA[i]=_aFrac[i];}delete [] _aFrac;_aFrac=tmpA; ExitGracefullyIf(_aFrac== NULL, "LatFLush::Initialize (1c)",OUT_OF_MEMORY);

kFrom [q]=k;
kTo [q]=kToSB;
_aFrac[q]=1.0; //only a single recipient
Expand Down
4 changes: 2 additions & 2 deletions src/LateralExchangeABC.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class CmvLatRedistribute: public CLateralExchangeProcessABC

CLatConnect **_pLatConnect; //< array of pointers to HRU source/recipient pairs [size:_nLatConnect]
int _nLatConnect; //< number of HRU source/recipient pairs


public:/*-------------------------------------------------------*/
//Constructors/destructors:
Expand All @@ -188,7 +188,7 @@ class CmvLatRedistribute: public CLateralExchangeProcessABC

//inherited functions
void Initialize();

static void GetParticipatingStateVarList(sv_type *aSV, int *aLev, int &nSV);

void GetParticipatingParamList(string *aP, class_type *aPC, int &nP) const;
Expand Down
2 changes: 1 addition & 1 deletion src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2737,7 +2737,7 @@ void CModel::ApplyStateOverrrides(const optStruct &Options,const time_struct &
if (val!=RAV_BLANK_DATA){
double maxv=max(_pHydroUnits[k]->GetStateVarMax(i,_pHydroUnits[k]->GetStateVarArray(),Options,true),0.0);
val=min(val,maxv);
_pHydroUnits[k]->SetStateVarValue(i,val);
_pHydroUnits[k]->SetStateVarValue(i,val);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ModelInitialize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ void CModel::Initialize(const optStruct &Options)

// Generate Gauge Weights from Interpolation (except if in BMI mode and no RVT file is specified)
//--------------------------------------------------------------
if ((!Options.in_bmi_mode) || (strcmp(Options.rvt_filename.c_str(), "") != 0))
if ((!Options.in_bmi_mode) || (strcmp(Options.rvt_filename.c_str(), "") != 0))
{
if (!Options.silent){cout <<" Generating Gauge Interpolation Weights..."<<endl;}
forcing_type f_gauge=F_PRECIP;
//search for the 'other' forcing- assume all gauges have same data
//search for the 'other' forcing- assume all gauges have same data
if (Options.air_pressure ==AIRPRESS_DATA ){f_gauge=F_AIR_PRES;}
else if (Options.SW_radiation ==SW_RAD_DATA ){f_gauge=F_SW_RADIA;}
else if (Options.evaporation ==PET_DATA ){f_gauge=F_PET; }
Expand Down
4 changes: 2 additions & 2 deletions src/ParseHRUFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r

if (StringIsLong(s[0]))
{
CLatConnect *pLatInstance = new CLatConnect(s_to_ll(s[0]),s_to_ll(s[1]), s_to_d(s[2]));
CLatConnect *pLatInstance = new CLatConnect(s_to_ll(s[0]),s_to_ll(s[1]), s_to_d(s[2]));
if (!DynArrayAppend((void**&)(pLat),(void*)(pLatInstance),nLat)){
ExitGracefully("CModel:::LateralConnections: adding NULL connection",BAD_DATA);}
}
Expand All @@ -1160,7 +1160,7 @@ bool ParseHRUPropsFile(CModel *&pModel, const optStruct &Options, bool terrain_r
}

// After all connections are added, check if weights sum to 1.0
if (nLat > 0)
if (nLat > 0)
{

// Check if weights sum to 1.0
Expand Down
2 changes: 1 addition & 1 deletion src/RavenInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ enum HRU_type
HRU_WATER, ///< Non-lake Waterbody HRU (streams)
HRU_GLACIER, ///< Glacier HRU
HRU_WETLAND, ///< Wetland HRU
HRU_MASKED_GLACIER, ///< masked glacier in coupled model
HRU_MASKED_GLACIER, ///< masked glacier in coupled model
HRU_ROCK, ///< Open Rock or Pavement (impermeable) HRUs
HRU_INVALID_TYPE ///< returned if type is invalid
};
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
14 changes: 7 additions & 7 deletions src/SnowRedistribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ CmvLatRedistribute::CmvLatRedistribute(int sv_ind,
//////////////////////////////////////////////////////////////////
/// \brief Implementation of the default destructor
//
CmvLatRedistribute::~CmvLatRedistribute()
CmvLatRedistribute::~CmvLatRedistribute()
{
for(int n=0; n<_nLatConnect;n++) { delete _pLatConnect[n]; } delete[] _pLatConnect;
}

//////////////////////////////////////////////////////////////////
/// \brief Copies connnection array - called during RVH file read
/// \brief Copies connnection array - called during RVH file read
//
void CmvLatRedistribute::AddConnectionArray(CLatConnect **pConnections, const int nConnections)
{
Expand Down Expand Up @@ -73,15 +73,15 @@ void CmvLatRedistribute::Initialize()
_iToLat = new int[_nLatConnections];

// Initialize the arrays using the methods from CLatConnect
for (int q = 0; q < _nLatConnections; q++)
for (int q = 0; q < _nLatConnections; q++)
{
CLatConnect* connection = _pLatConnect[q];

_kFrom [q] = _pModel->GetHRUByID(_pLatConnect[q]->GetSourceHRUID() )->GetGlobalIndex();
_kTo [q] = _pModel->GetHRUByID(_pLatConnect[q]->GetRecipientHRUID())->GetGlobalIndex();

_iFromLat[q] = _iRedistributeFrom;
_iToLat [q] = _iRedistributeTo;
_iFromLat[q] = _iRedistributeFrom;
_iToLat [q] = _iRedistributeTo;
}
}

Expand Down Expand Up @@ -206,10 +206,10 @@ void CmvLatRedistribute::GetLateralExchange(const double *const *state_vars,
// Debug info - uncomment when needed

// Debug info with comprehensive output
//std::cout << "Connection " << q << ": fromHRU=" << fromHRU << " toHRU=" << toHRU
//std::cout << "Connection " << q << ": fromHRU=" << fromHRU << " toHRU=" << toHRU
//<< " method=" << (_method == CONTINUOUS_REDIST ? "CONTINUOUS" : "THRESHOLD");

//std::cout << " snowMoved=" << snowMoved << " mm"
// << " exchange_rate=" << exchange_rates[q] << " mm-km²/d" << std::endl;
}
}
}
Loading
Loading