Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 49 additions & 6 deletions +combustiontoolbox/+core/@ChemicalSystem/ChemicalSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
propertiesMatrix % Properties matrix
propertyVector % Property vector
indexSpecies % Index of species
indexGas % Indeces gaseous species
indexCondensed % Indeces condensed species
indexCryogenic % Indeces cryogenic liquified species
indexIons % Indeces ionized species in species
indexReact % Indeces react species
indexFrozen % Indeces inert/frozen species
indexGas % Indices gaseous species
indexCondensed % Indices condensed species
indexCryogenic % Indices cryogenic liquified species
indexIons % Indices ionized species in species
indexReact % Indices react species
indexFrozen % Indices inert/frozen species
listSpeciesLean = {'CO2', 'H2O', 'N2', 'Ar', 'O2'} % List of species for a lean complete combustion (equivalence ratio < 1)
listSpeciesRich = {'CO2', 'H2O', 'N2', 'Ar', 'CO', 'H2'} % List of species for a rich complete combustion (equivalence ratio > 1)
listSpeciesSoot = {'N2', 'Ar', 'CO', 'H2', 'Cbgrb'} % List of species for a roch complete combustion with soot formation (equivalence ratio > equivalence ratio soot)
Expand Down Expand Up @@ -587,6 +587,49 @@

end

function [index, numSpecies] = filterSpeciesTemperatureRange(obj, T, index, numSpecies, FLAG_EXTRAPOLATE)
% Remove species indices out of the temperature range if FLAG_EXTRAPOLATE = false,
% e.g., extrapolation of the polynomial fits is not allowed.
%
% Args:
% obj (ChemicalSystem): Chemical system object
% T (float): Temperature
% index (float): Vector with the species indices
% numSpecies (float): Number of species
% FLAG_EXTRAPOLATE (bool): Flag indicating extrapolation of the polynomials fits is allowed
%
% Returns:
% Tuple containing:
%
% * index (float): Updated vector with the species indices
% * numSpecies (float): Update number of species

% Check if FLAG_EXTRAPOLATE is true
if FLAG_EXTRAPOLATE
return
end

% Definitions
DB = obj.species;

% Initialization
temperatureMatrix = zeros(numSpecies, 2);

% Remove species outside the bounds
for i = numSpecies:-1:1
species = obj.listSpecies{index(i)};
temperatureMatrix(i, 1) = DB.(species).T(1);
temperatureMatrix(i, 2) = DB.(species).T(end);
end

% Identify species to remove
FLAG_REMOVE = (T < temperatureMatrix(:, 1)) | (T > temperatureMatrix(:, 2));

% Update index and numSpecies
index = index(~FLAG_REMOVE);
numSpecies = length(index);
end

end

methods (Access = private)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
end

% Remove condensed species with temperature out of bounds
indexCondensed = check_temperature_range(system, T, indexCondensed, NS - NG, false);
indexCondensed = system.filterSpeciesTemperatureRange(T, indexCondensed, NS - NG, false);

% Remove gas species with temperature out of bounds
[indexGas, NG] = check_temperature_range(obj, T, indexGas, NG, obj.FLAG_EXTRAPOLATE);
[indexGas, NG] = system.filterSpeciesTemperatureRange(T, indexGas, NG, obj.FLAG_EXTRAPOLATE);

% First, compute chemical equilibrium with only gaseous species
indexGas_0 = indexGas;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@
end

% Remove condensed species with temperature out of bounds
indexCondensed = check_temperature_range(system, T, indexCondensed, NS - NG, false);
indexCondensed = system.filterSpeciesTemperatureRange(T, indexCondensed, NS - NG, false);

% Remove gas species with temperature out of bounds
[indexGas, NG] = check_temperature_range(obj, T, indexGas, NG, obj.FLAG_EXTRAPOLATE);
[indexGas, NG] = system.filterSpeciesTemperatureRange(T, indexGas, NG, obj.FLAG_EXTRAPOLATE);

% First, compute chemical equilibrium with only gaseous species
indexGas_0 = indexGas;
Expand Down
33 changes: 0 additions & 33 deletions utils/check_temperature_range.m

This file was deleted.