This shows you the differences between two versions of the page.
gnucap:manual:examples:things_that_can_go_wrong [2009/05/16 01:50] aldavis created |
gnucap:manual:examples:things_that_can_go_wrong [2015/12/11 15:39] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Things that can go wrong ====== | ||
+ | |||
+ | ===== Voltage sources in parallel ===== | ||
+ | |||
+ | eg4.ckt | ||
+ | |||
+ | <code> | ||
+ | VOLTAGE SOURCES IN PARALLEL | ||
+ | |||
+ | V1 1 0 10.0 | ||
+ | V2 1 0 10.2 | ||
+ | .print dc v(1) i(V1) i(V2) | ||
+ | .dc | ||
+ | .end | ||
+ | </code> | ||
+ | |||
+ | |||
+ | Here we have V1 and V2 both driving the same node at about 10 volts. | ||
+ | Actually, V2 is very slightly higher than 10 volts so there will be | ||
+ | some argument between V1 and V2 as to exactly what the final voltage | ||
+ | at node 1 really is. You should see that huge currents are flowing | ||
+ | through the supplies (10,000 amps) just due to this small voltage | ||
+ | difference. Also note that gnucap does not throw in the towel and give | ||
+ | up, nor does it fail to converge... the answer that it gets for v(1) | ||
+ | is a compromise, halfway between the two sources. | ||
+ | |||
+ | What is does is introduce a slight imperfection in the voltage sources | ||
+ | so that they do have a small internal series resistor. This allows it | ||
+ | to make the best guess that it can in a difficult situation. How much is | ||
+ | this resistance? You can find out like so: | ||
+ | |||
+ | acs | ||
+ | options | ||
+ | |||
+ | Look at the value of the option called "short" (near the middle of | ||
+ | the block of options), this is the value (in ohms) of the internal | ||
+ | resistance of a voltage source. The "u" character means "micro" | ||
+ | or 1e-6 so the default value of a short circuit is 1e-5 ohms. You | ||
+ | might decide that a different short circuit value is more appropriate | ||
+ | for running the above circuit so you can type (from the prompt): | ||
+ | |||
+ | options short=0.5 | ||
+ | get eg4.ckt | ||
+ | dc | ||
+ | exit | ||
+ | |||
+ | Which should show you the same voltage (10.1) but now the current | ||
+ | has reduced to only one fifth of an Amp (still not small but a lot | ||
+ | more reasonable if you were building this with real supplies). | ||
+ | Other option values can be altered in much the same way and input | ||
+ | files can contain ".options" command lines in order to set these | ||
+ | options whenever the circuit is loaded. | ||
+ | |||
+ | ===== Current sources in series ===== | ||
+ | |||
+ | eg5.ckt | ||
+ | |||
+ | <code> | ||
+ | CURRENT SOURCES IN SERIES | ||
+ | |||
+ | I1 0 1 2.0001 | ||
+ | I2 1 0 2.0 | ||
+ | .print dc v(1) i(I1) i(I2) | ||
+ | .dc | ||
+ | .end | ||
+ | </code> | ||
+ | |||
+ | The case of putting two current sources in series is much the same | ||
+ | concept as two voltage sources in parallel. However notice that gnucap | ||
+ | copes with it in a different manner. It cannot find a compromise current | ||
+ | that is partway between the two sources and it always gives a huge | ||
+ | value for the voltage at node 1. At least it doesn't crash and it does | ||
+ | give results that give some suggestion as to where the problem might | ||
+ | be. There is an option "gmin" that introduces resistance into a current | ||
+ | source, or you can explicitly add these resistors if you like by putting | ||
+ | the resistor in parallel with the current source. | ||
+ | |||
+ | What if you had a big, complex circuit, you messed up by putting | ||
+ | two current sources in series but you never thought about checking | ||
+ | the strange node? How would you ever know that the circuit was broken? | ||
+ | Try this exercise: | ||
+ | |||
+ | acs | ||
+ | get eg5.ckt | ||
+ | alarm dc v(*)(-1e3,1e3) | ||
+ | dc | ||
+ | quit | ||
+ | |||
+ | Now you get a warning whenever any component gets more that 1000 volts | ||
+ | across it. This can be used to test component breakdown if you know | ||
+ | that you are using components that cannot tolerate high voltages. It can | ||
+ | also be used to ensure that your simulated circuit stays within what you | ||
+ | might expect to be the absolute maximum values. | ||
+ | |||