Simulation of a nonlinear capacitor

Let's assume a nonlinear capacitor with c(v)=dq/dv. The q-v characteristic of the capacitor is given by the formula

q=3*(v^3)

Let's also assume that it's charged to 1V and then connected to a 0.2 Ohm linear ohmic resistance to discharge.

I tried to write the equations for this simple circuit and then simulate the behaviour by approximating through the forward Euler method.

My results are horrendous. First let's see the equations I used:

Using v as the state variable:

dv/dt = -0.556/v

Using q as the state variable:

dq/dt = -3.467*(q^.333), if q>0 dq/dt = 3.467*[(-q)^.333], if q

Reply to
sert
Loading thread data ...

Too many twists and turns.

Fundamentals...

i = d/dt(c?v) =>

i = c?dv/dt + v?dc/dt

Try manipulating from there, adding in c as a function of v. I suspect you inserted too many artificial restraints.

...Jim Thompson

--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
             
         America: Land of the Free, Because of the Brave
Reply to
Jim Thompson

"sert" schrieb im Newsbeitrag news:Xns9AB7D951B938Djtjdfjdfjnbj@147.102.222.230...

Hello,

You can have drawn the circuit and the result plotted in 5 minutes with LTspice. Is it required that you write your own program?

Best regards, Helmut

Reply to
Helmut Sennewald

How do you set up the nonlinear capacitor in LT Spice?

John

Reply to
John Larkin

"Helmut Sennewald" wrote in news:g2ha0d$kg0$03$ snipped-for-privacy@news.t-online.com:

Actually it was an exercise from a book. After getting the suspicious results I tried to do what you suggest but I couldn't find a model for a nonlinear capacitor of the parameters I specified (or any nonlinear capacitor.)

If you can help me model the circuit in LTSpice I'd be grateful.

Reply to
sert

Why ? Are you trying to prove EEStor is a fraud ?

I doubt you'd need too much evidence to prove that. The behaviour of hi-K ceramic dielectrics is very well understood.

Graham

Reply to
Eeyore

Jim Thompson wrote in news: snipped-for-privacy@4ax.com:

(Your post came up a bit garbled so I have it fixed above.)

I believe what you wrote is wrong, it is simply:

i = c*dv/dt

That equation is in the book, too.

Reply to
sert

Nope! The general equation is... i = d/dt(C*v)

Likewise for inductors it's... v = d/dt(L*i)

Don't dispute the MIT grad who found this stuff fascinating ;-)

...Jim Thompson

--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
             
         America: Land of the Free, Because of the Brave
Reply to
Jim Thompson

Look up device "C"

In virtually _any_ flavor of Spice, terms can be added to the model card to make it have a first and second order temperature sensitivity, and a first and second order voltage sensitivity.

If your version of Spice supports behavioral modeling you can have almost any kind of non-linear behavior.

...Jim Thompson

--
| James E.Thompson, P.E.                           |    mens     |
| Analog Innovations, Inc.                         |     et      |
| Analog/Mixed-Signal ASIC\'s and Discrete Systems  |    manus    |
| Phoenix, Arizona  85048    Skype: Contacts Only  |             |
| Voice:(480)460-2350  Fax: Available upon request |  Brass Rat  |
| E-mail Icon at http://www.analog-innovations.com |    1962     |
             
         America: Land of the Free, Because of the Brave
Reply to
Jim Thompson

Copied from LTspice help file for component capacitor:

(begin excerpt)

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.

Syntax: Cnnn n1 n2 Q= [ic=] [m=]

There is a special variable, x, that means the voltage across the device. Therefore, a 100pF constant capacitance can be written as

Cnnn n1 n2 Q=100p*x

A capacitance with an abrupt change from 100p to 300p at zero volts can be written as

