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: check time dependence with the number of chemical species #949

Merged
merged 1 commit into from
Feb 9, 2024
Merged
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
74 changes: 74 additions & 0 deletions examples/check_time_dependence_species.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
% -------------------------------------------------------------------------
% Check time dependence with number of chemical species
%
% @author: Alberto Cuadra Lara
% Postdoctoral researcher - Group Fluid Mechanics
% Universidad Carlos III de Madrid
%
% Last update Feb 08 2024
% -------------------------------------------------------------------------

% Definitions
nfrec = 10;
NS_min = 7;
phi = 0.5:0.1:2;

% Get list of species
self = App;
LS = find_products(self, {'C', 'H', 'O', 'N'}, 'flag_burcat', true);
LS = unique(['CO2', 'CO', 'H2O', 'H2', 'O2', 'N2', 'Cbgrb', LS], 'stable');

% Preallocation
NS = NS_min:nfrec:length(LS);
time = zeros(size(NS));
id = 0;

for i = NS_min:nfrec:length(LS)
% Update
id = id + 1;

% Initialization
self = App(LS(1:i));

% Set initial state
self = set_prop(self, 'TR', 300, 'pR', 1, 'phi', phi);
self.PD.S_Fuel = {'CH4'};
self.PD.S_Oxidizer = {'N2', 'O2'};
self.PD.ratio_oxidizers_O2 = [79, 21] / 21;

% Define additiational constrains (depends of the problem selected)
self = set_prop(self, 'pP', self.PD.pR.value);

% Tunning properties
self.TN.tolN = 1e-14;
self.TN.tol0 = 1e-4;

% Solve problem
t0 = tic;
self = solve_problem(self, 'HP');
time(id) = toc(t0);
end

time_per_case = time / length(phi);

% Least squares interpolation
[xData, yData] = prepareCurveData( NS, time_per_case );

% Set up fittype and options.
ft = fittype( 'poly1' );
excludedPoints = xData < 1;
opts = fitoptions( 'Method', 'LinearLeastSquares' );
opts.Exclude = excludedPoints;

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );

% Plot fit with data.
ax = set_figure;
h = plot( ax, fitresult, xData, yData, excludedPoints );
legend( h, 'Data', 'Least squares interpolation', 'Location', 'NorthEast', 'Interpreter', 'latex' );

% Label axes
xlabel( 'Number chemical species', 'Interpreter', 'latex' );
ylabel( 'Time per case', 'Interpreter', 'latex' );
grid on
Loading