From 14e6311b4d8e6a1ce53ee1853511ba5027c69da3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 8 Apr 2018 20:50:05 -0400 Subject: [PATCH] [WIP] inspector; bug fix PFR --- .../Base Classes/PropertyPackage.vb | 79 + DWSIM.UI.Desktop.Editors/General/Results.cs | 2 +- .../EditingForm_ReactorPFR.Designer.vb | 70 +- .../Editing Forms/EditingForm_ReactorPFR.resx | 1516 ++++++++++++----- .../Editing Forms/EditingForm_ReactorPFR.vb | 6 +- DWSIM.UnitOperations/Reactors/CSTR.vb | 22 +- DWSIM.UnitOperations/Reactors/Conversion.vb | 16 + DWSIM.UnitOperations/Reactors/PFR.vb | 94 +- 8 files changed, 1373 insertions(+), 432 deletions(-) diff --git a/DWSIM.Thermodynamics/Base Classes/PropertyPackage.vb b/DWSIM.Thermodynamics/Base Classes/PropertyPackage.vb index 50a0419e..c9802228 100644 --- a/DWSIM.Thermodynamics/Base Classes/PropertyPackage.vb +++ b/DWSIM.Thermodynamics/Base Classes/PropertyPackage.vb @@ -510,21 +510,100 @@ Namespace PropertyPackages Public Sub CalcAdditionalPhaseProperties() Implements IPropertyPackage.CalcAdditionalPhaseProperties + Dim IObj As Inspector.InspectorItem = Inspector.Host.GetNewInspectorItem() + + Inspector.Host.CheckAndAdd(IObj, "", "CalcAdditionalPhaseProperties", ComponentName & " (Additional Properties)", "Property Package Additional Phase Properties Calculation Routine") + + IObj?.Paragraphs.Add("

Isothermal Compressibility

") + + IObj?.Paragraphs.Add("Isothermal compressibility of a given phase is calculated + following the thermodynamic definition:") + + IObj?.Paragraphs.Add("\beta=-\frac{1}{V}\frac{\partial V}{\partial P}") + + IObj?.Paragraphs.Add("The above expression is calculated rigorously by the PR and SRK + equations of state. For the other models, a numerical derivative + approximation is used.") + + IObj?.Paragraphs.Add("

Bulk Modulus

") + + IObj?.Paragraphs.Add("The Bulk Modulus of a phase is defined as the inverse of the + isothermal compressibility:") + + IObj?.Paragraphs.Add("K=\frac{1}{\beta}") + + IObj?.Paragraphs.Add("

Speed of Sound

") + + IObj?.Paragraphs.Add("The speed of sound in a given phase is calculated by the + following equations:") + + IObj?.Paragraphs.Add("c=\sqrt{\frac{K}{\rho}},") + + IObj?.Paragraphs.Add("where:") + + IObj?.Paragraphs.Add("c Speed of sound (m/s)") + + IObj?.Paragraphs.Add("K Bulk Modulus (Pa)") + + IObj?.Paragraphs.Add("\rho Phase Density (kg/m³)") + + IObj?.Paragraphs.Add("

Joule-Thomson Coefficient

") + + IObj?.Paragraphs.Add("In thermodynamics, the Joule–Thomson effect (also known as the + Joule–Kelvin effect, Kelvin–Joule effect, or Joule–Thomson + expansion) describes the temperature change of a real gas or + liquid when it is forced through a valve or porous plug while + kept insulated so that no heat is exchanged with the environment. + This procedure is called a throttling process or Joule–Thomson + process. At room temperature, all gases except hydrogen, helium + and neon cool upon expansion by the Joule–Thomson process. The + rate of change of temperature with respect to pressure in a + Joule–Thomson process is the Joule–Thomson coefficient.") + + IObj?.Paragraphs.Add("The Joule-Thomson coefficient for a given phase is calculated by + the following definition:") + + IObj?.Paragraphs.Add("\mu=(\frac{\partial T}{\partial P})_{H},") + + IObj?.Paragraphs.Add("The JT coefficient is calculated rigorously by the PR and SRK + equations of state, while the Goldzberg correlation is used for + all other models,") + + IObj?.Paragraphs.Add("\mu=\frac{0.0048823T_{pc}(18/T_{pr}^{2}-1)}{P_{pc}C_{p}\gamma}, + for gases, and") + + IObj?.Paragraphs.Add("\mu=-\frac{1}{\rho C_{p}}") + + IObj?.Paragraphs.Add("for liquids.") + + IObj?.Paragraphs.Add("

Results

") + For Each p As IPhase In Me.CurrentMaterialStream.Phases.Values + IObj?.Paragraphs.Add(String.Format("

{0}

", p.Name)) If p.Name <> "Mixture" And p.Name <> "OverallLiquid" Then + With p.Properties .isothermal_compressibility = CalcIsothermalCompressibility(p) .bulk_modulus = CalcBulkModulus(p) .speedOfSound = CalcSpeedOfSound(p) .jouleThomsonCoefficient = CalcJouleThomsonCoefficient(p) End With + CalcInternalEnergy(p) CalcGibbsFreeEnergy(p) CalcHelmholtzEnergy(p) CalcDiffusionCoefficients(p) + + IObj?.Paragraphs.Add(String.Format("Isothermal Compressibility: {0} 1/Pa", p.Properties.isothermal_compressibility)) + IObj?.Paragraphs.Add(String.Format("Bulk Modulus: {0} Pa", p.Properties.bulk_modulus)) + IObj?.Paragraphs.Add(String.Format("Speed of Sound: {0} m/s", p.Properties.speedOfSound)) + IObj?.Paragraphs.Add(String.Format("Joule-Thomson Coefficient: {0} K/Pa", p.Properties.jouleThomsonCoefficient)) + End If Next + IObj?.Close() + End Sub Public Overridable Function CalcIsothermalCompressibility(p As IPhase) As Double diff --git a/DWSIM.UI.Desktop.Editors/General/Results.cs b/DWSIM.UI.Desktop.Editors/General/Results.cs index cf54ac63..f5040ae2 100644 --- a/DWSIM.UI.Desktop.Editors/General/Results.cs +++ b/DWSIM.UI.Desktop.Editors/General/Results.cs @@ -464,7 +464,7 @@ OxyPlot.PlotModel CreatePFRResultsModel(Reactor_PFR reactor) MinorGridlineStyle = LineStyle.Dot, Position = AxisPosition.Bottom, FontSize = 12, - Title = "Volume (" + su.volume + ")" + Title = "Reactor Length (" + su.distance + ")" }); model.Axes.Add(new LinearAxis() { diff --git a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.Designer.vb b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.Designer.vb index 604723ad..6f5554b5 100644 --- a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.Designer.vb +++ b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.Designer.vb @@ -25,15 +25,15 @@ Partial Class EditingForm_ReactorPFR Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(EditingForm_ReactorPFR)) - Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle4 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle5 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle6 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle7 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle8 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle9 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle10 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle11 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle12 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle13 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle14 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle15 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle16 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle17 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle18 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Me.GroupBox5 = New System.Windows.Forms.GroupBox() Me.lblTag = New System.Windows.Forms.TextBox() Me.chkActive = New System.Windows.Forms.CheckBox() @@ -184,7 +184,7 @@ Partial Class EditingForm_ReactorPFR ' resources.ApplyResources(Me.rtbAnnotations, "rtbAnnotations") Me.rtbAnnotations.Name = "rtbAnnotations" - Me.rtbAnnotations.Rtf = "{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fnil\fcharset0 Microsoft S" & _ + Me.rtbAnnotations.Rtf = "{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fnil\fcharset0 Microsoft S" & "ans Serif;}}" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "\viewkind4\uc1\pard\f0\fs17\par" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "}" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) Me.rtbAnnotations.ShowRedo = False Me.rtbAnnotations.ShowUndo = False @@ -534,8 +534,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn1 ' - DataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control - Me.DataGridViewTextBoxColumn1.DefaultCellStyle = DataGridViewCellStyle1 + DataGridViewCellStyle10.BackColor = System.Drawing.SystemColors.Control + Me.DataGridViewTextBoxColumn1.DefaultCellStyle = DataGridViewCellStyle10 Me.DataGridViewTextBoxColumn1.FillWeight = 60.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn1, "DataGridViewTextBoxColumn1") Me.DataGridViewTextBoxColumn1.Name = "DataGridViewTextBoxColumn1" @@ -543,8 +543,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn2 ' - DataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight - Me.DataGridViewTextBoxColumn2.DefaultCellStyle = DataGridViewCellStyle2 + DataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight + Me.DataGridViewTextBoxColumn2.DefaultCellStyle = DataGridViewCellStyle11 Me.DataGridViewTextBoxColumn2.FillWeight = 40.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn2, "DataGridViewTextBoxColumn2") Me.DataGridViewTextBoxColumn2.Name = "DataGridViewTextBoxColumn2" @@ -552,8 +552,8 @@ Partial Class EditingForm_ReactorPFR ' 'Column1 ' - DataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control - Me.Column1.DefaultCellStyle = DataGridViewCellStyle3 + DataGridViewCellStyle12.BackColor = System.Drawing.SystemColors.Control + Me.Column1.DefaultCellStyle = DataGridViewCellStyle12 Me.Column1.FillWeight = 30.0! resources.ApplyResources(Me.Column1, "Column1") Me.Column1.Name = "Column1" @@ -580,8 +580,8 @@ Partial Class EditingForm_ReactorPFR ' 'Column2 ' - DataGridViewCellStyle4.BackColor = System.Drawing.SystemColors.Control - Me.Column2.DefaultCellStyle = DataGridViewCellStyle4 + DataGridViewCellStyle13.BackColor = System.Drawing.SystemColors.Control + Me.Column2.DefaultCellStyle = DataGridViewCellStyle13 Me.Column2.FillWeight = 40.0! resources.ApplyResources(Me.Column2, "Column2") Me.Column2.Name = "Column2" @@ -589,8 +589,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn3 ' - DataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control - Me.DataGridViewTextBoxColumn3.DefaultCellStyle = DataGridViewCellStyle5 + DataGridViewCellStyle14.BackColor = System.Drawing.SystemColors.Control + Me.DataGridViewTextBoxColumn3.DefaultCellStyle = DataGridViewCellStyle14 Me.DataGridViewTextBoxColumn3.FillWeight = 60.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn3, "DataGridViewTextBoxColumn3") Me.DataGridViewTextBoxColumn3.Name = "DataGridViewTextBoxColumn3" @@ -598,8 +598,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn4 ' - DataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight - Me.DataGridViewTextBoxColumn4.DefaultCellStyle = DataGridViewCellStyle6 + DataGridViewCellStyle15.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight + Me.DataGridViewTextBoxColumn4.DefaultCellStyle = DataGridViewCellStyle15 Me.DataGridViewTextBoxColumn4.FillWeight = 40.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn4, "DataGridViewTextBoxColumn4") Me.DataGridViewTextBoxColumn4.Name = "DataGridViewTextBoxColumn4" @@ -607,8 +607,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn5 ' - DataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control - Me.DataGridViewTextBoxColumn5.DefaultCellStyle = DataGridViewCellStyle7 + DataGridViewCellStyle16.BackColor = System.Drawing.SystemColors.Control + Me.DataGridViewTextBoxColumn5.DefaultCellStyle = DataGridViewCellStyle16 Me.DataGridViewTextBoxColumn5.FillWeight = 30.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn5, "DataGridViewTextBoxColumn5") Me.DataGridViewTextBoxColumn5.Name = "DataGridViewTextBoxColumn5" @@ -635,8 +635,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn6 ' - DataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control - Me.DataGridViewTextBoxColumn6.DefaultCellStyle = DataGridViewCellStyle8 + DataGridViewCellStyle17.BackColor = System.Drawing.SystemColors.Control + Me.DataGridViewTextBoxColumn6.DefaultCellStyle = DataGridViewCellStyle17 Me.DataGridViewTextBoxColumn6.FillWeight = 60.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn6, "DataGridViewTextBoxColumn6") Me.DataGridViewTextBoxColumn6.Name = "DataGridViewTextBoxColumn6" @@ -644,8 +644,8 @@ Partial Class EditingForm_ReactorPFR ' 'DataGridViewTextBoxColumn7 ' - DataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight - Me.DataGridViewTextBoxColumn7.DefaultCellStyle = DataGridViewCellStyle9 + DataGridViewCellStyle18.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight + Me.DataGridViewTextBoxColumn7.DefaultCellStyle = DataGridViewCellStyle18 Me.DataGridViewTextBoxColumn7.FillWeight = 40.0! resources.ApplyResources(Me.DataGridViewTextBoxColumn7, "DataGridViewTextBoxColumn7") Me.DataGridViewTextBoxColumn7.Name = "DataGridViewTextBoxColumn7" @@ -665,13 +665,13 @@ Partial Class EditingForm_ReactorPFR Me.ZedGraphControl1.IsShowCopyMessage = False Me.ZedGraphControl1.IsShowPointValues = True Me.ZedGraphControl1.Name = "ZedGraphControl1" - Me.ZedGraphControl1.ScrollGrace = 0.0R - Me.ZedGraphControl1.ScrollMaxX = 0.0R - Me.ZedGraphControl1.ScrollMaxY = 0.0R - Me.ZedGraphControl1.ScrollMaxY2 = 0.0R - Me.ZedGraphControl1.ScrollMinX = 0.0R - Me.ZedGraphControl1.ScrollMinY = 0.0R - Me.ZedGraphControl1.ScrollMinY2 = 0.0R + Me.ZedGraphControl1.ScrollGrace = 0R + Me.ZedGraphControl1.ScrollMaxX = 0R + Me.ZedGraphControl1.ScrollMaxY = 0R + Me.ZedGraphControl1.ScrollMaxY2 = 0R + Me.ZedGraphControl1.ScrollMinX = 0R + Me.ZedGraphControl1.ScrollMinY = 0R + Me.ZedGraphControl1.ScrollMinY2 = 0R ' 'EditingForm_ReactorPFR ' diff --git a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.resx b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.resx index 65133027..988fb6e9 100644 --- a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.resx +++ b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.resx @@ -126,10 +126,13 @@ - 133, 19 + 288, 38 + + + 7, 6, 7, 6 - 203, 20 + 401, 32 @@ -147,6 +150,9 @@ 0 + + 17, 17 + Top, Right @@ -157,17 +163,17 @@ NoControl - 315, 43 + 649, 86 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 21 - - 17, 17 - Ativar/Desativar @@ -193,10 +199,13 @@ NoControl - 132, 72 + 286, 144 + + + 7, 0, 7, 0 - 38, 13 + 76, 26 20 @@ -226,10 +235,13 @@ NoControl - 132, 47 + 286, 94 + + + 7, 0, 7, 0 - 38, 13 + 76, 26 19 @@ -256,10 +268,13 @@ NoControl - 9, 72 + 20, 144 + + + 7, 0, 7, 0 - 48, 13 + 95, 26 17 @@ -286,10 +301,13 @@ NoControl - 9, 47 + 20, 94 + + + 7, 0, 7, 0 - 37, 13 + 74, 26 16 @@ -316,10 +334,13 @@ NoControl - 9, 22 + 20, 44 + + + 7, 0, 7, 0 - 38, 13 + 76, 26 14 @@ -340,10 +361,16 @@ 6 - 6, 6 + 13, 12 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 - 342, 98 + 707, 196 8 @@ -366,18 +393,6 @@ Top, Left, Right - - Fill - - - 3, 16 - - - 336, 154 - - - 0 - rtbAnnotations @@ -391,10 +406,16 @@ 0 - 6, 854 + 13, 1708 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 - 342, 173 + 707, 346 7 @@ -414,9 +435,138 @@ 0 + + Fill + + + 7, 31 + + + 7, 6, 7, 6 + + + 693, 309 + + + 0 + + + rtbAnnotations + + + Extended.Windows.Forms.RichTextBoxExtended, RichTextBoxExtended, Version=2.0.2954.894, Culture=neutral, PublicKeyToken=null + + + GroupBox4 + + + 0 + Top, Left, Right + + btnConfigureFlashAlg + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 0 + + + btnConfigurePP + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 1 + + + cbFlashAlg + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 2 + + + Label10 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 3 + + + cbPropPack + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 4 + + + Label9 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox3 + + + 5 + + + 13, 1524 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 + + + 707, 176 + + + 6 + + + Configurações do Pacote de Propriedades + + + GroupBox3 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + Top, Right @@ -427,10 +577,13 @@ NoControl - 315, 53 + 649, 106 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 21 @@ -460,10 +613,13 @@ NoControl - 315, 26 + 649, 52 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 20 @@ -487,10 +643,13 @@ Top, Left, Right - 147, 53 + 319, 106 + + + 7, 6, 7, 6 - 162, 21 + 312, 34 17 @@ -514,10 +673,13 @@ NoControl - 8, 56 + 17, 112 + + + 7, 0, 7, 0 - 78, 13 + 164, 26 16 @@ -541,10 +703,13 @@ Top, Left, Right - 147, 26 + 319, 52 + + + 7, 6, 7, 6 - 162, 21 + 312, 34 15 @@ -568,10 +733,13 @@ NoControl - 8, 29 + 17, 58 + + + 7, 0, 7, 0 - 121, 13 + 245, 26 14 @@ -591,48 +759,9 @@ 5 - - 6, 762 - - - 342, 88 - - - 6 - - - Configurações do Pacote de Propriedades - - - GroupBox3 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - Top, Left, Right - - Top, Left, Right - - - 147, 210 - - - 121, 20 - - - 53 - - - Right - tbCatVoidFrac @@ -645,24 +774,6 @@ 0 - - True - - - NoControl - - - 8, 213 - - - 117, 13 - - - 52 - - - Fração de Vazios (Cat.) - Label5 @@ -675,27 +786,6 @@ 1 - - Top, Right - - - Mínima das Entradas - - - Média das Entradas - - - Máxima das Entradas - - - 274, 183 - - - 61, 21 - - - 51 - cbCatDiam @@ -708,21 +798,6 @@ 2 - - Top, Left, Right - - - 147, 184 - - - 121, 20 - - - 50 - - - Right - tbCatDiam @@ -735,24 +810,6 @@ 3 - - True - - - NoControl - - - 8, 187 - - - 119, 13 - - - 49 - - - Diâmetro do Catalisador - Label15 @@ -765,10 +822,394 @@ 4 - - Top, Right + + cbCatLoad - + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 5 + + + tbCatLoad + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 6 + + + Label8 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 7 + + + cbLength + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 8 + + + tbLength + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 9 + + + Label6 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 10 + + + cbVol + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 11 + + + tbVol + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 12 + + + Label1 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 13 + + + cbReacSet + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 14 + + + Label4 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 15 + + + cbTemp + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 16 + + + tbOutletTemperature + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 17 + + + Label3 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 18 + + + cbCalcMode + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 19 + + + Label2 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 20 + + + 13, 442 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 + + + 707, 484 + + + 5 + + + Parâmetros de Cálculo + + + GroupBox2 + + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + Top, Left, Right + + + 319, 420 + + + 7, 6, 7, 6 + + + 224, 32 + + + 53 + + + Right + + + tbCatVoidFrac + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 0 + + + True + + + NoControl + + + 17, 426 + + + 7, 0, 7, 0 + + + 241, 26 + + + 52 + + + Fração de Vazios (Cat.) + + + Label5 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 1 + + + Top, Right + + + Mínima das Entradas + + + Média das Entradas + + + Máxima das Entradas + + + 560, 366 + + + 7, 6, 7, 6 + + + 128, 34 + + + 51 + + + cbCatDiam + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 2 + + + Top, Left, Right + + + 319, 368 + + + 7, 6, 7, 6 + + + 224, 32 + + + 50 + + + Right + + + tbCatDiam + + + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 3 + + + True + + + NoControl + + + 17, 374 + + + 7, 0, 7, 0 + + + 247, 26 + + + 49 + + + Diâmetro do Catalisador + + + Label15 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox2 + + + 4 + + + Top, Right + + Mínima das Entradas @@ -778,10 +1219,13 @@ Máxima das Entradas - 274, 157 + 560, 314 + + + 7, 6, 7, 6 - 61, 21 + 128, 34 48 @@ -802,10 +1246,13 @@ Top, Left, Right - 147, 158 + 319, 316 + + + 7, 6, 7, 6 - 121, 20 + 224, 32 47 @@ -832,10 +1279,13 @@ NoControl - 8, 161 + 17, 322 + + + 7, 0, 7, 0 - 105, 13 + 217, 26 46 @@ -868,10 +1318,13 @@ Máxima das Entradas - 274, 131 + 560, 262 + + + 7, 6, 7, 6 - 61, 21 + 128, 34 45 @@ -892,10 +1345,13 @@ Top, Left, Right - 147, 132 + 319, 264 + + + 7, 6, 7, 6 - 121, 20 + 224, 32 44 @@ -922,10 +1378,13 @@ NoControl - 8, 135 + 17, 270 + + + 7, 0, 7, 0 - 118, 13 + 245, 26 43 @@ -958,10 +1417,13 @@ Máxima das Entradas - 274, 105 + 560, 210 + + + 7, 6, 7, 6 - 61, 21 + 128, 34 39 @@ -982,10 +1444,13 @@ Top, Left, Right - 147, 106 + 319, 212 + + + 7, 6, 7, 6 - 121, 20 + 224, 32 38 @@ -1012,10 +1477,13 @@ NoControl - 8, 109 + 17, 218 + + + 7, 0, 7, 0 - 92, 13 + 188, 26 37 @@ -1048,10 +1516,13 @@ Definir Temperatura - 147, 25 + 319, 50 + + + 7, 6, 7, 6 - 188, 21 + 369, 34 36 @@ -1075,10 +1546,13 @@ NoControl - 9, 28 + 20, 56 + + + 7, 0, 7, 0 - 110, 13 + 221, 26 35 @@ -1111,10 +1585,13 @@ Máxima das Entradas - 274, 79 + 560, 158 + + + 7, 6, 7, 6 - 61, 21 + 128, 34 34 @@ -1135,10 +1612,13 @@ Top, Left, Right - 147, 80 + 319, 160 + + + 7, 6, 7, 6 - 121, 20 + 224, 32 33 @@ -1165,10 +1645,13 @@ NoControl - 8, 83 + 17, 166 + + + 7, 0, 7, 0 - 114, 13 + 227, 26 32 @@ -1201,10 +1684,13 @@ Definir Temperatura - 147, 52 + 319, 104 + + + 7, 6, 7, 6 - 188, 21 + 369, 34 3 @@ -1228,10 +1714,13 @@ NoControl - 9, 55 + 20, 110 + + + 7, 0, 7, 0 - 87, 13 + 175, 26 2 @@ -1251,32 +1740,182 @@ 20 - - 6, 221 + + Top, Left, Right - - 342, 242 + + btnCreateAndConnectEnergy - + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 0 + + + btnCreateAndConnectOutlet1 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 1 + + + btnCreateAndConnectInlet1 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 2 + + + btnDisconnectEnergy + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 3 + + + Label14 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 4 + + + cbEnergy + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + 5 - - Parâmetros de Cálculo + + btnDisconnectOutlet1 - - GroupBox2 + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + GroupBox1 + + + 6 + + + btnDisconnect1 + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 7 + + + Label7 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 8 + + + cbOutlet1 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 9 + + + cbInlet1 + + + System.Windows.Forms.ComboBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 10 + + + Label19 + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + GroupBox1 + + + 11 + + + 13, 212 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 + + + 707, 218 + + + 9 + + + Conexões + + + GroupBox1 + + System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + $this - - 5 - - - Top, Left, Right + + 3 Top, Right @@ -1285,10 +1924,13 @@ Zoom - 288, 77 + 590, 154 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 34 @@ -1315,10 +1957,13 @@ Zoom - 288, 50 + 590, 100 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 32 @@ -1345,10 +1990,13 @@ Zoom - 288, 23 + 590, 46 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 31 @@ -1375,10 +2023,13 @@ NoControl - 315, 77 + 649, 154 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 23 @@ -1405,10 +2056,13 @@ NoControl - 9, 80 + 20, 160 + + + 7, 0, 7, 0 - 101, 13 + 207, 26 22 @@ -1432,10 +2086,13 @@ Top, Left, Right - 147, 77 + 319, 154 + + + 7, 6, 7, 6 - 135, 21 + 254, 34 21 @@ -1459,10 +2116,13 @@ NoControl - 315, 50 + 649, 100 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 20 @@ -1489,10 +2149,13 @@ NoControl - 315, 23 + 649, 46 + + + 7, 6, 7, 6 - 21, 21 + 46, 42 14 @@ -1519,10 +2182,13 @@ NoControl - 9, 53 + 20, 106 + + + 7, 0, 7, 0 - 94, 13 + 188, 26 13 @@ -1546,10 +2212,13 @@ Top, Left, Right - 147, 50 + 319, 100 + + + 7, 6, 7, 6 - 135, 21 + 254, 34 8 @@ -1570,10 +2239,13 @@ Top, Left, Right - 147, 23 + 319, 46 + + + 7, 6, 7, 6 - 135, 21 + 254, 34 1 @@ -1597,88 +2269,37 @@ NoControl - 8, 26 - - - 102, 13 - - - 0 - - - Corrente de Entrada - - - Label19 - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - GroupBox1 - - - 11 - - - 6, 106 - - - 342, 109 - - - 9 - - - Conexões - - - GroupBox1 - - - System.Windows.Forms.GroupBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 + 17, 52 - - Top, Left, Right - - - True - - - Propriedade + + 7, 0, 7, 0 - - True - - - Valor + + 208, 26 - - True - - - Unidade + + 0 - - Fill + + Corrente de Entrada - - 3, 3 + + Label19 - - 0, 0, 0, 0 + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 322, 239 + + GroupBox1 - - 19 + + 11 + + + 17, 17 + + + Top, Left, Right gridResults @@ -1693,13 +2314,16 @@ 0 - 4, 22 + 8, 40 + + + 7, 6, 7, 6 - 3, 3, 3, 3 + 7, 6, 7, 6 - 328, 245 + 677, 495 0 @@ -1719,42 +2343,6 @@ 0 - - True - - - Reação - - - True - - - Propriedade - - - True - - - Valor - - - True - - - Unidade - - - Fill - - - 3, 3 - - - 322, 239 - - - 20 - gridReactions @@ -1768,13 +2356,16 @@ 0 - 4, 22 + 8, 40 + + + 7, 6, 7, 6 - 3, 3, 3, 3 + 7, 6, 7, 6 - 328, 245 + 712, 494 1 @@ -1794,30 +2385,6 @@ 1 - - True - - - Componente - - - True - - - Conversão (%) - - - Fill - - - 0, 0 - - - 328, 245 - - - 0 - gridConversions @@ -1831,10 +2398,13 @@ 0 - 4, 22 + 8, 40 + + + 7, 6, 7, 6 - 328, 245 + 712, 494 2 @@ -1858,10 +2428,13 @@ Fill - 3, 3 + 7, 6 + + + 13, 12, 13, 12 - 322, 239 + 663, 483 1 @@ -1870,7 +2443,7 @@ ZedGraphControl1 - ZedGraph.ZedGraphControl, ZedGraph, Version=5.1.5.16316, Culture=neutral, PublicKeyToken=null + ZedGraph.ZedGraphControl, ZedGraph, Version=5.1.5.18213, Culture=neutral, PublicKeyToken=null TabPage4 @@ -1879,13 +2452,16 @@ 0 - 4, 22 + 8, 40 + + + 7, 6, 7, 6 - 3, 3, 3, 3 + 7, 6, 7, 6 - 328, 245 + 677, 495 3 @@ -1909,10 +2485,13 @@ Fill - 3, 16 + 7, 31 + + + 7, 6, 7, 6 - 336, 271 + 693, 543 0 @@ -1930,10 +2509,16 @@ 0 - 6, 465 + 13, 930 + + + 7, 6, 7, 6 + + + 7, 6, 7, 6 - 342, 290 + 707, 580 10 @@ -1953,6 +2538,168 @@ 1 + + True + + + True + + + True + + + Fill + + + 7, 6 + + + 0, 0, 0, 0 + + + 663, 483 + + + 19 + + + gridResults + + + System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TabPage1 + + + 0 + + + True + + + Propriedade + + + True + + + Valor + + + True + + + Unidade + + + True + + + True + + + True + + + True + + + Fill + + + 7, 6 + + + 7, 6, 7, 6 + + + 698, 482 + + + 20 + + + gridReactions + + + System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TabPage2 + + + 0 + + + True + + + Reação + + + True + + + Propriedade + + + True + + + Valor + + + True + + + Unidade + + + True + + + True + + + Fill + + + 0, 0 + + + 7, 6, 7, 6 + + + 712, 494 + + + 0 + + + gridConversions + + + System.Windows.Forms.DataGridView, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TabPage3 + + + 0 + + + True + + + Componente + + + True + + + Conversão (%) + True @@ -1960,17 +2707,20 @@ 25 - 6, 13 + 13, 26 True - 355, 1032 + 769, 1759 Microsoft Sans Serif, 8.25pt + + 7, 6, 7, 6 + EditingForm_PFR_Reactor diff --git a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.vb b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.vb index d97d3b7d..73bbc95d 100644 --- a/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.vb +++ b/DWSIM.UnitOperations/Editing Forms/EditingForm_ReactorPFR.vb @@ -514,14 +514,14 @@ Public Class EditingForm_ReactorPFR i = 0 Do color1 = Color.FromArgb(255, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)) - With .AddCurve(vn(i), su.Converter.ConvertArrayFromSI(units.volume, vx), su.Converter.ConvertArrayFromSI(units.molar_conc, vya(i)), color1, ZedGraph.SymbolType.Circle) + With .AddCurve(vn(i), su.Converter.ConvertArrayFromSI(units.distance, vx), su.Converter.ConvertArrayFromSI(units.molar_conc, vya(i)), color1, ZedGraph.SymbolType.Circle) .Line.IsSmooth = True .Symbol.IsVisible = False End With i += 1 Loop Until i = vn.Length - 1 color1 = Color.FromArgb(255, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)) - With .AddCurve("T / " & units.temperature, su.Converter.ConvertArrayFromSI(units.volume, vx), su.Converter.ConvertArrayFromSI(units.temperature, vya(i)), color1, ZedGraph.SymbolType.Circle) + With .AddCurve("T / " & units.temperature, su.Converter.ConvertArrayFromSI(units.distance, vx), su.Converter.ConvertArrayFromSI(units.temperature, vya(i)), color1, ZedGraph.SymbolType.Circle) .Line.IsSmooth = True .Symbol.IsVisible = False .IsY2Axis = True @@ -534,7 +534,7 @@ Public Class EditingForm_ReactorPFR .IsY2Axis = True .YAxisIndex = 1 End With - .XAxis.Title.Text = "V / " & units.volume + .XAxis.Title.Text = "Reactor Length / " & units.distance .XAxis.Title.FontSpec.Size = 16 .XAxis.Scale.FontSpec.Size = 16 .XAxis.Scale.MaxAuto = False diff --git a/DWSIM.UnitOperations/Reactors/CSTR.vb b/DWSIM.UnitOperations/Reactors/CSTR.vb index 5aecde77..096a8f41 100644 --- a/DWSIM.UnitOperations/Reactors/CSTR.vb +++ b/DWSIM.UnitOperations/Reactors/CSTR.vb @@ -33,6 +33,8 @@ Namespace Reactors Inherits Reactor + Private _IObj As InspectorItem + Public Enum EReactorMode SingleOutlet TwoOutlets @@ -289,6 +291,22 @@ Namespace Reactors IObj?.SetCurrent() + IObj?.Paragraphs.Add("To run a simulation of a reactor, the user needs to define the chemical reactions which will take place in the reactor.

