Hello,
I am using a custom component to model a battery in Simscape. The model allows me to enter a lookup table for voltage in terms of the capacity, current and state of charge of the battery and simulate the battery's voltage, current and thermal response. The equations section of my Simscape component are shown below:
equations
assert(SOC >= 0, 'State of charge cannot be less than 0');
assert(SOC <= 1, 'State of charge cannot be greater than 1');
let
voc = tablelookup(IData, SOCData, VData, {0, 'A'}, SOC, interpolation = smooth, extrapolation = smooth);
in
SOC.der == -i/C;
v == p.v - n.v;
v == tablelookup(IData, SOCData, VData, abs(i), SOC, interpolation = smooth, extrapolation = smooth);
C == tablelookup(IData, CData, abs(i), interpolation = smooth, extrapolation = smooth);
T == H.T;
qg == abs(i)*(voc - v);
0 == Q + qg;
end
end
Testing of this model has worked quite well and has been able to match my test data but the initialization of the model is always an issue that I am trying to circumvent.
The model is unable to initialize appropriately when I apply a constant current to the model. For example if I attempt to draw a constant 2 A from the model, the solver will complain of being unable to initialize stating that the initial conditions fail to converge. I believe the issue behind this is because if I begin with a fully charged battery such that State of Charge is 100%, this would be technically when the battery has a 0 A current draw. However when I apply the current of 2 A to the battery, this coupled with the State of Charge initial condition forces the solver to be unable to converge on a solution because it doesn't exist.
I think my guess at this is valid because if I replace the constant current draw with a Step response with a final value of 2 A, the model appropriately initializes and can move forward. This is true, even if I set the Step Time of the Step block to eps = 2.2204e-16 which forces the solver to accept 0 A as the initial condition and then applies the proper 2 A current.
The problem with this is that I don't want to have to constantly utilize a Step block to drive the model at a constant current. I thought that I could bring this behavior inside the model code by using
equations(Initial=true)
i == 0;
end
But this always causes the model to fail regardless of the driving input.
Is there another way to accomplish this beahvior and get what I need or am I stuck with doing a step response for all of my driving inputs?
0 Comments
Sign in to comment.