Utilities#

A collection of routines with multiple purposes organized as follows:

  • unclasified

  • databases

  • display

  • eos

  • export

  • extensions

  • root_finding

  • thermo

  • validations

Unclasified utility functions#

A collection of unclasified functions necessary to perform all the calculations in CT.


Routines
Compute_YFuel(mix, mix_Fuel)#

Compute fuel mass fraction [-]

Parameters:
  • mix (struct) – Properties of the mixture (fuel + oxidizer + inerts)

  • mix_Fuel (struct) – Properties of the mixture (fuel)

Returns:

Yi_Fuel (float) – Mass fractions of the fuel mixture

Compute_density(mix)#

Get density of the set of mixtures

Parameters:

mix (struct) – Properties of the mixture/s

Returns:

rho (float) – Vector with the densities of all the mixtures

GPL()#

Return Combustion Toolbox license

Parameters:

none (empty) –

Returns:

license_content (str) – license content

abundances2moles(elements, filename, varargin)#

Read solar abundances in log 10 scale and compute the initial molar fractions in the mixture [-]

Parameters:
  • elements (cell) – List with the given elements

  • filename (file) – Filename with the data

Optional Args:

metallicity (float): Metallicity

Returns:

moles (float) – moles relative to H of the remaining elements in the mixture

append_cells(cell1, cell2, varargin)#

Append two or more cells in one common cell

Parameters:
  • cell1 (struct) – Cell 1

  • cell2 (struct) – Cell 2

Optional Args:

celli (struct): Additional cells

Returns:

append_cell (struct) – Merged cell

append_structs(s1, s2, varargin)#

Append two or more structs in one common struct

Parameters:
  • s1 (struct) – Struct 1

  • s2 (struct) – Struct 2

Optional Args:

si (struct): Additional structs

Returns:

append_s (struct) – Merged struct

ask_problem(self)#

Create a list selection dialog box

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

PT (string) – String with the problem selected

assign_vector2cell(cell, vector, varargin)#

Assign values of a vector into a cell

Parameters:
  • cell (cell) – Cell in which the values of the given vector are going to be included

  • vector (any) – Vector with the values that are going to be included in the cell

Optional Args:

ind (float): List of index positions to assign specific positions to the cell

Returns:

cell (cell) – Cell with the values of the given vector

cell2vector(value, varargin)#

Convert values of an individual cell into a vector. If the value correspond with a struct it can return as a vector the values of a given fieldname.

Parameters:

value (cell or struct) – Data of the mixture, conditions, and databases

Optional Args:

field (str): Fieldname of the given value (struct)

Returns:

vector (any) – Vector with the values of the individual cell/fieldname (struct)

check_FOI(self, FOI_species)#

Check that fuel species are contained in the list of products (only for initial computations)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • FOI_species (bool) – Species in the initial mixture (Fuel, Oxidizer, Inert)

Returns:

self (struct) – Data of the mixture, conditions, and databases

check_inputs(self)#

Check that all the inputs are specified

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

check_update(varargin)#

Check if there is a new release of Combustion Toolbox

Optional Args:

fig (uifigure): UIFigure class

Returns:

FLAG_UPDATE (bool) – FLAG indicating true (false) if there is (not) an update of Combustion Toolbox

compute_first_derivative(x, y)#

Compute first central derivate using a non-uniform grid

Parameters:
  • x (float) – Grid values

  • y (float) – Values for the corresponding grid

Returns:

dxdy (float) – Value of the first derivate for the given grid and its corresponding values

compute_phi_c(Fuel)#

Compute guess of equivalence ratio in which soot appears considering complete combustion

Parameters:

Fuel (struct) – Struct mix with all the properties of the Fuel mixture

Returns:

phi_c (float) – Equivalence ratio in which soot appears [-]

compute_properties(self, properties_matrix, p, T)#

Compute properties from the given properties matrix at pressure p [bar] and temperature T [K]

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • properties_matrix (float) – Matrix with the properties of the mixture

  • p (float) – Pressure [bar]

  • T (float) – Temperature [K]

Returns:

mix (struct) – Properties of the mixture

compute_ratio_oxidizers_O2(self)#

Compute ratio oxidizers/O2

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

compute_temperature_mixture(self, species, moles, temperatures)#

Compute equilibrium temperature [K] of a gaseous mixture compound of n species with species at different temperatures.

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (str) – Cell array with the species of the mixture

  • moles – Moles of the species in the mixture [mol]

  • temperatures – Vector or cell array with the temperatures of each species

Returns:

T (float) – Temperature of the mixture at equilibrium

convert_Pa_to_bar(value)#

Convert pressure in [Pa] units to [bar]

Parameters:

value (float) – pressure value(s) in [bar]

Returns:

value (float) – pressure value(s) in [bar]

convert_atm_to_bar(value)#

Convert pressure in [atm] units to [bar]

Parameters:

value (float) – pressure value(s) in [atm]

Returns:

value (float) – pressure value(s) in [bar]

convert_bar_to_Pa(value)#

Convert pressure in [bar] units to [Pa]

Parameters:

value (float) – pressure value(s) in [bar]

Returns:

value (float) – pressure value(s) in [Pa]

convert_bar_to_atm(value)#

Convert pressure in [bar] units to [atm]

