Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simulation of a nonlinear capacitor

743 views
Skip to first unread message

sert

unread,
Jun 8, 2008, 2:21:45 PM6/8/08
to
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<0

After simulating the circuit I get an oscillating behaviour with
the capacitor never discharging. What did I do wrong? Can
someone make a better analysis of the circuit in question?

Jim Thompson

unread,
Jun 8, 2008, 2:49:44 PM6/8/08
to
On Sun, 8 Jun 2008 18:21:45 +0000 (UTC), sert <je...@hotmail.com>
wrote:

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

Helmut Sennewald

unread,
Jun 8, 2008, 2:56:16 PM6/8/08
to
"sert" <je...@hotmail.com> schrieb im Newsbeitrag
news:Xns9AB7D951B93...@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


John Larkin

unread,
Jun 8, 2008, 3:18:10 PM6/8/08
to

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

John

sert

unread,
Jun 8, 2008, 3:19:54 PM6/8/08
to
"Helmut Sennewald" <helmuts...@t-online.de> wrote in
news:g2ha0d$kg0$03$1...@news.t-online.com:

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

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.

Eeyore

unread,
Jun 8, 2008, 3:30:30 PM6/8/08
to

sert wrote:

> Let's assume a nonlinear capacitor

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

sert

unread,
Jun 8, 2008, 3:40:46 PM6/8/08
to
Jim Thompson <To-Email-Use-Th...@My-Web-Site.com>
wrote in news:85ao441vohrgf00bo...@4ax.com:

> 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.
>

(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.

John Popelish

unread,
Jun 8, 2008, 3:56:31 PM6/8/08
to
John Larkin wrote:

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

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=<expression> [ic=<value>] [m=<value>]

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<0,100p,300p)

This device is useful for rapidly evaluating the behavior of
a new a hypothetical charge model for, e.g., a transistor.

(end excerpt)


--
Regards,

John Popelish

Jim Thompson

unread,
Jun 8, 2008, 3:52:59 PM6/8/08
to
On Sun, 8 Jun 2008 19:40:46 +0000 (UTC), sert <je...@hotmail.com>
wrote:

>Jim Thompson <To-Email-Use-Th...@My-Web-Site.com>

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

unread,
Jun 8, 2008, 3:55:47 PM6/8/08
to
On Sun, 8 Jun 2008 19:19:54 +0000 (UTC), sert <je...@hotmail.com>
wrote:

>"Helmut Sennewald" <helmuts...@t-online.de> wrote in

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.

Phil Hobbs

unread,
Jun 8, 2008, 4:07:04 PM6/8/08
to

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

Tim Wescott

unread,
Jun 8, 2008, 4:27:35 PM6/8/08
to

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

Helmut Sennewald

unread,
Jun 8, 2008, 4:27:51 PM6/8/08
to
"sert" <je...@hotmail.com> schrieb im Newsbeitrag
news:Xns9AB7E32E8D9...@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


Tim Woodall

unread,
Jun 8, 2008, 5:07:33 PM6/8/08
to
tim@feynman:~$ maxima

Maxima 5.10.0 http://maxima.sourceforge.net
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/

Fred Bloggs

unread,
Jun 8, 2008, 6:41:12 PM6/8/08
to

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
.
.

Jim Thompson

unread,
Jun 8, 2008, 6:39:55 PM6/8/08
to
On Sun, 8 Jun 2008 21:07:33 +0000 (UTC), Tim Woodall
<dev...@woodall.me.uk> wrote:

>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/

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

Then the div/curl expressions.

Tim Wescott

unread,
Jun 8, 2008, 7:50:40 PM6/8/08
to
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.

goo...@woodall.me.uk

unread,
Jun 9, 2008, 7:50:23 AM6/9/08
to
On Jun 9, 12:50 am, Tim Wescott <t...@seemywebsite.com> wrote:
> 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.
>
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.

Helmut Sennewald

unread,
Jun 9, 2008, 1:41:15 PM6/9/08
to
"Fred Bloggs" <nos...@nospam.com> schrieb im Newsbeitrag
news:484C6008...@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


sert

unread,
Jun 9, 2008, 5:19:04 PM6/9/08
to
Fred Bloggs <nos...@nospam.com> wrote in
news:484C6008...@nospam.com:

> View in a fixed-width font such as Courier.
> .

> --------------
> . 9 2 | 2
> . or t = - - x R x (v - 1) from which v = | 1 -
> ----- x t . 2
> \| 9 x R .
> .
>
>

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?

Tim Wescott

unread,
Jun 9, 2008, 6:14:22 PM6/9/08
to

A linear capacitor coupled with a linear resistor never discharges
completely.

The formula itself may go undefined once the time exceeds the discharge
time, but that just tells you that you need to tack another formula on
to it, piecewise, namely v = 0 for all t > (discharge time).

Fred Bloggs

unread,
Jun 10, 2008, 11:40:00 AM6/10/08
to

.


.
.
.
. 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
. | | |
. '----------.
.

