-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1000 from CombustionToolbox/oop
- Loading branch information
Showing
165 changed files
with
536 additions
and
519,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function gamma = getAdiabaticIndex(obj, T) | ||
% Compute adiabatic index of the species [-] at the given temperature | ||
% [K] using piecewise cubic Hermite interpolating polynomials and | ||
% linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% gamma (float): Adiabatic index [-] | ||
% | ||
% Example: | ||
% gamma = getAdiabaticIndex(obj, 300) | ||
|
||
gamma = getHeatCapacityPressure(obj, T) ./ getHeatCapacityVolume(obj, T); | ||
|
||
assert(any(~isnan(gamma)), 'Adibatic index equal NaN'); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function h0 = getEnthalpy(obj, T) | ||
% Compute enthalpy [J/mol] of the species at the given temperature [K] | ||
% using piecewise cubic Hermite interpolating polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% h0 (float): Enthalpy in molar basis [J/mol] | ||
% | ||
% Example: | ||
% h0 = getEnthalpy(obj, 300) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedH0curves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedH0curves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
h0curve = obj.h0curve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedH0curves{end+1} = h0curve; | ||
else | ||
% Retrieve cached data | ||
h0curve = cachedH0curves{index}; | ||
end | ||
|
||
% Compute enthalpy [J/mol] | ||
h0 = h0curve(T); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function s0 = getEntropy(obj, T) | ||
% Compute entropy [J/(mol-K)] of the species at the given temperature [K] | ||
% using piecewise cubic Hermite interpolating polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% s0 (float): Entropy in molar basis [J/(mol-K)] | ||
% | ||
% Example: | ||
% s0 = getEntropy(obj, 300) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedS0curves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedS0curves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
s0curve = obj.s0curve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedS0curves{end+1} = s0curve; | ||
else | ||
% Retrieve cached data | ||
s0curve = cachedS0curves{index}; | ||
end | ||
|
||
% Compute entropy [J/(mol-K)] | ||
s0 = s0curve(T); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function g0 = getGibbsEnergy(obj, T) | ||
% Compute Gibbs energy [J/mol] of the species at the given temperature [K] | ||
% using piecewise cubic Hermite interpolating polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% species (char): Chemical species | ||
% T (float): Temperature [K] | ||
% DB (struct): Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits | ||
% | ||
% Returns: | ||
% g0 (float): Gibbs energy in molar basis [J/mol] | ||
% | ||
% Example: | ||
% g0 = getGibbsEnergy('H2O', 298.15, DB) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedG0curves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedG0curves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
g0curve = obj.g0curve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedG0curves{end+1} = g0curve; | ||
else | ||
% Retrieve cached data | ||
g0curve = cachedG0curves{index}; | ||
end | ||
|
||
% Compute Gibbs energy [J/mol] | ||
g0 = g0curve(T); | ||
end |
38 changes: 38 additions & 0 deletions
38
+combustiontoolbox/+core/@Species/getHeatCapacityPressure.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function cp = getHeatCapacityPressure(obj, T) | ||
% Compute specific heat at constant pressure [J/(mol-K)] of the species | ||
% at the given temperature [K] using piecewise cubic Hermite | ||
% interpolating polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% cp (float): Specific heat at constant pressure in molar basis [J/(mol-K)] | ||
% | ||
% Example: | ||
% cp = getHeatCapacityPressure(obj, 300) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedCPcurves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedCPcurves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
cpcurve = obj.cpcurve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedCPcurves{end+1} = cpcurve; | ||
else | ||
% Retrieve cached data | ||
cpcurve = cachedCPcurves{index}; | ||
end | ||
|
||
% Compute specific heat at constant pressure [J/(mol-K)] | ||
cp = cpcurve(T); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function cv = getHeatCapacityVolume(obj, T) | ||
% Compute specific heat at constant volume [J/(mol-K)] of the species | ||
% at the given temperature [K] using piecewise cubic Hermite | ||
% interpolating polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% cv (float): Specific heat at constant volume in molar basis [J/(mol-K)] | ||
% | ||
% Example: | ||
% cv = getHeatCapacityVolume(obj, 300) | ||
|
||
% Universal gas constant [J/(mol-K)] | ||
R0 = combustiontoolbox.common.Constants.R0; | ||
|
||
% Compute specific heat at constant volume [J/(mol-K)] | ||
cv = getHeatCapacityPressure(obj, T) - R0; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function e0 = getInternalEnergy(obj, T) | ||
% Compute internal energy [J/mol] of the species at the given | ||
% temperature [K] using piecewise cubic Hermite interpolating | ||
% polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% e0 (float): Internal energy in molar basis [J/mol] | ||
% | ||
% Example: | ||
% e0 = getInternalEnergy(obj, 300) | ||
|
||
% Universal gas constant [J/(K mol)] | ||
R0 = combustiontoolbox.common.Constants.R0; | ||
|
||
% Enthalpy [J/mol] | ||
h0 = getEnthalpy(obj, T); | ||
|
||
% Internal energy [J/mol] | ||
e0 = h0 - R0 * T; | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function DhT = getThermalEnthalpy(obj, T) | ||
% Compute thermal enthalpy [J/mol] of the species at the given | ||
% temperature [K] using piecewise cubic Hermite interpolating | ||
% polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% DhT (float): Thermal enthalpy in molar basis [J/mol] | ||
% | ||
% Example: | ||
% DhT = getThermalEnthalpy(obj, 300) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedDHTcurves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedDHTcurves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
DhTcurve = obj.DhTcurve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedDHTcurves{end+1} = DhTcurve; | ||
else | ||
% Retrieve cached data | ||
DhTcurve = cachedDHTcurves{index}; | ||
end | ||
|
||
% Compute thermal enthalpy [J/mol] | ||
DhT = DhTcurve(T); | ||
end |
38 changes: 38 additions & 0 deletions
38
+combustiontoolbox/+core/@Species/getThermalInternalEnergy.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function DeT = getThermalInternalEnergy(obj, T) | ||
% Compute thermal internal energy [J/mol] of the species at the given | ||
% temperature [K] using piecewise cubic Hermite interpolating | ||
% polynomials and linear extrapolation | ||
% | ||
% Args: | ||
% obj (Species): Species object | ||
% T (float): Temperature [K] | ||
% | ||
% Returns: | ||
% DeT (float): Thermal internal energy in molar basis [J/mol] | ||
% | ||
% Example: | ||
% DeT = getThermalInternalEnergy(obj, 300) | ||
|
||
persistent cachedSpecies; | ||
persistent cachedDETcurves; | ||
|
||
if isempty(cachedSpecies) | ||
cachedSpecies = {}; | ||
cachedDETcurves = {}; | ||
end | ||
|
||
% Check if species data is already cached | ||
index = find(strcmp(cachedSpecies, obj.name), 1); | ||
if isempty(index) | ||
% Load species data and cache it | ||
DeTcurve = obj.DeTcurve; | ||
cachedSpecies{end+1} = obj.name; | ||
cachedDETcurves{end+1} = DeTcurve; | ||
else | ||
% Retrieve cached data | ||
DeTcurve = cachedDETcurves{index}; | ||
end | ||
|
||
% Compute thermal internal energy [J/mol] | ||
DeT = DeTcurve(T); | ||
end |
Oops, something went wrong.