Parameters:

value (float) – pressure value(s) in [bar]

Returns:

value (float) – pressure value(s) in [atm]

convert_weight_percentage_to_moles(LS, weight_percentage, DB)#

Convert weight percentage (wt%) to moles

Parameters:
  • LS (cell) – List of species

  • weight_percentage (float) – Weight percentage of the species [%]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

moles (float) – Number of moles [mol]

create_cell_ntimes(varargin)#

Create cell array with the same item n-times

define_F(self)#

Set Fuel of the mixture

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

define_FOI(self, i)#

Set up mixture: fuel, oxidizer and diluent/inert species

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • i (float) – Position of the evaluated problem

Returns:

self (struct) – Data of the mixture, conditions, and databases

define_I(self)#

Set Inert of the mixture

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

define_O(self)#

Set Oxidizer of the mixture

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

docs_CT()#

Open Combustion Toolbox’s documentation in default web browser

Parameters:

none (empty) –

find_ind(LS, species)#

Find the index of the species based on the given list (LS)

Parameters:
  • LS (cell) – List of species

  • species (cell) – Species to find index values

Returns:

index (float) – List with the index of the species based on the given list (LS)

get_FLAG_N(self)#

Flag if the number of moles of fuel, oxidant and inert species is specified. If not, consider 1 mole for the fuel and calculate the remaining moles from the equivalence relation.

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

get_combustion_toolbox_version()#

Get Combustion Toolbox version

get_index_phase_species(self, LS)#

Get index of gaseous, condensed and cryogenic species

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • LS (cell) – Name list species / list of species

Returns:

self (struct) – Data of the mixture, conditions, and databases

get_latest_version_github(user, repo_name)#

Get latest version from a repository from Github.

Parameters:
  • user (char) – Username of the owner of the repository

  • repo_name (char) – Name of the repository

Returns:

Tuple containing

  • release (char): Release tag (latest)

  • git_data (struct): Body data of the request

get_monitor_positions(varargin)#

Routine that gets the position in pixels of the monitor(s) connected to the device

Optional Args:

monitor_id (float): Get position in pixels for the given monitor

Returns:

position (float) – Position of the monitor(s)

get_order(value)#

Get order of magnitude of a number in base 10

Parameters:

value (float) – number in base 10

Returns:

order (float) – order of magnitude of a number in base 10

get_partial_derivative(self, mix)#

Get value of the partial derivative for the set problem type [kJ/K] (HP, EV) or [kJ/K^2] (SP, SV)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix (struct) – Properties of the mixture

Returns:

value (float) – Value of the partial derivative for the set problem type [kJ/K] (HP, EV) or [kJ/K^2] (SP, SV)

get_transformation(self, field)#

Get the corresponding value of the field in Problem Description (PD)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • field (str) – Fieldname in Problem Description (PD)

Returns:

value (float) – Value/s assigned to the field

get_typeSpecies(self)#

Create cell array with the type of species in the mixture

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

list_phase_species(self, LS)#

Establish cataloged list of species according to the state of the phase (gaseous or condensed). It also obtains the indices of cryogenic liquid species, i.e., liquified gases.

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • LS (cell) – List of species

Returns:

self (struct) – Data of the mixture, conditions, and databases

post_results(self)#

Postprocess all the results with predefined plots

Parameters:

self (struct) – Data of the mixture, conditions, and databases

print_error(ME, varargin)#

Print message error

Parameters:

ME (obj) – MException object that allows to identify the error

Optional Args:

message_solution (str): Message solution

Reutnrs:

error_message (str): Message error

read_abundances(filename)#

Read solar abundances file Format: [number element, element, abundance, name, molar mass (g/mol)]

Parameters:

filename (file) – Filename with the data

Returns:

Tuple containing

  • abundances (float): Vector with the logarithmic base 10 solar abundances

  • elements (cell): List with the given elements

reorganize_index_phase_species(self, LS)#

Reorginize index of gaseous, condensed and cryogenic species

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • LS (cell) – Name list species / list of species

Returns:

self (struct) – Data of the mixture, conditions, and databases

set_air(self, FLAG_IDEAL_AIR)#

Incluide air in the initial mixture

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • FLAG_IDEAL_AIR (bool) – Flag indicating consider ideal or non-ideal air mixture

Returns:

self (struct) – Data of the mixture, conditions, and databases

set_prop(self, varargin)#

Assign property values to the respective variables

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Optional Args:
  • field (str): Fieldname in Problem Description (PD)

  • value (float): Value/s to assing in the field in Problem Description (PD)

Returns:

self (struct) – Data of the mixture, conditions, and databases

set_react_index(self, species)#

Set index of no frozen (react) and frozen species

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (str) – Frozen species

Returns:

self (struct) – Data of the mixture, conditions, and databases

set_species(self, species, moles, T)#

Fill the properties matrix with the data of the mixture

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (cell) – Species contained in the system

  • moles (float) – Moles of the species in the mixture [mol]

  • T (float) – Temperature [K]

Returns:

properties_matrix (float) – Properties matrix

set_species_initilize(self, species)#

Fill the properties matrix with the data of the mixture

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (cell) – Species contained in the system

Returns:

properties_matrix (float) – Properties matrix

set_transformation(self, field, value)#