+ This Is done through the Reactions Manager, accessible through Simulation Settings > Basis > Open Chemical Reactions Manager or Tools > Reactions Manager menus (see separate documentation).

Reactions can be of Equilibrium, Conversion, Kinetic or Heterogeneous Catalytic types. One or more reactions can be combined to define + a Reaction Set. The reactors then 'see' the reactions through the reaction sets. +

Equilibrium + Reactions are defined by an equilibrium constant (K). The source Of + Information for the equilibrium constant can be a direct gibbs energy + calculation, an expression defined by the user Or a constant value. + Equilibrium Reactions can be used in Equilibrium And Gibbs reactors.

Conversion + Reactions are defined by the amount of a base compound which Is + consumed in the reaction. This amount can be a fixed value Or a + Function of() the system temperature. Conversion reactions are supported + by the Conversion reactor.

Kinetic reactions are reactions defined by a kinetic expression. These reactions are supported by the PFR and CSTR reactors.

Heterogeneous Catalytic reactions in DWSIM must obey the Langmuir–Hinshelwood + mechanism, where compounds react over a solid catalyst surface. In this + model, Reaction rates are a function of catalyst amount (i.e. mol/kg + cat.s). These Reactions are supported by the PFR And CStr reactors.

") + 'ims-stream (internal material stream) to be used during internal calculations 'Clone inlet stream as initial estimation ims = DirectCast(FlowSheet.SimulationObjects(Me.GraphicObject.InputConnectors(0).AttachedConnector.AttachedFrom.Name), MaterialStream).Clone @@ -347,7 +365,7 @@ Namespace Reactors 'Check Reaction type, Base components and reaction volume If FlowSheet.ReactionSets(Me.ReactionSetID).Reactions.Count = 0 Then Throw New Exception("No reaction defined") - ErrCode = "No kinetic or catalytic reaction found" + ErrCode = "No kinetic Or catalytic reaction found" For Each rxnsb As ReactionSetBase In FlowSheet.ReactionSets(Me.ReactionSetID).Reactions.Values rxn = FlowSheet.Reactions(rxnsb.ReactionID) If (rxn.ReactionType = ReactionType.Kinetic Or rxn.ReactionType = ReactionType.Heterogeneous_Catalytic) And rxnsb.IsActive Then @@ -1490,7 +1508,7 @@ out: Dim ms1, ms2 As MaterialStream Dim str As New Text.StringBuilder - str.AppendLine("Reactor: " & Me.GraphicObject.Tag) + str.AppendLine("Reactor: " & Me.GraphicObject.Tag) str.AppendLine("Property Package: " & Me.PropertyPackage.ComponentName) str.AppendLine() str.AppendLine("Calculation Parameters") diff --git a/DWSIM.UnitOperations/Reactors/Conversion.vb b/DWSIM.UnitOperations/Reactors/Conversion.vb index d3afd813..d3d15302 100644 --- a/DWSIM.UnitOperations/Reactors/Conversion.vb +++ b/DWSIM.UnitOperations/Reactors/Conversion.vb @@ -118,6 +118,22 @@ Namespace Reactors IObj?.SetCurrent() + IObj?.Paragraphs.Add("To run a simulation of a reactor, the user needs to define the chemical reactions which will take place in the reactor.

+ This Is done through the Reactions Manager, accessible through Simulation Settings > Basis > Open Chemical Reactions Manager or Tools > Reactions Manager menus (see separate documentation).

Reactions can be of Equilibrium, Conversion, Kinetic or Heterogeneous Catalytic types. One or more reactions can be combined to define + a Reaction Set. The reactors then 'see' the reactions through the reaction sets. +

Equilibrium + Reactions are defined by an equilibrium constant (K). The source Of + Information for the equilibrium constant can be a direct gibbs energy + calculation, an expression defined by the user Or a constant value. + Equilibrium Reactions can be used in Equilibrium And Gibbs reactors.

Conversion + Reactions are defined by the amount of a base compound which Is + consumed in the reaction. This amount can be a fixed value Or a + Function of() the system temperature. Conversion reactions are supported + by the Conversion reactor.

Kinetic reactions are reactions defined by a kinetic expression. These reactions are supported by the PFR and CSTR reactors.

Heterogeneous Catalytic reactions in DWSIM must obey the Langmuir–Hinshelwood + mechanism, where compounds react over a solid catalyst surface. In this + model, Reaction rates are a function of catalyst amount (i.e. mol/kg + cat.s). These Reactions are supported by the PFR And CStr reactors.

") + Validate() InitVars() diff --git a/DWSIM.UnitOperations/Reactors/PFR.vb b/DWSIM.UnitOperations/Reactors/PFR.vb index 166ab272..f668fcd8 100644 --- a/DWSIM.UnitOperations/Reactors/PFR.vb +++ b/DWSIM.UnitOperations/Reactors/PFR.vb @@ -35,6 +35,8 @@ Namespace Reactors Inherits Reactor + Private _IObj As InspectorItem + Protected m_vol As Double Protected m_dv As Double = 0.01 @@ -122,6 +124,21 @@ Namespace Reactors Public Function ODEFunc(ByVal x As Double, ByVal y As Double()) As Double() + _IObj?.SetCurrent + + Dim IObj2 As Inspector.InspectorItem = Inspector.Host.GetNewInspectorItem() + + Inspector.Host.CheckAndAdd(IObj2, "", "ODEFunc", "ODE solver for reactor concentrations", "", True) + + IObj2?.SetCurrent + + IObj2?.Paragraphs.Add("

Input Vars

") + + IObj2?.Paragraphs.Add(String.Format("Volume Step: {0}", x)) + IObj2?.Paragraphs.Add(String.Format("Compound Mole Flows: {0} mol/s", y.ToMathArrayString)) + + IObj2?.Paragraphs.Add("

Intermediate Calcs

") + Dim conv As New SystemsOfUnits.Converter Dim i As Integer = 0 @@ -131,10 +148,16 @@ Namespace Reactors j = 0 For Each s As String In N00.Keys - C(s) = y(j) * ResidenceTime / (Volume * VolumeFraction) + If y(j) < 0 Then + C(s) = 0.0# + Else + C(s) = y(j) * ResidenceTime / (Volume * VolumeFraction) + End If j = j + 1 Next + IObj2?.Paragraphs.Add(String.Format("Compound Concentrations: {0} mol/m3", C.Values.ToArray.ToMathArrayString)) + 'conversion factors for different basis other than molar concentrations Dim convfactors As New Dictionary(Of String, Double) @@ -154,13 +177,18 @@ Namespace Reactors i = 0 Do + 'process reaction i rxn = FlowSheet.Reactions(ar(i)) BC = rxn.BaseReactant scBC = rxn.Components(BC).StoichCoeff + IObj2?.Paragraphs.Add(String.Format("Reaction ID: {0}", rxn.Name)) + Dim T As Double = ims.Phases(0).Properties.temperature.GetValueOrDefault + IObj2?.Paragraphs.Add(String.Format("T: {0} K", T)) + Dim rx As Double = 0.0# convfactors = Me.GetConvFactors(rxn, ims) @@ -187,6 +215,8 @@ Namespace Reactors rx = kxf * rxf - kxr * rxr + IObj2?.Paragraphs.Add(String.Format("Reaction Rate: {0} {1}", rx, rxn.VelUnit)) + Rxi(rxn.ID) = SystemsOfUnits.Converter.ConvertToSI(rxn.VelUnit, rx) Kf(i) = kxf @@ -215,12 +245,15 @@ Namespace Reactors For Each sb As ReactionStoichBase In rxn.Components.Values If sb.StoichCoeff < 0 Then + IObj2?.Paragraphs.Add(String.Format("R{0} ({1}): {2} {3}", ir.ToString, sb.CompName, C(sb.CompName) * convfactors(sb.CompName), rxn.ConcUnit)) rxn.ExpContext.Variables.Add("R" & ir.ToString, C(sb.CompName) * convfactors(sb.CompName)) ir += 1 ElseIf sb.StoichCoeff > 0 Then + IObj2?.Paragraphs.Add(String.Format("P{0} ({1}): {2} {3}", ip.ToString, sb.CompName, C(sb.CompName) * convfactors(sb.CompName), rxn.ConcUnit)) rxn.ExpContext.Variables.Add("P" & ip.ToString, C(sb.CompName) * convfactors(sb.CompName)) ip += 1 Else + IObj2?.Paragraphs.Add(String.Format("N{0} ({1}): {2} {3}", ine.ToString, sb.CompName, C(sb.CompName) * convfactors(sb.CompName), rxn.ConcUnit)) rxn.ExpContext.Variables.Add("N" & ine.ToString, C(sb.CompName) * convfactors(sb.CompName)) ine += 1 End If @@ -234,10 +267,15 @@ Namespace Reactors denmval = rxn.Expr.Evaluate + IObj2?.Paragraphs.Add(String.Format("Numerator Value: {0}", numval)) + IObj2?.Paragraphs.Add(String.Format("Denominator Value: {0}", denmval)) + rx = numval / denmval End If + IObj2?.Paragraphs.Add(String.Format("Reaction Rate: {0} {1}", rx, rxn.VelUnit)) + Rxi(rxn.ID) = SystemsOfUnits.Converter.ConvertToSI(rxn.VelUnit, rx) End If @@ -266,6 +304,14 @@ Namespace Reactors FlowSheet.CheckStatus() + IObj2?.Paragraphs.Add("

