Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update: comments of all the functions #381 #412

Merged
merged 3 commits into from
Apr 2, 2022
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
46 changes: 27 additions & 19 deletions Databases/Functions/FullName2name.m
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
function name = FullName2name(Species)

name = Species;
if isempty(name)
return
function name = FullName2name(species)
% Get full name of the given species
%
% Args:
% species (str): Chemical species
%
% Return:
% name (str): Full name of the given species

name = species;
if isempty(name)
return
end
if name(end)=='+'
name=[name(1:end-1) 'plus'];
elseif name(end)=='-'
name=[name(1:end-1) 'minus'];
end
ind=regexp(name,'[()]');
name(ind)='b';
ind=regexp(name,'[.,+-]');
name(ind)='_';
if regexp(name(1),'[0-9]')
name=['num_' name];
end
ind=regexp(name,'\x27');
name(ind)='_';
end
if name(end)=='+'
name=[name(1:end-1) 'plus'];
elseif name(end)=='-'
name=[name(1:end-1) 'minus'];
end
ind=regexp(name,'[()]');
name(ind)='b';
ind=regexp(name,'[.,+-]');
name(ind)='_';
if regexp(name(1),'[0-9]')
name=['num_' name];
end
ind=regexp(name,'\x27');
name(ind)='_';
568 changes: 292 additions & 276 deletions Databases/Functions/check_DB.m

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion Databases/Functions/compute_interval_NASA.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
function tInterval = compute_interval_NASA(species, T, DB, tRange, ctTInt)
% Compute interval NASA polynomials

%
% Args:
% species (str) : Chemical species
% T (float): Temperature [K]
% DB (struct) : Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits
% tRange (cell): Ranges of temperatures [K]
% ctTInt (float): Number of intervals of temperatures
%
% Returns:
% tInterval (float): Index of the interval of temperatures

tInterval = [];
if DB.(species).ctTInt > 0
for j = 1:ctTInt
Expand Down
42 changes: 24 additions & 18 deletions Databases/Functions/detect_location_of_phase_specifier.m
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
function n_open_parenthesis = detect_location_of_phase_specifier(Species)
function index_open_parenthesis = detect_location_of_phase_specifier(species)
% Detect the location of the opening pharenthesis of the phase identifier (if any)
%
% Args:
% species (str): Chemical species
%
% Returns:
% n_open_parenthesis (float): Index of the location of the open parenthesis

% Detect the location of the opening pharentesis of the phase identifier (if any)

if ~isempty(find(Species(:)=='(', 1)) % If the species name includes parenthesis
n_open_parenthesis = find(Species(:)=='('); % then detect the location of the open parenthesis
n_close_parenthesis = find(Species(:)==')'); % and detect the location of the closing parenthesis
if n_close_parenthesis(end) == length(Species(:)) % If there is a closing parenthesis at the end of the species name, then it must be the closing parenthesis of the phase specifier
n_open_parenthesis = n_open_parenthesis(end); % then the phase specifier begins with the last parenthesys
else % Some other times, the phase specifier is located before a short alphabetic name (e.g., 'C8H18(L),isooct') which is always preceeded by a comma
n_comma = find(Species(:)==','); % Detect the location of the comma (if any)
if ~isempty(n_comma) % If there is a comma (e.g., 'C8H18(L),isooct') then the last parenthesis may be the phase specifier as well, even though it is not located at the end of the species name
if (n_comma-n_close_parenthesis(end)) == 1 % however, this is only true if the last parenthesis is just followed by the comma
n_open_parenthesis = n_open_parenthesis(end); % then the phase specifier begins also with the last parenthesys
if ~isempty(find(species(:)=='(', 1)) % If the species name includes parenthesis
index_open_parenthesis = find(species(:)=='('); % then detect the location of the open parenthesis
index_close_parenthesis = find(species(:)==')'); % and detect the location of the closing parenthesis
if index_close_parenthesis(end) == length(species(:)) % If there is a closing parenthesis at the end of the species name, then it must be the closing parenthesis of the phase specifier
index_open_parenthesis = index_open_parenthesis(end); % then the phase specifier begins with the last parenthesys
else % Some other times, the phase specifier is located before a short alphabetic name (e.g., 'C8H18(L),isooct') which is always preceeded by a comma
index_comma = find(species(:)==','); % detect the location of the comma (if any)
if ~isempty(index_comma) % If there is a comma (e.g., 'C8H18(L),isooct') then the last parenthesis may be the phase specifier as well, even though it is not located at the end of the species name
if (index_comma-index_close_parenthesis(end)) == 1 % However, this is only true if the last parenthesis is just followed by the comma
index_open_parenthesis = index_open_parenthesis(end); % then the phase specifier begins also with the last parenthesys
else
index_open_parenthesis = length(species)+1; % Valid for species names w/o phase specifiers
end
else
n_open_parenthesis = length(Species)+1; % valid for species names w/o phase specifiers
index_open_parenthesis = length(species)+1; % Valid for species names w/o phase specifiers
end
else
n_open_parenthesis = length(Species)+1; % valid for species names w/o phase specifiers
end
else
index_open_parenthesis = length(species)+1; % Valid for species names w/o phase specifiers
end
else
n_open_parenthesis = length(Species)+1; % valid for species names w/o phase specifiers
end
2 changes: 1 addition & 1 deletion Databases/Functions/generate_DB.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% DB_master (struct): Database with the thermodynamic data of the chemical species
%
% Returns:
% DB: Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits
% DB (struct): Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

if ~exist('DB', 'var')
if exist('DB.mat', 'file')
Expand Down
Loading