2
\$\begingroup\$

I've been trying to simulate an MLCC capacitor in LTspice. I started with a well behaved TANH curve to generate my C(V), to plug into the nonlinear capacitor Q = C(V)×V formula. I noticed after testing that I would get a negative capacitance out of my TANH function for capacitance (which when I plug it into a BV source never goes negative as this should be mathematically impossible).

My original plan:

C1 0 1 Q=((1-TANH((ABS(X)-'TH')*'SLOPE'))/2*'CMAX'+'CMIN')*X

.param TH=3.196

.param SLOPE=0.400

.param CMIN=6.701u

.param CMAX=45.330u

If you plot this in Desmos or Excel, you can see it can't possibly go negative for any real value of X.

I tried this simple experiment to understand the issue better:

C1 1 0 Q=(47u)*X

V1 1 0 PULSE(0 10 0 10 100 100 100)

The pulse gives dV/dt = 1 so that I=C in the capacitor as V grows. The simulation runs for 10 s (0V - 10V).

I get 47 μA in the cap the whole time, so far so good.

Then I try this:

C1 1 0 Q=(47u-1u*X)*X

When I do this I see the 47 μA (representing 47 μF) at 0 V, but at 10 V I get 27 μA, as though it lost 20 μF instead of 10 μF, or as though X was 20 and not 10, but it is a straight line.

A fix I tried here was to divide the inside X by 2. This worked and I get the expected result, but why this works I don't understand so I don't trust this as a fix.

C1 1 0 Q=(47u-1u*x/2)*X

I did try this divide X by 2 in my original TANH and it did not resolve the issue at all (still gives negative C), as though the evaluation of the C(V) portion of the charge equation is following some rules that are not clear to me.

Is this a bug in my understanding of how the charge model works? What is going on here?

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Charge is the integral of capacitance, so you have to integrate your desired capacitance equation with respect to voltage. That's why tacking on the extra *X only works for a constant capacitance. Have you read this? analog.com/en/analog-dialogue/raqs/raq-issue-192.html \$\endgroup\$
    – Ste Kulov
    Commented Apr 4, 2023 at 20:38

1 Answer 1

3
\$\begingroup\$

Your formula for the charge is incorrect. I believe you misread the LTspice Help page regarding the nonlinear capacitor charge expression (don't worry, I made the same mistake a couple years ago). If you start with the equation for the current through a capacitor, replace \$i(t)\$ with \$\frac{dq}{dt}\$, and integrate both sides you get:

$$ \begin{align} &&i(t) &= C \cdot \frac{dv}{dt} \\ \\ \implies&& \frac{dq}{dt} &= C \cdot \frac{dv}{dt} \\ \\ \implies&& dq &= C \cdot dv \\ \\ \implies&& \int dq &= \int C \cdot dv \end{align} $$

Now, if \$C\$ is constant (which is the typical case), then you can pull \$C\$ outside the integral like so and get:

$$ \begin{align} &&\int dq &= C \int dv \\ \\ \implies&& q &= C \cdot v \end{align} $$

However, if \$C\$ is instead a function of \$v\$ (i.e. \$C(v)\$) then you can't pull the \$C\$ out of the integral and the whole expression must be integrated like so:

$$ \begin{align} &&\int dq &= \int C(v) \cdot dv \\ \\ \implies&& q &= \int C(v) \cdot dv \end{align} $$


The following is stated on the LTspice Help page for C. Capacitor linked above:

There is also a general nonlinear capacitor available. Instead of specifying the capacitance, one writes an expression for the charge.

LTspice will compile this expression and symbolically differentiate it with respect to all the variables, finding the partial derivative's that correspond to capacitances.

This implies that you have to pre-integrate your desired capacitance expression into a charge expression, because LTspice will reverse the process with derivatives. I don't know the exact reason for why this is the case, but my guess is that it's easier for the engine to handle it in this way......which means more work for us. Yay.


There is a good article on the Analog Devices website which already tackles the problem of modeling the DC bias effect of MLCCs in LTspice. It includes an already integrated charge expression for DC bias capacitance using a \$tanh()\$ characteristic.

\$\endgroup\$
6
  • 1
    \$\begingroup\$ It is fairly easy to do symbolic differentiation, whereas symbolic integration to the extent necessary here would be an order of magnitude larger task at least and probably not worth it in the context of a circuit simulator. Of course, there are shortcuts - most capacitance vs voltage curves can be rather well approximated with polynomials or splines, and those have integrals that are easy to derive symbolically. \$\endgroup\$ Commented Apr 5, 2023 at 5:59
  • \$\begingroup\$ @Kubahasn'tforgottenMonica Right. That all makes sense. I was talking about the fact of why it makes you integrate, only for it to undo the integration with differentiation to recover C. It would only need to do that if it needs Q for something...and indeed it does. After looking at the ngspice source code again, I was reminded that the numerical integration function uses Q to simplify the calculation. So it needs Q to be compatible with that function. With constant C, it gets Q trivially as shown above. \$\endgroup\$
    – Ste Kulov
    Commented Apr 5, 2023 at 16:36
  • \$\begingroup\$ Thanks, this totally worked! However, I now notice that it seems to only give good results for positive voltages on the cap. I tried abs(x) and no difference at all. Did you find anything special to deal with negative voltages? \$\endgroup\$
    – A. Stickel
    Commented Apr 6, 2023 at 16:07
  • \$\begingroup\$ @A.Stickel I believe it has something to do with \$tanh()\$ being an odd function, so it's only valid for positive arguments when trying to fit the DC bias model. You can probably get around this by replacing all instances of x with abs(x) in the integrated charge expression. This should imply that tanh(_) turns into tanh(abs(_)) when it's differentiated, turning it into an even function (i.e. symmetric along the y-axis). You might also have to plot the abs() of the current in the waveform viewer too if you're going to sweep both positive and negative values in one run. \$\endgroup\$
    – Ste Kulov
    Commented Apr 7, 2023 at 5:57
  • \$\begingroup\$ @Kulov I tried the abs(x) and this didn't help, which it turns out is because of how LTSpice integrates the charge. I ended up starting with a C(v) function that is symmetrical for positive and negative V values "C = (Cmax - Cmin) / (1 + Slope * V^2) + Cmin". I fit the curve to measured data with a Python fitting script, then plugged the constants Cmin, Cmax, and Slope into the integral of that equation "Q = ( ( ( Cmax - Cmin ) * arctan( sqrt( Slope ) * V ) ) / ( sqrt( Slope ) ) + Cmin * V". After some verification this works consistently! Thanks for getting me started in the right direction! \$\endgroup\$
    – A. Stickel
    Commented Apr 16, 2023 at 20:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.