Functions#
A collection of functions necessary to obtain different data in the solver module. Here we can find:
general functions,
root finding algorithms,
thermodynamics properties.
General functions#
A collection of general functions necessary to obtain different data in the solver module.
Routines
- CalculatePhic(Fuel, Ninerts, phi, TP, pP, DB)#
Compute equivalence ratio in which soot appears considering complete combustion
- Parameters
Fuel (
struct
) – Struct mix with all the properties of the Fuel mixtureNinerts (
float
) – Number of moles of the inerts speciesphi (
float
) – Equivalence ratio [-]TP (
float
) – Temperature [K]pP (
float
) – Pressure [bar]DB (
struct
) – Database
- Returns
phi_c (float) – Equivalence ratio in which soot appears [-]
- ComputeProperties(self, SpeciesMatrix, p, T)#
Compute properties from the given SpeciesMatrix at pressure p [bar] and temperature T [K]
- Parameters
self (
struct
) – Data of the mixture, conditions, and databasesSpeciesMatrix (
float
) – Matrix with the properties values of the mixturep (
float
) – Pressure [bar]T (
float
) – Temperature [K]
- Returns
mix (struct) – Properties of the mixture
- 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
- 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 [-]
- SetSpecies(self, species, moles, T)#
Fill the properties matrix with the data of the mixture
- Parameters
self (
struct
) – Data of the mixture, conditions, and databasesspecies (
cell
) – Species contained in the systemmoles (
float
) – Moles of the species in the mixture [mol]T (
float
) – Temperature [K]
- Returns
M (float) – properties matrix
- Stoich_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
- cell2vector(value, varargin)#
Convert values of a 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)
- compute_first_derivative(x, y)#
Compute first central derivate using a non-uniform grid
- Parameters
x (
float
) – Grid valuesy (
float
) – Values for the corresponding grid
- Returns
dxdy (float) – Value of the first derivate for the given grid and its corresponding values
- 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 databasesspecies (
str
) – Cell array with the species of the mixturemoles – 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
- find_ind(LS, species)#
Find the index of the species based on the given list (LS)
- Parameters
LS (
cell
) – List of speciesspecies (
cell
) – Species to find index values
- Returns
index (float) – List with the index of the species based on the given list (LS)
- 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 databasesmix (
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 databasesfield (
str
) – Fieldname in Problem Description (PD)
- Returns
value (float) – Value/s assigned to the field
- 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 databasesLS (
cell
) – List of species
- 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_transformation(self, field, value)#
Set the corresponding value of the field in Problem Description (PD)
- Parameters
self (
struct
) – Data of the mixture, conditions, and databasesfield (
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
- soundspeed_eq(self, mix, phi, P0, T0)#
Compute speed of sound at equilibrium
- Parameters
self (
struct
) – Data of the mixture, conditions, and databasesmix (
struct
) – Struct mix with all the properties of the mixturephi (
float
) – Equivalence ratio [-]P0 (
float
) – Pressure [bar]T0 (
float
) – Temperature [K]
- Returns
sound (float) – sound speed [m/s]
- 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
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
- 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 methoditMax (
float
) – Maximum nNumber of iterations allowed in the methodT (
float
) – Temperature [K]STOP (
float
) – Relative error [-]
- newton(self, mix1, pP, field, 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 databasesmix1 (
struct
) – Properties of the initial mixturepP (
float
) – Pressure [bar]field (
str
) – Fieldname in Problem Description (PD)x0 (
float
) – Guess temperature [K]
- Returns
Tuple containing
x (float): Temperature at equilibrium [K]
STOP (float): Relative error [-]
- get_gpoint(self, mix1, pP, field, x0)#
Get fixed point of a function based on the chemical transformation
- Parameters
self (
struct
) – Data of the mixture, conditions, and databasesmix1 (
struct
) – Properties of the initial mixturepP (
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)#
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 databasesmix1 (
struct
) – Properties of the initial mixturepP (
float
) – Pressure [bar]field (
str
) – Fieldname in Problem Description (PD)x0 (
float
) – Guess temperature [K]
- Returns
Tuple containing
x (float): Temperature at equilibrium [K]
STOP (float): Relative error [-]
- 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 databasesmix1 (
struct
) – Properties of the initial mixturepP (
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
- 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
- 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_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
- 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
- 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