Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

Li battery charge/discharge with arbitrary current profile; linking with MATLAB

Please login with a confirmed email address before reporting spam

Hello,

I am using the capacity_fade.mph provided with the COMSOL installation. I am able to adjust the charging/discharging current in constant current ch/dch mode. Is it possible (and how?) to make an charging/discharging profile of an arbitrary shape (e.g. periodic pulses)?

If I use a COMSOL battery model linked to MATLAB, is it possible (and how?) to retain the internal states of the COMSOL model (e.g. SEI layer thickness) between two calls of the model?

Thank you!


2 Replies Last Post 17 apr 2022, 10:22 GMT-4
Remi Magnard COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 14 mar 2022, 10:17 GMT-4

Dear Danko,

It seems that what you want to do is exactly what LiveLink for Simulink allows, running cosimulation between COMSOL and MATLAB (using a Simulink diagram). Please have a look at the model libattery_llsimulink.slx in the LiveLink for Simulink's Application Library that exactly reuse the battery_fade model to implement a charge/discharge control of a Lithium-Ion battery.

If using Simulink is not an option, you can have a look in the LiveLInk for MATLAB' s Application Library you will find the model domain_activation_llmatlab.m. Eventhough it deals with a different physics, the model illustrate how to solve sequentially a transient problem and change the model settings between iteration (here it activates a domain heat source). The important point here is how to change the initial condition so that it reuse the last solution of the previous iteration (see step 12, page 7 of the PDF document).

Using LiveLink for MATLAB, it requires a bit more knowledge of the COMSOL API, while using LiveLink for Simulink you don't need worry about how the initial condition are set as it does it automatically for you.

I hope this will help!

Rémi Magnard

Dear Danko, It seems that what you want to do is exactly what LiveLink for Simulink allows, running cosimulation between COMSOL and MATLAB (using a Simulink diagram). Please have a look at the model libattery_llsimulink.slx in the LiveLink for Simulink's Application Library that exactly reuse the battery_fade model to implement a charge/discharge control of a Lithium-Ion battery. If using Simulink is not an option, you can have a look in the LiveLInk for MATLAB' s Application Library you will find the model domain_activation_llmatlab.m. Eventhough it deals with a different physics, the model illustrate how to solve sequentially a transient problem and change the model settings between iteration (here it activates a domain heat source). The important point here is how to change the initial condition so that it reuse the last solution of the previous iteration (see step 12, page 7 of the PDF document). Using LiveLink for MATLAB, it requires a bit more knowledge of the COMSOL API, while using LiveLink for Simulink you don't need worry about how the initial condition are set as it does it automatically for you. I hope this will help! Rémi Magnard

Please login with a confirmed email address before reporting spam

Posted: 3 years ago 17 apr 2022, 10:22 GMT-4
Updated: 3 years ago 17 apr 2022, 10:23 GMT-4

Hi,Danko Marusic did you make it clear about how to make an charging/discharging profile of an arbitrary shape?

Hi,Danko Marusic did you make it clear about how to make an charging/discharging profile of an arbitrary shape?

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.