You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think that if you have a voltage -> inductor -> capacitor -> ground, and the voltage toggles from 0V to 1V, the voltage between the inductor and capacitor should become a sine wave...right? Like, once the voltage goes to 1V, the inductor spins up until it sorta bounces off the capacitor and the current starts flowing the other way, until the opposite happens and the current starts flowing back in the first direction. With ideal components, without resistance, this cycle should continue indefinitely, I think; right? (I'm using this program in part to learn about circuits.) However, what I find with JSpice is that the cycle tapers off pretty quick - but LESS quickly if I increase the sample rate. This suggests to me that numerical error is affecting the results. To get the cycle-drain to a vaguely manageable level, I'm having to increase the sample rate by a factor of like 400, which seems like a lot. Is there anything that can be done about that, or is it sortof just an imperfection we have to live with?
Here's some example code:
private static final int SPS = 32000;
public static void main(String[] args) {
Netlist netlist = new Netlist();
netlist.addNetListComponent(new NetlistDCVoltage("V1", 0.0, "1", "0"));
netlist.addNetListComponent(new NetlistInductor("L1", 10E-4, "1", "2"));
netlist.addNetListComponent(new NetlistCapacitor("C1", 10E-6, "2", "0"));
int factor = 10;
TransientConfig transientConfig = new TransientConfig("0.01s", (1.0/factor)/SPS+"s", new Square("V1", 0.25, "-0.001", 0.25, "2.0"));
netlist.setSimulationConfig(transientConfig);
SimulationResult simulationResult = JSpice.simulate(netlist);
SimulationPlotter.plot(simulationResult, new String[]{"V(1)", "V(2)", "I(L1)"});
}
which gives:
Increasing factor from 10 to 100 gives:
The text was updated successfully, but these errors were encountered:
I think that if you have a voltage -> inductor -> capacitor -> ground, and the voltage toggles from 0V to 1V, the voltage between the inductor and capacitor should become a sine wave...right? Like, once the voltage goes to 1V, the inductor spins up until it sorta bounces off the capacitor and the current starts flowing the other way, until the opposite happens and the current starts flowing back in the first direction. With ideal components, without resistance, this cycle should continue indefinitely, I think; right? (I'm using this program in part to learn about circuits.) However, what I find with JSpice is that the cycle tapers off pretty quick - but LESS quickly if I increase the sample rate. This suggests to me that numerical error is affecting the results. To get the cycle-drain to a vaguely manageable level, I'm having to increase the sample rate by a factor of like 400, which seems like a lot. Is there anything that can be done about that, or is it sortof just an imperfection we have to live with?
Here's some example code:
which gives:
Increasing
factor
from 10 to 100 gives:The text was updated successfully, but these errors were encountered: