Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
Conversion Reactor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanWBR committed Jan 3, 2018
1 parent ef59564 commit 853865d
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 128 deletions.
4 changes: 2 additions & 2 deletions DWSIM.UI.Desktop.Forms/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// Change them to the values specific to your project.

[assembly: AssemblyTitle("DWSIM.UI")]
[assembly: AssemblyDescription("Cross-Platform User Interface for DWSIM Simulator")]
[assembly: AssemblyDescription("DWSIM Simulator (Cross Platform GUI Launcher)")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("DWSIM Project")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © 2017 Daniel Medeiros")]
[assembly: AssemblyCopyright("Copyright © 2017-2018 Daniel Medeiros")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
4 changes: 2 additions & 2 deletions DWSIM.UI.Desktop/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Change them to the values specific to your project.

[assembly: AssemblyTitle("DWSIM.UI.Desktop")]
[assembly: AssemblyDescription("Cross-Platform User Interface for DWSIM Simulator")]
[assembly: AssemblyDescription("DWSIM Simulator (Cross-Platform GUI Launcher)")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("DWSIM Project")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Copyright © 2017 Daniel Medeiros")]
[assembly: AssemblyCopyright("Copyright © 2017-2018 Daniel Medeiros")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand Down
24 changes: 4 additions & 20 deletions DWSIM.UnitOperations/Reactors/BaseReactor.vb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Namespace Reactors

Inherits UnitOperations.UnitOpBaseClass

Protected m_reactionSequence As SortedList(Of Integer, ArrayList)
Protected m_reactionSequence As List(Of List(Of String))
Protected m_reactions As List(Of String)
Protected m_conversions As Dictionary(Of String, Double)
Protected m_componentconversions As Dictionary(Of String, Double)
Expand All @@ -51,14 +51,6 @@ Namespace Reactors
MyBase.LoadData(data)
Dim ci As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture

For Each xel2 As XElement In (From xel As XElement In data Select xel Where xel.Name = "ReactionSequence").Elements
m_reactionSequence.Add(xel2.@Index, XMLSerializer.XMLSerializer.StringToArray(xel2.Value, ci))
Next

For Each xel2 As XElement In (From xel As XElement In data Select xel Where xel.Name = "Reaction").Elements
m_reactions.Add(xel2.@ID)
Next

For Each xel2 As XElement In (From xel As XElement In data Select xel Where xel.Name = "ReactionConversions").Elements
m_conversions.Add(xel2.@ID, Double.Parse(xel2.Value, ci))
Next
Expand All @@ -75,14 +67,6 @@ Namespace Reactors
Dim ci As Globalization.CultureInfo = Globalization.CultureInfo.InvariantCulture

With elements
.Add(New XElement("ReactionSequence"))
For Each kvp As KeyValuePair(Of Integer, ArrayList) In m_reactionSequence
.Item(.Count - 1).Add(New XElement("Item", New XAttribute("Index", kvp.Key), XMLSerializer.XMLSerializer.ArrayToString(kvp.Value, ci)))
Next
.Add(New XElement("Reactions"))
For Each s As String In m_reactions
.Item(.Count - 1).Add(New XElement("Reaction", New XAttribute("ID", s)))
Next
.Add(New XElement("ReactionConversions"))
For Each kvp As KeyValuePair(Of String, Double) In m_conversions
.Item(.Count - 1).Add(New XElement("Reaction", New XAttribute("ID", kvp.Key), kvp.Value.ToString(ci)))
Expand Down Expand Up @@ -187,19 +171,19 @@ Namespace Reactors

Sub New()
MyBase.CreateNew()
Me.m_reactionSequence = New SortedList(Of Integer, ArrayList)
Me.m_reactionSequence = New List(Of List(Of String))
Me.m_reactions = New List(Of String)
Me.m_conversions = New Dictionary(Of String, Double)
Me.m_componentconversions = New Dictionary(Of String, Double)
End Sub

Public Property OutletTemperature As Double = 298.15#

<Xml.Serialization.XmlIgnore()> Public Property ReactionsSequence() As SortedList(Of Integer, ArrayList)
<Xml.Serialization.XmlIgnore()> Public Property ReactionsSequence() As List(Of List(Of String))
Get
Return m_reactionSequence
End Get
Set(ByVal value As SortedList(Of Integer, ArrayList))
Set(ByVal value As List(Of List(Of String)))
m_reactionSequence = value
End Set
End Property
Expand Down
14 changes: 7 additions & 7 deletions DWSIM.UnitOperations/Reactors/CSTR.vb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ Namespace Reactors

'loop through reactions
Dim rxn As Reaction
Dim ar As ArrayList = Me.ReactionsSequence(activeAL)
Dim ar = Me.ReactionsSequence(activeAL)

i = 0
Do
Expand Down Expand Up @@ -871,13 +871,13 @@ out: Dim ms1, ms2 As MaterialStream

'ordering of parallel reactions
i = 0
Dim arr As New ArrayList
Dim arr As New List(Of String)
Do
arr = New ArrayList
arr = New List(Of String)
For Each rxnsb As ReactionSetBase In FlowSheet.ReactionSets(Me.ReactionSetID).Reactions.Values
If rxnsb.Rank = i And Me.Reactions.Contains(rxnsb.ReactionID) Then arr.Add(rxnsb.ReactionID)
Next
If arr.Count > 0 Then Me.ReactionsSequence.Add(i, arr)
If arr.Count > 0 Then Me.ReactionsSequence.Add(arr)
i = i + 1
Loop Until i = maxrank + 1

Expand Down Expand Up @@ -911,7 +911,7 @@ out: Dim ms1, ms2 As MaterialStream
Hr = ims.Phases(0).Properties.enthalpy.GetValueOrDefault * W

'loop through reactions
For Each ar As ArrayList In Me.ReactionsSequence.Values
For Each ar In Me.ReactionsSequence

DHr = 0

Expand Down Expand Up @@ -970,7 +970,7 @@ out: Dim ms1, ms2 As MaterialStream
Ri.Clear()
Rxi.Clear()

Me.activeAL = Me.ReactionsSequence.IndexOfValue(ar)
Me.activeAL = Me.ReactionsSequence.IndexOf(ar)

'solve ODEs

Expand Down Expand Up @@ -1147,7 +1147,7 @@ out: Dim ms1, ms2 As MaterialStream
RxiT.Clear()
DHRi.Clear()

For Each ar As ArrayList In Me.ReactionsSequence.Values
For Each ar In Me.ReactionsSequence

i = 0
Do
Expand Down
Loading

0 comments on commit 853865d

Please sign in to comment.