From 86831c17b010e5108fbde8369ef5ed1363a9404a Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Thu, 8 Aug 2024 09:13:30 -0500 Subject: [PATCH 01/15] [clib] Remove deprecated clib functions As of Cantera 3.1, the clib interface is considered experimental, where breakages are acceptable. --- include/cantera/clib/ctreactor.h | 5 +- .../matlab_experimental/Reactor/Reactor.m | 4 +- samples/clib/demo.c | 2 +- src/clib/ctreactor.cpp | 11 +-- test/clib/test_ctreactor.cpp | 86 +------------------ 5 files changed, 6 insertions(+), 102 deletions(-) diff --git a/include/cantera/clib/ctreactor.h b/include/cantera/clib/ctreactor.h index cdf489d6ce..4337b3c8ee 100644 --- a/include/cantera/clib/ctreactor.h +++ b/include/cantera/clib/ctreactor.h @@ -17,14 +17,11 @@ extern "C" { #endif - CANTERA_CAPI int reactor_new(const char* type); //!< @deprecated: remove after 3.1 - CANTERA_CAPI int reactor_new3(const char* type, int n, const char* name); + CANTERA_CAPI int reactor_new(const char* type, int n, const char* name); CANTERA_CAPI int reactor_del(int i); CANTERA_CAPI int reactor_setInitialVolume(int i, double v); CANTERA_CAPI int reactor_setChemistry(int i, int cflag); CANTERA_CAPI int reactor_setEnergy(int i, int eflag); - CANTERA_CAPI int reactor_setThermoMgr(int i, int n); //!< @deprecated: remove after 3.1 - CANTERA_CAPI int reactor_setKineticsMgr(int i, int n); //!< @deprecated: remove after 3.1 CANTERA_CAPI int reactor_insert(int i, int n); CANTERA_CAPI double reactor_mass(int i); CANTERA_CAPI double reactor_volume(int i); diff --git a/interfaces/matlab_experimental/Reactor/Reactor.m b/interfaces/matlab_experimental/Reactor/Reactor.m index 8075fa1c26..8f7b3d1511 100644 --- a/interfaces/matlab_experimental/Reactor/Reactor.m +++ b/interfaces/matlab_experimental/Reactor/Reactor.m @@ -130,9 +130,7 @@ end r.type = char(typ); - r.id = ctFunc('reactor_new3', typ, content.solnID, name); - - + r.id = ctFunc('reactor_new', typ, content.solnID, name); end %% Reactor Class Destructor diff --git a/samples/clib/demo.c b/samples/clib/demo.c index 6e8ac5726c..56cadc3181 100644 --- a/samples/clib/demo.c +++ b/samples/clib/demo.c @@ -87,7 +87,7 @@ int main(int argc, char** argv) thermo_print(thermo, 1, 1e-6); printf("\ntime Temperature\n"); - int reactor = reactor_new3("IdealGasReactor", soln, "test"); + int reactor = reactor_new("IdealGasReactor", soln, "test"); int net = reactornet_new(); reactornet_addreactor(net, reactor); diff --git a/src/clib/ctreactor.cpp b/src/clib/ctreactor.cpp index 334c43f18e..096a5f2680 100644 --- a/src/clib/ctreactor.cpp +++ b/src/clib/ctreactor.cpp @@ -40,16 +40,7 @@ extern "C" { // reactor - int reactor_new(const char* type) - { - try { - return ReactorCabinet::add(newReactor(type)); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int reactor_new3(const char* type, int n, const char* name) + int reactor_new(const char* type, int n, const char* name) { try { return ReactorCabinet::add(newReactor(type, SolutionCabinet::at(n), name)); diff --git a/test/clib/test_ctreactor.cpp b/test/clib/test_ctreactor.cpp index 242342d4da..179f0326d3 100644 --- a/test/clib/test_ctreactor.cpp +++ b/test/clib/test_ctreactor.cpp @@ -11,25 +11,10 @@ using namespace Cantera; TEST(ctreactor, reactor_soln) { int sol = soln_newSolution("gri30.yaml", "gri30", "none"); - int reactor = reactor_new3("IdealGasReactor", sol, "test"); + int reactor = reactor_new("IdealGasReactor", sol, "test"); ASSERT_EQ(reactor, 0); } -TEST(ctreactor, reactor_objects) -{ - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); - int kin = kin_newFromFile("gri30.yaml", "", thermo, -1, -1, -1, -1); - - suppress_deprecation_warnings(); - int reactor = reactor_new("IdealGasReactor"); - ASSERT_GE(reactor, 0); - int ret = reactor_setThermoMgr(reactor, thermo); - ASSERT_EQ(ret, 0); - ret = reactor_setKineticsMgr(reactor, kin); - ASSERT_EQ(ret, 0); - make_deprecation_warnings_fatal(); -} - vector T_ctreactor = { 1050.000, 1050.064, 1050.197, 1050.369, 1050.593, 1050.881, 1051.253, 1051.736, 1052.370, 1053.216, 1054.372, 1056.007, 1058.448, 1062.431, 1070.141, 1094.331, @@ -47,73 +32,7 @@ TEST(ctreactor, reactor_simple) thermo_setTemperature(thermo, T); thermo_setPressure(thermo, P); - int reactor = reactor_new3("IdealGasReactor", sol, "test"); - int net = reactornet_new(); - int ret = reactornet_addreactor(net, reactor); - ASSERT_EQ(ret, 0); - - double t = 0.0; - int count = 0; - while (t < 0.1) { - double Tref = T_ctreactor[count]; - ASSERT_NEAR(reactor_temperature(reactor), Tref, 1e-2); - t = reactornet_time(net) + 5e-3; - ret = reactornet_advance(net, t); - ASSERT_EQ(ret, 0); - count++; - } -} - -TEST(ctreactor, reactor_insert) -{ - double T = 1050; - double P = 5 * 101325; - string X = "CH4:1.0, O2:2.0, N2:7.52"; - - int sol = soln_newSolution("gri30.yaml", "gri30", "none"); - int thermo = soln_thermo(sol); - thermo_setMoleFractionsByName(thermo, X.c_str()); - thermo_setTemperature(thermo, T); - thermo_setPressure(thermo, P); - - suppress_deprecation_warnings(); - int reactor = reactor_new("IdealGasReactor"); - int ret = reactor_insert(reactor, sol); - make_deprecation_warnings_fatal(); - ASSERT_EQ(ret, 0); - int net = reactornet_new(); - ret = reactornet_addreactor(net, reactor); - ASSERT_EQ(ret, 0); - - double t = 0.0; - int count = 0; - while (t < 0.1) { - double Tref = T_ctreactor[count]; - ASSERT_NEAR(reactor_temperature(reactor), Tref, 1e-2); - t = reactornet_time(net) + 5e-3; - ret = reactornet_advance(net, t); - ASSERT_EQ(ret, 0); - count++; - } -} - -TEST(ctreactor, reactor_from_parts) -{ - double T = 1050; - double P = 5 * 101325; - string X = "CH4:1.0, O2:2.0, N2:7.52"; - - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); - int kin = kin_newFromFile("gri30.yaml", "", thermo, -1, -1, -1, -1); - thermo_setMoleFractionsByName(thermo, X.c_str()); - thermo_setTemperature(thermo, T); - thermo_setPressure(thermo, P); - - suppress_deprecation_warnings(); - int reactor = reactor_new("IdealGasReactor"); - reactor_setThermoMgr(reactor, thermo); - reactor_setKineticsMgr(reactor, kin); - make_deprecation_warnings_fatal(); + int reactor = reactor_new("IdealGasReactor", sol, "test"); int net = reactornet_new(); int ret = reactornet_addreactor(net, reactor); ASSERT_EQ(ret, 0); @@ -121,7 +40,6 @@ TEST(ctreactor, reactor_from_parts) double t = 0.0; int count = 0; while (t < 0.1) { - T = reactor_temperature(reactor); double Tref = T_ctreactor[count]; ASSERT_NEAR(reactor_temperature(reactor), Tref, 1e-2); t = reactornet_time(net) + 5e-3; From b75e53cf65c2c11806519c69216ffc22914b2ef0 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Thu, 8 Aug 2024 11:46:43 -0500 Subject: [PATCH 02/15] [clib] Remove deprecated stflow functions --- include/cantera/clib/ctonedim.h | 10 ----- src/clib/ctonedim.cpp | 71 --------------------------------- test/clib/test_ctonedim.cpp | 22 ---------- 3 files changed, 103 deletions(-) diff --git a/include/cantera/clib/ctonedim.h b/include/cantera/clib/ctonedim.h index 7b21c38285..e7c284f32e 100644 --- a/include/cantera/clib/ctonedim.h +++ b/include/cantera/clib/ctonedim.h @@ -70,16 +70,6 @@ extern "C" { size_t m, const double* temp); CANTERA_CAPI int flow1D_solveEnergyEqn(int i, int flag); - //! @todo: Remove all functions with `stflow` prefix after %Cantera 3.1 - CANTERA_CAPI int stflow_new(int iph, int ikin, int itr, int itype); - CANTERA_CAPI int stflow_setTransport(int i, int itr); - CANTERA_CAPI int stflow_enableSoret(int i, int iSoret); - CANTERA_CAPI int stflow_setPressure(int i, double p); - CANTERA_CAPI double stflow_pressure(int i); - CANTERA_CAPI int stflow_setFixedTempProfile(int i, size_t n, const double* pos, - size_t m, const double* temp); - CANTERA_CAPI int stflow_solveEnergyEqn(int i, int flag); - CANTERA_CAPI int sim1D_new(size_t nd, const int* domains); CANTERA_CAPI int sim1D_del(int i); CANTERA_CAPI int sim1D_setValue(int i, int dom, int comp, int localPoint, double value); diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index ee55c77408..b460950510 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -490,77 +490,6 @@ extern "C" { } } - int stflow_new(int iph, int ikin, int itr, int itype) - { - try { - throw NotImplementedError("stflow_new", - "Function replaced by 'flow1D_new'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int stflow_setTransport(int i, int itr) - { - try { - throw NotImplementedError("stflow_setTransport", - "Function replaced by 'flow1D_setTransport'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int stflow_enableSoret(int i, int iSoret) - { - try { - throw NotImplementedError("stflow_enableSoret", - "Function replaced by 'flow1D_enableSoret'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int stflow_setPressure(int i, double p) - { - try { - throw NotImplementedError("stflow_setPressure", - "Function replaced by 'flow1D_setPressure'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - double stflow_pressure(int i) - { - try { - throw NotImplementedError("stflow_pressure", - "Function replaced by 'flow1D_pressure'."); - } catch (...) { - return handleAllExceptions(DERR, DERR); - } - } - - int stflow_setFixedTempProfile(int i, size_t n, const double* pos, - size_t m, const double* temp) - { - try { - throw NotImplementedError("stflow_setFixedTempProfile", - "Function replaced by 'flow1D_setFixedTempProfile'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int stflow_solveEnergyEqn(int i, int flag) - { - try { - throw NotImplementedError("stflow_solveEnergyEqn", - "Function replaced by 'flow1D_solveEnergyEqn'."); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - //------------------- Sim1D -------------------------------------- int sim1D_new(size_t nd, const int* domains) diff --git a/test/clib/test_ctonedim.cpp b/test/clib/test_ctonedim.cpp index 24407c6e58..7d327cd374 100644 --- a/test/clib/test_ctonedim.cpp +++ b/test/clib/test_ctonedim.cpp @@ -254,25 +254,3 @@ TEST(ctonedim, freeflame_from_parts) Tprev = T; } } - -TEST(ctonedim, stflow_tests) -{ - //! @todo: To be removed after Cantera 3.1 - ct_resetStorage(); - auto gas = newThermo("h2o2.yaml", "ohmech"); - - int sol = soln_newSolution("h2o2.yaml", "ohmech", "default"); - int ph = soln_thermo(sol); - int kin = soln_kinetics(sol); - int tr = soln_transport(sol); - - // spot check some errors - int itype = 2; // free flow - int ret = stflow_new(ph, kin, tr, itype); - ASSERT_EQ(ret, -1); // -1 is an error code - - int flow = flow1D_new(ph, kin, tr, itype); - ASSERT_EQ(stflow_setTransport(flow, tr), -1); - ASSERT_EQ(stflow_pressure(flow), DERR); // DERR is an error code - ASSERT_EQ(stflow_setPressure(flow, OneAtm), -1); -} From 96f77a73393cc0ab3457094aa4be23332c212160 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 06:58:16 -0500 Subject: [PATCH 03/15] [sourcegen] Reformat preamble --- interfaces/sourcegen/sourcegen/_helpers.py | 2 +- interfaces/sourcegen/sourcegen/csharp/_Config.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/interfaces/sourcegen/sourcegen/_helpers.py b/interfaces/sourcegen/sourcegen/_helpers.py index 3b152d9eb7..9c3c5a009d 100644 --- a/interfaces/sourcegen/sourcegen/_helpers.py +++ b/interfaces/sourcegen/sourcegen/_helpers.py @@ -32,4 +32,4 @@ def normalize_indent(code: str) -> str: def get_preamble() -> str: - return Path(__file__).parent.joinpath("preamble.txt").read_text() + return Path(__file__).parent.joinpath("preamble.txt").read_text("utf-8").strip() diff --git a/interfaces/sourcegen/sourcegen/csharp/_Config.py b/interfaces/sourcegen/sourcegen/csharp/_Config.py index 4d71bd097a..e6259449ea 100644 --- a/interfaces/sourcegen/sourcegen/csharp/_Config.py +++ b/interfaces/sourcegen/sourcegen/csharp/_Config.py @@ -29,7 +29,8 @@ class Config: "double*": "double[]" } - preamble = "/*\n" + get_preamble() + "*/" + # Reformat preamble to standard comment block + preamble = "\n * ".join(["/*"] + get_preamble().split("\n")) + "\n */" # These we load from the parsed YAML config file class_crosswalk: Dict[str, str] From a0acb3ff14f5ee89fe678ab1cca93a892f1d7731 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Mon, 12 Aug 2024 17:25:34 -0500 Subject: [PATCH 04/15] [docs] Use CLib to refer to 'clib' --- interfaces/dotnet/Cantera/src/Enums.cs | 2 +- interfaces/dotnet/Cantera/src/ThermoPhase.cs | 2 +- interfaces/matlab_experimental/readme.md | 2 +- samples/clib/README.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interfaces/dotnet/Cantera/src/Enums.cs b/interfaces/dotnet/Cantera/src/Enums.cs index 4399d107bf..13ab049a7e 100644 --- a/interfaces/dotnet/Cantera/src/Enums.cs +++ b/interfaces/dotnet/Cantera/src/Enums.cs @@ -101,7 +101,7 @@ public static string ToInteropString(this ThermoPair thermoPair) } } -// the constants MUST match what CLIB is expecting +// the constants MUST match what Clib is expecting /// /// Determines which algorithm is used to find equilibrium. diff --git a/interfaces/dotnet/Cantera/src/ThermoPhase.cs b/interfaces/dotnet/Cantera/src/ThermoPhase.cs index fb9f5ddab7..6f227554a6 100644 --- a/interfaces/dotnet/Cantera/src/ThermoPhase.cs +++ b/interfaces/dotnet/Cantera/src/ThermoPhase.cs @@ -17,7 +17,7 @@ public partial class ThermoPhase unsafe delegate int SetPairFunc(ThermoPhaseHandle n, (double, double)* values); /// - /// Using reflection and the fact that CLIB follows a naming convention for + /// Using reflection and the fact that Clib follows a naming convention for /// the functions that set the pairs of thermodynamic variables simultaneously /// static readonly Lazy> s_pairSetters; diff --git a/interfaces/matlab_experimental/readme.md b/interfaces/matlab_experimental/readme.md index 0069bbedf2..577e08ffd0 100644 --- a/interfaces/matlab_experimental/readme.md +++ b/interfaces/matlab_experimental/readme.md @@ -1,7 +1,7 @@ # Experimental MATLAB Toolbox for Cantera This experimental Matlab Toolbox for Cantera changes the Matlab interface to the modern Matlab structure and syntaxes for OOP. It replaces the MEX interface with direct -function calling from Cantera Clib. +function calling from Cantera CLib. ## Installation guide: diff --git a/samples/clib/README.rst b/samples/clib/README.rst index 2a612c63ab..6cc4c1c125 100644 --- a/samples/clib/README.rst +++ b/samples/clib/README.rst @@ -6,5 +6,5 @@ which can also be used to call Cantera from other languages that are able to call C functions. .. caution:: - The Clib interface is an experimental part of the Cantera API and may be changed + The CLib interface is an experimental part of the Cantera API and may be changed or removed without notice. From 7467828d31dceab0be3ae99c73ff25cd7f9207da Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 13 Aug 2024 18:08:23 -0500 Subject: [PATCH 05/15] [.NET] Update README.md --- interfaces/dotnet/README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/interfaces/dotnet/README.md b/interfaces/dotnet/README.md index 6307aa5db3..1de579c4bc 100644 --- a/interfaces/dotnet/README.md +++ b/interfaces/dotnet/README.md @@ -3,20 +3,21 @@ This directory and its children contain the interface to Cantera for .NET languages such as C# and F#. It is written in C# and supports .NET Standard 2.0 (for the primary project) and .NET 6 (and newer) on all platforms that support both -.NET and the Cantera C++ library. +.NET and the Cantera C++ library. The .NET interface requires an installation of the +.NET 6.0 SDK. ## Project Layout -The primary C# project is Cantera.csproj. This project uses P/Invoke extensively with +The primary C# project is `Cantera.csproj`. This project uses P/Invoke extensively with the native Cantera library via the Cantera C interface (CLib), and wraps the low-level interfaces with classes and concepts familiar to a .NET developer. As part of the build process, it invokes [sourcegen](/interfaces/sourcegen) to scaffold the interop code and some of the code for the wrapper objects, such as simple properties which can mapped directly to CLib getter and setter functions. -Cantera.csproj targets .NET Standard 2.0 and .NET 6. This project will be released as +`Cantera.csproj` targets .NET Standard 2.0 and .NET 6. This project will be released as a NuGet package. -Cantera.Tests.csproj contains the unit tests for the Cantera .NET library and targets +`Cantera.Tests.csproj` contains the unit tests for the Cantera .NET library and targets .Net 6. The examples directory contains separate projects for each Cantera example. These will @@ -39,10 +40,18 @@ C# development installed. Visual Studio is _not_ required, and although contribu may choose to use it, submissions should not depend on Visual Studio or require the use of Windows. -### Running Tests +### Building the .NET Interface. After [building the main Cantera library](https://cantera.org/install/compiling-install.html), -switch to this directory and run `dotnet test`. +switch to this directory and run `dotnet build`. + +In order to force re-import of generated code from sourcegen, a manual deletion of +`obj` and `bin` folders in `Cantera`, `Cantera.Tests`, `examples/Applications` and +`examples/Soundspeed` may be necessary. + +### Running Tests + +After building the .NET interface, run `dotnet test`. ### Running Examples From a0daf9fc0b0f9e312da664063a859254c4057df3 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Tue, 13 Aug 2024 22:02:27 -0500 Subject: [PATCH 06/15] [sourcegen] Implement class accessor methods Also fix some crosswalk instances --- .../sourcegen/csharp/_CSharpSourceGenerator.py | 11 +++++++---- .../sourcegen/sourcegen/csharp/_Config.py | 4 ++++ .../sourcegen/sourcegen/csharp/config.yaml | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py index 73ca7c5b00..8f69691720 100644 --- a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py @@ -136,13 +136,17 @@ def _convert_func(self, parsed: Func) -> CsFunc: handle_class_name = self._get_handle_class_name(clib_area) # It’s not a “global” function, therefore: - # * It wraps a constructor and returns a handle, or + # * It wraps a constructor and returns a handle, + # * It wraps an instance method that returns a handle, or # * It wraps an instance method and takes the handle as the first param. if method.startswith("del"): release_func_handle_class_name = handle_class_name elif method.startswith("new"): ret_type = handle_class_name - else: + elif name in self._config.class_accessors: + ret_type = self._config.class_accessors[name] + params[0] = Param(handle_class_name, params[0].name) + elif params: params[0] = Param(handle_class_name, params[0].name) for c_type, cs_type in self._config.ret_type_crosswalk.items(): @@ -152,8 +156,7 @@ def _convert_func(self, parsed: Func) -> CsFunc: setter_double_arrays_count = 0 - for i in range(0, len(params)): - param_type, param_name = params[i] + for i, (param_type, param_name) in enumerate(params): for c_type, cs_type in self._config.ret_type_crosswalk.items(): if param_type == c_type: diff --git a/interfaces/sourcegen/sourcegen/csharp/_Config.py b/interfaces/sourcegen/sourcegen/csharp/_Config.py index e6259449ea..44b6538ad4 100644 --- a/interfaces/sourcegen/sourcegen/csharp/_Config.py +++ b/interfaces/sourcegen/sourcegen/csharp/_Config.py @@ -20,6 +20,7 @@ class Config: ret_type_crosswalk = { "const char*": "string", "const double*": "double[]", + "const int*": "int[]", "size_t": "nuint", "char*": "byte*" } @@ -35,6 +36,8 @@ class Config: # These we load from the parsed YAML config file class_crosswalk: Dict[str, str] + class_accessors: Dict[str, str] + derived_handles: Dict[str, str] wrapper_classes: Dict[str, Dict[str, str]] @@ -42,5 +45,6 @@ class Config: @staticmethod def from_parsed(parsed_config_file: dict): return Config(parsed_config_file["class_crosswalk"], + parsed_config_file["class_accessors"], parsed_config_file["derived_handles"], parsed_config_file["wrapper_classes"]) diff --git a/interfaces/sourcegen/sourcegen/csharp/config.yaml b/interfaces/sourcegen/sourcegen/csharp/config.yaml index 1a94885302..ff948f9628 100644 --- a/interfaces/sourcegen/sourcegen/csharp/config.yaml +++ b/interfaces/sourcegen/sourcegen/csharp/config.yaml @@ -1,20 +1,18 @@ -# ignore these files entirely: +# Ignore these files entirely: ignore_files: - ctfunc.h - ctmatlab.h - ctonedim.h - ctrpath.h -#ignore these specific functions: +# Ignore these specific functions: ignore_funcs: ct.h: - ct_setLogWriter - - soln_newInterface # signature causes syntax error in sourcegen - - thermo_size ctreactor.h: - flowReactor_setMassFlowRate -# replaces the name as determined by the C function prefix +# Replaces the name as determined by the C function prefix # with the name of the class that function is designed to expose class_crosswalk: flowdev: FlowDevice @@ -29,6 +27,16 @@ class_crosswalk: trans: Transport wall: Wall +# Provides information on instance methods that return instances +# of other C# classes. +class_accessors: + soln_thermo: ThermoPhaseHandle + soln_kinetics: KineticsHandle + soln_transport: TransportHandle + thermo_parent: SolutionHandle + kin_parent: SolutionHandle + trans_parent: SolutionHandle + # Handles for which there is no special delete function, # so we need to generate them manually because we can't # discover the type name from the delete. From db138729b18edc85faff0f9b3e0c2e181f3de0b8 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 08:15:53 -0500 Subject: [PATCH 07/15] [clib] Remove unused kin_speciesIndex argument --- include/cantera/clib/ct.h | 2 +- interfaces/matlab_experimental/Base/Kinetics.m | 11 +++-------- src/clib/ct.cpp | 4 +--- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index 038f8a818b..a9af9c80fc 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -165,7 +165,7 @@ extern "C" { CANTERA_CAPI int kin_isReversible(int n, int i); CANTERA_CAPI int kin_getType(int n, size_t len, char* name); CANTERA_CAPI size_t kin_start(int n, int p); - CANTERA_CAPI size_t kin_speciesIndex(int n, const char* nm, const char* ph); + CANTERA_CAPI size_t kin_speciesIndex(int n, const char* nm); CANTERA_CAPI int kin_advanceCoverages(int n, double tstep); CANTERA_CAPI size_t kin_phase(int n, size_t i); diff --git a/interfaces/matlab_experimental/Base/Kinetics.m b/interfaces/matlab_experimental/Base/Kinetics.m index 06ead3d788..2414df1a9b 100644 --- a/interfaces/matlab_experimental/Base/Kinetics.m +++ b/interfaces/matlab_experimental/Base/Kinetics.m @@ -107,22 +107,17 @@ %% Get scalar attributes - function n = kineticsSpeciesIndex(kin, name, phase) + function n = kineticsSpeciesIndex(kin, name) % Get the species index of a species of a phase in the Kinetics class. :: % - % >> n = kin.kineticsSpeciesIndex(name, phase) + % >> n = kin.kineticsSpeciesIndex(name) % % :param name: % String name or integer index of the species. - % :param phase: - % String name or integer index of the phase. % :return: % Index of the species. - if nargin == 2 - phase = ''; - end - n = ctFunc('kin_speciesIndex', kin.kinID, name, phase) + 1; + n = ctFunc('kin_speciesIndex', kin.kinID, name) + 1; end function n = multiplier(kin, irxn) diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index ea1416c126..5c0ad15e48 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -1196,11 +1196,9 @@ extern "C" { } } - size_t kin_speciesIndex(int n, const char* nm, const char* ph) + size_t kin_speciesIndex(int n, const char* nm) { try { - // @todo Introduce a version of this that only takes the 'nm' argument - // and deprecate this one. return KineticsCabinet::item(n).kineticsSpeciesIndex(nm); } catch (...) { return handleAllExceptions(npos, npos); From ad54a39b30052a93357c158f56d84b41dc0000f4 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 07:48:30 -0500 Subject: [PATCH 08/15] [.NET] Replace thermo_newFromFile --- interfaces/dotnet/Cantera/src/ThermoPhase.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interfaces/dotnet/Cantera/src/ThermoPhase.cs b/interfaces/dotnet/Cantera/src/ThermoPhase.cs index 6f227554a6..851da1130c 100644 --- a/interfaces/dotnet/Cantera/src/ThermoPhase.cs +++ b/interfaces/dotnet/Cantera/src/ThermoPhase.cs @@ -10,6 +10,8 @@ namespace Cantera; /// public partial class ThermoPhase { + readonly SolutionHandle _sol; + /// /// Represents a func that sets a pair of thermo variables using a pointer /// to a pair of doubles to stand in for a stack-allocated array with two elements. @@ -53,7 +55,8 @@ static ThermoPhase() internal ThermoPhase(string filename, string? phaseName) { - _handle = LibCantera.thermo_newFromFile(filename, phaseName ?? ""); + _sol = LibCantera.soln_newSolution(filename, phaseName ?? "", "none"); + _handle = LibCantera.soln_thermo(_sol); _handle.EnsureValid(); _species = new(() => new SpeciesCollection(_handle)); From eba7da6a971a3308a6362a86de52752df607a13d Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 08:11:12 -0500 Subject: [PATCH 09/15] [clib] Remove *_newFromFile Also remove associated *_del methods as objects are managed by owning Solution instance. --- include/cantera/clib/ct.h | 10 -- .../dotnet/Cantera.Tests/src/ExceptionTest.cs | 2 +- .../sourcegen/sourcegen/csharp/config.yaml | 3 + src/clib/ct.cpp | 94 ------------------- test/clib/test_clib.cpp | 26 +++-- test/clib/test_ctmultiphase.cpp | 3 +- test/clib/test_ctonedim.cpp | 49 ++++------ 7 files changed, 35 insertions(+), 152 deletions(-) diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index a9af9c80fc..1cae7e5e35 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -37,10 +37,8 @@ extern "C" { CANTERA_CAPI int soln_adjacent(int n, int a); CANTERA_CAPI int soln_adjacentName(int n, int a, int lennm, char* nm); - CANTERA_CAPI int thermo_newFromFile(const char* filename, const char* phasename); //!< @todo remove from .NET and Fortran interfaces CANTERA_CAPI int thermo_parent(int n); CANTERA_CAPI int thermo_size(); - CANTERA_CAPI int thermo_del(int n); CANTERA_CAPI size_t thermo_nElements(int n); CANTERA_CAPI size_t thermo_nSpecies(int n); CANTERA_CAPI double thermo_temperature(int n); @@ -132,12 +130,7 @@ extern "C" { CANTERA_CAPI int thermo_setState_Psat(int n, double p, double x); CANTERA_CAPI int thermo_setState_Tsat(int n, double t, double x); - //! @since Starting in %Cantera 3.0, the "phasename" argument should be blank - CANTERA_CAPI int kin_newFromFile(const char* filename, const char* phasename, - int reactingPhase, int neighbor1, int neighbor2, - int neighbor3, int neighbor4); //!< @todo remove from .NET and Fortran interfaces CANTERA_CAPI int kin_parent(int n); - CANTERA_CAPI int kin_del(int n); CANTERA_CAPI size_t kin_nSpecies(int n); CANTERA_CAPI size_t kin_nReactions(int n); CANTERA_CAPI size_t kin_nPhases(int n); @@ -169,10 +162,7 @@ extern "C" { CANTERA_CAPI int kin_advanceCoverages(int n, double tstep); CANTERA_CAPI size_t kin_phase(int n, size_t i); - CANTERA_CAPI int trans_newDefault(int th, int loglevel); //!< @todo remove from .NET and Fortran interfaces - CANTERA_CAPI int trans_new(const char* model, int th, int loglevel); //!< @todo remove from .NET and Fortran interfaces CANTERA_CAPI int trans_parent(int n); - CANTERA_CAPI int trans_del(int n); CANTERA_CAPI int trans_transportModel(int n, int lennm, char* nm); CANTERA_CAPI double trans_viscosity(int n); CANTERA_CAPI double trans_electricalConductivity(int n); diff --git a/interfaces/dotnet/Cantera.Tests/src/ExceptionTest.cs b/interfaces/dotnet/Cantera.Tests/src/ExceptionTest.cs index 089a543c27..379c9089ae 100644 --- a/interfaces/dotnet/Cantera.Tests/src/ExceptionTest.cs +++ b/interfaces/dotnet/Cantera.Tests/src/ExceptionTest.cs @@ -14,7 +14,7 @@ class FooException : Exception { } [Fact] public void CanteraException_Thrown() { - var handle = LibCantera.thermo_newFromFile(".yaml", ""); + var handle = LibCantera.soln_newSolution(".yaml", "", ""); Assert.True(handle.IsInvalid); diff --git a/interfaces/sourcegen/sourcegen/csharp/config.yaml b/interfaces/sourcegen/sourcegen/csharp/config.yaml index ff948f9628..2d5a4124d4 100644 --- a/interfaces/sourcegen/sourcegen/csharp/config.yaml +++ b/interfaces/sourcegen/sourcegen/csharp/config.yaml @@ -44,6 +44,9 @@ class_accessors: # Derived: Base derived_handles: SurfaceHandle: ThermoPhaseHandle + ThermoPhaseHandle: SolutionHandle + KineticsHandle: SolutionHandle + TransportHandle: SolutionHandle # Provides info for scaffolding higher-level idiomatic C# classes # At this stage, we can scaffold simple properties that follow the diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 5c0ad15e48..927fc91620 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -519,7 +519,6 @@ extern "C" { } } - double thermo_nAtoms(int n, size_t k, size_t m) { try { @@ -541,14 +540,6 @@ extern "C" { //-------------- Thermo --------------------// - int thermo_newFromFile(const char* filename, const char* phasename) { - try { - return ThermoCabinet::add(newThermo(filename, phasename)); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - int thermo_getEosType(int n, size_t leneos, char* eos) { try { @@ -1143,41 +1134,6 @@ extern "C" { //-------------- Kinetics ------------------// - // @todo Define a new version of this function that does not require the - // unused 'phasename' argument. - int kin_newFromFile(const char* filename, const char* phasename, - int reactingPhase, int neighbor1, int neighbor2, - int neighbor3, int neighbor4) - { - try { - vector> phases; - phases.push_back(ThermoCabinet::at(reactingPhase)); - if (neighbor1 >= 0) { - phases.push_back(ThermoCabinet::at(neighbor1)); - if (neighbor2 >= 0) { - phases.push_back(ThermoCabinet::at(neighbor2)); - if (neighbor3 >= 0) { - phases.push_back(ThermoCabinet::at(neighbor3)); - if (neighbor4 >= 0) { - phases.push_back(ThermoCabinet::at(neighbor4)); - } - } - } - } - if (phasename != nullptr) { - string phase_str(phasename); - if (!phase_str.empty() && phase_str != phases[0]->name()) { - throw CanteraError("kin_newFromFile", "Reacting phase must be first"); - } - } - shared_ptr kin = newKinetics(phases, filename); - return KineticsCabinet::add(kin); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - //------------------------------------- int kin_getType(int n, size_t lennm, char* nm) { try { @@ -1525,26 +1481,6 @@ extern "C" { //------------------- Transport --------------------------- - int trans_newDefault(int ith, int loglevel) - { - try { - auto tr = newTransport(ThermoCabinet::at(ith), "default"); - return TransportCabinet::add(tr); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int trans_new(const char* model, int ith, int loglevel) - { - try { - auto tr = newTransport(ThermoCabinet::at(ith), model); - return TransportCabinet::add(tr); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - int trans_transportModel(int i, int lennm, char* nm) { try { @@ -1831,34 +1767,4 @@ extern "C" { return handleAllExceptions(-2, ERR); } } - - int thermo_del(int n) - { - try { - ThermoCabinet::del(n); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int kin_del(int n) - { - try { - KineticsCabinet::del(n); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int trans_del(int n) - { - try { - TransportCabinet::del(n); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } } diff --git a/test/clib/test_clib.cpp b/test/clib/test_clib.cpp index be1027f4a4..2c261f7de6 100644 --- a/test/clib/test_clib.cpp +++ b/test/clib/test_clib.cpp @@ -73,23 +73,19 @@ TEST(ct, soln_objects) { ct_resetStorage(); - int thermo0 = thermo_newFromFile("gri30.yaml", "gri30"); - ASSERT_EQ(thermo_size(), 1); - int ref = soln_newSolution("gri30.yaml", "gri30", "none"); ASSERT_EQ(ref, 0); - ASSERT_EQ(thermo_size(), 2); + ASSERT_EQ(thermo_size(), 1); // one ThermoPhase object + int ref2 = soln_newSolution("h2o2.yaml", "ohmech", "default"); ASSERT_EQ(ref2, 1); - ASSERT_EQ(thermo_size(), 3); - - ASSERT_EQ(thermo_parent(thermo0), -1); + ASSERT_EQ(thermo_size(), 2); // two ThermoPhase objects int thermo = soln_thermo(ref); ASSERT_EQ(thermo_parent(thermo), ref); int thermo2 = soln_thermo(ref2); - ASSERT_EQ(thermo2, 2); + ASSERT_EQ(thermo2, 1); // references stored object with index '1' ASSERT_EQ(thermo_nSpecies(thermo2), 10u); ASSERT_EQ(thermo_parent(thermo2), ref2); @@ -191,7 +187,8 @@ TEST(ct, new_interface_auto) TEST(ct, thermo) { int ret; - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); + int sol = soln_newSolution("gri30.yaml", "gri30", "none"); + int thermo = soln_thermo(sol); ASSERT_GE(thermo, 0); size_t nsp = thermo_nSpecies(thermo); ASSERT_EQ(nsp, 53u); @@ -238,8 +235,9 @@ TEST(ct, thermo) TEST(ct, kinetics) { - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); - int kin = kin_newFromFile("gri30.yaml", "", thermo, -1, -1, -1, -1); + int sol0 = soln_newSolution("gri30.yaml", "gri30", "none"); + int thermo = soln_thermo(sol0); + int kin = soln_kinetics(sol0); ASSERT_GE(kin, 0); size_t nr = kin_nReactions(kin); @@ -269,9 +267,9 @@ TEST(ct, kinetics) TEST(ct, transport) { - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); - int tran = trans_newDefault(thermo, 0); - ASSERT_GE(tran, 0); + int sol0 = soln_newSolution("gri30.yaml", "gri30", "default"); + int thermo = soln_thermo(sol0); + int tran = soln_transport(sol0); size_t nsp = thermo_nSpecies(thermo); vector c_dkm(nsp); diff --git a/test/clib/test_ctmultiphase.cpp b/test/clib/test_ctmultiphase.cpp index d3a13b77a0..f6446e2c83 100644 --- a/test/clib/test_ctmultiphase.cpp +++ b/test/clib/test_ctmultiphase.cpp @@ -10,7 +10,8 @@ using namespace Cantera; TEST(ctmix, new) { - int thermo = thermo_newFromFile("gri30.yaml", "gri30"); + int sol = soln_newSolution("gri30.yaml", "gri30", "none"); + int thermo = soln_thermo(sol); int mix = mix_new(); ASSERT_GE(mix, 0); int ret = mix_addPhase(mix, thermo, 1.); diff --git a/test/clib/test_ctonedim.cpp b/test/clib/test_ctonedim.cpp index 7d327cd374..197ac46453 100644 --- a/test/clib/test_ctonedim.cpp +++ b/test/clib/test_ctonedim.cpp @@ -90,47 +90,32 @@ TEST(ctonedim, outlet) TEST(ctonedim, reacting_surface) { - int surf = soln_newInterface("ptcombust.yaml", "Pt_surf", 0, 0); - int index = domain_new("reacting-surface", surf, "surface"); - ASSERT_GE(index, 0); -} - -TEST(ctonedim, reacting_surface_from_parts) -{ - int index = reactingsurf_new(); - ASSERT_GE(index, 0); + int interface = soln_newInterface("ptcombust.yaml", "Pt_surf", 0, 0); - int gas = thermo_newFromFile("ptcombust.yaml", "gas"); - int surf = thermo_newFromFile("ptcombust.yaml", "Pt_surf"); - int kin = kin_newFromFile("ptcombust.yaml", "", surf, gas, -1, -1, -1); - ASSERT_GE(kin, 0); + int surf = domain_new("reacting-surface", interface, ""); + ASSERT_GE(surf, 0); - int ret = reactingsurf_setkineticsmgr(index, kin); - ASSERT_EQ(ret, 0); + int buflen = domain_type(surf, 0, 0); + char* buf = new char[buflen]; + domain_type(surf, buflen, buf); + string domName = buf; + ASSERT_EQ(domName, "reacting-surface"); + delete[] buf; } -TEST(ctonedim, catcomb_stack) +TEST(ctonedim, catcomb) { int sol = soln_newSolution("ptcombust.yaml", "gas", "default"); - int gas = soln_thermo(sol); - int gas_kin = soln_kinetics(sol); - int trans = soln_transport(sol); - - int surf = thermo_newFromFile("ptcombust.yaml", "Pt_surf"); - int surf_kin = kin_newFromFile("ptcombust.yaml", "", surf, gas, -1, -1, -1); + int interface = soln_newInterface("ptcombust.yaml", "Pt_surf", 0, 0); - // inlet - int inlet = inlet_new(); - - // flow - int itype = 1; // free flow - int flow = flow1D_new(gas, gas_kin, trans, itype); - domain_setID(flow, "flow"); + // inlet and flow domains + int inlet = domain_new("inlet", sol, "inlet"); + int flow = domain_new("axisymmetric-flow", sol, "flow"); + ASSERT_EQ(flow, inlet+1); // reacting surface - int reac_surf = reactingsurf_new(); - int ret = reactingsurf_setkineticsmgr(reac_surf, surf_kin); - ASSERT_EQ(ret, 0); + int reac_surf = domain_new("reacting-surface", interface, "surface"); + ASSERT_EQ(reac_surf, flow+1); // set up stack vector doms{inlet, flow, reac_surf}; From eb4d2a8ca8de745f2f10642746f648ef396417a0 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 08:34:10 -0500 Subject: [PATCH 10/15] [clib] Select equilibrium solver using string --- include/cantera/clib/ct.h | 2 +- .../dotnet/Cantera.Tests/src/EnumsTest.cs | 4 --- interfaces/dotnet/Cantera/src/Enums.cs | 28 +------------------ interfaces/dotnet/Cantera/src/ThermoPhase.cs | 10 +++---- .../matlab_experimental/Base/ThermoPhase.m | 13 ++++----- samples/clib/demo.c | 2 +- src/clib/ct.cpp | 17 ++--------- test/clib/test_clib.cpp | 4 +-- test/clib/test_ctonedim.cpp | 2 +- 9 files changed, 19 insertions(+), 63 deletions(-) diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index 1cae7e5e35..e4092ea7f2 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -117,7 +117,7 @@ extern "C" { CANTERA_CAPI int thermo_set_VH(int n, double* vals); CANTERA_CAPI int thermo_set_TH(int n, double* vals); CANTERA_CAPI int thermo_set_SH(int n, double* vals); - CANTERA_CAPI int thermo_equilibrate(int n, const char* XY, int solver, + CANTERA_CAPI int thermo_equilibrate(int n, const char* XY, const char* solver, double rtol, int maxsteps, int maxiter, int loglevel); diff --git a/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs b/interfaces/dotnet/Cantera.Tests/src/EnumsTest.cs index a2be7a4c8c..04995dcc9c 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/Enums.cs b/interfaces/dotnet/Cantera/src/Enums.cs index 13ab049a7e..ddcf27ff7b 100644 --- a/interfaces/dotnet/Cantera/src/Enums.cs +++ b/interfaces/dotnet/Cantera/src/Enums.cs @@ -101,33 +101,7 @@ 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 constants MUST match what CLib is expecting /// /// The diff --git a/interfaces/dotnet/Cantera/src/ThermoPhase.cs b/interfaces/dotnet/Cantera/src/ThermoPhase.cs index 851da1130c..11999cc3ac 100644 --- a/interfaces/dotnet/Cantera/src/ThermoPhase.cs +++ b/interfaces/dotnet/Cantera/src/ThermoPhase.cs @@ -19,7 +19,7 @@ public partial class ThermoPhase unsafe delegate int SetPairFunc(ThermoPhaseHandle n, (double, double)* values); /// - /// Using reflection and the fact that Clib follows a naming convention for + /// Using reflection and the fact that CLib follows a naming convention for /// the functions that set the pairs of thermodynamic variables simultaneously /// static readonly Lazy> s_pairSetters; @@ -64,17 +64,17 @@ 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 algorithm(s) + /// identified by the solver string. /// public void Equilibrate(ThermoPair thermoPair, - EquilibriumSolver solver = EquilibriumSolver.Auto, + string solver = "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, solver, tolerance, maxSteps, maxIterations, logVerbosity); InteropUtil.CheckReturn(retVal); diff --git a/interfaces/matlab_experimental/Base/ThermoPhase.m b/interfaces/matlab_experimental/Base/ThermoPhase.m index a7362e4a1c..8f42f53db8 100644 --- a/interfaces/matlab_experimental/Base/ThermoPhase.m +++ b/interfaces/matlab_experimental/Base/ThermoPhase.m @@ -451,11 +451,10 @@ function display(tp) % Not all of the properties to be held constant are available with % all of the solvers. % :param solver: - % Specifies the equilibrium solver to use. If solver = 0, a fast - % solver using the element potential method will be used. If - % solver = 1, a slower but more robust Gibbs minimization solver - % will be used. If solver >= 2, a version of the VCS algorithm will - % be used. If solver < 0 or is unspecified, the fast solver + % Specifies the equilibrium solver to use. Choices are + % 'element_potential' (fast solver using the element potential method), + % 'gibbs' (slower but more robust Gibbs minimization solver), 'vcs' + % (VCS algorithm). For the default 'auto' setting, the fast solver % will be tried first, then if it fails the Gibbs minimization solver % will be tried. % :param rtol: @@ -472,7 +471,7 @@ function display(tp) % generate more detailed information. if nargin < 3 - solver = -1; + solver = 'auto'; end if nargin < 4 @@ -492,7 +491,7 @@ function display(tp) end ctFunc('thermo_equilibrate', tp.tpID, xy, solver, rtol, ... - maxsteps, maxiter, loglevel); + maxsteps, maxiter, loglevel); end %% ThermoPhase inquiry methods diff --git a/samples/clib/demo.c b/samples/clib/demo.c index 56cadc3181..89ee13914d 100644 --- a/samples/clib/demo.c +++ b/samples/clib/demo.c @@ -54,7 +54,7 @@ int main(int argc, char** argv) thermo_setTemperature(thermo, 500); thermo_setPressure(thermo, 5 * 101325); thermo_setMoleFractionsByName(thermo, "CH4:1.0, O2:2.0, N2:7.52"); - thermo_equilibrate(thermo, "HP", 0, 1e-9, 50000, 1000, 0); + thermo_equilibrate(thermo, "HP", "auto", 1e-9, 50000, 1000, 0); thermo_print(thermo, 1, 0); int kin = soln_kinetics(soln); diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 927fc91620..f4ab4b641b 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -867,24 +867,11 @@ extern "C" { } } - int thermo_equilibrate(int n, const char* XY, int solver, + int thermo_equilibrate(int n, const char* XY, const char* solver, double rtol, int maxsteps, int maxiter, int loglevel) { try { - string ssolver; - if (solver < 0) { - ssolver = "auto"; - } else if (solver == 0) { - ssolver = "element_potential"; - } else if (solver == 1) { - ssolver = "gibbs"; - } else if (solver == 2) { - ssolver = "vcs"; - } else { - throw CanteraError("thermo_equilibrate", - "Invalid equilibrium solver specified."); - } - ThermoCabinet::item(n).equilibrate(XY, ssolver, rtol, maxsteps, + ThermoCabinet::item(n).equilibrate(XY, solver, rtol, maxsteps, maxiter, 0, loglevel); return 0; } catch (...) { diff --git a/test/clib/test_clib.cpp b/test/clib/test_clib.cpp index 2c261f7de6..a2b5128581 100644 --- a/test/clib/test_clib.cpp +++ b/test/clib/test_clib.cpp @@ -200,7 +200,7 @@ TEST(ct, thermo) ret = thermo_setMoleFractionsByName(thermo, "CH4:1.0, O2:2.0, N2:7.52"); ASSERT_EQ(ret, 0); - ret = thermo_equilibrate(thermo, "HP", 0, 1e-9, 50000, 1000, 0); + ret = thermo_equilibrate(thermo, "HP", "auto", 1e-9, 50000, 1000, 0); ASSERT_EQ(ret, 0); double T = thermo_temperature(thermo); ASSERT_GT(T, 2200); @@ -243,7 +243,7 @@ TEST(ct, kinetics) size_t nr = kin_nReactions(kin); ASSERT_EQ(nr, 325u); - thermo_equilibrate(thermo, "HP", 0, 1e-9, 50000, 1000, 0); + thermo_equilibrate(thermo, "HP", "auto", 1e-9, 50000, 1000, 0); double T = thermo_temperature(thermo); thermo_setTemperature(thermo, T - 200); diff --git a/test/clib/test_ctonedim.cpp b/test/clib/test_ctonedim.cpp index 197ac46453..5134d17da0 100644 --- a/test/clib/test_ctonedim.cpp +++ b/test/clib/test_ctonedim.cpp @@ -149,7 +149,7 @@ TEST(ctonedim, freeflame_from_parts) thermo_getMassFractions(ph, nsp, yin.data()); // product estimate - int ret = thermo_equilibrate(ph, "HP", 0, 1e-9, 50000, 1000, 0); + int ret = thermo_equilibrate(ph, "HP", "auto", 1e-9, 50000, 1000, 0); ASSERT_GE(ret, 0); double rho_out = thermo_density(ph); double Tad = thermo_temperature(ph); From 7b87b27c776f229d720470c22589b9767f9375d5 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 10:59:23 -0500 Subject: [PATCH 11/15] [sourcegen] Fix indentation levels --- interfaces/sourcegen/sourcegen/_helpers.py | 5 +++ .../csharp/_CSharpSourceGenerator.py | 35 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/interfaces/sourcegen/sourcegen/_helpers.py b/interfaces/sourcegen/sourcegen/_helpers.py index 9c3c5a009d..bd50011862 100644 --- a/interfaces/sourcegen/sourcegen/_helpers.py +++ b/interfaces/sourcegen/sourcegen/_helpers.py @@ -13,6 +13,11 @@ def with_unpack_iter(cls: type) -> type: return cls +def hanging_text(text: str, spaces: int) -> str: + ret = ("\n" + " "*spaces).join(text.split("\n")) + return "\n".join([line.rstrip() for line in ret.split("\n")]) + + def normalize_indent(code: str) -> str: code = textwrap.dedent(code).strip() diff --git a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py index 8f69691720..6e16eaa182 100644 --- a/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/csharp/_CSharpSourceGenerator.py @@ -5,10 +5,11 @@ from pathlib import Path from typing import List, Dict import re +import textwrap from ._dataclasses import CsFunc from ._Config import Config -from .._helpers import normalize_indent +from .._helpers import normalize_indent, hanging_text from .._dataclasses import Func, Param, HeaderFile from .._SourceGenerator import SourceGenerator @@ -200,8 +201,8 @@ def _write_file(self, filename: str, contents: str): def _scaffold_interop(self, header_file_path: Path, cs_funcs: List[CsFunc]): functions_text = "\n\n".join(map(self._get_interop_func_text, cs_funcs)) - interop_text = normalize_indent(f""" - {normalize_indent(self._config.preamble)} + interop_text = textwrap.dedent(f""" + {hanging_text(self._config.preamble, 12)} using System.Runtime.InteropServices; @@ -209,9 +210,9 @@ def _scaffold_interop(self, header_file_path: Path, cs_funcs: List[CsFunc]): static partial class LibCantera {{ - {normalize_indent(functions_text)} + {hanging_text(functions_text, 16)} }} - """) + """).lstrip() self._write_file("Interop.LibCantera." + header_file_path.name + ".g.cs", interop_text) @@ -219,13 +220,13 @@ def _scaffold_interop(self, header_file_path: Path, cs_funcs: List[CsFunc]): def _scaffold_handles(self, header_file_path: Path, handles: Dict[str, str]): handles_text = "\n\n".join(starmap(self._get_base_handle_text, handles.items())) - handles_text = normalize_indent(f""" - {normalize_indent(self._config.preamble)} + handles_text = textwrap.dedent(f""" + {hanging_text(self._config.preamble, 12)} namespace Cantera.Interop; - {normalize_indent(handles_text)} - """) + {hanging_text(handles_text, 12)} + """).lstrip() self._write_file("Interop.Handles." + header_file_path.name + ".g.cs", handles_text) @@ -234,13 +235,13 @@ def _scaffold_derived_handles(self): derived_handles = "\n\n".join(starmap(self._get_derived_handle_text, self._config.derived_handles.items())) - derived_handles_text = normalize_indent(f""" - {normalize_indent(self._config.preamble)} + derived_handles_text = textwrap.dedent(f""" + {hanging_text(self._config.preamble, 12)} namespace Cantera.Interop; - {derived_handles} - """) + {hanging_text(derived_handles, 12)} + """).lstrip() self._write_file("Interop.Handles.g.cs", derived_handles_text) @@ -253,8 +254,8 @@ def _scaffold_wrapper_class(self, clib_area: str, props: Dict[str, str], self._get_property_text(clib_area, c_name, cs_name, known_funcs) for (c_name, cs_name) in props.items()) - wrapper_class_text = normalize_indent(f""" - {normalize_indent(self._config.preamble)} + wrapper_class_text = textwrap.dedent(f""" + {hanging_text(self._config.preamble, 12)} using Cantera.Interop; @@ -266,7 +267,7 @@ def _scaffold_wrapper_class(self, clib_area: str, props: Dict[str, str], #pragma warning disable CS1591 - {normalize_indent(properties_text)} + {hanging_text(properties_text, 16)} #pragma warning restore CS1591 @@ -277,7 +278,7 @@ def _scaffold_wrapper_class(self, clib_area: str, props: Dict[str, str], public void Dispose() => _handle.Dispose(); }} - """) + """).lstrip() self._write_file(wrapper_class_name + ".g.cs", wrapper_class_text) From 27970761d1d13ec14687e6bb30911f6cc28636d6 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 11:55:04 -0500 Subject: [PATCH 12/15] [clib] Reintroduce no-op destructor methods --- include/cantera/clib/ct.h | 3 +++ .../sourcegen/sourcegen/csharp/config.yaml | 3 --- src/clib/ct.cpp | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/include/cantera/clib/ct.h b/include/cantera/clib/ct.h index e4092ea7f2..96a950d6c1 100644 --- a/include/cantera/clib/ct.h +++ b/include/cantera/clib/ct.h @@ -39,6 +39,7 @@ extern "C" { CANTERA_CAPI int thermo_parent(int n); CANTERA_CAPI int thermo_size(); + CANTERA_CAPI int thermo_del(int n); //!< no-op; object is managed by Solution CANTERA_CAPI size_t thermo_nElements(int n); CANTERA_CAPI size_t thermo_nSpecies(int n); CANTERA_CAPI double thermo_temperature(int n); @@ -131,6 +132,7 @@ extern "C" { CANTERA_CAPI int thermo_setState_Tsat(int n, double t, double x); CANTERA_CAPI int kin_parent(int n); + CANTERA_CAPI int kin_del(int n); //!< no-op; object is managed by Solution CANTERA_CAPI size_t kin_nSpecies(int n); CANTERA_CAPI size_t kin_nReactions(int n); CANTERA_CAPI size_t kin_nPhases(int n); @@ -163,6 +165,7 @@ extern "C" { CANTERA_CAPI size_t kin_phase(int n, size_t i); CANTERA_CAPI int trans_parent(int n); + CANTERA_CAPI int trans_del(int n); //!< no-op; object is managed by Solution CANTERA_CAPI int trans_transportModel(int n, int lennm, char* nm); CANTERA_CAPI double trans_viscosity(int n); CANTERA_CAPI double trans_electricalConductivity(int n); diff --git a/interfaces/sourcegen/sourcegen/csharp/config.yaml b/interfaces/sourcegen/sourcegen/csharp/config.yaml index 2d5a4124d4..ff948f9628 100644 --- a/interfaces/sourcegen/sourcegen/csharp/config.yaml +++ b/interfaces/sourcegen/sourcegen/csharp/config.yaml @@ -44,9 +44,6 @@ class_accessors: # Derived: Base derived_handles: SurfaceHandle: ThermoPhaseHandle - ThermoPhaseHandle: SolutionHandle - KineticsHandle: SolutionHandle - TransportHandle: SolutionHandle # Provides info for scaffolding higher-level idiomatic C# classes # At this stage, we can scaffold simple properties that follow the diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index f4ab4b641b..211926b669 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -1754,4 +1754,25 @@ extern "C" { return handleAllExceptions(-2, ERR); } } + + int thermo_del(int n) + { + // function is needed for sourcegen + // no-op: object is managed by Solution + return 0; + } + + int kin_del(int n) + { + // function is needed for sourcegen + // no-op: object is managed by Solution + return 0; + } + + int trans_del(int n) + { + // function is needed for sourcegen + // no-op: object is managed by Solution + return 0; + } } From 44b30f9eb80f3c69466e32199701883a4ddc1691 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 12:35:07 -0500 Subject: [PATCH 13/15] [clib] Rename inconsistent setters --- include/cantera/clib/ctreactor.h | 2 +- interfaces/sourcegen/sourcegen/csharp/config.yaml | 2 -- src/clib/ctonedim.cpp | 10 ---------- src/clib/ctreactor.cpp | 2 +- 4 files changed, 2 insertions(+), 14 deletions(-) diff --git a/include/cantera/clib/ctreactor.h b/include/cantera/clib/ctreactor.h index 4337b3c8ee..263f445af7 100644 --- a/include/cantera/clib/ctreactor.h +++ b/include/cantera/clib/ctreactor.h @@ -33,7 +33,7 @@ extern "C" { CANTERA_CAPI double reactor_massFraction(int i, int k); CANTERA_CAPI size_t reactor_nSensParams(int i); CANTERA_CAPI int reactor_addSensitivityReaction(int i, int rxn); - CANTERA_CAPI int flowReactor_setMassFlowRate(int i, double mdot); + CANTERA_CAPI int reactor_setMassFlowRate(int i, double mdot); CANTERA_CAPI int reactornet_new(); CANTERA_CAPI int reactornet_del(int i); diff --git a/interfaces/sourcegen/sourcegen/csharp/config.yaml b/interfaces/sourcegen/sourcegen/csharp/config.yaml index ff948f9628..74fff35562 100644 --- a/interfaces/sourcegen/sourcegen/csharp/config.yaml +++ b/interfaces/sourcegen/sourcegen/csharp/config.yaml @@ -9,8 +9,6 @@ ignore_files: ignore_funcs: ct.h: - ct_setLogWriter - ctreactor.h: - - flowReactor_setMassFlowRate # Replaces the name as determined by the C function prefix # with the name of the class that function is designed to expose diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index b460950510..a751ef160c 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -388,16 +388,6 @@ extern "C" { } } - int inlet_setSpreadRate(int i, double v) - { - try { - DomainCabinet::get(i).setSpreadRate(v); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - //------------------ flow domains -------------------- int flow1D_new(int iph, int ikin, int itr, int itype) diff --git a/src/clib/ctreactor.cpp b/src/clib/ctreactor.cpp index 096a5f2680..0cf66c1a2a 100644 --- a/src/clib/ctreactor.cpp +++ b/src/clib/ctreactor.cpp @@ -191,7 +191,7 @@ extern "C" { } } - int flowReactor_setMassFlowRate(int i, double mdot) + int reactor_setMassFlowRate(int i, double mdot) { try { ReactorCabinet::get(i).setMassFlowRate(mdot); From effabd29938e6b45ae575a0a5eae68671637ca59 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 12:48:37 -0500 Subject: [PATCH 14/15] [clib] Remove obsolete oneD constructors --- include/cantera/clib/ctonedim.h | 11 --- .../OneDim/ReactingSurface.m | 2 - src/clib/ctonedim.cpp | 65 ---------------- test/clib/test_ctonedim.cpp | 77 ++++++------------- 4 files changed, 23 insertions(+), 132 deletions(-) diff --git a/include/cantera/clib/ctonedim.h b/include/cantera/clib/ctonedim.h index e7c284f32e..8ae5e52904 100644 --- a/include/cantera/clib/ctonedim.h +++ b/include/cantera/clib/ctonedim.h @@ -49,19 +49,8 @@ extern "C" { CANTERA_CAPI double bdry_massFraction(int i, int k); CANTERA_CAPI double bdry_mdot(int i); - CANTERA_CAPI int reactingsurf_setkineticsmgr(int i, int j); CANTERA_CAPI int reactingsurf_enableCoverageEqs(int i, int onoff); - CANTERA_CAPI int inlet_new(); - CANTERA_CAPI int outlet_new(); - CANTERA_CAPI int outletres_new(); - CANTERA_CAPI int symm_new(); - CANTERA_CAPI int surf_new(); - CANTERA_CAPI int reactingsurf_new(); - - CANTERA_CAPI int inlet_setSpreadRate(int i, double v); - - CANTERA_CAPI int flow1D_new(int iph, int ikin, int itr, int itype); CANTERA_CAPI int flow1D_setTransport(int i, int itr); CANTERA_CAPI int flow1D_enableSoret(int i, int iSoret); CANTERA_CAPI int flow1D_setPressure(int i, double p); diff --git a/interfaces/matlab_experimental/OneDim/ReactingSurface.m b/interfaces/matlab_experimental/OneDim/ReactingSurface.m index 9d361c5803..32a3b5b0cd 100644 --- a/interfaces/matlab_experimental/OneDim/ReactingSurface.m +++ b/interfaces/matlab_experimental/OneDim/ReactingSurface.m @@ -38,8 +38,6 @@ end s@Boundary1D('reacting-surface', surface_mech, id); - - ctFunc('reactingsurf_setkineticsmgr', s.domainID, surface_mech.kinID); s.coverageEnabled = false; end diff --git a/src/clib/ctonedim.cpp b/src/clib/ctonedim.cpp index a751ef160c..0038280aa3 100644 --- a/src/clib/ctonedim.cpp +++ b/src/clib/ctonedim.cpp @@ -237,60 +237,6 @@ extern "C" { } } - int inlet_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int surf_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int reactingsurf_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int symm_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int outlet_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - - int outletres_new() - { - try { - return DomainCabinet::add(make_shared()); - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - int bdry_setMdot(int i, double mdot) { try { @@ -367,17 +313,6 @@ extern "C" { } } - int reactingsurf_setkineticsmgr(int i, int j) - { - try { - auto k = KineticsCabinet::at(j); - DomainCabinet::get(i).setKinetics(k); - return 0; - } catch (...) { - return handleAllExceptions(-1, ERR); - } - } - int reactingsurf_enableCoverageEqs(int i, int onoff) { try { diff --git a/test/clib/test_ctonedim.cpp b/test/clib/test_ctonedim.cpp index 5134d17da0..6325835b91 100644 --- a/test/clib/test_ctonedim.cpp +++ b/test/clib/test_ctonedim.cpp @@ -23,7 +23,7 @@ TEST(ctonedim, freeflow) thermo_setTemperature(ph, T); thermo_setPressure(ph, P); - int flow = domain_new("free-flow", sol, "flow"); + int flow = domain_new("free-flow", sol, ""); ASSERT_GE(flow, 0); domain_setID(flow, "flow"); ASSERT_NEAR(flow1D_pressure(flow), P, 1e-5); @@ -31,75 +31,50 @@ TEST(ctonedim, freeflow) int buflen = domain_type(flow, 0, 0); char* buf = new char[buflen]; domain_type(flow, buflen, buf); - string domName = buf; - ASSERT_EQ(domName, "free-flow"); - delete[] buf; -} - -TEST(ctonedim, freeflow_from_parts) -{ - ct_resetStorage(); - - int sol = soln_newSolution("h2o2.yaml", "ohmech", "default"); - int ph = soln_thermo(sol); - ASSERT_GE(ph, 0); - int kin = soln_kinetics(sol); - ASSERT_GE(kin, 0); - int tr = soln_transport(sol); - ASSERT_GE(tr, 0); - - double T = 1050; - double P = 5 * 101325; - string X = "CH4:1.0, O2:2.0, N2:7.52"; - thermo_setMoleFractionsByName(ph, X.c_str()); - thermo_setTemperature(ph, T); - thermo_setPressure(ph, P); - - int itype = 2; // free flow - int flow = flow1D_new(ph, kin, tr, itype); - ASSERT_GE(flow, 0); - domain_setID(flow, "flow"); - ASSERT_NEAR(flow1D_pressure(flow), P, 1e-5); - - int buflen = domain_type(flow, 0, 0); - char* buf = new char[buflen]; - domain_type(flow, buflen, buf); - string domName = buf; - ASSERT_EQ(domName, "free-flow"); + string domType = buf; + ASSERT_EQ(domType, "free-flow"); delete[] buf; } TEST(ctonedim, inlet) { - int inlet = inlet_new(); + int sol = soln_newSolution("h2o2.yaml", "ohmech", "default"); + int inlet = domain_new("inlet", sol, ""); ASSERT_GE(inlet, 0); int buflen = domain_type(inlet, 0, 0); char* buf = new char[buflen]; domain_type(inlet, buflen, buf); - string domName = buf; - ASSERT_EQ(domName, "inlet"); + string domType = buf; + ASSERT_EQ(domType, "inlet"); delete[] buf; } TEST(ctonedim, outlet) { - int index = outlet_new(); - ASSERT_GE(index, 0); + int sol = soln_newSolution("h2o2.yaml", "ohmech", "default"); + int outlet = domain_new("outlet", sol, ""); + ASSERT_GE(outlet, 0); + + int buflen = domain_type(outlet, 0, 0); + char* buf = new char[buflen]; + domain_type(outlet, buflen, buf); + string domType = buf; + ASSERT_EQ(domType, "outlet"); + delete[] buf; } TEST(ctonedim, reacting_surface) { int interface = soln_newInterface("ptcombust.yaml", "Pt_surf", 0, 0); - int surf = domain_new("reacting-surface", interface, ""); ASSERT_GE(surf, 0); int buflen = domain_type(surf, 0, 0); char* buf = new char[buflen]; domain_type(surf, buflen, buf); - string domName = buf; - ASSERT_EQ(domName, "reacting-surface"); + string domType = buf; + ASSERT_EQ(domType, "reacting-surface"); delete[] buf; } @@ -125,15 +100,13 @@ TEST(ctonedim, catcomb) ASSERT_GE(dom, 0); } -TEST(ctonedim, freeflame_from_parts) +TEST(ctonedim, freeflame) { ct_resetStorage(); auto gas = newThermo("h2o2.yaml", "ohmech"); int sol = soln_newSolution("h2o2.yaml", "ohmech", "default"); int ph = soln_thermo(sol); - int kin = soln_kinetics(sol); - int tr = soln_transport(sol); size_t nsp = thermo_nSpecies(ph); // reactants @@ -157,9 +130,7 @@ TEST(ctonedim, freeflame_from_parts) thermo_getMassFractions(ph, nsp, yout.data()); // flow - int itype = 2; // free flow - int flow = flow1D_new(ph, kin, tr, itype); - domain_setID(flow, "flow"); + int flow = domain_new("free-flow", sol, "flow"); // grid int nz = 21; @@ -173,15 +144,13 @@ TEST(ctonedim, freeflame_from_parts) domain_setupGrid(flow, nz, z.data()); // inlet - int reac = inlet_new(); - domain_setID(reac, "inlet"); + int reac = domain_new("inlet", sol, "inlet"); bdry_setMoleFractions(reac, X.c_str()); bdry_setMdot(reac, uin * rho_in); bdry_setTemperature(reac, T); // outlet - int prod = outlet_new(); - domain_setID(prod, "outlet"); + int prod = domain_new("outlet", sol, "outlet"); double uout = bdry_mdot(reac) / rho_out; // set up stack From fd66ed667c24b4d2d94cb340fecf9eb1f9376e16 Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Wed, 14 Aug 2024 21:53:14 -0500 Subject: [PATCH 15/15] [doxygen] Fix group glitches --- include/cantera/oneD/Flow1D.h | 1 + include/cantera/thermo/PlasmaPhase.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/cantera/oneD/Flow1D.h b/include/cantera/oneD/Flow1D.h index c3059c7852..ca6c0a0f02 100644 --- a/include/cantera/oneD/Flow1D.h +++ b/include/cantera/oneD/Flow1D.h @@ -465,6 +465,7 @@ class Flow1D : public Domain1D //! @name Governing Equations //! Methods called by eval() to calculate residuals for individual governing //! equations. + //! @{ /** * Evaluate the continuity equation residual. diff --git a/include/cantera/thermo/PlasmaPhase.h b/include/cantera/thermo/PlasmaPhase.h index 83e8197ed4..8debb8e7a1 100644 --- a/include/cantera/thermo/PlasmaPhase.h +++ b/include/cantera/thermo/PlasmaPhase.h @@ -52,7 +52,7 @@ namespace Cantera * changed or removed without notice. * @todo Implement electron Boltzmann equation solver to solve EEDF. * https://github.com/Cantera/enhancements/issues/127 - * @ingroup phase + * @ingroup thermoprops */ class PlasmaPhase: public IdealGasPhase {