Skip to content

Commit

Permalink
fix in initStateChen2020
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierr committed May 16, 2024
1 parent c1d7e14 commit aad223d
Showing 1 changed file with 72 additions and 15 deletions.
87 changes: 72 additions & 15 deletions Examples/Utilities/initStateChen2020.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,86 @@
% setup initial positive electrode external coupling values

initstate.(ctrl).E = OCP(1) - ref;
initstate.(ctrl).I = 0;
initstate.(ctrl).ctrlType = 'constantCurrent';

switch model.(ctrl).controlPolicy

case {'CCDischarge', 'CCCharge'}

initstate.(ctrl).ctrlType = 'constantCurrent';
initstate.(ctrl).I = model.(ctrl).Imax;

case 'CC'

initstate.(ctrl).ctrlType = 'constantCurrent';
initstate.(ctrl).I = 0;

case 'CCCV'

initstate.(ctrl).numberOfCycles = 0;

switch model.(ctrl).initialControl
case 'discharging'
initstate.(ctrl).ctrlType = 'CC_discharge1';
initstate.(ctrl).nextCtrlType = 'CC_discharge1';
initstate.(ctrl).I = model.(ctrl).ImaxDischarge;
case 'charging'
initstate.(ctrl).ctrlType = 'CC_charge1';
initstate.(ctrl).nextCtrlType = 'CC_charge1';
initstate.(ctrl).I = - model.(ctrl).ImaxCharge;
otherwise
error('initialControl not recognized');
end

case 'powerControl'

switch model.(ctrl).initialControl
case 'discharging'
error('to implement (should be easy...)')
case 'charging'
initstate.(ctrl).ctrlType = 'charge';
E = initstate.(ctrl).E;
P = model.(ctrl).chargingPower;
initstate.(ctrl).I = -P/E;
otherwise
error('initialControl not recognized');
end

case 'CC'

% this value will be overwritten after first iteration
initstate.(ctrl).I = 0;
switch model.(ctrl).initialControl
case 'discharging'
initstate.(ctrl).ctrlType = 'discharge';
case 'charging'
initstate.(ctrl).ctrlType = 'charge';
otherwise
error('initialControl not recognized');
end
otherwise
error('control policy not recognized');
end

end



%{
Copyright 2021-2024 SINTEF Industry, Sustainable Energy Technology
and SINTEF Digital, Mathematics & Cybernetics.
Copyright 2021-2024 SINTEF Industry, Sustainable Energy Technology
and SINTEF Digital, Mathematics & Cybernetics.
This file is part of The Battery Modeling Toolbox BattMo
This file is part of The Battery Modeling Toolbox BattMo
BattMo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BattMo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
BattMo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
BattMo is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with BattMo. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
along with BattMo. If not, see <http://www.gnu.org/licenses/>.
%}

0 comments on commit aad223d

Please sign in to comment.