Results

") + + IObj2?.Paragraphs.Add(String.Format("Compound Mole Flows Variation: {0} mol/[m3.s]", dy.ToMathArrayString)) + + IObj2?.Close() + + If Double.IsNaN(dy.Sum) Then Throw New Exception("PFR ODE solver failed to find a solution.") + Return dy End Function @@ -278,6 +324,22 @@ Namespace Reactors IObj?.SetCurrent() + IObj?.Paragraphs.Add("To run a simulation of a reactor, the user needs to define the chemical reactions which will take place in the reactor.

+ This Is done through the Reactions Manager, accessible through Simulation Settings > Basis > Open Chemical Reactions Manager or Tools > Reactions Manager menus (see separate documentation).

Reactions can be of Equilibrium, Conversion, Kinetic or Heterogeneous Catalytic types. One or more reactions can be combined to define + a Reaction Set. The reactors then 'see' the reactions through the reaction sets. +

Equilibrium + Reactions are defined by an equilibrium constant (K). The source Of + Information for the equilibrium constant can be a direct gibbs energy + calculation, an expression defined by the user Or a constant value. + Equilibrium Reactions can be used in Equilibrium And Gibbs reactors.

Conversion + Reactions are defined by the amount of a base compound which Is + consumed in the reaction. This amount can be a fixed value Or a + Function of() the system temperature. Conversion reactions are supported + by the Conversion reactor.

