Ngspice Capacitor Simulation problem

Click For Summary

Discussion Overview

The discussion revolves around issues encountered while simulating a capacitor in an RC circuit using ngspice. Participants explore the behavior of the capacitor in the simulation, particularly focusing on the unexpected rapid voltage rise and the implications of different netlist configurations. The conversation includes technical aspects of circuit simulation, netlist formatting, and the effects of component values.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes a problem where a capacitor reaches maximum voltage instantaneously, questioning the correctness of their netlist.
  • Another participant suggests that the original netlist is not wrong but represents a high-pass filter, and recommends adding internal resistance to the voltage source to observe different behavior.
  • A suggestion is made to remove the "F" from the 10 Farad capacitor to avoid confusion with unit modifiers, as the simulator may misinterpret the value.
  • Further clarification is provided that the circuit is indeed a high-pass filter, and a different netlist configuration is proposed for AC simulation to illustrate the filter response.
  • A participant acknowledges the misunderstanding regarding the time constant due to the large capacitor value initially estimated, which affected their simulation parameters.
  • Another participant expresses gratitude for the responses and notes that the provided simulation tips may be useful for future reference.

Areas of Agreement / Disagreement

Participants express differing views on the interpretation of the netlist and the behavior of the circuit. While some agree on the need for adjustments to the netlist, there is no consensus on the best approach to resolve the initial problem.

Contextual Notes

Participants highlight limitations related to the interpretation of capacitance values and the effects of component configurations on simulation results. There are unresolved aspects regarding the impact of internal resistance and the correct setup for transient analysis.

Who May Find This Useful

This discussion may be useful for individuals interested in circuit simulation, particularly those using ngspice, as well as those exploring the behavior of capacitors in RC circuits.

wolterh
Messages
7
Reaction score
0
I intend to use circuit simulation (namely ngspice because it runs on linux) to aid me through electric circuit studies.

However, I recently encountered a problem in a circuit I was simulating: the plots were not logical - a capacitor was taking no time to reach its maximum voltage.

At first I thought it was only my machine so I tried it on PSPICE and on ngspice online simulator, which yielded the plot attached with the following netlist:
Code:
A simple RC circuit
V0 n1 GND DC 12V
R1 n2 GND 10k
C2 n1 n2 10F
.END

Is the netlist wrong?
I found that the following netlist does model the capacitor alright, but the first I generated with a circuit designer application (gEDA) and the second I based on a website example.

Working netlist:
Code:
Test circuit
V0 n1 GND DC 10V
R1 n1 n2 3.3k
C2 n2 GND 47uF
.END
 

Attachments

  • plot0.png
    plot0.png
    8.8 KB · Views: 623
Engineering news on Phys.org
wolterh said:
However, I recently encountered a problem in a circuit I was simulating: the plots were not logical - a capacitor was taking no time to reach its maximum voltage.
Your netlist is not wrong, it describes a high-pass filter (the second one is a low-pass filter). But you're plotting the voltage of the ideal voltage source when it turns on. Add some internal resistance to it and see what happens.
 
Try removing the F from the 10 Farad capacitor. Just leave it as 10.

The simulator knows that the unit of capacitance is Farads, but it looks for modifiers like "k" or "μ" after the number.

It would assume you mean "femto" if you put an F there.
 
As mentioned before, the circuit as you have it is a high pass filter. If you want to do AC simulation, you can go to www.ngspice.com and the following in the netlist textbox:

A simple RC circuit
V0 n1 GND DC 12V AC 1V
R1 n2 GND 10k
C2 n1 n2 10F

.AC DEC 10 1 1e10

.END

and then "db(v(n2))" in the plot textbox. You'll get a plot with high pass filter response, but with the pole at very high frequency. This is because your capacitor is really small--10 femto farads (10e-15). If you don't have the "F" then you'd end up with 10 farads--a much larger value than you may want also.

To see a transient step response of the capacitor, put the following into the netlist textbox:

A simple RC circuit
V0 n1 GND DC 12V AC 1V
R1 n2 GND 10k
C2 n1 n2 10n

.ic v(n2)=12V

.TRAN 100n 500u

.END

and then "v(n2)" into the plot textbox. Here I used a 10nF capacitor and an initial condition on v(n2) so that you could see it transition from 12V to GND.
 
I'm sorry I have been trying to reply this post for hours but my internet just keeps dying. Thanks for your answers, they are appreciated much!

gnurf: I have not researched on how to add an internal resistance to a source but the resistor present in the circuit (between nodes n2 and GND) does the same role.

vk6kro: I would say you have nailed the problem! Because I had estimated a time constant for the circuit with 10 Farads, the time interval and time step I was taking were useless for a 10 fF capacitor, which ngspice was interpreting.

ngspice.com: I was trying to do a transient analysis, but the other simulation tips you provided may prove useful for me in the future or for some other thread visitor!

Thanks for your answers. We can consider this thread closed from now on.
 

Similar threads

Replies
4
Views
3K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 12 ·
Replies
12
Views
5K
  • · Replies 10 ·
Replies
10
Views
10K
Replies
8
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K