Centrifugal Pump Calculation Routines
Transcript of Centrifugal Pump Calculation Routines
-
7/29/2019 Centrifugal Pump Calculation Routines
1/22
' Centrifugal Pump Calculation Routines' Copyright 2008 Daniel Wagner O. de Medeiros'' This file is part of DWSIM.'' DWSIM is free software: you can redistribute it and/or modify
' it under the terms of the GNU General Public License as published by' the Free Software Foundation, either version 3 of the License, or' (at your option) any later version.'' DWSIM is distributed in the hope that it will be useful,' but WITHOUT ANY WARRANTY; without even the implied warranty of' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' GNU General Public License for more details.'' You should have received a copy of the GNU General Public License' along with DWSIM. If not, see .
Imports Microsoft.MSDN.Samples.GraphicObjects
Imports DWSIM.DWSIM.MathEx.InterpolationImports DWSIM.DWSIM.SimulationObjects.UnitOps.Auxiliary.PipingOpsImports DWSIM.DWSIM.Flowsheet.FlowSheetSolver
Namespace DWSIM.SimulationObjects.UnitOps.Auxiliary.PipingOps
Public Enum CurveTypeHeadPowerNPSHrEfficiencySystemHeadNone
End Enum
Public Class Curve
Protected _x As ArrayListProtected _y As ArrayListProtected _xunit As StringProtected _yunit As StringProtected _type As CurveTypeProtected _id As StringProtected _name As StringProtected _enabled As Boolean = True
Sub New(ByVal id As String, ByVal name As String, ByVal x AsArrayList, ByVal xunit As String, ByVal y As ArrayList, ByVal yunit AsString, ByVal type As CurveType)
Me.New()Me.ID = idMe.Name = nameMe.x = xMe.y = yMe.xunit = xunitMe.yunit = yunitMe.Type = type
End Sub
Sub New(ByVal id As String, ByVal name As String, ByVal type As
CurveType)Me.New()
-
7/29/2019 Centrifugal Pump Calculation Routines
2/22
Me.ID = idMe.Name = nameMe.Type = type
End Sub
Sub New()
_x = New ArrayList_y = New ArrayListEnd Sub
Public Property Enabled() As BooleanGet
Return _enabledEnd GetSet(ByVal value As Boolean)
_enabled = valueEnd Set
End Property
Public Property Name() As StringGetReturn _name
End GetSet(ByVal value As String)
_name = valueEnd Set
End Property
Public Property ID() As StringGet
Return _idEnd GetSet(ByVal value As String)
_id = valueEnd Set
End Property
Public Property Type() As CurveTypeGet
Return _typeEnd GetSet(ByVal value As CurveType)
_type = valueEnd Set
End Property
Public Property yunit() As StringGet
Return _yunitEnd GetSet(ByVal value As String)
_yunit = valueEnd Set
End Property
Public Property xunit() As StringGet
Return _xunitEnd Get
Set(ByVal value As String)_xunit = value
-
7/29/2019 Centrifugal Pump Calculation Routines
3/22
End SetEnd Property
Public Property y() As ArrayListGet
Return _y
End GetSet(ByVal value As ArrayList)_y = value
End SetEnd Property
Public Property x() As ArrayListGet
Return _xEnd GetSet(ByVal value As ArrayList)
_x = valueEnd Set
End Property
End Class
End Namespace
Namespace DWSIM.SimulationObjects.UnitOps
Public Class Pump
Inherits SimulationObjects_UnitOpBaseClass
Public Enum CalculationModeDelta_P = 0OutletPressure = 1EnergyStream = 2Curves = 3
End Enum
Protected m_dp As Nullable(Of Double)Protected m_dt As Nullable(Of Double)Protected m_DQ As Nullable(Of Double)
Protected m_eta As Nullable(Of Double) = 75Protected m_npsh As Nullable(Of Double)Protected m_pout As Double = 0
Protected m_ignorephase As Boolean = True
Protected m_FixOnDeltaP As Boolean = TrueProtected m_cmode As CalculationMode = CalculationMode.Delta_P
Protected m_curves As Dictionary(Of String,UnitOps.Auxiliary.PipingOps.Curve)
Protected _curvehead As DoubleProtected _curveeff As DoubleProtected _curvenpsh As DoubleProtected _curvepower As DoubleProtected _curvesyshead As Double
Protected _curveflow As Double
-
7/29/2019 Centrifugal Pump Calculation Routines
4/22
Public Property CurveFlow() As DoubleGet
Return _curveflowEnd GetSet(ByVal value As Double)
_curveflow = value
End SetEnd Property
Public Property CurveSysHead() As DoubleGet
Return _curvesysheadEnd GetSet(ByVal value As Double)
_curvesyshead = valueEnd Set
End Property
Public Property CurvePower() As Double
Get Return _curvepowerEnd GetSet(ByVal value As Double)
_curvepower = valueEnd Set
End Property
Public Property CurveNPSHr() As DoubleGet
Return _curvenpshEnd GetSet(ByVal value As Double)
_curvenpsh = valueEnd Set
End Property
Public Property CurveEff() As DoubleGet
Return _curveeffEnd GetSet(ByVal value As Double)
_curveeff = valueEnd Set
End Property
Public Property CurveHead() As DoubleGet
Return _curveheadEnd GetSet(ByVal value As Double)
_curvehead = valueEnd Set
End Property
Public Property Curves() As Dictionary(Of String,UnitOps.Auxiliary.PipingOps.Curve)
GetIf m_curves Is Nothing Then
m_curves = New Dictionary(Of String,
UnitOps.Auxiliary.PipingOps.Curve)CreateCurves()
-
7/29/2019 Centrifugal Pump Calculation Routines
5/22
End IfReturn m_curves
End GetSet(ByVal value As Dictionary(Of String,
UnitOps.Auxiliary.PipingOps.Curve))m_curves = value
End SetEnd Property
Public Property Pout() As DoubleGet
Return m_poutEnd GetSet(ByVal value As Double)
m_pout = valueEnd Set
End Property
Public Property CalcMode() As CalculationMode
Get Return m_cmodeEnd GetSet(ByVal value As CalculationMode)
m_cmode = valueEnd Set
End Property
Public Property FixOnDeltaP() As BooleanGet
Return m_FixOnDeltaPEnd GetSet(ByVal value As Boolean)
m_FixOnDeltaP = valueEnd Set
End Property
Public Property IgnorePhase() As BooleanGet
Return m_ignorephaseEnd GetSet(ByVal value As Boolean)
m_ignorephase = valueEnd Set
End Property
Public Sub New(ByVal nome As String, ByVal descricao As String)MyBase.CreateNew()Me.m_ComponentName = nomeMe.m_ComponentDescription = descricaoMe.FillNodeItems()Me.QTFillNodeItems()Me.CreateCurves()
End Sub
Public Property NPSH() As Nullable(Of Double)Get
Return m_npshEnd GetSet(ByVal value As Nullable(Of Double))
m_npsh = valueEnd Set
-
7/29/2019 Centrifugal Pump Calculation Routines
6/22
End Property
Public Property Eficiencia() As Nullable(Of Double)Get
Return m_etaEnd Get
Set(ByVal value As Nullable(Of Double))m_eta = valueEnd Set
End Property
Public Property DeltaP() As Nullable(Of Double)Get
Return m_dpEnd GetSet(ByVal value As Nullable(Of Double))
m_dp = valueEnd Set
End Property
Public Property DeltaT() As Nullable(Of Double)Get
Return m_dtEnd GetSet(ByVal value As Nullable(Of Double))
m_dt = valueEnd Set
End Property
Public Property DeltaQ() As Nullable(Of Double)Get
Return m_DQEnd GetSet(ByVal value As Nullable(Of Double))
m_DQ = valueEnd Set
End Property
Sub CreateCurves()
If Not Me.Curves.ContainsKey("NPSH") ThenMe.Curves.Add("NPSH", New Curve(Guid.NewGuid().ToString,
"NPSH", CurveType.NPSHr))End IfIf Not Me.Curves.ContainsKey("HEAD") Then
Me.Curves.Add("HEAD", New Curve(Guid.NewGuid().ToString,"HEAD", CurveType.Head))
End IfIf Not Me.Curves.ContainsKey("EFF") Then
Me.Curves.Add("EFF", New Curve(Guid.NewGuid().ToString,"EFF", CurveType.Efficiency))
End IfIf Not Me.Curves.ContainsKey("POWER") Then
Me.Curves.Add("POWER", New Curve(Guid.NewGuid().ToString,"POWER", CurveType.Power))
End IfIf Not Me.Curves.ContainsKey("SYSTEM") Then
Me.Curves.Add("SYSTEM", New Curve(Guid.NewGuid().ToString,"SYSTEM", CurveType.SystemHead))
End If
-
7/29/2019 Centrifugal Pump Calculation Routines
7/22
End Sub
Public Overrides Function Calculate(Optional ByVal args As Object =Nothing) As Integer
Dim form As Global.DWSIM.FormFlowsheet =
My.Application.ActiveSimulationDim objargs As New DWSIM.Outros.StatusChangeEventArgs
If Not Me.GraphicObject.InputConnectors(1).IsAttached Then'Call function to calculate flowsheetWith objargs
.Calculado = False
.Nome = Me.Nome
.Tipo = TipoObjeto.PumpEnd WithCalculateFlowsheet(FlowSheet, objargs, Nothing)Throw New
Exception(DWSIM.App.GetLocalString("Nohcorrentedeenergia4"))
ElseIf Not Me.GraphicObject.OutputConnectors(0).IsAttached Then'Call function to calculate flowsheetWith objargs
.Calculado = False
.Nome = Me.Nome
.Tipo = TipoObjeto.PumpEnd WithCalculateFlowsheet(FlowSheet, objargs, Nothing)Throw New
Exception(DWSIM.App.GetLocalString("Verifiqueasconexesdo"))ElseIf Not Me.GraphicObject.InputConnectors(0).IsAttached Then
'Call function to calculate flowsheetWith objargs
.Calculado = False
.Nome = Me.Nome
.Tipo = TipoObjeto.PumpEnd WithCalculateFlowsheet(FlowSheet, objargs, Nothing)Throw New
Exception(DWSIM.App.GetLocalString("Verifiqueasconexesdo"))End If
Dim Ti, Pi, Hi, Wi, rho_li, qli, qvi, ei, ein, T2, P2, H2 AsDouble
qvi =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(2).SPMProperties.volumetric_flow.GetValueOrDefault.ToString
If qvi > 0 And Not Me.IgnorePhase Then Throw NewException(DWSIM.App.GetLocalString("Existeumafasevaporna"))
Me.PropertyPackage.CurrentMaterialStream =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name)
Ti =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.temperature.GetValueOrDefault.ToString
Pi =
form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnec
-
7/29/2019 Centrifugal Pump Calculation Routines
8/22
tors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.pressure.GetValueOrDefault.ToString
rho_li =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.density.GetValueOrDefault.ToString
qli =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.volumetric_flow.GetValueOrDefault.ToString
Hi =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.enthalpy.GetValueOrDefault.ToString
Wi =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.massflow.GetValueOrDefault.ToString
ei = Hi * Wi
ein = ei
Select Case Me.CalcMode
Case CalculationMode.Curves
Dim cv As New SistemasDeUnidades.Conversor
Dim cnpsh, chead, ceff, cpower, csystem As Curve
Me.createcurves()
cnpsh = Me.Curves("NPSH")chead = Me.Curves("HEAD")ceff = Me.Curves("EFF")cpower = Me.Curves("POWER")csystem = Me.Curves("SYSTEM")
Dim xhead, yhead, xnpsh, ynpsh, xeff, yeff, xpower,ypower, xsystem, ysystem As New ArrayList
Dim i As Integer
For i = 0 To chead.x.Count - 1If Double.TryParse(chead.x(i), New Double) And
Double.TryParse(chead.y(i), New Double) Thenxhead.Add(cv.ConverterParaSI(chead.xunit,
chead.x(i)))yhead.Add(cv.ConverterParaSI(chead.yunit,
chead.y(i)))End If
NextFor i = 0 To cnpsh.x.Count - 1
If Double.TryParse(cnpsh.x(i), New Double) AndDouble.TryParse(cnpsh.y(i), New Double) Then
xnpsh.Add(cv.ConverterParaSI(cnpsh.xunit,cnpsh.x(i)))
ynpsh.Add(cv.ConverterParaSI(cnpsh.yunit,cnpsh.y(i)))
End If
NextFor i = 0 To ceff.x.Count - 1
-
7/29/2019 Centrifugal Pump Calculation Routines
9/22
If Double.TryParse(ceff.x(i), New Double) AndDouble.TryParse(ceff.y(i), New Double) Then
xeff.Add(cv.ConverterParaSI(ceff.xunit,ceff.x(i)))
If ceff.yunit = "%" Thenyeff.Add(ceff.y(i) / 100)
Elseyeff.Add(ceff.y(i))End If
End IfNextFor i = 0 To cpower.x.Count - 1
If Double.TryParse(cpower.x(i), New Double) AndDouble.TryParse(cpower.y(i), New Double) Then
xpower.Add(cv.ConverterParaSI(cpower.xunit,cpower.x(i)))
ypower.Add(cv.ConverterParaSI(cpower.yunit,cpower.y(i)))
End If
NextFor i = 0 To csystem.x.Count - 1If Double.TryParse(csystem.x(i), New Double) And
Double.TryParse(csystem.y(i), New Double) Thenxsystem.Add(cv.ConverterParaSI(csystem.xunit,
csystem.x(i)))ysystem.Add(cv.ConverterParaSI(csystem.yunit,
csystem.y(i)))End If
Next
Dim w() As Double
'get operating pointsDim head, npshr, eff, power, syshead As Double
'headReDim w(xhead.Count)
ratinterpolation.buildfloaterhormannrationalinterpolant(xhead.ToArray(GetType(Double)), xhead.Count, 0.5, w)
head =polinterpolation.barycentricinterpolation(xhead.ToArray(GetType(Double)),yhead.ToArray(GetType(Double)), w, xhead.Count, qli)
Me.CurveHead = head
'npshrIf Me.Curves("NPSH").Enabled Then
ReDim w(xnpsh.Count)
ratinterpolation.buildfloaterhormannrationalinterpolant(xnpsh.ToArray(GetType(Double)), xnpsh.Count, 0.5, w)
npshr =polinterpolation.barycentricinterpolation(xnpsh.ToArray(GetType(Double)),ynpsh.ToArray(GetType(Double)), w, xnpsh.Count, qli)
Elsenpshr = 0
End If
Me.CurveNPSHr = npshr
-
7/29/2019 Centrifugal Pump Calculation Routines
10/22
'efficiencyIf Me.Curves("EFF").Enabled Then
ReDim w(xeff.Count)
ratinterpolation.buildfloaterhormannrationalinterpolant(xeff.ToArray(GetType(Double)), xeff.Count, 0.5, w)
eff =polinterpolation.barycentricinterpolation(xeff.ToArray(GetType(Double)),yeff.ToArray(GetType(Double)), w, xeff.Count, qli)
Elseeff = Me.Eficiencia.GetValueOrDefault / 100
End If
Me.CurveEff = eff * 100
'sysheadIf Me.Curves("SYSTEM").Enabled Then
ReDim w(xsystem.Count)
ratinterpolation.buildfloaterhormannrationalinterpolant(xsystem.ToArray(GetType(Double)), xsystem.Count, 0.5, w)syshead =
polinterpolation.barycentricinterpolation(xsystem.ToArray(GetType(Double)),ysystem.ToArray(GetType(Double)), w, xsystem.Count, qli)
Elsesyshead = head
End If
Me.CurveSysHead = syshead
'we need -> head, power, eff, to calculate P2, H2, T2
P2 = Pi + syshead * 9.81 * rho_li
Me.DeltaP = P2 - Pi
Dim tmp As Object
'powerIf Me.Curves("POWER").Enabled Then
ReDim w(xpower.Count)
ratinterpolation.buildfloaterhormannrationalinterpolant(xpower.ToArray(GetType(Double)), xpower.Count, 0.5, w)
power =polinterpolation.barycentricinterpolation(xpower.ToArray(GetType(Double)),ypower.ToArray(GetType(Double)), w, xpower.Count, qli)
H2 = Hi + power * eff / WiElse
power = Wi * 9.81 * syshead / eff / 1000H2 = Hi + power * eff / Wi
End If
Me.CurvePower = power
Me.DeltaQ = power
tmp =Me.PropertyPackage.DW_CalcEquilibrio_ISOL(PropertyPackages.FlashSpec.P,
PropertyPackages.FlashSpec.H, P2, H2, Ti)T2 = tmp(2)
-
7/29/2019 Centrifugal Pump Calculation Routines
11/22
Me.DeltaT = T2 - Ti
Me.Eficiencia = eff * 100
Me.NPSH = (Pi -
Me.PropertyPackage.DW_CalcPVAP_ISOL(Ti)) / (rho_li * 9.81)
Me.CurveFlow = qli
'Corrente de energia - atualizar valor da potncia(kJ/s)
Withform.Collections.CLCS_EnergyStreamCollection(Me.GraphicObject.InputConnectors(1).AttachedConnector.AttachedFrom.Name)
.Energia = Me.DeltaQ.GetValueOrDefault
.GraphicObject.Calculated = TrueEnd With
Case CalculationMode.EnergyStream
Dim tmp As Object
'Corrente de energia - pegar valor do DHWith
form.Collections.CLCS_EnergyStreamCollection(Me.GraphicObject.InputConnectors(1).AttachedConnector.AttachedFrom.Name)
Me.DeltaQ = .Energia.GetValueOrDefault 'Wi * (H2 -Hi) / (Me.Eficiencia.GetValueOrDefault / 100)
End With
H2 = Hi + Me.DeltaQ.GetValueOrDefault *(Me.Eficiencia.GetValueOrDefault / 100) / Wi
P2 = Pi + (H2 - Hi) * rho_li * 1000
DeltaP = P2 - Pi
tmp =Me.PropertyPackage.DW_CalcEquilibrio_ISOL(PropertyPackages.FlashSpec.P,PropertyPackages.FlashSpec.H, P2, H2, Ti)
T2 = tmp(2)
Me.DeltaT = T2 - Ti
Me.NPSH = (Pi -Me.PropertyPackage.DW_CalcPVAP_ISOL(Ti)) / (rho_li * 9.81)
Case CalculationMode.Delta_P
qvi =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(2).SPMProperties.volumetric_flow.GetValueOrDefault.ToString
If qvi > 0 And Not Me.IgnorePhase Then Throw NewException(DWSIM.App.GetLocalString("Existeumafasevaporna"))
Me.PropertyPackage.CurrentMaterialStream =
form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name)
-
7/29/2019 Centrifugal Pump Calculation Routines
12/22
P2 = Pi + Me.DeltaP.GetValueOrDefault
Me.DeltaQ = (P2 - Pi) / rho_li / 1000 /(Me.Eficiencia.GetValueOrDefault / 100) * Wi
H2 = Hi + Me.DeltaQ / Wi
Dim tmp =Me.PropertyPackage.DW_CalcEquilibrio_ISOL(PropertyPackages.FlashSpec.P,PropertyPackages.FlashSpec.H, P2, H2, Ti)
T2 = tmp(2)
Me.DeltaT = T2 - Ti
Me.NPSH = (Pi -Me.PropertyPackage.DW_CalcPVAP_ISOL(Ti)) / (rho_li * 9.81)
'Corrente de energia - atualizar valor da potncia(kJ/s)
Withform.Collections.CLCS_EnergyStreamCollection(Me.GraphicObject.InputConnectors(1).AttachedConnector.AttachedFrom.Name)
.Energia = Me.DeltaQ.GetValueOrDefault
.GraphicObject.Calculated = TrueEnd With
Case CalculationMode.OutletPressure
Me.PropertyPackage.CurrentMaterialStream =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name)
P2 = Me.Pout
Me.DeltaP = P2 - Pi
Me.DeltaQ = (P2 - Pi) / rho_li / 1000 /(Me.Eficiencia.GetValueOrDefault / 100) * Wi
H2 = Hi + Me.DeltaQ / Wi
Dim tmp =Me.PropertyPackage.DW_CalcEquilibrio_ISOL(PropertyPackages.FlashSpec.P,PropertyPackages.FlashSpec.H, P2, H2, Ti)
T2 = tmp(2)
Me.DeltaT = T2 - Ti
Me.NPSH = (Pi -Me.PropertyPackage.DW_CalcPVAP_ISOL(Ti)) / (rho_li * 9.81)
'Corrente de energia - atualizar valor da potncia(kJ/s)
Withform.Collections.CLCS_EnergyStreamCollection(Me.GraphicObject.InputConnectors(1).AttachedConnector.AttachedFrom.Name)
.Energia = Me.DeltaQ.GetValueOrDefault
.GraphicObject.Calculated = TrueEnd With
End Select
-
7/29/2019 Centrifugal Pump Calculation Routines
13/22
'Atribuir valores corrente de matria conectada jusanteWith
form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.OutputConnectors(0).AttachedConnector.AttachedTo.Name)
.Fases(0).SPMProperties.temperature = T2
.Fases(0).SPMProperties.pressure = P2.Fases(0).SPMProperties.enthalpy = H2Dim comp As DWSIM.ClassesBasicasTermodinamica.SubstanciaDim i As Integer = 0For Each comp In .Fases(0).Componentes.Values
comp.FracaoMolar =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).Componentes(comp.Nome).FracaoMolar
comp.FracaoMassica =form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).Componentes(comp.Nome).FracaoMassica
i += 1Next.Fases(0).SPMProperties.massflow =
form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name).Fases(0).SPMProperties.massflow.GetValueOrDefault
End With
'Call function to calculate flowsheetWith objargs
.Calculado = True
.Nome = Me.Nome
.Tag = Me.GraphicObject.Tag
.Tipo = TipoObjeto.PumpEnd With
form.CalculationQueue.Enqueue(objargs)
End Function
Public Overrides Function DeCalculate() As Integer
Dim form As Global.DWSIM.FormFlowsheet =My.Application.ActiveSimulation
If Me.GraphicObject.OutputConnectors(0).IsAttached Then
'Zerar valores da corrente de matria conectada a jusanteWith
form.Collections.CLCS_MaterialStreamCollection(Me.GraphicObject.OutputConnectors(0).AttachedConnector.AttachedTo.Name)
.Fases(0).SPMProperties.temperature = Nothing
.Fases(0).SPMProperties.pressure = Nothing
.Fases(0).SPMProperties.molarfraction = 1
.Fases(0).SPMProperties.massfraction = 1
.Fases(0).SPMProperties.enthalpy = NothingDim comp As
DWSIM.ClassesBasicasTermodinamica.SubstanciaDim i As Integer = 0For Each comp In .Fases(0).Componentes.Values
comp.FracaoMolar = 0comp.FracaoMassica = 0
-
7/29/2019 Centrifugal Pump Calculation Routines
14/22
i += 1Next.Fases(0).SPMProperties.massflow = Nothing.Fases(0).SPMProperties.molarflow = Nothing.GraphicObject.Calculated = False
End With
End If
'Corrente de energia - atualizar valor da potncia (kJ/s)If Me.GraphicObject.EnergyConnector.IsAttached Then
Withform.Collections.CLCS_EnergyStreamCollection(Me.GraphicObject.EnergyConnector.AttachedConnector.AttachedTo.Name)
.Energia = Nothing
.GraphicObject.Calculated = FalseEnd With
End If
'Call function to calculate flowsheetDim objargs As New DWSIM.Outros.StatusChangeEventArgsWith objargs
.Calculado = False
.Nome = Me.Nome
.Tipo = TipoObjeto.PumpEnd With
form.CalculationQueue.Enqueue(objargs)
End Function
Public Overloads Overrides Sub UpdatePropertyNodes(ByVal su AsSistemasDeUnidades.Unidades, ByVal nf As String)
Dim Conversor As New DWSIM.SistemasDeUnidades.ConversorIf Me.NodeTableItems Is Nothing Then
Me.NodeTableItems = NewSystem.Collections.Generic.Dictionary(Of Integer, DWSIM.Outros.NodeItem)
Me.FillNodeItems()End If
For Each nti As Outros.NodeItem In Me.NodeTableItems.Valuesnti.Value = GetPropertyValue(nti.Text,
FlowSheet.Options.SelectedUnitSystem)nti.Unit = GetPropertyUnit(nti.Text,
FlowSheet.Options.SelectedUnitSystem)Next
If Me.QTNodeTableItems Is Nothing ThenMe.QTNodeTableItems = New
System.Collections.Generic.Dictionary(Of Integer, DWSIM.Outros.NodeItem)Me.QTFillNodeItems()
End If
With Me.QTNodeTableItems
Dim valor As String
If Me.DeltaP.HasValue Then
valor = Format(Conversor.ConverterDoSI(su.spmp_deltaP,Me.DeltaP), nf)
-
7/29/2019 Centrifugal Pump Calculation Routines
15/22
Elsevalor = DWSIM.App.GetLocalString("NC")
End If.Item(0).Value = valor.Item(0).Unit = su.spmp_deltaP
If Me.DeltaT.HasValue Thenvalor = Format(Conversor.ConverterDoSI(su.spmp_deltaT,Me.DeltaT), nf)
Elsevalor = DWSIM.App.GetLocalString("NC")
End If.Item(1).Value = valor.Item(1).Unit = su.spmp_deltaT
If Me.DeltaQ.HasValue Thenvalor =
Format(Conversor.ConverterDoSI(su.spmp_heatflow, Me.DeltaQ), nf)Else
valor = DWSIM.App.GetLocalString("NC")End If.Item(2).Value = valor.Item(2).Unit = su.spmp_heatflow
End With
End Sub
Public Overrides Sub QTFillNodeItems()
With Me.QTNodeTableItems
.Clear()
.Add(0, New DWSIM.Outros.NodeItem("DP", "", "", 0, 0, ""))
.Add(1, New DWSIM.Outros.NodeItem("DT", "", "", 1, 0, ""))
.Add(2, NewDWSIM.Outros.NodeItem(DWSIM.App.GetLocalString("Pot"), "", "", 2, 0, ""))
End WithEnd Sub
Public Overrides Sub PopulatePropertyGrid(ByRef pgrid AsPropertyGridEx.PropertyGridEx, ByVal su As SistemasDeUnidades.Unidades)
Dim Conversor As New DWSIM.SistemasDeUnidades.Conversor
With pgrid
.PropertySort = PropertySort.Categorized
.ShowCustomProperties = True
.Item.Clear()
MyBase.PopulatePropertyGrid(pgrid, su)
Dim ent, saida, energ As StringIf Me.GraphicObject.InputConnectors(0).IsAttached = True
Thenent =
Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Tag
Elseent = ""
-
7/29/2019 Centrifugal Pump Calculation Routines
16/22
End IfIf Me.GraphicObject.OutputConnectors(0).IsAttached = True
Thensaida =
Me.GraphicObject.OutputConnectors(0).AttachedConnector.AttachedTo.TagElse
saida = ""End If
If Me.GraphicObject.InputConnectors(1).IsAttached = TrueThen
energ =Me.GraphicObject.InputConnectors(1).AttachedConnector.AttachedFrom.Tag
Elseenerg = ""
End If
.Item.Add(DWSIM.App.GetLocalString("Correntedeentrada"),ent, False, DWSIM.App.GetLocalString("Conexes1"), "", True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.CustomEditor = New
DWSIM.Editors.Streams.UIInputMSSelectorEnd With
.Item.Add(DWSIM.App.GetLocalString("Correntedesada"),saida, False, DWSIM.App.GetLocalString("Conexes1"), "", True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.CustomEditor = New
DWSIM.Editors.Streams.UIOutputMSSelectorEnd With
.Item.Add(DWSIM.App.GetLocalString("Correntedeenergia"),energ, False, DWSIM.App.GetLocalString("Conexes1"), "", True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.CustomEditor = New
DWSIM.Editors.Streams.UIInputESSelectorEnd With
.Item.Add(DWSIM.App.GetLocalString("PumpCalcMode"), Me,"CalcMode", False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"), "",True)
Select Case Me.CalcModeCase CalculationMode.Curves
.Item.Add(DWSIM.App.GetLocalString("PumpSetupCurves"), Me, "Curves", False,DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.CustomEditor = New
DWSIM.Editors.Pump.UIPumpCurvesEditorEnd WithIf Me.Curves.ContainsKey("EFF") Then
If Not Me.Curves("EFF").Enabled Then
.Item.Add(DWSIM.App.GetLocalString("Eficincia0100"), Me, "Eficiencia",
-
7/29/2019 Centrifugal Pump Calculation Routines
17/22
False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Eficinciaglobaldabom"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of
Double))
End WithEnd IfEnd If
Case CalculationMode.Delta_PDim valor =
Format(Conversor.ConverterDoSI(su.spmp_deltaP,Me.DeltaP.GetValueOrDefault), FlowSheet.Options.NumberFormat)
.Item.Add(FT("Delta P", su.spmp_deltaP), valor,False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).Tag = New Object()
{FlowSheet.Options.NumberFormat, su.spmp_deltaP, "DP"}
.CustomEditor = NewDWSIM.Editors.Generic.UIUnitConverterEnd With
.Item.Add(DWSIM.App.GetLocalString("Eficincia0100"), Me, "Eficiencia",False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Eficinciaglobaldabom"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End WithCase CalculationMode.EnergyStream
.Item.Add(DWSIM.App.GetLocalString("Eficincia0100"), Me, "Eficiencia",False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Eficinciaglobaldabom"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End WithCase CalculationMode.OutletPressure
Dim valor =Format(Conversor.ConverterDoSI(su.spmp_pressure, Me.Pout),FlowSheet.Options.NumberFormat)
.Item.Add(FT(DWSIM.App.GetLocalString("Pressoajusante"), su.spmp_pressure),valor, False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).Tag = New Object()
{FlowSheet.Options.NumberFormat, su.spmp_pressure, "P"}.CustomEditor = New
DWSIM.Editors.Generic.UIUnitConverterEnd With
.Item.Add(DWSIM.App.GetLocalString("Eficincia0100"), Me, "Eficiencia",False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("Eficinciaglobaldabom"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing
.DefaultType = GetType(Nullable(Of Double))End With
-
7/29/2019 Centrifugal Pump Calculation Routines
18/22
End Select
.Item.Add(DWSIM.App.GetLocalString("IgnorarVapornaEntrad"),Me, "IgnorePhase", False, DWSIM.App.GetLocalString("Parmetrosdeclculo2"),DWSIM.App.GetLocalString("SelecioLiquidrueparaign"), True)
With .Item(.Item.Count - 1)
.DefaultType = GetType(Boolean)End With
If Me.GraphicObject.Calculated ThenSelect Case Me.CalcMode
Case CalculationMode.Curves
.Item.Add(DWSIM.App.GetLocalString("PumpViewCurves"), Me, "Curves", False,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.CustomEditor = New
DWSIM.Editors.Pump.UIPumpCurvesEditorEnd With
.Item.Add(FT(DWSIM.App.GetLocalString("PumpCurveHead"), su.spmp_head),Format(Conversor.ConverterDoSI(su.spmp_head, Me.CurveHead),FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
.Item.Add(DWSIM.App.GetLocalString("PumpCurveEfficiency"),Format(Me.CurveEff, FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
.Item.Add(FT(DWSIM.App.GetLocalString("PumpCurvePower"), su.spmp_heatflow),Format(Conversor.ConverterDoSI(su.spmp_heatflow, Me.CurvePower),FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
Dim valor =Format(Conversor.ConverterDoSI(su.spmp_deltaP,Me.DeltaP.GetValueOrDefault), FlowSheet.Options.NumberFormat)
.Item.Add(FT("Delta P", su.spmp_deltaP), valor,True, DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("DeltaT2"), su.spmp_deltaT),Format(Conversor.ConverterDoSI(su.spmp_deltaT,Me.DeltaT.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("PumpCurveNPSHr"), su.spmp_head),Format(Conversor.ConverterDoSI(su.spmp_head, Me.CurveNPSHr),
-
7/29/2019 Centrifugal Pump Calculation Routines
19/22
FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
Case CalculationMode.Delta_P
.Item.Add(FT(DWSIM.App.GetLocalString("DeltaT2"), su.spmp_deltaT),
Format(Conversor.ConverterDoSI(su.spmp_deltaT,Me.DeltaT.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("Energianecessria"),su.spmp_heatflow), Format(Conversor.ConverterDoSI(su.spmp_heatflow,Me.DeltaQ.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),
DWSIM.App.GetLocalString("Potnciarequeridapela"), True)With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End WithCase CalculationMode.EnergyStream
Dim valor =Format(Conversor.ConverterDoSI(su.spmp_deltaP,Me.DeltaP.GetValueOrDefault), FlowSheet.Options.NumberFormat)
.Item.Add(FT("Delta P", su.spmp_deltaP), valor,True, DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("DeltaT2"), su.spmp_deltaT),Format(Conversor.ConverterDoSI(su.spmp_deltaT,Me.DeltaT.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End WithCase CalculationMode.OutletPressure
Dim valor =Format(Conversor.ConverterDoSI(su.spmp_deltaP,Me.DeltaP.GetValueOrDefault), FlowSheet.Options.NumberFormat)
.Item.Add(FT("Delta P", su.spmp_deltaP), valor,True, DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadepressoentr"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("DeltaT2"), su.spmp_deltaT),Format(Conversor.ConverterDoSI(su.spmp_deltaT,
Me.DeltaT.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,
-
7/29/2019 Centrifugal Pump Calculation Routines
20/22
DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Diferenadetemperatur"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
.Item.Add(FT(DWSIM.App.GetLocalString("Energianecessria"),su.spmp_heatflow), Format(Conversor.ConverterDoSI(su.spmp_heatflow,Me.DeltaQ.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Potnciarequeridapela"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End WithEnd Select
End If.Item.Add(FT(DWSIM.App.GetLocalString("PumpNPSHd"),
su.spmp_head), Format(Conversor.ConverterDoSI(su.spmp_head,Me.NPSH.GetValueOrDefault), FlowSheet.Options.NumberFormat), True,DWSIM.App.GetLocalString("Resultados3"),DWSIM.App.GetLocalString("Potnciarequeridapela"), True)
With .Item(.Item.Count - 1).DefaultValue = Nothing.DefaultType = GetType(Nullable(Of Double))
End With
If Me.GraphicObject.Calculated = False Then.Item.Add(DWSIM.App.GetLocalString("Mensagemdeerro"),
Me, "ErrorMessage", True, DWSIM.App.GetLocalString("Miscelnea4"),DWSIM.App.GetLocalString("Mensagemretornadaqua"), True)
With .Item(.Item.Count - 1).DefaultType = GetType(System.String)
End WithEnd If
If Me.IsSpecAttached = True Then
.Item.Add(DWSIM.App.GetLocalString("ObjetoUtilizadopor"),FlowSheet.Collections.ObjectCollection(Me.AttachedSpecId).GraphicObject.Tag, True, DWSIM.App.GetLocalString("Miscelnea4"), "", True)
.Item.Add(DWSIM.App.GetLocalString("Utilizadocomo"),Me.SpecVarType, True, DWSIM.App.GetLocalString("Miscelnea4"), "", True)
End If
If Not Me.Annotation Is Nothing Then.Item.Add(DWSIM.App.GetLocalString("Anotaes"), Me,
"Annotation", False, DWSIM.App.GetLocalString("Outros"),DWSIM.App.GetLocalString("Cliquenobotocomretic"), True)
With .Item(.Item.Count - 1).IsBrowsable = False.CustomEditor = New
DWSIM.Editors.Annotation.UIAnnotationEditorEnd With
End If
End With
End Sub
-
7/29/2019 Centrifugal Pump Calculation Routines
21/22
Public Overrides Function GetPropertyValue(ByVal prop As String,Optional ByVal su As SistemasDeUnidades.Unidades = Nothing) As Object
If su Is Nothing Then su = NewDWSIM.SistemasDeUnidades.UnidadesSI
Dim cv As New DWSIM.SistemasDeUnidades.Conversor
Dim value As Double = 0Dim propidx As Integer = CInt(prop.Split("_")(2))
Select Case propidx
Case 0'PROP_PU_0 Pressure Increase (Head)value = cv.ConverterDoSI(su.spmp_deltaP,
Me.DeltaP.GetValueOrDefault)Case 1
'PROP_PU_1(Efficiency)value = Me.Eficiencia.GetValueOrDefault
Case 2
'PROP_PU_2(Delta - T)value = cv.ConverterDoSI(su.spmp_deltaT,Me.DeltaT.GetValueOrDefault)
Case 3'PROP_PU_3 Power Requiredvalue = cv.ConverterDoSI(su.spmp_heatflow,
Me.DeltaQ.GetValueOrDefault)
End Select
Return value
End Function
Public Overloads Overrides Function GetProperties(ByVal proptype AsSimulationObjects_BaseClass.PropertyType) As String()
Dim i As Integer = 0Dim proplist As New ArrayListSelect Case proptype
Case PropertyType.ROFor i = 2 To 3
proplist.Add("PROP_PU_" + CStr(i))Next
Case PropertyType.RWFor i = 0 To 1
proplist.Add("PROP_PU_" + CStr(i))Next
Case PropertyType.WRFor i = 0 To 1
proplist.Add("PROP_PU_" + CStr(i))Next
Case PropertyType.ALLFor i = 0 To 3
proplist.Add("PROP_PU_" + CStr(i))Next
End SelectReturn proplist.ToArray(GetType(System.String))proplist = Nothing
End Function
-
7/29/2019 Centrifugal Pump Calculation Routines
22/22
Public Overrides Function SetPropertyValue(ByVal prop As String,ByVal propval As Object, Optional ByVal su AsDWSIM.SistemasDeUnidades.Unidades = Nothing) As Object
If su Is Nothing Then su = NewDWSIM.SistemasDeUnidades.UnidadesSI
Dim cv As New DWSIM.SistemasDeUnidades.Conversor
Dim propidx As Integer = CInt(prop.Split("_")(2))
Select Case propidxCase 0
'PROP_PU_0 Pressure Increase (Head)Me.DeltaP = cv.ConverterParaSI(su.spmp_deltaP, propval)
Case 1'PROP_PU_1(Efficiency)Me.Eficiencia = propval
End SelectReturn 1
End Function
Public Overrides Function GetPropertyUnit(ByVal prop As String,Optional ByVal su As SistemasDeUnidades.Unidades = Nothing) As ObjectIf su Is Nothing Then su = New
DWSIM.SistemasDeUnidades.UnidadesSIDim cv As New DWSIM.SistemasDeUnidades.ConversorDim value As String = ""Dim propidx As Integer = CInt(prop.Split("_")(2))
Select Case propidx
Case 0'PROP_PU_0 Pressure Increase (Head)value = su.spmp_deltaP
Case 1'PROP_PU_1(Efficiency)value = ""
Case 2'PROP_PU_2(Delta - T)value = su.spmp_deltaT
Case 3'PROP_PU_3 Power Requiredvalue = su.spmp_heatflow
End Select
Return value
End Function
End Class
End Namespace