Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DanWBR committed Jun 24, 2022
1 parent 68233e6 commit f15d585
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
11 changes: 11 additions & 0 deletions DWSIM.Automation/Automation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ public void CalculateFlowsheet3(IFlowsheet flowsheet, int timeout_seconds)
((Flowsheet2)flowsheet).SolveFlowsheet2();
}

public List<Exception> CalculateFlowsheet4(IFlowsheet flowsheet)
{
Settings.CalculatorActivated = true;
Settings.SolverBreakOnException = true;
Settings.SolverMode = 1;
Settings.SolverTimeoutSeconds = 3600;
Settings.EnableGPUProcessing = false;
Settings.EnableParallelProcessing = false;
return ((Flowsheet2)flowsheet).SolveFlowsheet2();
}

public void SaveFlowsheet2(IFlowsheet flowsheet, string filepath)
{
SaveFlowsheet(flowsheet, filepath, true);
Expand Down
15 changes: 9 additions & 6 deletions DWSIM.Automation/Flowsheet2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,27 @@ public void SolveFlowsheet()

}

public void SolveFlowsheet2( )
public List<Exception> SolveFlowsheet2( )
{
if (PropertyPackages.Count == 0)
{
ShowMessage("Please select a Property Package before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
return;
return new List<Exception>();
}

if (SelectedCompounds.Count == 0)
{
ShowMessage("Please select a Compound before solving the flowsheet.", IFlowsheet.MessageType.GeneralError);
return;
return new List<Exception>();
}

Settings.CalculatorActivated = true;

Task st = new Task(() =>
Task<List<Exception>> st = new Task<List<Exception>>(() =>
{
RequestCalculation(null, false);
return FlowsheetSolver.FlowsheetSolver.SolveFlowsheet(this, GlobalSettings.Settings.SolverMode);
});

st.ContinueWith((t) =>
{
Settings.CalculatorStopRequested = false;
Expand All @@ -145,6 +145,7 @@ public void SolveFlowsheet2( )
{
st.Start(TaskScheduler.Default);
st.Wait();
return st.Result;
}
catch (AggregateException aex)
{
Expand All @@ -154,12 +155,14 @@ public void SolveFlowsheet2( )
}
Settings.CalculatorBusy = false;
Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
return new List<Exception>(aex.InnerExceptions);
}
catch (Exception ex)
{
ShowMessage(ex.ToString(), IFlowsheet.MessageType.GeneralError);
Settings.CalculatorBusy = false;
Settings.TaskCancellationTokenSource = new System.Threading.CancellationTokenSource();
return new List<Exception> { ex };
}

}
Expand Down
2 changes: 1 addition & 1 deletion DWSIM.SharedClasses/Patrons/activepatrons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ H-Tec Systems GmbH
Hugo Burbach
Hurudza
Jan Boshoff
Javier Alzate
Javier Fontalvo
Jens Greimeier
Jeremiah McAfoose
Joe Rhodes
Expand Down
10 changes: 5 additions & 5 deletions DWSIM.Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Program
static void Main(string[] args)
{

DWSIM.Automation.Automation interf = new DWSIM.Automation.Automation();
var interf = new DWSIM.Automation.Automation3();

var samples = Directory.EnumerateFiles("samples", "*.dwxm*", SearchOption.TopDirectoryOnly).OrderBy(x => x).ToList();
var fossee = Directory.EnumerateFiles("tests", "*.dwxm*", SearchOption.TopDirectoryOnly).OrderBy(x => x).ToList();
Expand Down Expand Up @@ -43,7 +43,7 @@ static void Main(string[] args)
Console.ReadKey();
}

static void RunTests(List<string> filelist, DWSIM.Automation.Automation interf)
static void RunTests(List<string> filelist, DWSIM.Automation.Automation3 interf)
{

TimeSpan totaltime;
Expand Down Expand Up @@ -84,7 +84,7 @@ static void RunTests(List<string> filelist, DWSIM.Automation.Automation interf)
Console.WriteLine("[" + i + "/" + totaltests + "] " + "Running '" + Path.GetFileNameWithoutExtension(s) + "'...");
Console.WriteLine();

errors = interf.CalculateFlowsheet2(sim);
errors = interf.CalculateFlowsheet4(sim);

if (errors.Count > 0)
{
Expand Down Expand Up @@ -136,8 +136,8 @@ static void RunTests(List<string> filelist, DWSIM.Automation.Automation interf)
Console.WriteLine();
}

//Console.WriteLine("Press Any Key to Continue...");
//Console.ReadKey();
Console.WriteLine("Press Any Key to Continue...");
Console.ReadKey();

}

Expand Down

0 comments on commit f15d585

Please sign in to comment.