Set the corresponding value of the field in Problem Description (PD)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • field (str) – Fieldname in Problem Description (PD)

  • value (float) – Value/s to assign to the field

Returns:

self (struct) – Data of the mixture, conditions, and databases

setup_segregated_solver(self, LS)#

Get additional inputs necessary to use the segregated model

smooth_data(x, y, start_point)#

Prepare data for curve fitting

solve_problem(self, ProblemType)#

Solve the given ProblemType with the conditions and mixture specified in self

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • ProblemType (str) – Tag of the problem to solve

Returns:

self (struct) – Data of the mixtures (initial and final), conditions, databases

soundspeed_eq(self, mix, P0, T0)#

Compute speed of sound at equilibrium

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix (struct) – Struct mix with all the properties of the mixture

  • P0 (float) – Pressure [bar]

  • T0 (float) – Temperature [K]

Returns:

sound (float) – sound speed [m/s]

stoich_prop_matrix(self)#

Initialize the stoichiometric matrix and properties matrix

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Returns:

self (struct) – Data of the mixture, conditions, and databases

vector2cell(value)#

Create cell array from vector

Parameters:

value (any) – Vector with data of any type

Returns:

c (cell) – Cell with the values of the vector

website_CT()#

Open Combustion Toolbox’s website in default web browser

Parameters:

none (empty) –

Database functions#

A collection of functions necessary to obtain generate the databases in CT.


Routines
FullName2name(species)#

Get full name of the given species

Parameters:

species (str) – Chemical species

Returns:

name (str) – Full name of the given species

check_DB(self, DB_master, DB, varargin)#

Include not defined species in database from master database

Parameters:
  • self (struct) – struct with elements data

  • DB_master (struct) – Database with the thermodynamic data of the chemical species

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Optional Args:

LS_check (cell)

Returns:

Tuple containing

  • DB (struct): Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

  • E (struct): Elements data

  • S (struct): Slements data

  • C (struct): Constant data

compute_change_moles_gas_reaction(element_matrix, swtCondensed)#

In order to compute the internal energy of formation from the enthalpy of formation of a given species, we must determine the change in moles of gases during the formation reaction of a mole of that species starting from the elements in their reference state.

Notes: The only elements that are stable as diatomic gases are elements 1 (H), 8 (N), 9 (O), 10 (F), and 18 (Cl). The remaining elements that are stable as (monoatomic) gases are the noble gases He (3), Ne (11), Ar (19), Kr (37), Xe (55), and Rn (87), which do not form any compound.

Parameters:
  • element_matrix (float) – Element matrix of the species

  • swtCondensed (float) – 0 or 1 indicating gas or condensed species

Returns:

Delta_n (float) – Change in moles of gases during the formation reaction of a mole of that species starting from the elements in their reference state

compute_interval_NASA(species, T, DB, tRange, ctTInt)#

Compute interval NASA polynomials

Parameters:
  • 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

detect_location_of_phase_specifier(species)#

Detect the location of the opening pharenthesis of the phase identifier (if any)

Parameters:

species (str) – Chemical species

Returns:

n_open_parenthesis (float) – Index of the location of the open parenthesis

find_species_LS(LS, cond_with, type_with, cond_without, type_without)#

Find species in the given list that contain all/any elements of cond_with and that not include all/any elements of cond_without

Parameters:
  • LS (cell) – List of species

  • cond_with (cell) – List of elements to include

  • type_with (str) – Satisfy all or any of the elements in cond_with

  • cond_without (cell) – List of elements to avoid

  • type_without (str) – Satisfy all or any of the elements in cond_without

Returns:

LS (cell) – List of species

Examples

LS = find_species_LS(LS, {‘C’,’N’,’O’,’minus’,’plus’,’Ar’}, ‘any’,…
{‘I’, ‘S’, ‘L’, ‘T’, ‘P’, ‘F’, ‘ab’, ‘W’,…

‘Z’,’X’,’R’,’Os’,’Cr’,’H’,’Br’,’G’,’K’,… ‘U’,’Co’,’Cu’,’B’,’V’,’Ni’,’Na’,’Mg’,… ‘Mo’,’Ag’,’Nb’,’Cb’,’Cl’,’D’,’T’,… ‘Ca’,’Cs’,’Ne’,’Cd’,’Mn’}, ‘all’)

generate_DB(DB_master)#

Generate Database (DB) with thermochemical interpolation curves for the species contained in DB_master

Parameters:

DB_master (struct) – Database with the thermodynamic data of the chemical species

Returns:

DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

generate_DB_Theo()#

Generate database for theoretical computation of the jump conditions of a diatomic species only considering dissociation.

Returns:

DB_Theo (struct) – Database with quantum data of several diatomic species

generate_DB_master(varargin)#

Generate Mater Database (DB_master) with the thermodynamic data of the chemical species

Optional args:
  • reducedDB (flag): Flag indicating reduced database

  • thermoFile (file): File with NASA’s thermodynamic database

Returns:

DB_master (struct) – Database with the thermodynamic data of the chemical species

generate_DB_master_reduced(DB_master)#

Generate Reduced Mater Database (DB_master_reduced) with the thermodynamic data of the chemical species

Parameters:

DB_master (struct) – Database with the thermodynamic data of the chemical species

Returns:

