Skip to content

Commit

Permalink
Merge branch 'main' into protonicmembrane
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierr committed Dec 12, 2024
2 parents a2e7a91 + 9921203 commit ead68c3
Show file tree
Hide file tree
Showing 26 changed files with 1,431 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
708 changes: 708 additions & 0 deletions Documentation/computationalGraph/graphdoc.rst

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions Documentation/computationalGraph/scripts/ConcentrationModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
classdef ConcentrationModel < BaseModel

methods

function model = registerVarAndPropfuncNames(model)

%% Declaration of the Dynamical Variables and Function of the model
% (setup of varnameList and propertyFunctionList)

model = registerVarAndPropfuncNames@BaseModel(model);

varnames = {};
% Concentration
varnames{end + 1} = 'c';
% Mass accumulation term
varnames{end + 1} = 'massAccum';
% Source term
varnames{end + 1} = 'source';
% Mass conservation equation
varnames{end + 1} = 'massCons';

model = model.registerVarNames(varnames);

fn = @ConcentrationModel.updateMassAccum;
inputnames = {'c'};
model = model.registerPropFunction({'massAccum', fn, inputnames});

fn = @ConcentrationModel.updateMassCons;
inputnames = {'massAccum', 'source'};
model = model.registerPropFunction({'massCons', fn, inputnames});

end

end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
classdef ConcentrationReactionModel < BaseModel

properties

Reaction
Solid
Elyte

end

methods

function model = ConcentrationReactionModel()

model.Reaction = ReactionModel();
model.Solid = ConcentrationModel();
model.Elyte = ConcentrationModel();

end

function model = registerVarAndPropfuncNames(model)

%% Declaration of the Dynamical Variables and Function of the model

model = registerVarAndPropfuncNames@BaseModel(model);

fn = @ConcentrationReactionModel.updateConcentrationSource;
inputnames = {{'Reaction', 'R'}};
model = model.registerPropFunction({{'Solid', 'source'}, fn, inputnames});
model = model.registerPropFunction({{'Elyte', 'source'}, fn, inputnames});

fn = @ConcentrationReactionModel.updateReactionConcentrationE;
inputnames = {{'Elyte', 'c'}};
model = model.registerPropFunction({{'Reaction', 'c_e'}, fn, inputnames});

fn = @ConcentrationReactionModel.updateReactionConcentrationS;
inputnames = {{'Solid', 'c'}};
model = model.registerPropFunction({{'Reaction', 'c_s'}, fn, inputnames});

end

end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
classdef ConcentrationReactionThermalModel < BaseModel

properties

Masses
Thermal

end

methods

function model = ConcentrationReactionThermalModel()

model.Masses = ConcentrationReactionModel();
model.Thermal = ThermalModel();

end

function model = registerVarAndPropfuncNames(model)

%% Declaration of the Dynamical Variables and Function of the model

model = registerVarAndPropfuncNames@BaseModel(model);

fn = @ConcentrationReactionThermalModel.updateOCP;
inputnames = {{'Masses', 'Reaction', 'c_s'}, {'Thermal', 'T'}};
model = model.registerPropFunction({{'Masses', 'Reaction', 'OCP'}, fn, inputnames});

fn = @ConcentrationReactionThermalModel.updateThermalSource;
inputnames = {{'Masses', 'Reaction', 'R'}};
model = model.registerPropFunction({{'Thermal', 'source'}, fn, inputnames});

end

end

end
49 changes: 49 additions & 0 deletions Documentation/computationalGraph/scripts/ReactionModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
classdef ReactionModel < BaseModel

methods

function model = registerVarAndPropfuncNames(model)

model = registerVarAndPropfuncNames@BaseModel(model);

varnames = {};
% potential in electrode
varnames{end + 1} = 'phi_s';
% charge carrier concentration in electrode - value at surface
varnames{end + 1} = 'c_s';
% potential in electrolyte
varnames{end + 1} = 'phi_e';
% charge carrier concentration in electrolyte
varnames{end + 1} = 'c_e';
% Electrode over potential
varnames{end + 1} = 'eta';
% Reaction rate [mol s^-1 m^-2]
varnames{end + 1} = 'R';
% OCP [V]
varnames{end + 1} = 'OCP';
% Reaction rate coefficient [A m^-2]
varnames{end + 1} = 'j';

model = model.registerVarNames(varnames);

fn = @ReactionModel.updateReactionRateCoefficient;
inputnames = {'c_e', 'c_s'};
model = model.registerPropFunction({'j', fn, inputnames});

fn = @ReactionModel.updateOCP;
inputnames = {'c_s'};
model = model.registerPropFunction({'OCP', fn, inputnames});