Cnnn n1 n2 Q=x*if(x

Reply to
John Popelish

The Euler method and its relatives (such as the Milne predictor-corrector) have real trouble with decaying exponential-ish things like this. The problem is that the difference scheme has an extraneous solution (the oscillating one) that dominates the decaying exponential.

You need a better solver--a simple one that works OK for this is the classical fourth-order Runge-Kutta scheme, or with a bit more work you can code up the Adams-Bashforth-Moulton predictor-corrector (my personal fave). You can look them up on the web, or find them in most elementary numerical analysis books.

Cheers,

Phil Hobbs

Reply to
Phil Hobbs

After all that extra crap you have to simulate this?

First, you don't have to go past q = 3 * v^3, and dq/dt = -v/0.2 ohms. This gives you your dv/dt = -(5/9)(1/v).

Then, you have an ordinary separable differential equation, and you don't have to simulate it. A few minutes of quality time with a

2nd-year differential equations book (you did save yours, didn't you?) gets you

v^2 = -(10/9 V^2/sec)t + C, with C = 1V^2.

So v = sqrt(1V^2 - (10/9 V^2/sec)t)

Couldn't be easier.

You can do a similar exercise using q as the state variable. I didn't, because solving one first-order nonlinear problem keeps the really nerdy part of me happy for about a year, so unless I'm getting paid for it I don't do more than that.

I suspect that you are running into trouble with your simulation because with v being a perfect square root of time, your effective gain is going to infinity as the charge goes to zero. Modifying your model to a more easily calculated

q = (some constant)*v + (some other constant)*v^3

would alleviate your simulation problems, and would probably be more realistic, too, in that you'd model the inevitable capacitance formed by the end conductors and whatever space is between them.

(note that you didn't have to solve the whole differential equation to see the infinite gain; it's buried in your dq/dt = -(something)*q^(1/3), which goes to infinity as q goes to zero).

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

"sert" schrieb im Newsbeitrag news:Xns9AB7E32E8D917jtjdfjdfjnbj@147.102.222.230...

Hello,

Save the text below into a file named test.asc . Open it with LTspice and press RUN.

It's using the charge equation (x=voltage)

q=3*x*x*x

This is a capacitor with the voltage dependent capcitance of

C = dq/dv = 9*x*x

Best regards, Helmut

Version 4 SHEET 1 880 680 WIRE 96 48 16 48 WIRE 192 48 96 48 WIRE 192 80 192 48 WIRE 16 96 16 48 WIRE 16 192 16 160 WIRE 192 192 192 160 FLAG 16 192 0 FLAG 192 192 0 FLAG 96 48 vc SYMBOL cap 0 96 R0 SYMATTR InstName C1 SYMATTR Value q=3*x*x*x SYMBOL res 176 64 R0 SYMATTR InstName R1 SYMATTR Value 0.2 TEXT 16 -8 Left 0 !..ic V(vc)=1 TEXT 16 -40 Left 0 !.tran 0 1 0 1m

Reply to
Helmut Sennewald

tim@feynman:~$ maxima

Maxima 5.10.0

formatting link
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. This is a development version of Maxima. The function bug_report() provides bug reporting information. (%i1) 'diff(v,t) = -5/(9*v); dv 5 (%o1) -- = - --- dt 9 v (%i2) ode2(%,v,t); 2 9 v (%o2) - ---- = t + %c 10 (%i3)

That's easier ;-)

Tim.

--
God said, "div D = rho, div B = 0, curl E = - @B/@t, curl H = J + @D/@t," 
and there was light.

     http://tjw.hn.org/      http://www.locofungus.btinternet.co.uk/
Reply to
Tim Woodall

My sweat shirt says, "And God said, 'Let there be light'..."

Then the div/curl expressions.

...Jim Thompson

-- | James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at

formatting link
| 1962 | America: Land of the Free, Because of the Brave

Reply to
Jim Thompson

View in a fixed-width font such as Courier.

. . . . . i . ->

. .----------. v= i x R . | ^ | . | | | d 3 . | | | and i= - -- (3 x v ) . --- / dt . C --- v \\ R . | / 2 dv . | | \\ so v = -9 x R x v x -- . | | | dt . | | | . '----------. . or dt= -9 x R x v x dv . . . . t v(t) . / / . from which | dt = | -9 x R x v x dv . / / . 0 v(0) . . . -------------- . 9 2 | 2 . or t = - - x R x (v - 1) from which v = | 1 - ----- x t . 2 \\| 9 x R . .

Reply to
Fred Bloggs

Only if you already have Maxima (or some commercial variant) loaded.

Besides, every once in a while you need to do it by hand, just to remind your self that it _can_ be done.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
Reply to
Tim Wescott

True, but you have to also use maxima occasionally or you forget how to drive it. I started with:

(%i1) 'diff(v(t),t) = -1/(9*R*v(t)); d 1 (%o1) -- (v(t)) = - ------ dt 9 v(t) R (%i2) desolve(%,v(t)); 1 9 v(0) R - laplace(----, t, lvar) v(t) (%o2) v(t) = ilt(---------------------------------, lvar, t) 9 lvar R

"That CAN'T be right, I think there should be a square root in there somewhere ... well it can be but I don't think it's what the OP was expecting."

Goes and looks in manual. "Oh, of course, it's ode2 for ordinary differential equations"

Tim.

Reply to
google

"Fred Bloggs" schrieb im Newsbeitrag news: snipped-for-privacy@nospam.com...

Hello Fred,

Thanks for this calculation. It's perfect. It's exactly the same curve which I see in LTspice.

Best regards, Helmut

Reply to
Helmut Sennewald

Fred Bloggs wrote in news: snipped-for-privacy@nospam.com:

Thanks. But there's something unusual going on; the capacitor is discharging completely. A linear capacitor, as we know, never discharges completely.

Also, for values of t over a certain threshold the formula is undefined.

Let's assume that the capacitor will discharge completely as the formula suggests. Surely the time t will continue (time will not stop!) but the formula doesn't actually give v=0 for any t after the discharging, it's simply undefined.

Why? Is there some other non-obvious solution to the DE?

Reply to
sert

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.