J
john jardine
- Jan 1, 1970
- 0
Egads!. You've just given away the secret of Spice Transient Analysis. TheJohn Larkin said:How about this:
Charge a 1 farad capacitor to 1 volt and slap a 1 ohm resistor across
it. The resistor current is 1 amp, so the cap discharges, and the
voltage is at first declining at a rate of 1 volt per second. But
1/100 of a second later, the voltage is 0.99 volts, so the current is
only 0.99 amps, so the rate of discharge is only 0.99 volts per
second.
So we write a Basic program:
v = 1 ' charge the cap
for t = 1 to 100 ' then, for 1 second at 0.01 sec steps,
v = v - 0.01 * v ' discharge the cap by 1%
next
print v ' voltage is this, 1 second later
which simulates what I was doing above, but for a full second. The
value of v at the end is 0.36603 volts. That's close to 1/e, not exact
because I took 100 discrete steps, as an approximation to
continuous-time math. With 1000 steps, simulating 1 second of
discharge in 1 millisecond steps, you get 0.367700, even closer.
'e' is just nature's answer to a natural discharge curve.
John
programmers will be calling for you with torches ablaze.
Why is it that if anyone wants to *clearly* explain an algorithm or
sequential idea, they'll use "Basic" or a very Basic looking 'Pseudo-code',
yet most programmes seem written in "C".
It just isn't logical.
regards
john