From 28c3444bd5ef420b800be7a75c189dc6bab9e0bb Mon Sep 17 00:00:00 2001 From: Ingmar Schoegl Date: Thu, 8 Aug 2024 12:06:24 -0500 Subject: [PATCH] [MATLAB] Update API & docstrings --- .../Reactor/ConstPressureReactor.m | 9 ++++----- interfaces/matlab_experimental/Reactor/FlowReactor.m | 11 ++++++----- .../Reactor/IdealGasConstPressureReactor.m | 9 ++++----- .../matlab_experimental/Reactor/IdealGasReactor.m | 9 ++++----- .../matlab_experimental/Reactor/MassFlowController.m | 12 +++++++++--- interfaces/matlab_experimental/Reactor/Reservoir.m | 11 ++++++----- interfaces/matlab_experimental/Reactor/Valve.m | 11 ++++++++--- interfaces/matlab_experimental/Reactor/Wall.m | 2 ++ 8 files changed, 43 insertions(+), 31 deletions(-) diff --git a/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m b/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m index 0b45ee3aaaa..9445c7ac973 100644 --- a/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m +++ b/interfaces/matlab_experimental/Reactor/ConstPressureReactor.m @@ -10,7 +10,6 @@ % % .. code-block:: matlab % - % r1 = ConstPressureReactor % an empty reactor % r2 = ConstPressureReactor(contents) % a reactor containing contents % % See also: :mat:class:`Reactor` @@ -22,14 +21,14 @@ methods - function r = ConstPressureReactor(contents) + function r = ConstPressureReactor(contents, name) % Constructor - if nargin == 0 - contents = 0; + if nargin < 2 + name = '(none)' end - r@Reactor(contents, 'ConstPressureReactor'); + r@Reactor(contents, 'ConstPressureReactor', name); end end diff --git a/interfaces/matlab_experimental/Reactor/FlowReactor.m b/interfaces/matlab_experimental/Reactor/FlowReactor.m index 60652cb5679..1220ee58030 100644 --- a/interfaces/matlab_experimental/Reactor/FlowReactor.m +++ b/interfaces/matlab_experimental/Reactor/FlowReactor.m @@ -8,26 +8,27 @@ % % .. code-block:: matlab % - % r1 = FlowReactor % an empty reactor % r2 = FlowReactor(gas) % a reactor containing a gas % % See also: :mat:class:`Reactor` % % :param contents: % Cantera :mat:class:`Solution` to be set as the contents of the reactor. + % :param name: + % Reactor name (optional; default is ``(none)``). % :return: % Instance of class :mat:class:`FlowReactor`. methods - function r = FlowReactor(contents) + function r = FlowReactor(contents, name) % Constructor - if nargin == 0 - contents = 0; + if nargin < 2 + name = '(none)' end - r@Reactor(contents, 'FlowReactor'); + r@Reactor(contents, 'FlowReactor', name); end end diff --git a/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m b/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m index fdbb703fdf6..190ad39b80e 100644 --- a/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m +++ b/interfaces/matlab_experimental/Reactor/IdealGasConstPressureReactor.m @@ -13,7 +13,6 @@ % % .. code-block:: matlab % - % r1 = IdealGasConstPressureReactor % an empty reactor % r2 = IdealGasConstPressureReactor(gas) % a reactor containing a gas % % See also: :mat:class:`Reactor` @@ -25,14 +24,14 @@ methods - function r = IdealGasConstPressureReactor(contents) + function r = IdealGasConstPressureReactor(contents, name) % Constructor - if nargin == 0 - contents = 0; + if nargin < 2 + name = '(none)'; end - r@Reactor(contents, 'IdealGasConstPressureReactor'); + r@Reactor(contents, 'IdealGasConstPressureReactor', name); end end diff --git a/interfaces/matlab_experimental/Reactor/IdealGasReactor.m b/interfaces/matlab_experimental/Reactor/IdealGasReactor.m index 1ba96fdf2c8..e2e9a51c17f 100644 --- a/interfaces/matlab_experimental/Reactor/IdealGasReactor.m +++ b/interfaces/matlab_experimental/Reactor/IdealGasReactor.m @@ -9,7 +9,6 @@ % % .. code-block:: matlab % - % r1 = IdealGasReactor % an empty reactor % r2 = IdealGasReactor(gas) % a reactor containing a gas % % See also: :mat:class:`Reactor` @@ -21,14 +20,14 @@ methods - function r = IdealGasReactor(contents) + function r = IdealGasReactor(contents, name) % Constructor - if nargin == 0 - contents = 0; + if nargin < 2 + name = '(none)'; end - r@Reactor(contents, 'IdealGasReactor'); + r@Reactor(contents, 'IdealGasReactor', name); end end diff --git a/interfaces/matlab_experimental/Reactor/MassFlowController.m b/interfaces/matlab_experimental/Reactor/MassFlowController.m index c6f9f0c243c..db319a991dd 100644 --- a/interfaces/matlab_experimental/Reactor/MassFlowController.m +++ b/interfaces/matlab_experimental/Reactor/MassFlowController.m @@ -17,17 +17,23 @@ % Upstream :mat:class:`Reactor` or :mat:class:`Reservoir`. % :param downstream: % Downstream :mat:class:`Reactor` or :mat:class:`Reservoir`. + % :param name: + % Flow device name (optional; default is ``(none)``). % :return: % Instance of class :mat:class:`FlowDevice`. methods - function m = MassFlowController(upstream, downstream) + function m = MassFlowController(upstream, downstream, name) % Constructor - m@FlowDevice('MassFlowController'); + if nargin < 3 + name = '(none)'; + end + + m@FlowDevice('MassFlowController', name); - if nargin == 2 + if nargin >= 2 m.install(upstream, downstream) end diff --git a/interfaces/matlab_experimental/Reactor/Reservoir.m b/interfaces/matlab_experimental/Reactor/Reservoir.m index 8097fe3fd7a..148480ad8ee 100644 --- a/interfaces/matlab_experimental/Reactor/Reservoir.m +++ b/interfaces/matlab_experimental/Reactor/Reservoir.m @@ -14,26 +14,27 @@ % % .. code-block:: matlab % - % r1 = Reservoir % an empty reservoir % r2 = Reservoir(gas) % a reservoir containing a gas % % See also: :mat:class:`Reactor` % % :param contents: % Cantera :mat:class:`Solution` to be set as the contents of the reactor. + % :param name: + % Reservoir name (optional; default is ``(none)``). % :return: % Instance of class :mat:class:`Reactor`. methods - function r = Reservoir(contents) + function r = Reservoir(contents, name) % Constructor - if nargin == 0 - contents = 0; + if nargin < 2 + name = '(none)'; end - r@Reactor(contents, 'Reservoir'); + r@Reactor(contents, 'Reservoir', name); end end diff --git a/interfaces/matlab_experimental/Reactor/Valve.m b/interfaces/matlab_experimental/Reactor/Valve.m index 2a9bef3d2a7..1d938599b27 100644 --- a/interfaces/matlab_experimental/Reactor/Valve.m +++ b/interfaces/matlab_experimental/Reactor/Valve.m @@ -26,17 +26,22 @@ % Upstream reactor or reservoir. % :param downstream: % Downstream Reactor or reservoir. + % :param name: + % Valve name (optional; default is ``(none)``). % :return: % Instance of class :mat:class:`FlowDevice`. methods - function v = Valve(upstream, downstream) + function v = Valve(upstream, downstream, name) % Constructor - v@FlowDevice('Valve'); + if nargin < 3 + name = '(none)'; + end + v@FlowDevice('Valve', name); - if nargin == 2 + if nargin >= 2 v.install(upstream, downstream) end diff --git a/interfaces/matlab_experimental/Reactor/Wall.m b/interfaces/matlab_experimental/Reactor/Wall.m index 4712dc1e2da..a6b10fbefe7 100644 --- a/interfaces/matlab_experimental/Reactor/Wall.m +++ b/interfaces/matlab_experimental/Reactor/Wall.m @@ -40,6 +40,8 @@ % :param r: % Instance of class :mat:class:`Reactor` to be used as the bulk phase % on the right side of the wall. + % :param name: + % Wall name (optional; default is ``(none)``). % :return: % Instance of class :mat:class:`Wall`.