Battery Modeling - What am I Doing Wrong? - Page 1
Forum section: electronics / projects

author: SolidBanks
author_rank: Contributor
timestamp: January 20, 2022, 09:57:20 pm
content: Hello all,I'm looking to model a system where there are 3 sources tied in parallel. Two batteries of the same open circuit voltage but with different capacities, and a current source. The point of modeling this is mainly for my edification but I've become quite frustrated with myself for not being able to figure out why my model outputs an eventual and unexpected decay in SOC and voltage of the two batteries.I'm attaching a presentation I put together that describes my approach to the model and the result I'm talking about. Could someone smarter than me please take a look and tell me what I'm missing? I've been staring at this for far too long. lol-Cheers

author: Daixiwen
author_rank: Frequent Contributor
timestamp: January 21, 2022, 07:27:53 am
content: On page 4 when you are using the superposition model, I think you made a mistake with the current source. When you turn off a source, a voltage source becomes a short circuit (U=0) but a current source becomes an open circuit (I=0).The way you did it the batteries will discharge in both RL and R2, and it could explain why the SOC of your batteries decreases so quickly.

author: SolidBanks
author_rank: Contributor
timestamp: January 21, 2022, 02:52:11 pm
content: Daixiwen,After thinking through it, I'm inclined to agree with you that I might have made an error in my superposition analysis. I'll re-run the calculations and see what the model puts out. Thanks for responding!

author: SolidBanks
author_rank: Contributor
timestamp: January 21, 2022, 08:34:04 pm
content: So I doublechecked my calculations and I do treat the current source as an open when it's removed during superposition, my charts were wrong as it showed that I didn't. I've since updated the charts to correctly reflect how it's being calculated. Thanks for the feedback though, made my charts better.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: January 24, 2022, 07:51:12 am
content: What conditions are you using when you do your plot? If Is is off, the batteries will discharge in RL and their SOC and voltage will fall to 0. If Is is on, then both voltages will converge towards RL*Is and their current will fall to 0 at the end of the simulation.By the way you don't need R2 in your model, it is just in series with an ideal current source and can be removed without changing anything.

author: SolidBanks
author_rank: Contributor
timestamp: January 24, 2022, 10:55:45 pm
content: Conditions:-RLis under a load profile that demands around 1kW for eight minutes every 86 minutes, approximately.-ISis also under a current sourcing profile that contributes around 15A for 60 minutes every 36 minutes.As you describe, when ISis off, I expect the battery SOC and voltage to drop. But what happens is that, after minute 1489, the 15A isn't enough to recover the battery voltages and then an exponential decay results in an unrecoverable system. By my accounts, everything unchanged, the whole plot should basically be the performance noted from minute 0 to minute 1489 repeated every cycle; no exponential decay.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: January 25, 2022, 08:01:58 am
content: Yes indeed, when I look more closely to your curve something weird happens around 1400-1500 minutes, it looks like the SoC doesn't increase as much as the other times during the charge cycle, and this happens just before the first sudden drop.What function do you use to calculate the voltage depending on the SoC? Could you also trace the 3 currents on the same curve? The one in Rl, and the one in each battery model?

author: SolidBanks
author_rank: Contributor
timestamp: January 25, 2022, 10:21:38 pm
content: Exactly!The equation used to calculate each battery's terminal voltage is:v(t) = OCV(SOC(t)) - R1*iR1(t) - RINT*i(t)Where:t = timei = total currentiR1= current through R1There's more detail regarding terminal voltage from slide 9 - 11.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: January 26, 2022, 08:12:16 am
content: I was more specifically wondering about your OCV() function. What kind of model did you use? Are you sure that the function is monotonous?

author: SolidBanks
author_rank: Contributor
timestamp: January 26, 2022, 05:29:35 pm
content: Ah, I see. I updated the chart package to include an elaboration on OCV as a function of SOC. You can find it on slides 8 and 9. Let me know if this helps.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: January 27, 2022, 07:58:28 am
content: Oh I see. So you are using a purely linear model. It's not very accurate, but should be good enough to see how things work, and it shouldn't cause any instability.I didn't notice at first how huge your value for C1 is. I wonder if this would cause some oscillations or weird values in the currents through the batteries. As I suggested before I think it would help to have on the same graph that you have on the last page the currents through the batteries. If you can also show the voltage across C1 maybe it will give some clues about what is going on

author: SolidBanks
author_rank: Contributor
timestamp: January 28, 2022, 09:04:04 pm
content: I'll work on it this weekend and reply again when I'm done.