.
. 2 dv dv
. this becomes v + 9 x R x v x -- = v x ( 1 + 9 x R x v x -- )=0
. dt dt
.
. at each instant of time because although C is nonlinear the basic
.
.
. laws of physics still apply to the circuit.
.
.
. The above equation has only two possible solutions:
.
.
. 1) v(t)=0 for all t, which is ruled out because we need v(0)=1
.
. --------------
. | 2
. 2) v(t)= | 1 - ----- x t
. \| 9 x R
.
.
.
. 9 x R dv
. at time t= ----- v=0, the v x ( 1 + 9 x R x v x -- )=0
. 2 dt
.
. 9 x R
. equation still applies where t is now measured from -----
. 2
.
. and since v(0)=0 the v(t)=0 solution does
.
. dv
. apply, and the 1 + 9 x R x v x -- = 0 solution leads to an
. dt
.
. an imaginary and extraneous result.
.
.
. All of this can be condensed into:
.
.
.
. ----------------------
. | 2
. v(t)= | MAX(0,1 - ----- x t) t>=0
. \| 9 x R
.
.

JosephKK

unread,
Jun 11, 2008, 1:24:13 AM6/11/08
to
On Sun, 08 Jun 2008 12:52:59 -0700, Jim Thompson
<To-Email-Use-Th...@My-Web-Site.com> wrote:

>On Sun, 8 Jun 2008 19:40:46 +0000 (UTC), sert <je...@hotmail.com>
>wrote:
>
>>Jim Thompson <To-Email-Use-Th...@My-Web-Site.com>
>>wrote in news:85ao441vohrgf00bo...@4ax.com:
>>
>>> 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.
>>>
>>
>>(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.
>
>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

Nice swat on some twit who clearly deserved it.

JosephKK

unread,
Jun 11, 2008, 2:46:51 AM6/11/08
to
On Sun, 08 Jun 2008 15:56:31 -0400, John Popelish <jpop...@rica.net>
wrote:

While it is true that LTSpice supports it, i believe that it is
generic to all spice v.3

JosephKK

unread,
Jun 11, 2008, 2:53:07 AM6/11/08
to

Haven't a clue if that is over OP's head or not, but now i know who to
call when the math is getting tough for me.

redbelly

unread,
Jun 11, 2008, 7:37:15 AM6/11/08
to
On Jun 8, 4:27 pm, Tim Wescott <t...@seemywebsite.com> wrote:

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

I get the same result, but have a problem that v is imaginary for
times greater than 0.9 sec. I guess the way to interpret this is that
this "capacitor" really discharges to 0 V in a finite time, and simply
remains 0 thereafter.

Mark


Helmut Sennewald

unread,
Jun 11, 2008, 1:59:33 PM6/11/08
to
"redbelly" <redbe...@yahoo.com> schrieb im Newsbeitrag
news:2b4e90a7-74f5-4843...@c65g2000hsa.googlegroups.com...


Hello Mark,

When the capacitor is discharged by the resistor,
its energy is changed to heat in the resistor.
That means that all the energy is lost.

E = 1/2*C*V^2

After V has become 0, E will be 0:

0 = 1/2*C*V^2

-> V remains 0V after the discharge.

Best regards,
Helmut


Helmut Sennewald

unread,
Jun 11, 2008, 2:08:07 PM6/11/08
to

"JosephKK" <quiett...@yahoo.com> schrieb im Newsbeitrag
news:e2tu44t1r59k0948m...@4ax.com...


Hello,

A nice wish regarding SPICE3, but it's not available there!
I have the feeling there isn't much activity around SPICE3
since a decade.

Helmut


JosephKK

unread,
Jun 12, 2008, 10:00:54 PM6/12/08
to

The current base version from Berkeley is v.3f5. The initial
development of v.3 included all kinds of added non-linear components
changes and a complete set of linear or non-linear dependant sources.

Helmut Sennewald

unread,
Jun 13, 2008, 1:59:43 PM6/13/08
to

"JosephKK" <quiett...@yahoo.com> schrieb im Newsbeitrag
news:4uk354l503c7a2gu4...@4ax.com...

Hello Joseph,

SPICE 3f5 is from 1997.

http://www.mes.tu-darmstadt.de/lectures/summer/gel/schmankerl/SpiceSchmankerl.pdf

Do you have any link about a manual-page with an
arbitrary capacitor model? I couldn't find one.

Best regards,
Helmut


JosephKK

unread,
Jun 13, 2008, 9:17:45 PM6/13/08
to
On Fri, 13 Jun 2008 19:59:43 +0200, "Helmut Sennewald"
<helmuts...@t-online.de> wrote:

It does not seem to be listed on the Berkeley SPICE models page:

http://bwrc.eecs.berkeley.edu/Classes/icbook/SPICE/UserGuide/elements_fr.html

but with a pair of non-linear dependant sources is should be pretty
easy to make a macro for one. In fact they provide an annotated
subcircuit for a non-linear capacitor in the non-linear source
description.

redbelly

unread,
Jun 15, 2008, 8:58:57 AM6/15/08
to
On Jun 11, 1:59 pm, "Helmut Sennewald" <helmutsennew...@t-online.de>
wrote:
> "redbelly" <redbell...@yahoo.com> schrieb im Newsbeitragnews:2b4e90a7-74f5-4843...@c65g2000hsa.googlegroups.com...

Hello Helmut,

Much of what you say is also true of standard linear capacitors, which
of course do not go to zero volts in a finite time.

After reviewing my derivation, I found that as V --> 0, the current
becomes infinitely large, thereby draining all the charge. At V=0,
the differential equation I had come up with is no longer valid, so I
guess it makes sense in a way that the solution is not valid for times
beyond when V reaches 0.

Regards,
Mark

0 new messages