diff --git a/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs b/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs index a2be7a4c8c4..04995dcc9c9 100644 --- a/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs +++ b/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs @@ -37,10 +37,6 @@ public void ThermoPair_ToStringsCorrectly() } } - [Fact] - public void EquilibriumSolver_MapsCorrectly() => - TestInteropEnumInvariants(true, -1, 2); - [Fact] public void LogLevel_MapsCorrectly() => TestInteropEnumInvariants(true, 0, 2); diff --git a/interfaces/dotnet/Cantera/src/DataDirectoryCollection.cs b/interfaces/dotnet/Cantera/src/DataDirectoryCollection.cs index 1d89c71971e..c831586e62f 100644 --- a/interfaces/dotnet/Cantera/src/DataDirectoryCollection.cs +++ b/interfaces/dotnet/Cantera/src/DataDirectoryCollection.cs @@ -46,7 +46,7 @@ public void Add(string dir) => public void Add(DirectoryInfo dir) { InteropUtil.CheckReturn(LibCantera.ct_addCanteraDirectory( - (nuint) dir.FullName.Length, dir.FullName)); + dir.FullName.Length, dir.FullName)); _dirs.Clear(); _dirs.AddRange(GetDirs()); diff --git a/interfaces/dotnet/Cantera/src/Enums.cs b/interfaces/dotnet/Cantera/src/Enums.cs index 4399d107bf0..a171edbef8e 100644 --- a/interfaces/dotnet/Cantera/src/Enums.cs +++ b/interfaces/dotnet/Cantera/src/Enums.cs @@ -103,32 +103,6 @@ public static string ToInteropString(this ThermoPair thermoPair) // the constants MUST match what CLIB is expecting -/// -/// Determines which algorithm is used to find equilibrium. -/// -public enum EquilibriumSolver -{ - /// - /// Allow Cantera to determine the optimum algorithm. - /// - Auto = -1, - - /// - /// Solve by using the element potential algorithm. - /// - ElementPotential, - - /// - /// Solve by using the general algorithm to minimize Gibbs free energy. - /// - Gibbs, - - /// - /// Solved by using the VCS algorithm to minimize Gibbs free energy. - /// - Vcs -} - /// /// The /// diff --git a/interfaces/dotnet/Cantera/src/SpeciesCollection.cs b/interfaces/dotnet/Cantera/src/SpeciesCollection.cs index 348a1ecc5dd..3e6138f03d1 100644 --- a/interfaces/dotnet/Cantera/src/SpeciesCollection.cs +++ b/interfaces/dotnet/Cantera/src/SpeciesCollection.cs @@ -12,6 +12,8 @@ namespace Cantera; /// public class SpeciesCollection : IReadOnlyList { + readonly SolutionHandle _sol; + readonly ThermoPhaseHandle _handle; // this collection should be eagerly-initialized because it depends on interop diff --git a/interfaces/dotnet/Cantera/src/ThermoPhase.cs b/interfaces/dotnet/Cantera/src/ThermoPhase.cs index fb9f5ddab7a..8a3e3815eb8 100644 --- a/interfaces/dotnet/Cantera/src/ThermoPhase.cs +++ b/interfaces/dotnet/Cantera/src/ThermoPhase.cs @@ -51,9 +51,11 @@ static ThermoPhase() /// public SpeciesCollection Species => _species.Value; - internal ThermoPhase(string filename, string? phaseName) + internal ThermoPhase(string filename, string? phaseName, string? transModel) { - _handle = LibCantera.thermo_newFromFile(filename, phaseName ?? ""); + _sol = LibCantera.soln_newSolution( + filename, phaseName ?? "", transModel ?? "default"); + _handle = LibCantera.soln_thermo(_sol); _handle.EnsureValid(); _species = new(() => new SpeciesCollection(_handle)); @@ -61,17 +63,16 @@ internal ThermoPhase(string filename, string? phaseName) /// /// Simulates bringing the phase to thermodynamic equilibrium by holding the - /// specified constant and using the algorithm - /// identified by the given . + /// specified constant and using the identified algorithm. /// public void Equilibrate(ThermoPair thermoPair, - EquilibriumSolver solver = EquilibriumSolver.Auto, + string algorithm = "auto", double tolerance = 1e-9, int maxSteps = 1000, int maxIterations = 100, int logVerbosity = 0) { var interopString = thermoPair.ToInteropString(); - var retVal = LibCantera.thermo_equilibrate(_handle, interopString, (int) solver, + var retVal = LibCantera.thermo_equilibrate(_handle, interopString, algorithm, tolerance, maxSteps, maxIterations, logVerbosity); InteropUtil.CheckReturn(retVal);