DB_master_reduced (struct) – Reduced database with the thermodynamic data of the chemical species

get_g0(self, species, T, DB)#

Compute Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • self (str) – Data of the mixture, conditions, and databases

  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

g0 (float) – Gibbs energy [kJ/mol]

get_interval(species, T, DB)#

Get interval of the NASA’s polynomials from the Database (DB) for the given species and temperature [K].

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

tInterval (float) – Index of the interval of temperatures

get_reference_elements_with_T_intervals()#

Get list with reference form of elements and its temperature intervals

Returns:

list (cell) – List with reference form of elements and its temperature intervals

get_speciesProperties(DB, species, T, MassOrMolar, echo)#

Calculates the thermodynamic properties of any species included in the NASA database

Parameters:
  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • MassOrMolar (str) – Label indicating mass [kg] or molar [mol] units

  • echo (float) – 0 or 1 indicating species not found

Returns:

Tuple containing

  • txFormula (str): Chemical formula

  • mm (float): Molar weight [g/mol]

  • cP0 (float): Specific heat at constant pressure [J/(mol-k)]

  • hf0 (float): Enthalpy of formation [J/mol]

  • h0 (float): Enthalpy [J/mol]

  • ef0 (float): Internal energy of formation [J/mol]

  • s0 (float): Entropy [J/(mol-k)]

  • Dg0 (float): Gibbs energy [J/mol]

isRefElm(reference_elements, species, T)#

Check if the given species is a reference element

Parameters:
  • reference_elements (cell) – List of reference elements with temperature intervals [K]

  • species (str) – Chemical species

  • T (float) – Temperature

Returns:

name (str) – Full name of the given species

name_with_parenthesis(species)#

Update the name of the given string with parenthesis. The character b if comes in pair represents parenthesis in the NASA’s database

Parameters:

species (str) – Chemical species in NASA’s Database format

Returns:

species_with (str) – Chemical species with parenthesis

set_DhT(LS, T, DB)#

Function that computes the vector of thermal enthalpy for the given set of species [J/mol]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

DhT (float) – Thermal enthalpy [J/mol]

set_cP(LS, T, DB)#

Function that computes the vector of specific heats at constant pressure for the given set of species [J/(mol-K)]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

cP (float) – Specific heat at constant pressure [J/(mol-K)]

set_e0(LS, T, DB)#

Function that computes the vector of internal energy for the given set of species [J/mol]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

e0 (float) – Internal energy [J/mol]

set_element_matrix(txFormula, elements)#

Compute element matrix of the given species

Parameters:

txFormula (str) – Chemical formula

Returns:

element_matrix(float) – Element matrix

Example

For CO2

element_matrix = [7, 9; 1, 2]

That is, the species contains 1 atom of element 7 (C) and 2 atoms of element 9 (O)

set_g0(LS, T, DB)#

Function that computes the vector of gibbs free energy for the given set of species [J/mol]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

g0 (float) – Gibbs energy [J/mol]

set_h0(LS, T, DB)#

Function that computes the vector of enthalpies for the given set of species [J/mol]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

h0 (float) – Enthalpy in molar basis [J/mol]

set_prop_DB(LS, property, DB)#

Function that gets the vector of the defined property for the given set of species

Parameters:
  • LS (cell) – List of species

  • property (str) – Property to obtain from the database

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

value (float) – Property vector

set_reference_form_of_elements#

Get list with reference form of elements

Returns:

list (cell) – List with reference form of elements

set_reference_form_of_elements_with_T_intervals#

Get list with reference form of elements and its temperature intervals

Returns:

list (cell) – List with reference form of elements and its temperature intervals

set_s0(LS, T, DB)#

Function that computes the vector of entropy for the given set of species [J/(mol-K)]

Parameters:
  • LS (cell) – List of species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

s0 (float) – Entropy [J/(mol-K)]

species_DeT(species, T, DB)#

Compute thermal internal energy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

DeT (float) – Thermal internal energy [kJ/mol]

species_DeT_NASA(species, temperature, DB)#

Compute thermal internal energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

DeT (float) – Thermal internal energy [kJ/mol]

species_DhT(species, T, DB)#

Compute thermal enthalpy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

DhT (float) – Thermal enthalpy [kJ/mol]

species_DhT_NASA(species, temperature, DB)#

Compute thermal enthalpy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

DhT (float) – Thermal enthalpy [kJ/mol]

species_cP(species, T, DB)#

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

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

cP (float) – Specific heat at constant pressure [J/(mol-K)]

species_cP_NASA(species, temperature, DB)#