fn = @ReactionModel.updateEta;
inputnames = {'phi_e', 'phi_s', 'OCP'};
model = model.registerPropFunction({'eta', fn, inputnames});

fn = @ReactionModel.updateReactionRate;
inputnames = {'eta', 'j'};
model = model.registerPropFunction({'R', fn, inputnames});

end

end

end
23 changes: 23 additions & 0 deletions Documentation/computationalGraph/scripts/ReactionModel2.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
classdef ReactionModel2 < ReactionModel

methods

function model = registerVarAndPropfuncNames(model)

model = registerVarAndPropfuncNames@ReactionModel(model);

varnames = {};
% potential in electrode
varnames{end + 1} = 'T';

model = model.registerVarNames(varnames);

fn = @ReactionModel.updateOCP;
inputnames = {'c_s', 'T'};
model = model.registerPropFunction({'OCP', fn, inputnames});

end

end

end
36 changes: 36 additions & 0 deletions Documentation/computationalGraph/scripts/ReactionThermalModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
classdef ReactionThermalModel < BaseModel

properties

Reaction
Thermal

end

methods

function model = ReactionThermalModel()

model.Reaction = ReactionModel();
model.Thermal = ThermalModel();

end
function model = registerVarAndPropfuncNames(model)

%% Declaration of the Dynamical Variables and Function of the model

model = registerVarAndPropfuncNames@BaseModel(model);

fn = @ReactionThermalModel.updateOCP;
inputnames = {{'Reaction', 'c_s'}, {'Thermal', 'T'}};
model = model.registerPropFunction({{'Reaction', 'OCP'}, fn, inputnames});

fn = @ReactionThermalModel.updateThermalSource;
inputnames = {{'Reaction', 'R'}};
model = model.registerPropFunction({{'Thermal', 'source'}, fn, inputnames});

end

end

end
38 changes: 38 additions & 0 deletions Documentation/computationalGraph/scripts/ThermalModel.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
classdef ThermalModel < BaseModel

methods

function model = registerVarAndPropfuncNames(model)

model = registerVarAndPropfuncNames@BaseModel(model);

varnames = {};
% Temperature
varnames{end + 1} = 'T';
% Accumulation term
varnames{end + 1} = 'accumTerm';
% Flux flux
varnames{end + 1} = 'flux';
% Heat source
varnames{end + 1} = 'source';
% Energy conservation
varnames{end + 1} = 'energyCons';

model = model.registerVarNames(varnames);

fn = @ThermalModel.updateFlux;
model = model.registerPropFunction({'flux', fn, {'T'}});

fn = @ThermalModel.updateAccumTerm;
model = model.registerPropFunction({'accumTerm', fn, {'T'}});

fn = @ThermalModel.updateEnergyCons;
inputnames = {'accumTerm', 'flux', 'source'};
model = model.registerPropFunction({'energyCons', fn, inputnames});


end

end

end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
classdef UncoupledReactionThermalModel < BaseModel
properties
Reaction
Thermal
end
methods
function model = UncoupledReactionThermalModel()
model.Reaction = ReactionModel();
model.Thermal = ThermalModel();
end
end
end
34 changes: 34 additions & 0 deletions Documentation/computationalGraph/scripts/runScript.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set(0, 'defaultlinelinewidth', 3);
set(0, 'defaultaxesfontsize', 15);

% model = ReactionModel();
% model = ReactionModel2();
% model = ThermalModel();
% model = ReactionThermalModel();
model = UncoupledReactionThermalModel();
% model = ConcentrationModel();
% model = ConcentrationReactionModel();
% model = ConcentrationReactionThermalModel();
cgp = model.cgp;
cgt = model.cgt;
h = cgp.plot();
% h = cgp.plotModelGraph();
set(h, 'nodefontsize', 14);
% set(h, 'nodefontsize', 9);
set(h, 'linewidth', 3);
set(h, 'arrowsize', 20);

dosave = true;
savedir = '../img';

if dosave
% filename = 'reacmodelgraph.png';
% filename = 'reacmodelgraph2.png';
% filename = 'tempgraph.png';
% filename = 'concreacgraph.png';
% filename = 'tempconcreacgraphmodel.png';
filename = 'uncoupledreactemp.png';
filename = fullfile(savedir, filename);
saveas(gcf, filename)
end

1 change: 1 addition & 0 deletions Documentation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
Electrolyser simulation <publishedExamples/runElectrolyser>
Protonic Membrane <publishedExamples/runProtonicMembrane>
gui
Computational Graph <computationalGraph/graphdoc>
seealso
References <bibliography>

Expand Down
Loading

0 comments on commit ead68c3

Please sign in to comment.