Skip to content

Commit

Permalink
Mono/Linux bug fixes; enhanced realiability of gibbs reactor solver (…
Browse files Browse the repository at this point in the history
…added an option to initialize from previous solution); fixed Sensitivity Analysis utility not displaying variables (CPUI)
  • Loading branch information
DanWBR committed Sep 7, 2020
1 parent eb637d1 commit 47a229c
Show file tree
Hide file tree
Showing 13 changed files with 2,711 additions and 1,813 deletions.
2 changes: 2 additions & 0 deletions DWSIM.FlowsheetSolver/FlowsheetSolver.vb
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ Public Delegate Sub CustomEvent2(ByVal objinfo As CalculationArgs)
baseexception = iex.InnerException
End While
fgui.ShowMessage(baseexception.Message.ToString, IFlowsheet.MessageType.GeneralError, euid)
Console.WriteLine(baseexception.ToString)
IObj?.Paragraphs.Add(baseexception.Message)
Next
Else
Expand All @@ -1446,6 +1447,7 @@ Public Delegate Sub CustomEvent2(ByVal objinfo As CalculationArgs)
End While
End If
fgui.ShowMessage(baseexception.Message.ToString, IFlowsheet.MessageType.GeneralError, euid)
Console.WriteLine(baseexception.ToString)
IObj?.Paragraphs.Add(baseexception.Message)
End If
Next
Expand Down
21 changes: 3 additions & 18 deletions DWSIM.Math/LP_Solve.vb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Public Class lpsolve55

'lpsolve version 5 routines

Private Declare Function SetEnvironmentVariableA Lib "kernel32" (ByVal lpname As String, ByVal lpValue As String) As Integer
Private Declare Function GetEnvironmentVariableA Lib "kernel32" (ByVal lpname As String, ByVal lpBuffer As String, ByVal nSize As Integer) As Integer

'-----------------------------------------------------------------------------------------------------------------------------

Public Declare Function add_column Lib "lpsolve55" Alias "add_column" (ByVal lp As IntPtr, ByVal column() As Double) As Boolean
Expand Down Expand Up @@ -402,24 +399,12 @@ Public Class lpsolve55
End Enum

Private Shared Function SetEnvironmentVariable(ByRef name As String, ByRef value As String) As Boolean

SetEnvironmentVariable = SetEnvironmentVariableA(name, value)

Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process)
Return True
End Function

Private Shared Function GetEnvironmentVariable(ByRef name As String) As String
Dim l As Integer
Dim buf As String

l = GetEnvironmentVariableA(name, vbNullString, 0)
If l > 0 Then
buf = Space(l)
l = GetEnvironmentVariableA(name, buf, Len(buf))
GetEnvironmentVariable = Mid(buf, 1, l)
Else
GetEnvironmentVariable = ""
End If

Return Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process)
End Function

Shared Function Init(Optional ByVal dllPath As String = "") As Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void Init()
p2 = UI.Shared.Common.GetDefaultContainer();

p1.Width = 380;
p2.Width = 380;
p2.Width = 470;

t1 = new StackLayout();
t1.Items.Add(new StackLayoutItem(p1));
Expand Down Expand Up @@ -182,10 +182,10 @@ void Init()
p1.Height = p1.ParentWindow.Height - 170;
p2.Height = p1.Height;
sc.Height = p2.Height - btnAddDepVar.Height - 30;
foreach (var item in ll.Items)
{
item.Control.Width = sc.Width - 25;
}
//foreach (var item in ll.Items)
//{
// item.Control.Width = sc.Width - 25;
//}
}
};

Expand Down Expand Up @@ -417,7 +417,7 @@ private void AddDepVar(StackLayout container, DWSIM.SharedClasses.Flowsheet.Opti
var su = flowsheet.FlowsheetOptions.SelectedUnitSystem;

List<string> proplist2 = new List<string>();
var myview = new DynamicLayout { Padding = new Padding(5), Width = container.Width - 25};
var myview = new DynamicLayout { Padding = new Padding(5), Width = 400};
var slcontainer = new StackLayoutItem(myview);
s.CreateAndAddLabelRow(myview, "Dependent Variable #" + (container.Items.Count + 1).ToString());
var spinobj = s.CreateAndAddDropDownRow(myview, "Object", objlist, 0, null);
Expand Down
2 changes: 1 addition & 1 deletion DWSIM.UI.Desktop.Editors/UnitOperations/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,7 +1701,7 @@ void Initialize()
f.ShowDialog();
});
s.CreateAndAddLabelRow(container, "Convergence Parameters");
//s.CreateAndAddDescriptionRow(container, "Tune the following parameters if you're having convergence issues.");
s.CreateAndAddCheckBoxRow(container, "Initialize from Previous Solution", reactor2g.InitializeFromPreviousSolution, (sender, e) => reactor2g.InitializeFromPreviousSolution = sender.Checked.GetValueOrDefault(), () => CallSolverIfNeeded());
s.CreateAndAddTextBoxRow(container, nf, "Maximum Internal Iterations", reactor2g.MaximumInternalIterations, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) reactor2g.MaximumInternalIterations = int.Parse(sender.Text); }, () => CallSolverIfNeeded());
s.CreateAndAddTextBoxRow(container, nf, "Maximum External Iterations", reactor2g.MaximumExternalIterations, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) reactor2g.MaximumExternalIterations = int.Parse(sender.Text); }, () => CallSolverIfNeeded());
s.CreateAndAddTextBoxRow(container, nf, "Minimum Internal Error", reactor2g.InternalTolerance, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) reactor2g.InternalTolerance = sender.Text.ParseExpressionToDouble(); }, () => CallSolverIfNeeded());
Expand Down
Loading

0 comments on commit 47a229c

Please sign in to comment.