Compute specific heats at constant pressure and at constant volume [J/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

Tuple containing

  • cP (float): Specific heat at constant pressure [J/(mol-K)]

  • cV (float): Specific heat at constant volume [J/(mol-K)]

species_cV(species, T, DB)#

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

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

cV (float) – Specific heat at constant volume [J/(mol-K)]

species_cV_NASA(species, temperature, DB)#

Compute specific heat at constant volume [J/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

cV (float) – Specific heat at constant volume [J/(mol-K)]

species_e0_NASA(species, temperature, DB)#

Compute internal energy and the thermal internal energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

Tuple containing

  • e0 (float): Internal energy [kJ/mol]

  • DeT (float): Thermal internal energy [kJ/mol]

species_g0(species, T, DB)#

Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters:
  • species (str) – 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 [kJ/mol]

species_g0_NASA(species, temperature, DB)#

Compute Compute Gibbs energy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

g0 (float) – Gibbs energy [kJ/mol]

species_h0(species, T, DB)#

Compute enthalpy [kJ/mol] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

h0 (float) – enthalpy [kJ/mol]

species_h0_NASA(species, temperature, DB)#

Compute enthalpy and thermal enthalpy [kJ/mol] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

Tuple containing

  • h0 (float): Enthalpy [kJ/mol]

  • DhT (float): Thermal enthalpy [kJ/mol]

species_s0(species, T, DB)#

Compute entropy [kJ/(mol-K)] of the species at the given temperature [K] using piecewise cubic Hermite interpolating polynomials and linear extrapolation

Parameters:
  • species (str) – Chemical species

  • T (float) – Temperature [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

s0 (float) – Entropy [kJ/(mol-K)]

species_s0_NASA(species, temperature, DB)#

Compute entropy [kJ/(mol-K)] of the species at the given temperature [K] using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

s0 (float) – Entropy [kJ/(mol-K)]

species_thermo_NASA(species, temperature, DB)#

Compute thermodynamic function using NASA’s 9 polynomials

Parameters:
  • species (str) – Chemical species

  • temperature (float) – Range of temperatures to evaluate [K]

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

Tuple containing

  • cP (float): Specific heat at constant pressure [J/(mol-K)]

  • cV (float): Specific heat at constant volume [J/(mol-K)]

  • h0 (float): Enthalpy [kJ/mol]

  • DhT (float): Thermal enthalpy [kJ/mol]

  • e0 (float): Internal energy [kJ/mol]

  • DeT (float): Thermal internal energy [kJ/mol]

  • s0 (float): Entropy [J/(mol-K)]

  • g0 (float): Gibbs energy [kJ/mol]

thermo_millenium_2_thermoNASA9(filename)#

Read Extended Third Millennium Thermodynamic Database of New NASA Polynomials with Active Thermochemical Tables update and write a new file compatible with thermo NASA 9 format

Parameters:

filename (file) – Filename of the thermo_millenium data

unpack_NASA_coefficients(species, DB)#

Unpack NASA’s polynomials coefficients from database

Parameters:
  • species (str) – Chemical species

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Returns:

Tuple containing

  • a (cell): Temperature coefficients

  • b (cell): Integration constants

  • tRange (cell): Ranges of temperatures [K]

  • tExponents (cell): Exponent coefficients

  • ctTInt (float): Number of intervals of temperatures

  • txFormula (str): Chemical formula

  • phase (float): 0 or 1 indicating gas or condensed phase, respectively

Display functions#

A collection of functions necessary to display the results (command window and plots).


Routines
displaysweepresults(self, mix, xvar, varargin)#

Plot a given variable against the molar fractions of the mixture

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix (struct) – Properties of the mixture

  • xvar (float) – Vector with the x data

Returns:

ax (axes) – Axes object

get_mixtures(PS, pattern)#

Get all non-empty mixture

Parameters:
  • PS (struct) – Struct with all the data of Problem Solution (PS)

  • pattern (str) – Pattern/s name of the mixture

Returns:

mixtures (cell) – Cell with all the non-empty mixtures

Example

mixtures = get_mixtures(self.PS, ‘mix’); mixtures = get_mixtures(self.PS, ‘strP’);

interpreter_label(property, varargin)#

Interpreter label for properties - returns property name

Parameters:

property (str) – Property name

Returns:

value (str) – Corresponding name of the property

plot_figure(x_field, x_var, y_field, y_var, varargin)#

Plot figure

plot_molar_fractions(self, x_var, x_field, y_field, varargin)#

Plot molar fractions againts any variable

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • x_var (cell) – Properties of the mixture for all the cases

  • x_field (char) – Fieldname to plot on the x-axis

  • y_field (char) – Fieldname to plot on the y-axis

Optional Args:
  • validation (struct): Struct that contains validations with (x_field, y_field)

  • nfrec (float): Frequency points to plot validations

  • mintol (float): Minimum limit i-axis with the composition of the mixture

  • config (struct): Struct with the configuration for plots

  • axis_x (char): Set x-axis limits

  • axis_y (char): Set y-axis limits

  • xscale (char): Set x-axis scale (linear or logarithmic)

  • yscale (char): Set y-axis scale (linear or logarithmic)

  • xdir (char): Set x-axis direction (normal or reverse)

  • ydir (char): Set y-axis direction (normal or reverse)

Returns:

Tuple containing * ax (axes): Axes object * fig (figure): Figure object

plot_shock_polar(varargin)#

Routine to obtain shock polar plots * Plot (pressure, deflection) * Plot (wave angle, deflection) * Plot velocity components

polynomial_regression(x, y, n)#

Obtain polynomial regression for the given dataset (x, y) and polynomial order

Parameters:
  • x (float) – x values

  • y (float) – y values

  • n (float) – polynomial order

Returns:

y_poly (float) – y values of the polynomial regression

print_mixture(self, varargin)#

Print properties and composition of a given mixture

Parameters:
  • self (struct) –

  • mix (struct) –

Optional Args:

Returns:

Results on command window

print_stoichiometric_matrix(self, varargin)#

Print stoichiometric matrix

Parameters:

self (struct) – Data of the mixture, conditions, and databases

Optional args:

type (str): ‘transpose’

Optional returns:
A0 (table): Stoichiometric matrix. In case type == ‘transpose’

it returns the transpose of stoichiometric matrix

results(self, i)#

Display results in the command window

set_figure(varargin)#

Initialize figure with a standard composition

Optional Args:
  • ax (axis): Figure axis

  • config (struct): Struct with default plot parameters

Returns:

Tuple containing

  • ax (axis): Axis of the standard figure

  • config (struct): Struct with default plot parameters

  • fig (figure): Standard figure

set_legends(ax, legend_name, varargin)#

Set legend to the given axes

set_title(ax, varargin)#

Set legend to the given axes

species2latex(species)#

Convert string of a species into latex

Equation of State functions#

A collection of Equation of States (EoS) implemented in CT.


Routines
eos_PengRobinson(self, T, p, species, Xi)#

Compute molar volume of the mixture considering Peng-Robinson Equation of State (EoS)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (cell) – List of the species in the mixture

  • Xi (float) – molar fractions of the mixture

  • T (float) – Temperature [K]

  • p (float) – Pressure [bar]

Returns:

Tuple containing

  • V (float): molar volume of the mixture [m3/mol]

  • Vi (float): molar volume of the components [m3/mol]

eos_VanderWaals(self, species, Xi, T, p)#

Compute molar volume of the mixture considering Van der Waals Equation of State (EoS)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • species (cell) – List of the species in the mixture

  • Xi (float) – molar fractions of the mixture

  • T (float) – Temperature [K]

  • p (float) – Pressure [bar]

Returns:

Tuple containing

  • V (float): molar volume of the mixture [m3/mol]

  • Vi (float): molar volume of the components [m3/mol]

eos_ideal(self, T, p, varargin)#

Compute pressure considering ideal Equation of State (EoS)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • T (float) – temperature of the mixture [K]

  • p (float) – pressure of the mixture [Pa]

Returns:

V (float) – molar volume of the mixture [m3/mol]

eos_ideal_p(self, n, T, v, varargin)#

Compute pressure considering ideal Equation of State (EoS)

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • n (float) – number of moles of the mixture in gaseous phase [mol]

  • T (float) – temperature of the mixture [K]

  • v (float) – volume of the mixture [m3]

Returns:

p (float) – pressure of the mixture [Pa]

mu_ex_eos(self, Xi, T, p, V, a_mix, b_mix, a, b)#

Compute non ideal contribution (excess) of the chemical potential assuming cubic Equation of State (EoS) [J/mol]

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • T (float) – Temperature of the mixture [K]

  • p (float) – Pressure of the mixture [bar]

  • V (float) – Molar volume of the mixture [m3/mol]

  • a_mix (float) – Atraction factor mixture of the cubic EoS

  • b_mix (float) – Repulsion factor mixture of the cubic EoS

  • a (float) – Atraction factor components of the cubic EoS

  • b (float) – Repulsion factor components of the cubic EoS

Returns:

chemical_potential_ex (float) – chemical potential excess [J/mol]

mu_ex_ideal(self, moles, temperature, volume)#

Compute non ideal contribution (excess) of the chemical potential assuming ideal Equation of State [J/mol]

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • moles (float) – number of moles of the mixture in gaseous phase [mol]

  • temperature (float) – temperature of the mixture [K]

  • volume (float) – volume of the mixture [m3]

Returns:

pressure (float) – pressure of the mixture [Pa]

mu_ex_vanderwaals(self, moles, temperature, volume)#

Compute non ideal contribution (excess) of the chemical potential assuming Van der Waal’s Equation of State [J/mol]

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • moles (float) – number of moles of the mixture in gaseous phase [mol]

  • temperature (float) – temperature of the mixture [K]

  • volume (float) – volume of the mixture [m3]

Returns:

pressure (float) – pressure of the mixture [Pa]

mu_ex_virial(self, moles, temperature, volume)#

Compute non ideal contribution (excess) of the chemical potential assuming Virial Equation of State [J/mol]

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • moles (float) – number of moles of the mixture in gaseous phase [mol]

  • temperature (float) – temperature of the mixture [K]

  • volume (float) – volume of the mixture [m3]

Returns:

pressure (float) – pressure of the mixture [Pa]

Export functions#

A collection of functions to export results.


Routines
export_results(self)#

Export results of reactants (mix1) and products (mix2) into a .xls file

protected_function#

Extensions functions#

A collection of external functions from other repositories.

  • Combustion Toolbox’s color palette is obtained from the following repository: Stephen (2021). ColorBrewer: Attractive and Distinctive Colormaps (https://github.com/DrosteEffect/BrewerMap), GitHub. Retrieved December 3, 2021.

  • For validations, Combustion Toolbox uses CPU Info from the following repository: Ben Tordoff (2022). CPU Info (https://github.com/BJTor/CPUInfo/releases/tag/v1.3), GitHub. Retrieved March 22, 2022.

  • Combustion Toolbox’s splash screen is based on a routine from the following repository: Ben Tordoff (2022). SplashScreen (https://www.mathworks.com/matlabcentral/fileexchange/30508-splashscreen), MATLAB Central File Exchange. Retrieved October 15, 2022.

Root finding algorithms#

Roots algorithm used to obtain the temperature at equilibrium for a given thermochemical transformation. The methods implemented are:

  • Newton-Raphson method.

  • Steffensen-Aitken method.


Routines
newton_2(f, fprime, x0)#

Find the temperature [K] (root) for the set chemical transformation at equilibrium using the Newton-Raphson method

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix1 (struct) – Properties of the initial mixture

  • pP (float) – Pressure [bar]

  • field (str) – Fieldname in Problem Description (PD)

  • x0 (float) – Guess temperature [K]

  • guess_moles (float) – Guess moles final mixture

Returns:

Tuple containing

  • x (float): Temperature at equilibrium [K]

  • STOP (float): Relative error [-]

  • guess_moles (struct): Guess moles final mixture

print_error_root(it, itMax, T, STOP)#

Print error of the method if the number of iterations is greater than maximum iterations allowed

Parameters:
  • it (float) – Number of iterations executed in the method

  • itMax (float) – Maximum nNumber of iterations allowed in the method

  • T (float) – Temperature [K]

  • STOP (float) – Relative error [-]

newton(self, mix1, pP, field, x0, guess_moles)#

Find the temperature [K] (root) for the set chemical transformation at equilibrium using the Newton-Raphson method

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix1 (struct) – Properties of the initial mixture

  • pP (float) – Pressure [bar]

  • field (str) – Fieldname in Problem Description (PD)

  • x0 (float) – Guess temperature [K]

  • guess_moles (float) – Guess moles final mixture

Returns:

Tuple containing

  • x (float): Temperature at equilibrium [K]

  • STOP (float): Relative error [-]

  • guess_moles (struct): Guess moles final mixture

get_gpoint(self, mix1, pP, field, x0, guess_moles)#

Get fixed point of a function based on the chemical transformation

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix1 (struct) – Properties of the initial mixture

  • pP (float) – Pressure [bar]

  • field (str) – Fieldname in Problem Description (PD)

  • x0 (float) – Guess temperature [K]

Returns:

Tuple containing

  • gpoint (float): Fixed point of the function [kJ] (HP, EV) or [kJ/K] (SP, SV)

  • gpoint_relative (float): Fixed relative point of the function [kJ] (HP, EV) or [kJ/K] (SP, SV)

get_point(x_vector, g_vector)#

Get point of the fixed point function

Parameters:
  • x_vector (float) – Guess temperature [K]

  • g_vector (struct) – Fixed points of the function [kJ] (HP, EV) or [kJ/K] (SP, SV)

Returns:

point (float) – Point of the function [K]

get_point_aitken(x0, g_vector)#

Get fixed point of a function based on the chemical transformation using the Aitken acceleration method

Parameters:
  • x0 (float) – Guess temperature [K]

  • g_vector (struct) – Fixed points of the function [kJ] (HP, EV) or [kJ/K] (SP, SV)

Returns:

point (float) – Point of the function [K]

steff(self, mix1, pP, field, x0, guess_moles)#

Find the temperature [K] (root) for the set chemical transformation at equilibrium using the Steffenson-Aitken method

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix1 (struct) – Properties of the initial mixture

  • pP (float) – Pressure [bar]

  • field (str) – Fieldname in Problem Description (PD)

  • x0 (float) – Guess temperature [K]

  • guess_moles (float) – Guess moles final mixture

Returns:

Tuple containing

  • x (float): Temperature at equilibrium [K]

  • STOP (float): Relative error [-]

  • guess_moles (float): Guess moles final mixture

steff_guess(self, mix1, pP, field)#

Find a estimate of the temperature for the set chemical equilibrium transformation

Parameters:
  • self (struct) – Data of the mixture, conditions, and databases

  • mix1 (struct) – Properties of the initial mixture

  • pP (float) – Pressure [bar]

  • field (str) – Fieldname in Problem Description (PD)

Returns:

x0 (float) – Guess temperature [K]

Thermodynamic properties#

Functions to obtain thermodynamic properties from a given mixture.


Routines
MolecularWeight(mix)#

Get the molecular weight [g/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Molecular weight [g/mol] of the mixture

adiabaticIndex(mix)#

Get the adiabatic index [-] of the mixture from the ratio of the specific heat capacities

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Adiabatic index of the mixture [-]

adiabaticIndex_sound(mix)#

Get the adiabatic index [-] of the mixture from definition of sound velocity

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Adiabatic index [-] of the mixture

compressibility_factor(mix)#

Compute compressibility factor of the mixture [-]

Parameters:

mix (struct) – Properties of the mixture

Returns:

Z (float) – Compressibility factor [-]

cp_mass(mix)#

Get the mass-basis specific heat at constant pressure [kJ/kg-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific heat at constant pressure [kJ/kg-K] of the mixture

cp_mole(mix)#

Get the mole-basis specific heat at constant pressure [kJ/mol-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific heat at constant pressure [kJ/mol-K] of the mixture

cv_mass(mix)#

Get the mass-basis specific heat at constant volume [kJ/kg-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific heat at constant volume [kJ/kg-K] of the mixture

cv_mole(mix)#

Get the mole-basis specific heat at constant volume [kJ/mol-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific heat at constant volume [kJ/mol-K] of the mixture

density(mix)#

Get the density [kg/m3] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – density [kg/m3] of the mixture

enthalpy_formation_mass(mix)#

Get the mass specific enthalpy formation [kJ/kg] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific enthalpy formation [kJ/kg] of the mixture

enthalpy_formation_mole(mix)#

Get the mole specific enthalpy formation [kJ/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific enthalpy formation [kJ/mol] of the mixture

enthalpy_mass(mix)#

Get the mass specific enthalpy [kJ/kg] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific enthalpy [kJ/kg] of the mixture

enthalpy_mole(mix)#

Get the mole specific enthalpy [kJ/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific enthalpy [kJ/mol] of the mixture

entropy_mass(mix)#

Get the mass specific entropy [kJ/kg-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific entropy [kJ/kg-K] of the mixture

entropy_mole(mix)#

Get the mole specific entropy [kJ/mol-K] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific entropy [kJ/mol-K] of the mixture

equivalenceRatio(mix)#

Get the equivalence ratio of the initial mixture [-]

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Equivalence ratio of the initial mixture [-]

gibbs_mass(mix)#

Get the mass specific gibbs free energy [kJ/kg] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific gibbs free energy [kJ/kg] of the mixture

gibbs_mole(mix)#

Get the mole specific gibbs free energy [kJ/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific gibbs free energy [kJ/mol] of the mixture

intEnergy_mass(mix)#

Get the mass specific internal energy [kJ/kg] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass-basis specific internal energy [kJ/kg] of the mixture

intEnergy_mole(mix)#

Get the mole specific internal energy [kJ/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole-basis specific internal energy [kJ/mol] of the mixture

mass(mix)#

Get the mass [kg] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – mass [kg] of the mixture

massFractions(mix)#

Get the mass fractions of all the species in the mixture [-]

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mass fractions of all the species in the mixture [-]

meanMolecularWeight(mix)#

Get the mean molecular weight [g/mol] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mean molecular weight [g/mol] of the mixture

moleFractions(mix)#

Get the mole fractions of all the species in the mixture [-]

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Mole fractions of all the species in the mixture [-]

moles(mix)#

Get the moles [mol] of all the species in the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Moles [mol] of all the species in the mixture

molesGas(mix)#

Get the moles of the gases in the mixture [mol]

pressure(mix)#

Get the pressure [bar] in the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Pressure [bar] in the mixture

soundspeed(mix)#

Get the speed of sound [m/s] in the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Speed of sound [m/s] in the mixture

temperature(mix)#

Get the temperature [K] in the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Temperature [K] in the mixture

velocity_relative(mix)#

Get the velocity of the gases relative to the shock front [m/s] in the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – Velocity of the gases relative to the shock front [m/s] in the mixture

volume(mix)#

Get the volume [m3] of the mixture

Parameters:

mix (struct) – Properties of the mixture

Returns:

value (float) – volume [m3] of the mixture

Validations functions#

A collection of functions to generate the validations automatically.


Routines
compute_error_moles_CEA(results1, results2, varname_x, value, varname_y, species)#

Compute max error of CT against CEA

compute_error_prop_CEA(results1, results2, varsname_x, value, varsname_y, type)#

Compute max error of CT against CEA

debug_plot_error(it, STOP, Delta)#

Debug function that plots the error per iteration along with the value of the correction factor

get_problems_solved(varargin)#

Get problems solved based on the length of the given variable

load_struct(filename, variable_name)#

Load variable from a struct saved in a file

plot_molar_fractions_validation(results1, results2, varname_x, varname_y, species, varargin)#

Default values

plot_properties_validation(results1, results2, varsname_x, varsname_y, type, varargin)#

Plot properties varname_y vs varname_x from CT (results1) against results obtained from other code (results2)

plot_thermo_validation(species, property, DB, varargin)#

Validation custom thermodynamic polynomials with NASA’s 9 polynomials

Parameters:
  • species (cell) – List of species

  • property (str) – Name of the thermodynamic property to check

  • DB (struct) – Database with custom thermodynamic polynomials functions generated from NASAs 9 polynomials fits

Optional Args:

nfrec(float): Points frequency for NASA values range(float): Temperature range [K]

Returns:

ax (axes) – Axes of the plotted figure

plot_validation_shock_polar_SDToolbox(results_CT, results_SDToolbox, config)#

Plot numerical results obtained with SDToolbox, which use CANTERA as a thermochemical kernel. * Pressure ratio with the deflection angle [deg] * Wave angle [deg] with the deflection angle [deg]

read_CEA(filename)#

READ DATA FROM CEA AS TXT EXTENSION fid=fopen(‘test_soot_acetylene.txt’,’r’);

run_CT(varargin)#

A generalized function to run Combustion Toolbox for a given set of inputs. Otherwise, it will run the predefined case.

set_inputs_thermo_validations(property)#

Set corresponding thermodynamic functions for NASA and Combustion Toolbox

Parameters:

property (str) – Thermodynamic property name

Returns:

Tuple containing

  • funname_NASA (function): Function to use NASA’s polynomials

  • funname_CT (function): Function to use Combustion Toolbox polynomials

  • y_labelname (str): Label y axis