From b9439b4a54586937845067a105f878e98b684941 Mon Sep 17 00:00:00 2001 From: Anurag Mishra Date: Mon, 26 Feb 2018 09:51:15 -0800 Subject: [PATCH] HSPEXP+ Updates 1. In the reach budget tables for NO3. Process flux for NO3 were also added. 2. GENER Load column was added in the Reach Budget Reports for constituents. 3. GENER load was added to individual constituents. 4. GENER loading was updated in constituent budget reports as well. 5. Constituent Budget Reports has been tested in Patuxent, Snake, Chippewa, and Illinois RIver watershed. Will need some cleaning. 6. GetGENERSum function was added to sum the GENER TS in modUtility.vb 7. Finding MASS-LINK Factor was simplified and updated. 8. Updated relevant sections for TotalP reports. --- HSPEXP/HSPFOutputReports.vb | 1 + atcHspfSupport/atcConstituentTables.vb | 422 +++++++------ atcHspfSupport/atcHspfConstituentBudget.vb | 672 ++++++++++++--------- atcHspfSupport/modUtility.vb | 534 +++++++++------- 4 files changed, 975 insertions(+), 654 deletions(-) diff --git a/HSPEXP/HSPFOutputReports.vb b/HSPEXP/HSPFOutputReports.vb index bd74a9801..55a560443 100644 --- a/HSPEXP/HSPFOutputReports.vb +++ b/HSPEXP/HSPFOutputReports.vb @@ -476,6 +476,7 @@ Module HSPFOutputReports Case "TotalP" lConstituentName = "TP" lConstProperties = Utility.LocateConstituentNames(aHspfUci, lConstituent) + lActiveSections.Add("NITR") lActiveSections.Add("PHOS") lActiveSections.Add("PQUAL") lActiveSections.Add("IQUAL") diff --git a/atcHspfSupport/atcConstituentTables.vb b/atcHspfSupport/atcConstituentTables.vb index 31220ebf2..25630eed6 100644 --- a/atcHspfSupport/atcConstituentTables.vb +++ b/atcHspfSupport/atcConstituentTables.vb @@ -445,10 +445,7 @@ Public Module atcConstituentTables If Not ((lOperation.Name = "PERLND" AndAlso lOperation.Tables("ACTIVITY").Parms("SEDFG").Value = "1") OrElse (lOperation.Name = "IMPLND" AndAlso lOperation.Tables("ACTIVITY").Parms("SLDFG").Value = "1")) Then Continue For - - - 'If Not (lOperation.Name = "PERLND" OrElse lOperation.Name = "IMPLND") Then Continue For - 'If Not lOperation.Tables("ACTIVITY").Parms("SEDFG").Value = "1" Then Continue For + 'If lOperation.Name = "IMPLND" Then Stop Dim LocationName As String = lOperation.Name.Substring(0, 1) & ":" & lOperation.Id landUseNameForTheCollection = lOperation.Name.Substring(0, 1) & ":" & lOperation.Description If Not listLanduses.Contains(landUseNameForTheCollection) Then @@ -780,7 +777,7 @@ Public Module atcConstituentTables Dim SelectExpression As String = "OpTypeNumber = '" & lOperation & "' And Year = '" & lYear & "'" Dim foundRows() As DataRow = Land_Constituent_Table.Select(SelectExpression) row = Land_Constituent_Table.NewRow - Logger.Dbg(SelectExpression) + 'Logger.Dbg(SelectExpression) row("OpTypeNumber") = foundRows(0)("OpTypeNumber") row("OpDesc") = foundRows(0)("OpDesc") row("Year") = foundRows(0)("Year") @@ -1486,12 +1483,28 @@ Public Module atcConstituentTables Dim lPSLoad As Double = CalculatePSLoad(aUCI, lReach, aSDateJ, aEDateJ, lReachConstituent) Dim lOutflow As Double = SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lReachConstituent & "-OUTTOT")(0), aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + Dim lTotalIn As Double = SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lReachConstituent & "-INTOT")(0), aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value Dim lTotalAtmDep As Double = SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lReachConstituent & "-ATMDEPTOT")(0), aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + Dim lProcFluxTot As Double = SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", lReachConstituent & "-PROCFLUX-TOT")(0), + aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + If lReachConstituent = "NO3" Then + Try + lOutflow += SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", "NO2-OUTTOT")(0), + aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + lTotalIn += SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", "NO2-INTOT")(0), + aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + lProcFluxTot += SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", "NO2-PROCFLUX-TOT")(0), + aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value + Catch + End Try + + End If + Dim lDiversion As Double = CalculateDiversion(aUCI, aBinaryData, lReach, lUpstreamInflows, lDownstreamReachID, lOutflow, lReachConstituent) - Dim lGENERLoad As Double = CalculateGENERLoad(aUCI, lReach, aBalanceType, aSDateJ, aEDateJ) + Dim lGENERLoad As Double = CalculateGENERLoad(aUCI, lReach, lReachConstituent, aSDateJ, aEDateJ) Dim lMassBalance As Double = lTotalIn - lNPSLoad - lUpstreamIn - lPSLoad - lGENERLoad - lTotalAtmDep For Each columnValue As DataColumn In Reach_Budget_Table.Columns Dim ColumnName As String = columnValue.ColumnName @@ -1504,15 +1517,24 @@ Public Module atcConstituentTables row(ColumnName) = HspfTable.NumFmtRE(lNPSLoad, 10) Case "PSLoad" row(ColumnName) = HspfTable.NumFmtRE(lPSLoad, 10) + Case "GENERLoad" + row(ColumnName) = HspfTable.NumFmtRE(lGENERLoad, 10) Case "Diversion" row(ColumnName) = HspfTable.NumFmtRE(lDiversion, 10) Case "MassBalance" row(ColumnName) = HspfTable.NumFmtRE(lMassBalance, 10) Case "UpstreamIn" row(ColumnName) = HspfTable.NumFmtRE(lUpstreamIn, 10) + Case lReachConstituent & "-INTOT" + row(ColumnName) = HspfTable.NumFmtRE(lTotalIn, 10) + Case lReachConstituent & "-PROCFLUX-TOT" + row(ColumnName) = lProcFluxTot + Case lReachConstituent & "-OUTTOT" + row(ColumnName) = lOutflow Case Else row(ColumnName) = HspfTable.NumFmtRE(SubsetByDate(aBinaryData.DataSets.FindData("Location", LocationName).FindData("Constituent", ColumnName)(0), aSDateJ, aEDateJ, Nothing).Attributes.GetDefinedValue("SumAnnual").Value, 10) + End Select Next columnValue @@ -1607,7 +1629,7 @@ Public Module atcConstituentTables Dim lDiversion As Double = CalculateDiversion(aUCI, aBinaryData, lReach, lUpstreamInflows, lDownstreamReachID, lOutflow, lReachConstituent) - Dim lGENERLoad As Double = CalculateGENERLoad(aUCI, lReach, aBalanceType, aSDateJ, aEDateJ) + Dim lGENERLoad As Double = CalculateGENERLoad(aUCI, lReach, lReachConstituent, aSDateJ, aEDateJ) Dim lMassBalance As Double = lTotalIn - lNPSLoad - lUpstreamIn - lPSLoad - lGENERLoad - lTotalAtmDep For Each columnValue As DataColumn In Reach_Budget_Table.Columns Dim ColumnName As String = columnValue.ColumnName @@ -1620,6 +1642,8 @@ Public Module atcConstituentTables row(ColumnName) = HspfTable.NumFmtRE(lNPSLoad, 10) Case "PSLoad" row(ColumnName) = HspfTable.NumFmtRE(lPSLoad, 10) + Case "GENERLoad" + row(ColumnName) = HspfTable.NumFmtRE(lGENERLoad, 10) Case "Diversion" row(ColumnName) = HspfTable.NumFmtRE(lDiversion, 10) Case "MassBalance" @@ -1667,7 +1691,7 @@ Public Module atcConstituentTables Dim SelectExpression As String = "" For Each lReachSource As HspfConnection In aReach.Sources Try - If lReachSource.Source.Opn Is Nothing Then Continue For + If lReachSource.Source.Opn Is Nothing OrElse lReachSource.Source.Opn.Name = "RCHRES" Then Continue For 'If Not ((lReachSource.Source.Opn.Name = "PERLND" AndAlso lReachSource.Source.Opn.Tables("ACTIVITY").Parms("PQALFG").Value = "1") OrElse ' (lReachSource.Source.Opn.Name = "IMPLND" AndAlso lReachSource.Source.Opn.Tables("ACTIVITY").Parms("IQALFG").Value = "1")) Then Continue For Dim lConnectionArea As Double = lReachSource.MFact @@ -1679,7 +1703,7 @@ Public Module atcConstituentTables End If Dim foundRows() As DataRow = Land_Constituent_Table.Select(SelectExpression) - 'If foundRows.Length > 1 Then Stop + If foundRows.Length = 0 Then Continue For NPSLoad += lConnectionArea * foundRows(0)("TotalOutflow") Catch End Try @@ -1896,7 +1920,7 @@ Public Module atcConstituentTables Dim lDiversion As Double = 0.0 Try If aReach.Tables("GEN-INFO").Parms("NEXITS").Value = 1 Then - Logger.Dbg(aReach.Id) + 'Logger.Dbg(aReach.Id) aUpstreamInflows.Increment(aDownstreamReachID, aOutflow) Else Dim lExitNUmber As Integer = 0 @@ -1945,7 +1969,7 @@ Public Module atcConstituentTables Case "PO4" - + lExitFlowConstituent = "PO4-OUTDIS-EXIT" & lExitNUmber lTotalOutFlow = (aBinaryDataSource.DataSets.FindData("Location", "R:" & aReach.Id). FindData("Constituent", lExitFlowConstituent)(0).Attributes.GetDefinedValue("SumAnnual").Value) lExitFlowConstituent = "PO4-OUTPART-TOT-EXIT" & lExitNUmber @@ -1969,181 +1993,237 @@ Public Module atcConstituentTables ByVal aSDateJ As Double, ByVal aEDateJ As Double) As Double Dim lGENERLoad As Double = 0.0 - Select Case aConstituentName + Select Case aConstituentName + Case "PO4" + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource + Case "TAM" + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource + Case "NO3" + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + ElseIf lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 3 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource Case "Heat" - For Each lSource As HspfConnection In aReach.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "IHEAT" Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUCI.FilesBlock.Count - - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) - - End If - Next - - End If - - Next EXTTarget + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "IHEAT" Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "IHEAT" Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If If Not lGENEROperationisOutputtoWDM Then - Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") - - - End If - - End If + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + Next lSource Case "DO" - For Each lSource As HspfConnection In aReach.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 1 Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUCI.FilesBlock.Count - - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) - - End If - Next - - End If - - Next EXTTarget + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 1 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 1 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If If Not lGENEROperationisOutputtoWDM Then - Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") - - - End If - - End If + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + Next lSource Case "BOD-Labile" - For Each lSource As HspfConnection In aReach.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2 Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUCI.FilesBlock.Count - - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) - - End If - Next - - End If - - Next EXTTarget + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2 Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2 Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If If Not lGENEROperationisOutputtoWDM Then - Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") - - - End If - - End If - Next lSource + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource + Case "Sediment" - For Each lSource As HspfConnection In aReach.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "ISED" Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - For i As Integer = 0 To aUCI.FilesBlock.Count - If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) - - End If - Next - - End If - Next EXTTarget + lGENERLoad = 0 + 'If aReach.Id = 157 Then Stop + For Each lSource As HspfConnection In aReach.Sources + Dim lGENERSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then + Dim lGENEROperationisOutputtoWDM As Boolean = False + With GetGENERSum(aUCI, lSource, aSDateJ, aEDateJ) + lGENERSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERSum *= lSource.MFact + For Each lMassLink As HspfMassLink In aUCI.MassLinks + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "ISED" Then + lGENERSum *= lMassLink.MFact + lGENERLoad += lGENERSum + Exit For + End If + Next lMassLink + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "ISED" Then + lGENERSum *= lSource.MFact + lGENERLoad += lGENERSum + End If If Not lGENEROperationisOutputtoWDM Then - Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") - - - End If + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & aReach.Id & " has loadings input for the constituent " & aConstituentName & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If + + Next lSource - End If - Next lSource End Select Return lGENERLoad - End Function + End Function + Private Function AddFirstSixColumnsReachBudget(ByRef aDataTable As Data.DataTable, ByRef aUnits As String) As DataTable Dim column As DataColumn column = New DataColumn() diff --git a/atcHspfSupport/atcHspfConstituentBudget.vb b/atcHspfSupport/atcHspfConstituentBudget.vb index 6c026a1f3..85137af52 100644 --- a/atcHspfSupport/atcHspfConstituentBudget.vb +++ b/atcHspfSupport/atcHspfConstituentBudget.vb @@ -223,17 +223,18 @@ Public Module ConstituentBudget For Each lID As HspfOperation In lRchresOperations + + Dim lTotalPointVol As Double = 0.0 .CurrentRecord += 1 - Dim lPointVol As Double = 0.0 For Each lSource As HspfPointSource In lID.PointSources If lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "IVOL" Then + Dim lPointVol As Double = 0.0 Dim TimeSeriesTransformaton As String = lSource.Tran.ToString Dim VolName As String = lSource.Source.VolName Dim lDSN As Integer = lSource.Source.VolId Dim lMfact As Double = lSource.MFact For i As Integer = 0 To aUci.FilesBlock.Count - Dim lPointSourceLoad As Double = 0.0 If aUci.FilesBlock.Value(i).Typ = VolName Then Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) @@ -244,57 +245,45 @@ Public Module ConstituentBudget End If Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lPointSourceLoad = ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation - lPointSourceLoad *= MultiFactorForPointSource(ltimeseries.Attributes.GetDefinedValue("Time Step").Value, ltimeseries.Attributes.GetDefinedValue("Time Unit").Value.ToString, - TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) - lPointVol += lPointSourceLoad + lPointVol += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + lPointVol *= MultiFactorForPointSource(ltimeseries.Attributes.GetDefinedValue("Time Step").Value, ltimeseries.Attributes.GetDefinedValue("Time Unit").Value.ToString, + TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) End If Next + lTotalPointVol += lPointVol End If - Next lSource + Next + Dim lGENERLoad As Double = 0.0 For Each lSource As HspfConnection In lID.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Member = "IVOL" Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact + Dim lGENERTSSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUci.FilesBlock.Count - Dim lGENERSourceLoad As Double = 0.0 - If aUci.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERSourceLoad = ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation - lGENERLoad += lGENERSourceLoad - - End If - Next - - End If - - Next EXTTarget - If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then - Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. - Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) - 'lGENERInNetworkBlockMessageShown = True + With GetGENERSum(aUci, lSource, aSDateJ, aEDateJ) + lGENERTSSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERTSSum *= lSource.MFact 'Multiplying with MFact in Schematic Block + For Each lMassLink As HspfMassLink In aUci.MassLinks + Dim GENERMassLinkMFact As Double = 0 + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "IVOL" Then + GENERMassLinkMFact = lMassLink.MFact + lMfact += GENERMassLinkMFact + End If + Next lMassLink + lGENERTSSum *= lMfact + lGENERLoad += lGENERTSSum + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "IVOL" Then + Dim lGENERTSSourceMFact As Double = lSource.MFact + lGENERTSSum *= lGENERTSSourceMFact + lGENERLoad += lGENERTSSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & lID.Id & " has loadings input for the constituent " & aBalanceType & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") End If - End If Next lSource @@ -323,7 +312,7 @@ Public Module ConstituentBudget End If - With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, 0.0, lPointVol, lGENERLoad, 0.0, 0.0, + With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, 0.0, lTotalPointVol, lGENERLoad, 0.0, 0.0, lTotalInflow, lUpstreamIn, lDiversion, aSDateJ, aEDateJ, aConstProperties) lReport2.Append(.Item1) lNonpointVol = .Item2 @@ -335,8 +324,8 @@ Public Module ConstituentBudget Dim lEvapLoss As Double = ValueForReach(lID, lEvapLossData) Dim lAdditionalSource As Double = 0.0 - lAdditionalSource = lTotalInflow - lNonpointVol - lUpstreamIn - lPointVol - lGENERLoad - Dim lCumulativePointNonpoint As Double = lNonpointVol + lPointVol + lAdditionalSource + lAdditionalSource = lTotalInflow - lNonpointVol - lUpstreamIn - lTotalPointVol - lGENERLoad + Dim lCumulativePointNonpoint As Double = lNonpointVol + lTotalPointVol + lAdditionalSource If lCumulativePointNonpointColl.Keys.Contains(lID.Id) Then lCumulativePointNonpoint += lCumulativePointNonpointColl.ItemByKey(lID.Id) End If @@ -360,7 +349,7 @@ Public Module ConstituentBudget lField = 0 lField += 1 : .Value(lField) = lID.Name & " " & lID.Id & " - " & lID.Description lField += 1 : .Value(lField) = DoubleToString(lNonpointVol, , lNumberFormat,,, lNumberOfSignificantDigits) - lField += 1 : .Value(lField) = DoubleToString(lPointVol, , lNumberFormat,,, lNumberOfSignificantDigits) + lField += 1 : .Value(lField) = DoubleToString(lTotalPointVol, , lNumberFormat,,, lNumberOfSignificantDigits) If pGENERLoadingExists Then lField += 1 : .Value(lField) = DoubleToString(lGENERLoad, , lNumberFormat,,, lNumberOfSignificantDigits) @@ -416,11 +405,12 @@ Public Module ConstituentBudget End If If lID.Tables("ACTIVITY").Parms("SEDFG").Value = 1 Then - Dim lPointTons As Double = 0.0 + Dim lTotalPointTons As Double = 0.0 .CurrentRecord += 1 - 'If lID.Id = 610 Then Stop + For Each lSource As HspfPointSource In lID.PointSources If lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "ISED" Then + Dim lPointTons As Double = 0.0 Dim TimeSeriesTransformaton As String = lSource.Tran.ToString Dim VolName As String = lSource.Source.VolName Dim lDSN As Integer = lSource.Source.VolId @@ -438,54 +428,44 @@ Public Module ConstituentBudget ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) lPointTons += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation lPointTons *= MultiFactorForPointSource(ltimeseries.Attributes.GetDefinedValue("Time Step").Value, ltimeseries.Attributes.GetDefinedValue("Time Unit").Value.ToString, - TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) + TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) End If Next - + lTotalPointTons += lPointTons End If - Next lSource + Next Dim lGENERLoad As Double = 0.0 - For Each lSource As HspfConnection In lID.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "ISED" Then - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact + For Each lSource As HspfConnection In lID.Sources + Dim lGENERTSSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then Dim lGENEROperationisOutputtoWDM As Boolean = False - Dim lGENEROperation As HspfOperation = lSource.Source.Opn - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUci.FilesBlock.Count - - If aUci.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation - - End If - Next - - End If + With GetGENERSum(aUci, lSource, aSDateJ, aEDateJ) + lGENERTSSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERTSSum *= lSource.MFact 'Multiplying with MFact in Schematic Block + For Each lMassLink As HspfMassLink In aUci.MassLinks + Dim GENERMassLinkMFact As Double = 0 + If lMassLink.MassLinkId = lSource.MassLink AndAlso lMassLink.Target.Member = "ISED" Then + GENERMassLinkMFact = lMassLink.MFact + lMfact += GENERMassLinkMFact - Next EXTTarget - If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then - Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. - Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) - 'lGENERInNetworkBlockMessageShown = True + End If + Next lMassLink + lGENERTSSum *= lMfact + lGENERLoad += lGENERTSSum + ElseIf lSource.Target.Group = "INFLOW" AndAlso lSource.Target.Member = "ISED" Then + Dim lGENERTSSourceMFact As Double = lSource.MFact + lGENERTSSum *= lGENERTSSourceMFact + lGENERLoad += lGENERTSSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & lID.Id & " has loadings input for the constituent " & aBalanceType & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") End If - End If Next lSource @@ -525,7 +505,7 @@ Public Module ConstituentBudget End Try - With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, 0.0, lPointTons, lGENERLoad, 0.0, -lDepScour, lTotalInflow, lUpstreamIn, + With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, 0.0, lTotalPointTons, lGENERLoad, 0.0, -lDepScour, lTotalInflow, lUpstreamIn, lDiversion, aSDateJ, aEDateJ, aConstProperties) lReport2.Append(.Item1) lNonpointTons = .Item2 @@ -534,8 +514,8 @@ Public Module ConstituentBudget 'scour is the gain from the stream. Using this terminology for Load Allocation report makes it consistent for the Load Allocation Report. End With - Dim lAdditionalSourceTons As Double = lTotalInflow - lNonpointTons - lUpstreamIn - lPointTons - lGENERLoad - Dim lCumulativePointNonpoint As Double = lNonpointTons + lAdditionalSourceTons + lPointTons + Dim lAdditionalSourceTons As Double = lTotalInflow - lNonpointTons - lUpstreamIn - lTotalPointTons - lGENERLoad + Dim lCumulativePointNonpoint As Double = lNonpointTons + lAdditionalSourceTons + lTotalPointTons If lCumulativePointNonpointColl.Keys.Contains(lID.Id) Then lCumulativePointNonpoint += lCumulativePointNonpointColl.ItemByKey(lID.Id) End If @@ -560,7 +540,7 @@ Public Module ConstituentBudget lField = 0 lField += 1 : .Value(lField) = lID.Name & " " & lID.Id & " - " & lID.Description lField += 1 : .Value(lField) = DoubleToString(lNonpointTons, , lNumberFormat,,, lNumberOfSignificantDigits) - lField += 1 : .Value(lField) = DoubleToString(lPointTons, , lNumberFormat,,, lNumberOfSignificantDigits) + lField += 1 : .Value(lField) = DoubleToString(lTotalPointTons, , lNumberFormat,,, lNumberOfSignificantDigits) If pGENERLoadingExists Then lField += 1 : .Value(lField) = DoubleToString(lGENERLoad, , lNumberFormat,,, lNumberOfSignificantDigits) End If @@ -620,21 +600,20 @@ Public Module ConstituentBudget Return Nothing End If - Dim lPointlbs As Double = 0.0 + Dim lTotalPointlbs As Double = 0.0 .CurrentRecord += 1 Dim CVON As Double = ConversionFactorfromOxygen(aUci, aBalanceType, lID) For Each lSource As HspfPointSource In lID.PointSources - If lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 3) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + If lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3) OrElse + (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub2 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 3) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + Dim lPointlbs As Double = 0.0 Dim TimeSeriesTransformaton As String = lSource.Tran.ToString Dim VolName As String = lSource.Source.VolName Dim lDSN As Integer = lSource.Source.VolId @@ -658,62 +637,119 @@ Public Module ConstituentBudget TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) End If Next + lTotalPointlbs += lPointlbs End If Next Dim lGENERLoad As Double = 0.0 + For Each lSource As HspfConnection In lID.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 3) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - If lSource.Target.Member = "OXIF" Then lMfact *= CVON - If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lMfact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) - Dim lGENEROperation As HspfOperation = lSource.Source.Opn + Dim lGENERTSSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then Dim lGENEROperationisOutputtoWDM As Boolean = False - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUci.FilesBlock.Count - - If aUci.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + With GetGENERSum(aUci, lSource, aSDateJ, aEDateJ) + lGENERTSSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERTSSum *= lSource.MFact 'Multiplying with MFact in Schematic Block + For Each lMassLink As HspfMassLink In aUci.MassLinks + Dim GENERMassLinkMFact As Double = 0 + If lMassLink.MassLinkId = lSource.MassLink AndAlso + ((lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1) OrElse + (lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2) OrElse + (lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 3) OrElse + (lMassLink.Target.Member = "NUIF2" AndAlso lMassLink.Target.MemSub2 = 1) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 1) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 2) OrElse + (lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2)) Then + GENERMassLinkMFact = lMassLink.MFact + If lMassLink.Target.Member = "OXIF" Then GENERMassLinkMFact = lMassLink.MFact * CVON + If lMassLink.Target.Member = "PKIF" And (lMassLink.Target.MemSub1 = 1 Or lMassLink.Target.MemSub1 = 2) Then GENERMassLinkMFact = lMassLink.MFact * ConversionFactorfromBiomass(aUci, aBalanceType, lID) + lMfact += GENERMassLinkMFact - End If - Next + End If + Next lMassLink + lGENERTSSum *= lMfact + lGENERLoad += lGENERTSSum + ElseIf lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3) OrElse + (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub2 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 3) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + Dim lGENERTSSourceMFact As Double = lSource.MFact + If lSource.Target.Member = "OXIF" Then lGENERTSSourceMFact *= CVON + If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lGENERTSSourceMFact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) + lGENERTSSum *= lGENERTSSourceMFact + lGENERLoad += lGENERTSSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & lID.Id & " has loadings input for the constituent " & aBalanceType & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") + End If + End If - End If - Next EXTTarget - If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then - Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. - Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) - 'lGENERInNetworkBlockMessageShown = True - End If - End If + 'If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 1) _ + ' Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 2) _ + ' Or (lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 3) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 1) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 1) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 1) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 3) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ + ' Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + + 'Dim lGENERID As Integer = lSource.Source.VolId + 'Dim lMfact As Double = lSource.MFact + 'If lSource.Target.Member = "OXIF" Then lMfact *= CVON + 'If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lMfact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) + 'Dim lGENEROperation As HspfOperation = lSource.Source.Opn + 'Dim lGENEROperationisOutputtoWDM As Boolean = False + 'With GetGENERSum(aUci, lSource, aSDateJ, aEDateJ) + ' lGENERLoad = .Item1 * lMfact + ' lGENEROperationisOutputtoWDM = .Item2 + 'End With + 'For Each EXTTarget As HspfConnection In lGENEROperation.Targets + + ' If EXTTarget.Target.VolName.Contains("WDM") Then + ' lGENEROperationisOutputtoWDM = True + ' Dim lWDMFile As String = EXTTarget.Target.VolName.ToString + ' Dim lDSN As Integer = EXTTarget.Target.VolId + + ' For i As Integer = 0 To aUci.FilesBlock.Count + + ' If aUci.FilesBlock.Value(i).Typ = lWDMFile Then + ' Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) + ' Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' If lDataSource Is Nothing Then + ' If atcDataManager.OpenDataSource(lFileName) Then + ' lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' End If + ' End If + ' Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ' ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + ' lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + + ' End If + ' Next + + ' End If + + 'Next EXTTarget + 'If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then + ' Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. + ' Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) + ' 'lGENERInNetworkBlockMessageShown = True + 'End If + + 'End If Next lSource Dim lNonpointlbs As Double = 0.0 @@ -757,16 +793,16 @@ Public Module ConstituentBudget Return Nothing End Try - With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVON, lPointlbs, lGENERLoad, lTotalAtmDep, lDepScour, lTotalInflow, lUpstreamIn, + With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVON, lTotalPointlbs, lGENERLoad, lTotalAtmDep, lDepScour, lTotalInflow, lUpstreamIn, lDiversion, aSDateJ, aEDateJ, aConstProperties) lReport2.Append(.Item1) lNonpointlbs = .Item2 lGENERLoad = .Item3 End With - lAdditionalSourcelbs = lTotalInflow - lNonpointlbs - lTotalAtmDep - lUpstreamIn - lPointlbs - lGENERLoad + lAdditionalSourcelbs = lTotalInflow - lNonpointlbs - lTotalAtmDep - lUpstreamIn - lTotalPointlbs - lGENERLoad - Dim lCumulativePointNonpoint As Double = lNonpointlbs + lPointlbs + lAdditionalSourcelbs + Dim lCumulativePointNonpoint As Double = lNonpointlbs + lTotalPointlbs + lAdditionalSourcelbs If lCumulativePointNonpointColl.Keys.Contains(lID.Id) Then lCumulativePointNonpoint += lCumulativePointNonpointColl.ItemByKey(lID.Id) End If @@ -790,7 +826,7 @@ Public Module ConstituentBudget lField = 0 lField += 1 : .Value(lField) = lID.Name & " " & lID.Id & " - " & lID.Description lField += 1 : .Value(lField) = DoubleToString(lNonpointlbs, 15, lNumberFormat,,, lNumberOfSignificantDigits) - lField += 1 : .Value(lField) = DoubleToString(lPointlbs, 15, lNumberFormat,,, lNumberOfSignificantDigits) + lField += 1 : .Value(lField) = DoubleToString(lTotalPointlbs, 15, lNumberFormat,,, lNumberOfSignificantDigits) lField += 1 : .Value(lField) = DoubleToString(lTotalAtmDep, 15, lNumberFormat,,, lNumberOfSignificantDigits) If pGENERLoadingExists Then lField += 1 : .Value(lField) = DoubleToString(lGENERLoad, , lNumberFormat,,, lNumberOfSignificantDigits) @@ -854,20 +890,18 @@ Public Module ConstituentBudget End If If lID.Tables("ACTIVITY").Parms("NUTFG").Value = 1 Then 'If lID.Id = 815 Then Stop - - Dim lPointlbs As Double = 0.0 + Dim lTotalPointlbs As Double = 0.0 .CurrentRecord += 1 - Dim CVOP As Double = ConversionFactorfromOxygen(aUci, aBalanceType, lID) + Dim CVOP As Double = ConversionFactorfromOxygen(aUci, aBalanceType, lID) For Each lSource As HspfPointSource In lID.PointSources - If lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + If lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) OrElse + (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub2 = 2) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + Dim lPointlbs As Double = 0.0 Dim TimeSeriesTransformaton As String = lSource.Tran.ToString Dim VolName As String = lSource.Source.VolName Dim lDSN As Integer = lSource.Source.VolId @@ -891,61 +925,149 @@ Public Module ConstituentBudget TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) End If Next + lTotalPointlbs += lPointlbs End If Next Dim lGENERLoad As Double = 0.0 + For Each lSource As HspfConnection In lID.Sources - If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 2) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ - Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ - Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then - - Dim lGENERID As Integer = lSource.Source.VolId - Dim lMfact As Double = lSource.MFact - If lSource.Target.Member = "OXIF" Then lMfact *= CVOP - If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lMfact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) - Dim lGENEROperation As HspfOperation = lSource.Source.Opn + Dim lGENERTSSum As Double = 0.0 + Dim lMfact As Double = 0.0 + If lSource.Source.VolName = "GENER" Then Dim lGENEROperationisOutputtoWDM As Boolean = False - For Each EXTTarget As HspfConnection In lGENEROperation.Targets - - If EXTTarget.Target.VolName.Contains("WDM") Then - lGENEROperationisOutputtoWDM = True - Dim lWDMFile As String = EXTTarget.Target.VolName.ToString - Dim lDSN As Integer = EXTTarget.Target.VolId - - For i As Integer = 0 To aUci.FilesBlock.Count - - If aUci.FilesBlock.Value(i).Typ = lWDMFile Then - Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + With GetGENERSum(aUci, lSource, aSDateJ, aEDateJ) + lGENERTSSum = .Item1 + lGENEROperationisOutputtoWDM = .Item2 + End With + If lSource.MassLink > 0 Then + lGENERTSSum *= lSource.MFact 'Multiplying with MFact in Schematic Block + For Each lMassLink As HspfMassLink In aUci.MassLinks + Dim GENERMassLinkMFact As Double = 0 + If lMassLink.MassLinkId = lSource.MassLink AndAlso + ((lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4) OrElse + (lMassLink.Target.Member = "NUIF2" AndAlso lMassLink.Target.MemSub2 = 2) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 4) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 1) OrElse + (lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 2) OrElse + (lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2)) Then + GENERMassLinkMFact = lMassLink.MFact + If lMassLink.Target.Member = "OXIF" Then GENERMassLinkMFact = lMassLink.MFact * CVOP + If lMassLink.Target.Member = "PKIF" And (lMassLink.Target.MemSub1 = 1 Or lMassLink.Target.MemSub1 = 2) Then GENERMassLinkMFact = lMassLink.MFact * ConversionFactorfromBiomass(aUci, aBalanceType, lID) + lMfact += GENERMassLinkMFact - End If - Next - - End If - - Next EXTTarget - If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then - Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. - Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) - 'lGENERInNetworkBlockMessageShown = True + End If + Next lMassLink + lGENERTSSum *= lMfact + lGENERLoad += lGENERTSSum + ElseIf lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) OrElse + (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub2 = 2) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) OrElse + (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) OrElse + (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + Dim lGENERTSSourceMFact As Double = lSource.MFact + If lSource.Target.Member = "OXIF" Then lGENERTSSourceMFact *= CVOP + If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lGENERTSSourceMFact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) + lGENERTSSum *= lGENERTSSourceMFact + lGENERLoad += lGENERTSSum + End If + If Not lGENEROperationisOutputtoWDM Then + Logger.Dbg("GENER Loadings Issue: The RCHRES operation " & lID.Id & " has loadings input for the constituent " & aBalanceType & " from GENER connections in the Network Block. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting.") End If - End If Next lSource + 'Dim lPointlbs As Double = 0.0 + '.CurrentRecord += 1 + 'Dim CVOP As Double = ConversionFactorfromOxygen(aUci, aBalanceType, lID) + + 'For Each lSource As HspfPointSource In lID.PointSources + ' If lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ + ' Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + ' Dim TimeSeriesTransformaton As String = lSource.Tran.ToString + ' Dim VolName As String = lSource.Source.VolName + ' Dim lDSN As Integer = lSource.Source.VolId + ' Dim lMfact As Double = lSource.MFact + ' If lSource.Target.Member = "OXIF" Then lMfact *= CVOP + ' If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lMfact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) + ' For i As Integer = 0 To aUci.FilesBlock.Count + + ' If aUci.FilesBlock.Value(i).Typ = VolName Then + ' Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) + ' Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' If lDataSource Is Nothing Then + ' If atcDataManager.OpenDataSource(lFileName) Then + ' lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' End If + ' End If + ' Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ' ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + ' lPointlbs += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + ' lPointlbs *= MultiFactorForPointSource(ltimeseries.Attributes.GetDefinedValue("Time Step").Value, ltimeseries.Attributes.GetDefinedValue("Time Unit").Value.ToString, + ' TimeSeriesTransformaton, aUci.OpnSeqBlock.Delt) + ' End If + ' Next + ' End If + 'Next + + 'Dim lGENERLoad As Double = 0.0 + 'For Each lSource As HspfConnection In lID.Sources + ' If lSource.Source.VolName = "GENER" AndAlso lSource.Target.Group = "INFLOW" AndAlso ((lSource.Target.Member = "NUIF1" AndAlso lSource.Target.MemSub1 = 4) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 1 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 2 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "NUIF2" AndAlso lSource.Target.MemSub1 = 3 AndAlso lSource.Target.MemSub2 = 2) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 4) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 1) _ + ' Or (lSource.Target.Member = "PKIF" AndAlso lSource.Target.MemSub1 = 2) _ + ' Or (lSource.Target.Member = "OXIF" AndAlso lSource.Target.MemSub1 = 2)) Then + + ' Dim lGENERID As Integer = lSource.Source.VolId + ' Dim lMfact As Double = lSource.MFact + ' If lSource.Target.Member = "OXIF" Then lMfact *= CVOP + ' If lSource.Target.Member = "PKIF" And (lSource.Target.MemSub1 = 1 Or lSource.Target.MemSub1 = 2) Then lMfact *= ConversionFactorfromBiomass(aUci, aBalanceType, lID) + ' Dim lGENEROperation As HspfOperation = lSource.Source.Opn + ' Dim lGENEROperationisOutputtoWDM As Boolean = False + ' For Each EXTTarget As HspfConnection In lGENEROperation.Targets + + ' If EXTTarget.Target.VolName.Contains("WDM") Then + ' lGENEROperationisOutputtoWDM = True + ' Dim lWDMFile As String = EXTTarget.Target.VolName.ToString + ' Dim lDSN As Integer = EXTTarget.Target.VolId + + ' For i As Integer = 0 To aUci.FilesBlock.Count + + ' If aUci.FilesBlock.Value(i).Typ = lWDMFile Then + ' Dim lFileName As String = AbsolutePath(aUci.FilesBlock.Value(i).Name.Trim, CurDir()) + ' Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' If lDataSource Is Nothing Then + ' If atcDataManager.OpenDataSource(lFileName) Then + ' lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' End If + ' End If + ' Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ' ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + ' lGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearsOfSimulation + + ' End If + ' Next + + ' End If + + ' Next EXTTarget + ' If Not lGENEROperationisOutputtoWDM Then 'AndAlso Not lGENERInNetworkBlockMessageShown Then + ' Logger.Dbg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections in the Network Block. + ' Please make sure that these GENER operations output to a WDM dataset for accurate source accounting." & aBalanceType) + ' 'lGENERInNetworkBlockMessageShown = True + ' End If + + ' End If + 'Next lSource Dim lNonpointlbs As Double = 0.0 Dim lUpstreamIn As Double = 0.0 @@ -988,13 +1110,13 @@ Public Module ConstituentBudget End Try Dim lDepScour As Double = lOutflow - lTotalInflow - lDiversion - With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVOP, lPointlbs, lGENERLoad, lTotalAtmDep, + With ConstituentLoadingByLanduse(aUci, lID, aBalanceType, lNonpointData, CVOP, lTotalPointlbs, lGENERLoad, lTotalAtmDep, lDepScour, lTotalInflow, lUpstreamIn, lDiversion, aSDateJ, aEDateJ, aConstProperties) lReport2.Append(.Item1) lNonpointlbs = .Item2 lGENERLoad = .Item3 End With - lAdditionalSourcelbs = lTotalInflow - lNonpointlbs - lUpstreamIn - lTotalAtmDep - lPointlbs - lGENERLoad + lAdditionalSourcelbs = lTotalInflow - lNonpointlbs - lUpstreamIn - lTotalAtmDep - lTotalPointlbs - lGENERLoad Dim lCumulativePointNonpoint As Double = lNonpointlbs + lAdditionalSourcelbs If lCumulativePointNonpointColl.Keys.Contains(lID.Id) Then @@ -1020,7 +1142,7 @@ Public Module ConstituentBudget lField = 0 lField += 1 : .Value(lField) = lID.Name & " " & lID.Id & " - " & lID.Description lField += 1 : .Value(lField) = DoubleToString(lNonpointlbs, , lNumberFormat,,, lNumberOfSignificantDigits) - lField += 1 : .Value(lField) = DoubleToString(lPointlbs, , lNumberFormat,,, lNumberOfSignificantDigits) + lField += 1 : .Value(lField) = DoubleToString(lTotalPointlbs, , lNumberFormat,,, lNumberOfSignificantDigits) lField += 1 : .Value(lField) = DoubleToString(lTotalAtmDep, , lNumberFormat,,, lNumberOfSignificantDigits) If pGENERLoadingExists Then @@ -1301,7 +1423,7 @@ Public Module ConstituentBudget For Each lTs As atcTimeseries In aNonpointData.FindData("Location", lTestLocation) Dim lMassLinkFactor As Double = 0.0 - If lTs.Attributes.GetValue("SumAnnual") > 0 Then + If lTs.Attributes.GetDefinedValue("SumAnnual").Value > 0 Then Dim ConstNameMassLink As String = lTs.Attributes.GetValue("Constituent") If Not (aConstProperties.Count = 0 OrElse (lConnection.Source.Opn.Name = "PERLND" AndAlso lConnection.Source.Opn.Tables("ACTIVITY").Parms("PQALFG").Value = "0")) Then @@ -1317,7 +1439,7 @@ Public Module ConstituentBudget Next End If - + 'If ConstNameMassLink = "SOSLD" Then Stop lMassLinkFactor = FindMassLinkFactor(aUCI, lMassLinkID, ConstNameMassLink, aBalanceType, aConversionFactor, aMultipleIndex:=0) End If @@ -1432,7 +1554,7 @@ Public Module ConstituentBudget ByVal aNonpointData As atcTimeseriesGroup, ByVal aConversionFactor As Double, ByVal aPoint As Double, - ByRef aGENERLoad As Double, + ByVal aGENERLoad As Double, ByVal aAtmDep As Double, ByVal GainLoss As Double, ByVal aTotalInflow As Double, @@ -1462,63 +1584,63 @@ Public Module ConstituentBudget felu(aUCI, aReach, aBalanceType, "IMPLND", pIMPLND, aNonpointData, aConversionFactor, LoadingByLanduse, aTotalInflow, True, lContribPercent, aConstProperties) 'If aReach.Id = 102 Then Stop - Dim GENERTSinWDM As Boolean = False - Dim SingleGENERLoad As Double = 0.0 - Dim TotalGENERLoad As Double = 0.0 - Dim lGENERLoadingExists As Boolean = False - - For Each GENERConnection As HspfConnection In aReach.Sources - If GENERConnection.Source.VolName = "GENER" Then - Dim GENERID As String = GENERConnection.Source.VolId - Dim lSchematicMFact As Double = GENERConnection.MFact - Dim lMassLinkID As Integer = GENERConnection.MassLink - If Not aUCI.OperationExists("GENER", GENERID) Or lMassLinkID = 0 Then Continue For - lGENERLoadingExists = True - - For Each EXTTarget As HspfConnection In aUCI.Connections - If EXTTarget.Source.VolName = "GENER" AndAlso EXTTarget.Source.VolId = GENERID AndAlso EXTTarget.Target.VolName.Contains("WDM") Then - 'The GENER timeseries is available as a WDM timeseries - GENERTSinWDM = True - Dim VolName As String = EXTTarget.Target.VolName - Dim lDSN As Integer = EXTTarget.Target.VolId - Dim lMfact As Double = EXTTarget.MFact - For i As Integer = 0 To aUCI.FilesBlock.Count - If aUCI.FilesBlock.Value(i).Typ = VolName Then - Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) - Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) - If lDataSource Is Nothing Then - If atcDataManager.OpenDataSource(lFileName) Then - lDataSource = atcDataManager.DataSourceBySpecification(lFileName) - End If - End If - Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) - ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) - SingleGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) - Exit For - End If - Next - - End If - - Next - - SingleGENERLoad *= FindMassLinkFactor(aUCI, lMassLinkID, "GENER", aBalanceType, aConversionFactor, aMultipleIndex:=0) - SingleGENERLoad *= lSchematicMFact - - End If - TotalGENERLoad += SingleGENERLoad - SingleGENERLoad = 0.0 - - Next GENERConnection - - - aGENERLoad += TotalGENERLoad + 'Dim GENERTSinWDM As Boolean = False + 'Dim SingleGENERLoad As Double = 0.0 + 'Dim TotalGENERLoad As Double = 0.0 + 'Dim lGENERLoadingExists As Boolean = False + + 'For Each GENERConnection As HspfConnection In aReach.Sources + ' If GENERConnection.Source.VolName = "GENER" Then + ' Dim GENERID As String = GENERConnection.Source.VolId + ' Dim lSchematicMFact As Double = GENERConnection.MFact + ' Dim lMassLinkID As Integer = GENERConnection.MassLink + ' If Not aUCI.OperationExists("GENER", GENERID) Or lMassLinkID = 0 Then Continue For + ' lGENERLoadingExists = True + + ' For Each EXTTarget As HspfConnection In aUCI.Connections + ' If EXTTarget.Source.VolName = "GENER" AndAlso EXTTarget.Source.VolId = GENERID AndAlso EXTTarget.Target.VolName.Contains("WDM") Then + ' 'The GENER timeseries is available as a WDM timeseries + ' GENERTSinWDM = True + ' Dim VolName As String = EXTTarget.Target.VolName + ' Dim lDSN As Integer = EXTTarget.Target.VolId + ' Dim lMfact As Double = EXTTarget.MFact + ' For i As Integer = 0 To aUCI.FilesBlock.Count + ' If aUCI.FilesBlock.Value(i).Typ = VolName Then + ' Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) + ' Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' If lDataSource Is Nothing Then + ' If atcDataManager.OpenDataSource(lFileName) Then + ' lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + ' End If + ' End If + ' Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ' ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + ' SingleGENERLoad += ltimeseries.Attributes.GetDefinedValue("Sum").Value * lMfact / YearCount(aSDateJ, aEDateJ) + ' Exit For + ' End If + ' Next + + ' End If + + ' Next + + ' SingleGENERLoad *= FindMassLinkFactor(aUCI, lMassLinkID, "GENER", aBalanceType, aConversionFactor, aMultipleIndex:=0) + ' SingleGENERLoad *= lSchematicMFact + + ' End If + ' TotalGENERLoad += SingleGENERLoad + ' SingleGENERLoad = 0.0 + + 'Next GENERConnection + + + 'aGENERLoad += TotalGENERLoad Dim lAdditionalSource As Double = aTotalInflow - lReachTotal - aAtmDep - aPoint - aUpstreamIn - aGENERLoad + UpStreamDiversion - If lGENERLoadingExists AndAlso (Not GENERTSinWDM) AndAlso (Not pMessageShown) Then - Logger.Msg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting. -This message box will not be shown again for." & aBalanceType) - pMessageShown = True - End If + ' If lGENERLoadingExists AndAlso (Not GENERTSinWDM) AndAlso (Not pMessageShown) Then + ' Logger.Msg("GENER Loadings Issue: Some RCHRES operation have loadings input from GENER connections. Please make sure that these GENER operations output to a WDM dataset for accurate source accounting. + 'This message box will not be shown again for." & aBalanceType) + ' pMessageShown = True + ' End If For Each lTributary As HspfConnection In aReach.Sources If lTributary.Source.VolName = "RCHRES" Then @@ -1528,7 +1650,7 @@ This message box will not be shown again for." & aBalanceType) aAtmDep += pRunningTotals.ItemByKey("Reach" & lTributaryId & " DirectAtmosphericDeposition") aDiversion += pRunningTotals.ItemByKey("Reach" & lTributaryId & " Diversion") If pGENERLoadingExists Then - aGENERLoad += pRunningTotals.ItemByKey("Reach" & lTributaryId & " GENERSources") + 'aGENERLoad += pRunningTotals.ItemByKey("Reach" & lTributaryId & " GENERSources") End If pRunningTotals.Increment("Reach" & aReach.Id & " Gain", pRunningTotals.ItemByKey("Reach" & lTributaryId & " Gain")) pRunningTotals.Increment("Reach" & aReach.Id & " Loss", pRunningTotals.ItemByKey("Reach" & lTributaryId & " Loss")) @@ -1575,7 +1697,7 @@ This message box will not be shown again for." & aBalanceType) End If - Return New Tuple(Of String, Double, Double)(LoadingByLanduse, lReachTotal, TotalGENERLoad) + Return New Tuple(Of String, Double, Double)(LoadingByLanduse, lReachTotal, aGENERLoad) End Function diff --git a/atcHspfSupport/modUtility.vb b/atcHspfSupport/modUtility.vb index fd8705aed..5b0c03991 100644 --- a/atcHspfSupport/modUtility.vb +++ b/atcHspfSupport/modUtility.vb @@ -514,29 +514,32 @@ Public Module Utility Select Case ConstProperty.ConstNameForEXPPlus Case "NO3" .Add("P:Header4", "NO3+NO2 (PQUAL)") - .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI, " Surface Flow") - .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI, " Interflow") - .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI, " Groundwater Flow") + .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Surface Flow") + .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Interflow") + .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Groundwater Flow") Case "TAM" .Add("P:Header5", "NH3+NH4 (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI, " Sediment Attached") - .Add("P:SOQUAL-" & ConstProperty.ConstituentNameInUCI, " Surface Flow") - .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI, " Interflow") - .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI, " Groundwater Flow") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI, " Scoured Sediment Attached") + .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Surface Flow") + .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Interflow") + .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI, " Dissolved with Groundwater Flow") Case "lab-OrgN" .Add("P:Header6", "LabileOrgN (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI & "2", " Sediment Attached") - .Add("P:SOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Surface Flow") - .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Interflow") - .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Groundwater Flow") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI & "2", " Scoured Sediment Attached") + .Add("P:SOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Dissolved with Surface Flow") + .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Dissolved with Interflow") + .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Dissolved with Groundwater Flow") Case "Ref-OrgN" .Add("P:Header7", "RefOrgN (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI & "1", " Sediment Attached") - .Add("P:SOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Surface Flow") - .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Interflow") - .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Groundwater Flow") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI & "1", " Scoured Sediment Attached") + .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI & "1", " Dissolved with Surface Flow") + .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Dissolved with Interflow") + .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Dissolved with Groundwater Flow") End Select .Add("P:Total3" & headerLabel(headerLabelCount), " Total") @@ -692,25 +695,28 @@ Public Module Utility Case "PO4" .Add("P:Header7", "ORTHO P (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI, " Surface Flow with Sediment") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI, " Surface Flow with Scoured Sediment") .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI, " Surface Flow as Dissolved") .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI, " Interflow") .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI, " Groundwater Flow") - .Add("P:Total3a", " Total") + .Add("P:Total3c", " Total") Case "Ref-OrgP" .Add("P:Header8", "RefOrgP (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI & "1", " Surface Flow with Sediment") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI & "1", " Surface Flow with Scoured Sediment") .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI & "1", " Surface Flow as Dissolved") .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Interflow") .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "1", " Groundwater Flow") - .Add("P:Total3b", " Total") + .Add("P:Total3d", " Total") Case "lab-OrgP" .Add("P:Header9", "LabileOrgP (PQUAL)") .Add("P:WASHQS-" & ConstProperty.ConstituentNameInUCI & "2", " Surface Flow with Sediment") - .Add("P:SOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Surface Flow as Dissolved") + .Add("P:SCRQS-" & ConstProperty.ConstituentNameInUCI & "2", " Surface Flow with Scoured Sediment") + .Add("P:SOQO-" & ConstProperty.ConstituentNameInUCI & "2", " Surface Flow as Dissolved") .Add("P:IOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Interflow") .Add("P:AOQUAL-" & ConstProperty.ConstituentNameInUCI & "2", " Groundwater Flow") - .Add("P:Total3c", " Total") + .Add("P:Total3e", " Total") End Select Next @@ -1157,102 +1163,83 @@ Public Module Utility End If Case "TotalN" + Select Case True + Case (aConstituent = "NO3+NO2-N - SURFACE LAYER OUTFLOW" OrElse aConstituent = "NO3+NO2-N - UPPER LAYER OUTFLOW" OrElse + aConstituent = "NO3+NO2-N - GROUNDWATER OUTFLOW" OrElse aConstituent = "NO3-N - TOTAL OUTFLOW") AndAlso + lMassLink.Target.Member.ToString = "NUIF1" And lMassLink.Target.MemSub1 = 1 + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor - Select Case aConstituent & "_" & lMassLink.Target.Member.ToString & "_" & lMassLink.Target.MemSub1 - Case "NO3+NO2-N - SURFACE LAYER OUTFLOW_NUIF1_1", "NO3+NO2-N - UPPER LAYER OUTFLOW_NUIF1_1", "NO3+NO2-N - GROUNDWATER OUTFLOW_NUIF1_1", - "NO3-N - TOTAL OUTFLOW_NUIF1_1" + Case (aConstituent = "NH4-N IN SOLUTION - SURFACE LAYER OUTFLOW" OrElse aConstituent = "NH4-N IN SOLUTION - UPPER LAYER OUTFLOW" OrElse + aConstituent = "NH4-N IN SOLUTION - GROUNDWATER OUTFLOW") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2 lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "NH4-N IN SOLUTION - SURFACE LAYER OUTFLOW_NUIF1_2", "NH4-N IN SOLUTION - UPPER LAYER OUTFLOW_NUIF1_2", - "NH4-N IN SOLUTION - GROUNDWATER OUTFLOW_NUIF1_2" + Case aConstituent = "NH4-N ADS - SEDIMENT ASSOC OUTFLOW" AndAlso lMassLink.Target.Member.ToString = "NUIF2" AndAlso + lMassLink.Target.MemSub2 = 1 'lMassLink.Target.MemSub1 = 1 AndAlso + lMassLinkFactor += lMassLink.MFact + Case (aConstituent = "SOQUAL-NH3+NH4" OrElse aConstituent = "SOQO-NH3+NH4") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "NH4-N ADS - SEDIMENT ASSOC OUTFLOW_NUIF2_1" - If lMassLink.Target.MemSub2 = 1 Then - lMassLinkFactor += lMassLink.MFact - End If - Case "NH4-N ADS - SEDIMENT ASSOC OUTFLOW_NUIF2_2" - If lMassLink.Target.MemSub2 = 1 Then - lMassLinkFactor += lMassLink.MFact - End If - Case "NH4-N ADS - SEDIMENT ASSOC OUTFLOW_NUIF2_3" - If lMassLink.Target.MemSub2 = 1 Then - lMassLinkFactor += lMassLink.MFact - End If - - Case "POQUAL-NH3+NH4_NUIF1_2", "SOQUAL-NH3+NH4_NUIF1_2", - "AOQUAL-NH3+NH4_NUIF1_2", "IOQUAL-NH3+NH4_NUIF1_2", - "SOQO-NH3+NH4_NUIF1_2" - - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + Case aConstituent = "AOQUAL-NH3+NH4" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "IOQUAL-NH3+NH4" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case (aConstituent = "WASHQS-NH3+NH4" OrElse aConstituent = "SCRQS-NH3+NH4") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso + lMassLink.Target.MemSub1 = 2 AndAlso (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Case (aConstituent = "SOQUAL-NO3" OrElse aConstituent = "SOQO-NO3") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "AOQUAL-NO3" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "IOQUAL-NO3" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case (aConstituent = "WASHQS-BOD" OrElse aConstituent = "SCRQS-BOD" OrElse aConstituent = "SOQO-BOD" OrElse aConstituent = "SOQUAL-BOD" OrElse + aConstituent = "WASHQS-Ref-OrgN" OrElse aConstituent = "SCRQS-Ref-OrgN" OrElse aConstituent = "SOQO-Ref-OrgN" OrElse aConstituent = "SOQUAL-Ref-OrgN" OrElse + aConstituent = "WASHQS-lab-OrgN" OrElse aConstituent = "SCRQS-lab-OrgN" OrElse aConstituent = "SOQO-lab-OrgN" OrElse aConstituent = "SOQUAL-lab-OrgN") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then lMassLinkFactor = lMassLink.MFact - 'Return lMassLinkFactor - End If - - Case "POQUAL-NH3+NH4_NUIF2_2", "SOQUAL-NH3+NH4_NUIF2_2", "AOQUAL-NH3+NH4_NUIF2_2", "IOQUAL-NH3+NH4_NUIF2_2", - "POQUAL-NH3+NH4_NUIF2_3", "SOQUAL-NH3+NH4_NUIF2_3", "AOQUAL-NH3+NH4_NUIF2_3", "IOQUAL-NH3+NH4_NUIF2_3", - "POQUAL-NH3+NH4_NUIF2_1", "SOQUAL-NH3+NH4_NUIF2_1", "AOQUAL-NH3+NH4_NUIF2_1", "IOQUAL-NH3+NH4_NUIF2_1", - "WASHQS-NH3+NH4_NUIF2_1", "WASHQS-NH3+NH4_NUIF2_2", "WASHQS-NH3+NH4_NUIF2_3", - "SCRQS-NH3+NH4_NUIF2_1", "SCRQS-NH3+NH4_NUIF2_2", "SCRQS-NH3+NH4_NUIF2_3" - If lMassLink.Target.MemSub2 = 1 Then - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Then - lMassLinkFactor += lMassLink.MFact - 'Return lMassLinkFactor - End If - + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "SOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "SOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - - Case "SOQO-NO3_NUIF1_1", "POQUAL-NO3_NUIF1_1", "SOQUAL-NO3_NUIF1_1", "IOQUAL-NO3_NUIF1_1", "AOQUAL-NO3_NUIF1_1" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + Return lMassLinkFactor + Case (aConstituent = "IOQUAL-BOD" OrElse aConstituent = "IOQUAL-Ref-OrgN" OrElse aConstituent = "IOQUAL-lab-OrgN") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then lMassLinkFactor = lMassLink.MFact - Return lMassLinkFactor - End If - Case "WASHQS-BOD_PKIF_3", "SCRQS-BOD_PKIF_3", "SOQO-BOD_PKIF_3", "SOQUAL-BOD_PKIF_3", "IOQUAL-BOD_PKIF_3", "AOQUAL-BOD_PKIF_3", "POQUAL-BOD_PKIF_3" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor - - End If - Case "WASHQS-Ref-OrgN_PKIF_3", "SCRQS-Ref-OrgN_PKIF_3", "SOQO-Ref-OrgN_PKIF_3", "SOQUAL-Ref-OrgN_PKIF_3", "IOQUAL-Ref-OrgN_PKIF_3", "AOQUAL-Ref-OrgN_PKIF_3", "POQUAL-Ref-OrgN_PKIF_3" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor - + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "IOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "IOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - Case "WASHQS-lab-OrgN_PKIF_3", "SCRQS-lab-OrgN_PKIF_3", "SOQO-lab-OrgN_PKIF_3", "SOQUAL-lab-OrgN_PKIF_3", "IOQUAL-lab-OrgN_PKIF_3", "AOQUAL-lab-OrgN_PKIF_3", "POQUAL-lab-OrgN_PKIF_3" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor - + Return lMassLinkFactor + Case (aConstituent = "AOQUAL-BOD" OrElse aConstituent = "AOQUAL-Ref-OrgN" OrElse aConstituent = "AOQUAL-lab-OrgN") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then + lMassLinkFactor = lMassLink.MFact + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "AOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "AOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - - Case "ORGN - TOTAL OUTFLOW_PKIF_3" + Return lMassLinkFactor + Case aConstituent = "ORGN - TOTAL OUTFLOW" AndAlso lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3 If aMultipleIndex = 2 Then lMassLinkFactor = lMassLink.MFact ElseIf aMultipleIndex = 1 Then @@ -1261,147 +1248,248 @@ Public Module Utility lMassLinkFactor = 1 End If Return lMassLinkFactor - Case "LABILE ORGN - SEDIMENT ASSOC OUTFLOW_PKIF_3", "REFRAC ORGN - SEDIMENT ASSOC OUTFLOW_PKIF_3" + Case (aConstituent = "LABILE ORGN - SEDIMENT ASSOC OUTFLOW" OrElse aConstituent = "REFRAC ORGN - SEDIMENT ASSOC OUTFLOW") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 3 If aConstituent.Contains("REFRAC") Then lMassLinkFactor = 0 Else lMassLinkFactor = 0 End If Return lMassLinkFactor + Case aConstituent.Contains("NITROGEN - TOTAL OUTFLOW") + lMassLinkFactor = 1 + Return lMassLinkFactor + End Select - If aConstituent.Contains("NITROGEN - TOTAL OUTFLOW") Then - lMassLinkFactor = 1 - Return lMassLinkFactor - ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1) Then - lMassLinkFactor += lMassLink.MFact - ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2) Then - lMassLinkFactor += lMassLink.MFact + ' 'Anurag does not remember what specific cases do three following lines address. + 'ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 1) Then + ' lMassLinkFactor += lMassLink.MFact - ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2) Then - lMassLinkFactor += lMassLink.MFact * aConversionFactor + 'ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 2) Then + ' lMassLinkFactor += lMassLink.MFact - End If + 'ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2) Then + ' lMassLinkFactor += lMassLink.MFact * aConversionFactor + + 'End If Case "TotalP" 'If aConstituent.Contains("SOQUAL") Then Stop - Select Case aConstituent & "_" & lMassLink.Target.Member.ToString & "_" & lMassLink.Target.MemSub1 - - Case "POQUAL-ORTHO P_NUIF1_4", "SOQO-ORTHO P_NUIF1_4", "SOQUAL-ORTHO P_NUIF1_4", "IOQUAL-ORTHO P_NUIF1_4", - "AOQUAL-ORTHO P_NUIF1_4", "SCRQS-ORTHO P_NUIF1_4", "WASHQS-ORTHO P_NUIF1_4" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - lMassLinkFactor = lMassLink.MFact - 'Return lMassLinkFactor - End If - - Case "POQUAL-PO4_NUIF1_4", "SOQO-PO4_NUIF1_4", "SOQUAL-PO4_NUIF1_4", "IOQUAL-PO4_NUIF1_4", - "AOQUAL-PO4_NUIF1_4", "SCRQS-PO4_NUIF1_4", "WASHQS-PO4_NUIF1_4" - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - lMassLinkFactor = lMassLink.MFact - 'Return lMassLinkFactor - End If - - Case "POQUAL-ORTHO P_NUIF2_2", "SOQUAL-ORTHO P_NUIF2_2", "AOQUAL-ORTHO P_NUIF2_2", "IOQUAL-ORTHO P_NUIF2_2", - "POQUAL-ORTHO P_NUIF2_3", "SOQUAL-ORTHO P_NUIF2_3", "AOQUAL-ORTHO P_NUIF2_3", "IOQUAL-ORTHO P_NUIF2_3", - "POQUAL-ORTHO P_NUIF2_1", "SOQUAL-ORTHO P_NUIF2_1", "AOQUAL-ORTHO P_NUIF2_1", "IOQUAL-ORTHO P_NUIF2_1", - "WASHQS-ORTHO P_NUIF2_1", "WASHQS-ORTHO P_NUIF2_2", "WASHQS-ORTHO P_NUIF2_3", - "SCRQS-ORTHO P_NUIF2_1", "SCRQS-ORTHO P_NUIF2_2", "SCRQS-ORTHO P_NUIF2_3" - - If lMassLink.Target.MemSub2 = 2 Then - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Then - lMassLinkFactor += lMassLink.MFact - 'Return lMassLinkFactor - End If - End If - + Select Case True + Case (aConstituent = "SOQUAL-PO4" OrElse aConstituent = "SOQO-PO4") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "AOQUAL-PO4" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "IOQUAL-PO4" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor += lMassLink.MFact + Case (aConstituent = "WASHQS-PO4" OrElse aConstituent = "SCRQS-PO4") AndAlso lMassLink.Target.Member.ToString = "NUIF2" AndAlso + lMassLink.Target.MemSub2 = 2 AndAlso (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor += lMassLink.MFact - Case "POQUAL-PO4_NUIF2_2", "SOQUAL-PO4_NUIF2_2", "AOQUAL-PO4_NUIF2_2", "IOQUAL-PO4_NUIF2_2", - "POQUAL-PO4_NUIF2_3", "SOQUAL-PO4_NUIF2_3", "AOQUAL-PO4_NUIF2_3", "IOQUAL-PO4_NUIF2_3", - "POQUAL-PO4_NUIF2_1", "SOQUAL-PO4_NUIF2_1", "AOQUAL-PO4_NUIF2_1", "IOQUAL-PO4_NUIF2_1", - "WASHQS-PO4_NUIF2_1", "WASHQS-PO4_NUIF2_2", "WASHQS-PO4_NUIF2_3", - "SCRQS-PO4_NUIF2_1", "SCRQS-PO4_NUIF2_2", "SCRQS-PO4_NUIF2_3" + Case (aConstituent = "WASHQS-PO4" OrElse aConstituent = "SCRQS-PO4") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso + lMassLink.Target.MemSub1 = 4 AndAlso (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact - If lMassLink.Target.MemSub2 = 2 Then - If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Then - lMassLinkFactor += lMassLink.MFact - 'Return lMassLinkFactor - End If - End If + Case (aConstituent = "SOQUAL-ORTHO P" OrElse aConstituent = "SOQO-ORTHO P") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "AOQUAL-ORTHO P" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case aConstituent = "IOQUAL-ORTHO P" AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor = lMassLink.MFact + Return lMassLinkFactor + Case (aConstituent = "WASHQS-ORTHO P" OrElse aConstituent = "SCRQS-ORTHO P") AndAlso lMassLink.Target.Member.ToString = "NUIF1" AndAlso + lMassLink.Target.MemSub1 = 4 AndAlso (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor += lMassLink.MFact + Case (aConstituent = "WASHQS-ORTHO P" OrElse aConstituent = "SCRQS-ORTHO P") AndAlso lMassLink.Target.Member.ToString = "NUIF2" AndAlso + lMassLink.Target.MemSub2 = 2 AndAlso (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + lMassLinkFactor += lMassLink.MFact - Case "WASHQS-BOD_PKIF_4", "SOQUAL-BOD_PKIF_4", "IOQUAL-BOD_PKIF_4", "AOQUAL-BOD_PKIF_4", "POQUAL-BOD_PKIF_4" - If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor + Case (aConstituent = "WASHQS-BOD" OrElse aConstituent = "SCRQS-BOD" OrElse aConstituent = "SOQO-BOD" OrElse aConstituent = "SOQUAL-BOD" OrElse + aConstituent = "WASHQS-Ref-OrgP" OrElse aConstituent = "SCRQS-Ref-OrgP" OrElse aConstituent = "SOQO-Ref-OrgP" OrElse aConstituent = "SOQUAL-Ref-OrgP" OrElse + aConstituent = "WASHQS-lab-OrgP" OrElse aConstituent = "SCRQS-lab-OrgP" OrElse aConstituent = "SOQO-lab-OrgP" OrElse aConstituent = "SOQUAL-lab-OrgP") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "SOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then + lMassLinkFactor = lMassLink.MFact + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "SOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "SOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - Case "WASHQS-Ref-OrgP_PKIF_4", "SOQO-Ref-OrgP_PKIF_4", "IOQUAL-Ref-OrgP_PKIF_4", "AOQUAL-Ref-OrgP_PKIF_4", "POQUAL-Ref-OrgP_PKIF_4" - If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor + Return lMassLinkFactor + Case (aConstituent = "IOQUAL-BOD" OrElse aConstituent = "IOQUAL-Ref-OrgP" OrElse aConstituent = "IOQUAL-lab-OrgP") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "IOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then + lMassLinkFactor = lMassLink.MFact + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "IOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "IOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - Case "WASHQS-lab-OrgP_PKIF_4", "SOQO-lab-OrgP_PKIF_4", "IOQUAL-lab-OrgP_PKIF_4", "AOQUAL-lab-OrgP_PKIF_4", "POQUAL-lab-OrgP_PKIF_4" - If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or - (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then - If aMultipleIndex = 1 Then - lMassLinkFactor = lMassLink.MFact - ElseIf aMultipleIndex = 2 Then - lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - ElseIf aMultipleIndex = 0 Then - lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor - End If - Return lMassLinkFactor + Return lMassLinkFactor + Case (aConstituent = "AOQUAL-BOD" OrElse aConstituent = "AOQUAL-Ref-OrgP" OrElse aConstituent = "AOQUAL-lab-OrgP") AndAlso + lMassLink.Target.Member.ToString = "PKIF" AndAlso lMassLink.Target.MemSub1 = 4 AndAlso + (lMassLink.Source.Member = "AOQUAL" OrElse lMassLink.Source.Member = "POQUAL") + If aMultipleIndex = 1 Then + lMassLinkFactor = lMassLink.MFact + ElseIf aMultipleIndex = 2 Then + lMassLinkFactor = BODMFact(aUCI, "AOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor + ElseIf aMultipleIndex = 0 Then + lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, "AOQUAL-BOD", lMassLink.MassLinkId) * aConversionFactor End If - - - Case "PO4-P IN SOLUTION - SURFACE LAYER - OUTFLOW_NUIF1_4" + Return lMassLinkFactor + Case aConstituent = "PO4-P IN SOLUTION - SURFACE LAYER - OUTFLOW" AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "PO4-P IN SOLUTION - INTERFLOW - OUTFLOW_NUIF1_4" + + Case aConstituent = "PO4-P IN SOLUTION - INTERFLOW - OUTFLOW" AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "PO4-P IN SOLUTION - GROUNDWATER - OUTFLOW_NUIF1_4" + Case aConstituent = "PO4-P IN SOLUTION - GROUNDWATER - OUTFLOW" AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4 lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "SDP4A_NUIF2_1", "SDP4A_NUIF2_2", "SDP4A_NUIF2_3", "SOQUAL-ORTHO P_NUIF2_1", - "SOQUAL-ORTHO P_NUIF2_2", "SOQUAL-ORTHO P_NUIF2_3" - If lMassLink.Target.MemSub2 = 2 Then - lMassLinkFactor += lMassLink.MFact - End If + Case aConstituent = "SDP4A" AndAlso lMassLink.Target.Member = "NUIF2" AndAlso lMassLink.Target.MemSub2 = 2 + + lMassLinkFactor += lMassLink.MFact - Case "SDORP_PKIF_4" + Case aConstituent = "SDORP" AndAlso lMassLink.Target.Member = "PKIF" AndAlso lMassLink.Target.MemSub1 = 4 lMassLinkFactor = lMassLink.MFact Return lMassLinkFactor - Case "ORGN - TOTAL OUTFLOW_OXIF_2" + Case aConstituent = "ORGN - TOTAL OUTFLOW" AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2 lMassLinkFactor = lMassLink.MFact * aConversionFactor Return lMassLinkFactor - End Select - If (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4) Then - lMassLinkFactor += lMassLink.MFact + 'Select Case aConstituent & "_" & lMassLink.Target.Member.ToString & "_" & lMassLink.Target.MemSub1 + + ' 'Case "POQUAL-ORTHO P_NUIF1_4", "SOQO-ORTHO P_NUIF1_4", "SOQUAL-ORTHO P_NUIF1_4", "IOQUAL-ORTHO P_NUIF1_4", + ' ' "AOQUAL-ORTHO P_NUIF1_4", "SCRQS-ORTHO P_NUIF1_4", "WASHQS-ORTHO P_NUIF1_4" + ' ' If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Or + ' ' (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + ' ' lMassLinkFactor = lMassLink.MFact + ' ' 'Return lMassLinkFactor + ' ' End If - ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2) Then - lMassLinkFactor += lMassLink.MFact * aConversionFactor + ' 'Case "POQUAL-PO4_NUIF1_4", "SOQO-PO4_NUIF1_4", "SOQUAL-PO4_NUIF1_4", "IOQUAL-PO4_NUIF1_4", + ' ' "AOQUAL-PO4_NUIF1_4", "SCRQS-PO4_NUIF1_4", "WASHQS-PO4_NUIF1_4" + ' ' If lMassLink.Source.Member = aConstituent.Substring(0, 6) OrElse lMassLink.Source.Member = "POQUAL" OrElse + ' ' lMassLink.Source.Member = "SOQUAL" Then 'AndAlso lMassLink.Source.Group = "IQUAL") Then + ' ' lMassLinkFactor = lMassLink.MFact + ' ' 'Return lMassLinkFactor + ' ' End If + + ' 'Case "POQUAL-ORTHO P_NUIF2_2", "SOQUAL-ORTHO P_NUIF2_2", "AOQUAL-ORTHO P_NUIF2_2", "IOQUAL-ORTHO P_NUIF2_2", + ' ' "POQUAL-ORTHO P_NUIF2_3", "SOQUAL-ORTHO P_NUIF2_3", "AOQUAL-ORTHO P_NUIF2_3", "IOQUAL-ORTHO P_NUIF2_3", + ' ' "POQUAL-ORTHO P_NUIF2_1", "SOQUAL-ORTHO P_NUIF2_1", "AOQUAL-ORTHO P_NUIF2_1", "IOQUAL-ORTHO P_NUIF2_1", + ' ' "WASHQS-ORTHO P_NUIF2_1", "WASHQS-ORTHO P_NUIF2_2", "WASHQS-ORTHO P_NUIF2_3", + ' ' "SCRQS-ORTHO P_NUIF2_1", "SCRQS-ORTHO P_NUIF2_2", "SCRQS-ORTHO P_NUIF2_3" + + ' ' If lMassLink.Target.MemSub2 = 2 Then + ' ' If lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL" Then + ' ' lMassLinkFactor += lMassLink.MFact + ' ' 'Return lMassLinkFactor + ' ' End If + ' ' End If - End If + + ' 'Case "POQUAL-PO4_NUIF2_2", "SOQUAL-PO4_NUIF2_2", "AOQUAL-PO4_NUIF2_2", "IOQUAL-PO4_NUIF2_2", + ' ' "POQUAL-PO4_NUIF2_3", "SOQUAL-PO4_NUIF2_3", "AOQUAL-PO4_NUIF2_3", "IOQUAL-PO4_NUIF2_3", + ' ' "POQUAL-PO4_NUIF2_1", "SOQUAL-PO4_NUIF2_1", "AOQUAL-PO4_NUIF2_1", "IOQUAL-PO4_NUIF2_1", + ' ' "WASHQS-PO4_NUIF2_1", "WASHQS-PO4_NUIF2_2", "WASHQS-PO4_NUIF2_3", + ' ' "SCRQS-PO4_NUIF2_1", "SCRQS-PO4_NUIF2_2", "SCRQS-PO4_NUIF2_3" + + ' ' If lMassLink.Target.MemSub2 = 2 Then + ' ' If lMassLink.Source.Member = aConstituent.Substring(0, 6) OrElse lMassLink.Source.Member = "POQUAL" OrElse lMassLink.Source.Member = "SOQUAL" Then + ' ' lMassLinkFactor += lMassLink.MFact + ' ' 'Return lMassLinkFactor + ' ' End If + ' ' End If + + ' 'Case "WASHQS-BOD_PKIF_4", "SOQUAL-BOD_PKIF_4", "IOQUAL-BOD_PKIF_4", "AOQUAL-BOD_PKIF_4", "POQUAL-BOD_PKIF_4" + ' ' If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or + ' ' (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + ' ' If aMultipleIndex = 1 Then + ' ' lMassLinkFactor = lMassLink.MFact + ' ' ElseIf aMultipleIndex = 2 Then + ' ' lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' ElseIf aMultipleIndex = 0 Then + ' ' lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' End If + ' ' Return lMassLinkFactor + ' ' End If + + ' 'Case "WASHQS-Ref-OrgP_PKIF_4", "SOQO-Ref-OrgP_PKIF_4", "IOQUAL-Ref-OrgP_PKIF_4", "AOQUAL-Ref-OrgP_PKIF_4", "POQUAL-Ref-OrgP_PKIF_4" + ' ' If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or + ' ' (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + ' ' If aMultipleIndex = 1 Then + ' ' lMassLinkFactor = lMassLink.MFact + ' ' ElseIf aMultipleIndex = 2 Then + ' ' lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' ElseIf aMultipleIndex = 0 Then + ' ' lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' End If + ' ' Return lMassLinkFactor + ' ' End If + + ' 'Case "WASHQS-lab-OrgP_PKIF_4", "SOQO-lab-OrgP_PKIF_4", "IOQUAL-lab-OrgP_PKIF_4", "AOQUAL-lab-OrgP_PKIF_4", "POQUAL-lab-OrgP_PKIF_4" + ' ' If (lMassLink.Source.Member = aConstituent.Substring(0, 6) Or lMassLink.Source.Member = "POQUAL") Or + ' ' (lMassLink.Source.Member = "SOQUAL" AndAlso lMassLink.Source.Group = "IQUAL") Then + ' ' If aMultipleIndex = 1 Then + ' ' lMassLinkFactor = lMassLink.MFact + ' ' ElseIf aMultipleIndex = 2 Then + ' ' lMassLinkFactor = BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' ElseIf aMultipleIndex = 0 Then + ' ' lMassLinkFactor = lMassLink.MFact + BODMFact(aUCI, aConstituent, lMassLink.MassLinkId) * aConversionFactor + ' ' End If + ' ' Return lMassLinkFactor + ' ' End If + + + ' 'Case "PO4-P IN SOLUTION - SURFACE LAYER - OUTFLOW_NUIF1_4" + ' ' lMassLinkFactor = lMassLink.MFact + ' ' Return lMassLinkFactor + ' Case "PO4-P IN SOLUTION - INTERFLOW - OUTFLOW_NUIF1_4" + ' lMassLinkFactor = lMassLink.MFact + ' Return lMassLinkFactor + ' Case "PO4-P IN SOLUTION - GROUNDWATER - OUTFLOW_NUIF1_4" + ' lMassLinkFactor = lMassLink.MFact + ' Return lMassLinkFactor + ' Case "SDP4A_NUIF2_1", "SDP4A_NUIF2_2", "SDP4A_NUIF2_3", "SOQUAL-ORTHO P_NUIF2_1", + ' "SOQUAL-ORTHO P_NUIF2_2", "SOQUAL-ORTHO P_NUIF2_3" + ' If lMassLink.Target.MemSub2 = 2 Then + ' lMassLinkFactor += lMassLink.MFact + ' End If + + ' Case "SDORP_PKIF_4" + ' lMassLinkFactor = lMassLink.MFact + ' Return lMassLinkFactor + ' Case "ORGN - TOTAL OUTFLOW_OXIF_2" + ' lMassLinkFactor = lMassLink.MFact * aConversionFactor + ' Return lMassLinkFactor + + 'End Select + + 'Anurag is not sure about following two cases. + 'If (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "NUIF1" AndAlso lMassLink.Target.MemSub1 = 4) Then + ' lMassLinkFactor += lMassLink.MFact + + 'ElseIf (lMassLink.Source.VolName = aConstituent AndAlso lMassLink.Target.Member = "OXIF" AndAlso lMassLink.Target.MemSub1 = 2) Then + ' lMassLinkFactor += lMassLink.MFact * aConversionFactor + + 'End If Case "BOD-Labile" @@ -1921,4 +2009,34 @@ Public Module Utility Next Return aExitNumber End Function + Public Function GetGENERSum(ByVal aUCI As HspfUci, ByVal aSource As HspfConnection, ByVal aSDateJ As Double, ByVal aEDateJ As Double) As Tuple(Of Double, Boolean) + Dim aGenerSum As Double = 0 + Dim aGENERID As Integer = aSource.Source.VolId + Dim aGENEROperationisOutputtoWDM As Boolean = False + Dim aGENEROperation As HspfOperation = aSource.Source.Opn + For Each EXTTarget As HspfConnection In aGENEROperation.Targets + If EXTTarget.Target.VolName.Contains("WDM") Then + aGENEROperationisOutputtoWDM = True + Dim lWDMFile As String = EXTTarget.Target.VolName.ToString + Dim lDSN As Integer = EXTTarget.Target.VolId + For i As Integer = 0 To aUCI.FilesBlock.Count + If aUCI.FilesBlock.Value(i).Typ = lWDMFile Then + Dim lFileName As String = AbsolutePath(aUCI.FilesBlock.Value(i).Name.Trim, CurDir()) + Dim lDataSource As atcDataSource = atcDataManager.DataSourceBySpecification(lFileName) + If lDataSource Is Nothing Then + If atcDataManager.OpenDataSource(lFileName) Then + lDataSource = atcDataManager.DataSourceBySpecification(lFileName) + End If + End If + Dim ltimeseries As atcTimeseries = lDataSource.DataSets.FindData("ID", lDSN)(0) + ltimeseries = SubsetByDate(ltimeseries, aSDateJ, aEDateJ, Nothing) + aGenerSum = ltimeseries.Attributes.GetDefinedValue("Sum").Value / YearCount(aSDateJ, aEDateJ) + + End If + Next + End If + Next EXTTarget + + Return New Tuple(Of Double, Boolean)(aGenerSum, aGENEROperationisOutputtoWDM) + End Function End Module