From 4ac5bdf707174e95c2450ff546a88c8e12c97e65 Mon Sep 17 00:00:00 2001 From: ssun30 Date: Fri, 9 Sep 2022 19:57:58 -0400 Subject: [PATCH] Deleted unnecessay code and added Cantera version info in LoadCantera --- .../matlab_experimental/Base/Interface.m | 2 - .../matlab_experimental/Phases/importEdge.m | 33 ----------- .../Phases/importInterface.m | 24 -------- .../matlab_experimental/Utility/LoadCantera.m | 3 +- samples/matlab_experimental/catcomb.m | 2 +- samples/matlab_experimental/diamond_cvd.m | 2 +- samples/matlab_experimental/rankine.m | 59 +++++++++++-------- samples/matlab_experimental/surfreactor.m | 2 +- 8 files changed, 40 insertions(+), 87 deletions(-) delete mode 100644 interfaces/matlab_experimental/Phases/importEdge.m delete mode 100644 interfaces/matlab_experimental/Phases/importInterface.m diff --git a/interfaces/matlab_experimental/Base/Interface.m b/interfaces/matlab_experimental/Base/Interface.m index 17f6becd5..0617ae147 100644 --- a/interfaces/matlab_experimental/Base/Interface.m +++ b/interfaces/matlab_experimental/Base/Interface.m @@ -12,8 +12,6 @@ classdef Interface < handle & ThermoPhase & Kinetics % INTERFACE Interface class constructor. % s = Interface(src, id, p1, p2, p3, p4) % - % See also: :mat:func:`importEdge`, :mat:func:`importInterface` - % % :param src: % YAML file containing the interface or edge phase. % :param id: diff --git a/interfaces/matlab_experimental/Phases/importEdge.m b/interfaces/matlab_experimental/Phases/importEdge.m deleted file mode 100644 index fefd51236..000000000 --- a/interfaces/matlab_experimental/Phases/importEdge.m +++ /dev/null @@ -1,33 +0,0 @@ -function s = importEdge(file, name, phase1, phase2, phase3, phase4) - % Import edges between phases. - % s = importEdge(file, name, phase1, phase2, phase3, phase4) - % Supports up to four neighbor phases. See - % - % :param file: - % File containing phases - % :param name: - % Name of phase - % :param phase1: - % First neighbor phase - % :param phase2: - % Second neighbor phase - % :param phase3: - % Third neighbor phase - % :param phase4: - % Fourth neighbor phase - % :return: - % Instance of class :mat:func:`Interface` - % - - if nargin == 3 - s = Interface(file, name, phase1); - elseif nargin == 4 - s = Interface(file, name, phase1, phase2); - elseif nargin == 5 - s = Interface(file, name, phase1, phase2, phase3); - elseif nargin == 6 - s = Interface(file, name, phase1, phase2, phase3, phase4); - else - error('importEdge only supports 4 neighbor phases.'); - end -end diff --git a/interfaces/matlab_experimental/Phases/importInterface.m b/interfaces/matlab_experimental/Phases/importInterface.m deleted file mode 100644 index cbfe82db3..000000000 --- a/interfaces/matlab_experimental/Phases/importInterface.m +++ /dev/null @@ -1,24 +0,0 @@ -function s = importInterface(file, name, phase1, phase2) - % Import an interface between phases. - % s = importInterface(file, name, phase1, phase2) - % - % :param file: - % YAML file containing the interface - % :param name: - % Name of the interface to import - % :param phase1: - % First phase in the interface - % :param phase2: - % Second phase in the interface - % :return: - % Instance of class :mat:func:`Interface` - % - - if nargin == 3 - s = Interface(file, name, phase1); - elseif nargin == 4 - s = Interface(file, name, phase1, phase2); - else - error('importInterface only supports 2 bulk phases'); - end -end diff --git a/interfaces/matlab_experimental/Utility/LoadCantera.m b/interfaces/matlab_experimental/Utility/LoadCantera.m index 5634c6397..fe25f505a 100644 --- a/interfaces/matlab_experimental/Utility/LoadCantera.m +++ b/interfaces/matlab_experimental/Utility/LoadCantera.m @@ -20,5 +20,6 @@ if ~libisloaded(ct) 'ctonedim','addheader','ctreactor', ... 'addheader','ctrpath','addheader','ctsurf'); end -disp('Cantera is ready for use'); +ct_ver = canteraVersion; +sprintf('%s is ready for use.', ct_ver); clear all diff --git a/samples/matlab_experimental/catcomb.m b/samples/matlab_experimental/catcomb.m index e44bd755b..be356bd43 100644 --- a/samples/matlab_experimental/catcomb.m +++ b/samples/matlab_experimental/catcomb.m @@ -73,7 +73,7 @@ gas.TPX = {tinlet, p, comp1}; % mechanism of Deutschmann et al., 1995 for catalytic combustion on % platinum. -surf_phase = importInterface('ptcombust.yaml', 'Pt_surf', gas); +surf_phase = Interface('ptcombust.yaml', 'Pt_surf', gas); surf_phase.T = tsurf; % integrate the coverage equations in time for 1 s, holding the gas diff --git a/samples/matlab_experimental/diamond_cvd.m b/samples/matlab_experimental/diamond_cvd.m index c18376de1..54d37c208 100644 --- a/samples/matlab_experimental/diamond_cvd.m +++ b/samples/matlab_experimental/diamond_cvd.m @@ -53,7 +53,7 @@ mw = dbulk.MolecularWeights; % rates. It will be created from the interface definition 'diamond_100' % in input file 'diamond.yaml'. -surf_phase = importInterface('diamond.yaml', 'diamond_100', gas, dbulk); +surf_phase = Interface('diamond.yaml', 'diamond_100', gas, dbulk); %% Advance Coverages diff --git a/samples/matlab_experimental/rankine.m b/samples/matlab_experimental/rankine.m index e6b976bf9..4607ca8d0 100644 --- a/samples/matlab_experimental/rankine.m +++ b/samples/matlab_experimental/rankine.m @@ -1,36 +1,47 @@ -function [work, efficiency] = rankine(t1, p2, eta_pump, eta_turbine) - % This example computes the efficiency of a simple vapor power cycle. - % - % Keywords: thermodynamics, thermodynamic cycle, non-ideal fluid +% RANKINE - This example computes the efficiency of a simple vapor power cycle. +% +% Keywords: thermodynamics, thermodynamic cycle, non-ideal fluid - help rankine +clear all +close all +cleanup - % create an object representing water - w = Water; +help rankine - % start with saturated liquid water at t1 - w.setState_Tsat(t1, 1.0); - p1 = w.P; +% Initialize parameters +eta_pump = 0.6; +eta_turbine = 0.8; +p_max = 8.0 * oneatm; - % pump it to p2 - basis = 'mass'; - pump_work = pump(w, p2, eta_pump); - h2 = w.H; - p2 = w.P; +% create an object representing water +w = Water; - % heat to saturated vapor - w.setState_Psat(p2, 1.0); - h3 = w.H; +% start with saturated liquid water at t1 +basis = 'mass'; +w.setState_Tsat(t1, 1.0); +h1 = w.H; +p1 = w.P; +w - heat_added = h3 - h2; +% pump it to p2 +pump_work = pump(w, p_max, eta_pump); +h2 = w.H; +w - % expand adiabatically back to the initial pressure - work = expand(w, p1, eta_turbine); +% heat to saturated vapor +w.setState_Psat(p_max, 1.0); +h3 = w.H; +w - % compute the efficiency - efficiency = (work - pump_work)/heat_added; -end +heat_added = h3 - h2; +% expand adiabatically back to the initial pressure +turbine_work = w.expand(p1, eta_turbine); +w + +% compute the efficiency +efficiency = (turbine_work - pump_work)/heat_added; +disp('efficiency = ', eff); function w = pump(fluid, pfinal, eta) % PUMP - Adiabatically pump a fluid to pressure pfinal, using a pump diff --git a/samples/matlab_experimental/surfreactor.m b/samples/matlab_experimental/surfreactor.m index fb890c5c8..3ed133eb4 100644 --- a/samples/matlab_experimental/surfreactor.m +++ b/samples/matlab_experimental/surfreactor.m @@ -25,7 +25,7 @@ gas.TPX = {t, oneatm, 'CH4:0.01, O2:0.21, N2:0.78'}; % The surface reaction mechanism describes catalytic combustion of % methane on platinum, and is from Deutschman et al., 26th % Symp. (Intl.) on Combustion,1996, pp. 1747-1754 -surf = importInterface('ptcombust.yaml','Pt_surf', gas); +surf = Interface('ptcombust.yaml','Pt_surf', gas); surf.T = t; nsp = gas.nSpecies;