author: amosborne
author_rank: Contributor
timestamp: January 29, 2022, 05:22:27 am
content: I have done this sort of modeling before for the closed loop control and energy balance of spacecraft power electronics, solar arrays, and lithium ion batteries.You should consider the energy balance of your model. You are injecting energy with your current source, and the load is consuming is energy. But you are also losing energy due to the batteries internal resistance. I bet that you are losing more energy than you are pushing in.You said in a post above that the conditions are pulse source 60min every 36min and pulse load 8min every 86min. I don’t know exactly how you time that, but I guesstimate the beat frequency to be around 1/1000min, which explains the scallops.It you are modeling the nonlinear open circuit voltage to state of charge relationship, that easily explains why the voltage craters at the end. Batteries don’t hold voltage well at low state of charge.The fact that you have a “communication” model puts me on a spectrum somewhere between curious and concerned. I suppose it can work, but I guess you’re not taking advantage of ODE solvers to perform numeric integration.By the way, the best way to determine the RC dynamic battery impedance is with a step response. And these parameters also end up being a function of state of charge

author: SolidBanks
author_rank: Contributor
timestamp: January 31, 2022, 04:19:33 pm
content: Attached include the following:Both battery currentsCurrent source profileC1 VoltageLoad Current

author: SolidBanks
author_rank: Contributor
timestamp: January 31, 2022, 04:33:01 pm
content: My responses:You should consider the energy balance of your model. You are injecting energy with your current source, and the load is consuming is energy. But you are also losing energy due to the batteries internal resistance. I bet that you are losing more energy than you are pushing in.I provided the ISprofile in a graphic in another response. That might be the case as I'm only source around 15A each time the ISis switched on.You said in a post above that the conditions are pulse source 60min every 36min and pulse load 8min every 86min. I don’t know exactly how you time that, but I guesstimate the beat frequency to be around 1/1000min, which explains the scallops.The graphic I attached in another reply might clear up what I was trying to communicate. It has the ISand load profile.It you are modeling the nonlinear open circuit voltage to state of charge relationship, that easily explains why the voltage craters at the end. Batteries don’t hold voltage well at low state of charge.So I understand completely that battery performance worsens as it reaches low state of charge but I've been more confused about the battery performance earlier on in the simulation when things just seem to suddenly take a turn for the worse. Happens around 1489 minutes.The fact that you have a “communication” model puts me on a spectrum somewhere between curious and concerned. I suppose it can work, but I guess you’re not taking advantage of ODE solvers to perform numeric integration.Yeah this could be where my not knowing will get me. I'm trying to learn so it sounds like this could be something I use to improve the model. I never liked the separation I have between the circuit and the battery, where the results of one have to feed the other in order to continue progressing but I've heard that it's not uncommon.By the way, the best way to determine the RC dynamic battery impedance is with a step response. And these parameters also end up being a function of state of chargeIndeed it is. I used a ballpark method in an attempt to estimate the parameters for RINTand the RC branch. That ballpark method included starting the battery model at a relaxed state and then applying a load to draw a steady current for an amount of time that allowed the magical 5 time constants. Now I had no idea that they'd be a function of SOC. Are you referring to the calculation of terminal voltage? When the OCV, as a function of SOC, is reduced because of the voltage drop across RINTand then the voltage drop across the RC pair? Or are you referring to something I'm completely missing?

author: Daixiwen
author_rank: Frequent Contributor
timestamp: February 01, 2022, 08:19:30 am
content: The first thing that strikes me when looking at the curve is the load current that has some huge peaks from time to time, often corresponding to sudden drops of state of charge. The amplitude of the spikes is much higher than what the battery is supposed to produce from its voltage so there is clearly something wrong there.Also if I read the graph correctly, the current in the load is actually higher when you turn off Is? That doesn't make a lot of sense either.I'm still wondering if the big value for C1 doesn't make the simulation completely unstable. Just to check that hypothesis, could you run a simulation with a value of C1 lowered by several orders of magnitude?

author: SolidBanks
author_rank: Contributor
timestamp: February 02, 2022, 05:45:18 pm
content: Quote from: Daixiwen on February 01, 2022, 08:19:30 amI'm also wondering if my time stepping might be wrong. I'm using a time step of 1 in my ODEs. I apologize for not making this easier, hopefully the next graph will be more helpful.

author: Daixiwen
author_rank: Frequent Contributor
timestamp: February 03, 2022, 07:11:58 am
content: Quote from: SolidBanks on February 02, 2022, 05:45:18 pmBut you are using 0.8 ohms for RL when discharging, aren't you? If you have a look at the spikes at around 3000 minutes, the spikes go up to 36-38A if I'm not mistaken, which means a voltage of 32-34V, higher than the batteries OCV. It gets worse around 4900 minutes.It is a good idea to try and change the time step. I also wonder if changing both IS and RL at the same time when you switch from charging to discharging (if I understand your document correctly) doesn't cause further unstability.