Hello, I have a question about a memory issue whil...
# analog-design
u
Hello, I have a question about a memory issue while running a simulation using ngspice. Due to the current memory shortage problem, I've created a raw file using batch mode. However, I cannot open this raw file in ngspice due to memory shortage issue. Is there another way to view the values in the raw file? (without using ngspice) Also, is there a way to save only the voltage of a specific node, similar to the wrdata option, in batch mode? (I'm asking because I can't use wrdata in batch mode.) Lastly, I am currently trying to run simulations by specifying the time domain using options in tran. However, due to the nature of tran, dividing the simulation into segments and running it gradually takes increasingly longer as it progresses. Is there a way to save the final state and then load it to continue the simulation for the next segment?
a
@정진형학부생 You have few questions here: • Yes, you could load raw files directly into python in pandas and do appropriate data representation. Check this file https://github.com/mabrains/PLL_design/blob/main/pll/Integeration/circuit_integeration/convert_raw.py
Code might be old though
As to saving, you might need to use
Copy code
.save v(vctrl) v(UP) v(DN) v(REF) v(FB) v(vp) i(Vt)
This will save selected voltages and currents only.
As for time segmentation, I believe it’s feasible in NGSpice. But we never used that option though and we haven’t tested it.
@정진형학부생 hope that helps
u
Thank you for your advice. I'll give it a try!
s
> Is there a way to save the final state and then load it to continue the simulation for the next segment? You might want to use:
17.5.100 Wrnodev: Write node voltage values to a file (.ic=xx format)
this command saves all the voltages, you can then include this file for another simulation with a .tran instruction that has the
uic
option (Use Initial Conditions). If your circuit is sufficiently "digital" such that the state of all voltages is sufficient to define the circuit state you will be able to restart the transient simulation. A good advice is to use
wrnodev
when the circuit is not in the middle of a voltage transition, so stay away from clock edges or any other switching event when saving the circuit state. keep in mind that restarting the simulation this way the time for the next simulation starts from 0 so you probably need to adjust voltage / current source stimuli if they depend on time.
It is also possible to write two different raw files splitting the data, see the image, first transient section saved in
solar_panel.raw
, second section in `solar_panel2.raw`: Keep in mind however that this will just split the output raw files but does not solve the memory issue. If simulation data does not fit in memory using interactive ngspice simulation this will not work.
for reference here the commands:
Copy code
.option savecurrents
.control
  save all
  stop when time=0.3m
  tran .05u 1m uic
  write solar_panel.raw
  resume
  let cut-tstart = 0.3m
  let cut-end = 1m
  cutout
  write solar_panel2.raw
  quit 0
.endc
👍 1
u
Is it possible to perform this operation(.control) in batch mode?
Due to memory constraints, I need to perform the simulation in batch mode.
s
@정진형학부생 in latest xschem I have added the ability to load only a portion of a raw file. You can generate a very big raw file in batch mode and load only a portion of it with xschem: the syntax is:
xschem raw_read $netlist_dir/circuit_name.raw tran 10u 20u
In the example above 10u and 20u is the interval to load. (10u included, 20u excluded, 10u <= t < 20u). If you may set an interval small enough such that the raw portion fits in xschem memory. This is very new in xschem, you need to rebuild the program from github sources.
u
Thank you!! It seems like I need to update xschem and give it another try.
Hello, I have one more question. Is there a feature in ngspice that allows me to reduce the amount of data by checking values only at a 200ns interval in the results of the simulation, without the need to examine results for every time point? The simulation time step should be maintained at 10ps (tran 10ps 10us).
s
@정진형학부생 the
.tran
command has optional parameters tstart and tmax:
.tran tstep tstop tstart tmax
, tstart is defaulted to 0 if unspecified. If you specify a value for it the raw file is recorded from that point.
.tran 10p 201n  199nn 10p
will save simulation from 199ns to 201ns only. The last
10p
ensures a maximum timestep of 10ps, even if numerical solution could use bigger time steps (in case for example if a steady circuit).