Kinetic reactions are reactions defined by a kinetic expression. These reactions are supported by the PFR and CSTR reactors.

Heterogeneous Catalytic reactions in DWSIM must obey the Langmuir–Hinshelwood + mechanism, where compounds react over a solid catalyst surface. In this + model, Reaction rates are a function of catalyst amount (i.e. mol/kg + cat.s). These Reactions are supported by the PFR And CStr reactors.

") + N00 = New Dictionary(Of String, Double) C0 = New Dictionary(Of String, Double) C = New Dictionary(Of String, Double) @@ -386,6 +448,16 @@ Namespace Reactors Dim prevvol As Double = 0.0# Do + IObj?.SetCurrent + + Dim IObj2 As Inspector.InspectorItem = Inspector.Host.GetNewInspectorItem() + + Inspector.Host.CheckAndAdd(IObj2, "", "Calculate", String.Format("PFR Volume Step Calculation (V = {0} m3)", currvol), "", True) + + IObj2?.SetCurrent() + + _IObj = IObj2 + C = New Dictionary(Of String, Double) C0 = New Dictionary(Of String, Double) @@ -475,16 +547,18 @@ Namespace Reactors Next Dim odesolver = New DotNumerics.ODE.OdeImplicitRungeKutta5() - 'odesolver.RelTol = 0.000001 - 'odesolver.AbsTol = 0.0000000001 + odesolver.RelTol = 0.000001 + odesolver.AbsTol = 0.0000000001 odesolver.InitializeODEs(AddressOf ODEFunc, N.Count) - odesolver.Solve(vc, 0.0#, 0.05 * dV * Volume, dV * Volume, Sub(x As Double, y As Double()) vc = y) + IObj2?.SetCurrent + odesolver.Solve(vc, 0.0#, 0.1 * dV * Volume, dV * Volume, Sub(x As Double, y As Double()) vc = y) If Double.IsNaN(vc.Sum) Then Throw New Exception(FlowSheet.GetTranslatedString("PFRMassBalanceError")) C.Clear() i = 0 For Each sb As KeyValuePair(Of String, Double) In C0 + If vc(i) < 0.0# Then vc(i) = 0.0# C(sb.Key) = Convert.ToDouble(vc(i) * ResidenceTime / Volume / VolumeFraction) i = i + 1 Next @@ -529,7 +603,7 @@ Namespace Reactors DHr += rxn.ReactionHeat * Abs(Rxi(rxn.ID)) / 1000 * CatalystLoading * dV * Volume End If - If Ri.Values.Sum = 0.0# Then DHr = 0.0# + 'If Ri.Values.Sum = 0.0# Then DHr = 0.0# i += 1 @@ -617,7 +691,7 @@ Namespace Reactors 'add data to array Dim tmparr(C.Count + 2) As Double - tmparr(0) = currvol + tmparr(0) = currvol / Volume * Length i = 1 For Each d As Double In Me.C.Values tmparr(i) = d @@ -682,7 +756,7 @@ Namespace Reactors prevvol = currvol currvol += dV * Volume - Loop Until (currvol - Volume) >= dV + Loop Until (currvol - Volume) >= Volume Me.DeltaP = P0 - P @@ -696,9 +770,13 @@ Namespace Reactors Do 'process reaction i + rxn = FlowSheet.Reactions(ar(i)) - RxiT.Add(rxn.ID, (N(rxn.BaseReactant) - N00(rxn.BaseReactant)) / rxn.Components(rxn.BaseReactant).StoichCoeff / 1000 * Rxi(rxn.ID) / Ri(rxn.BaseReactant)) + Dim f = Rxi(rxn.ID) / Ri(rxn.BaseReactant) + If Double.IsNaN(f) Or Double.IsInfinity(f) Then f = 1.0# + + RxiT.Add(rxn.ID, (N(rxn.BaseReactant) - N00(rxn.BaseReactant)) / rxn.Components(rxn.BaseReactant).StoichCoeff / 1000 * f) DHRi.Add(rxn.ID, rxn.ReactionHeat * RxiT(rxn.ID)) i += 1