Simulation-Data Export

Hi guys,
I am doing some simulation on audi-amps using ngspice producing quite a few datafiles.
For post-processing I prefer Matlab for more flexibility.
When doing it with ngspice stand-alone with gspiceui, it produces nice results-files in a csv-format with numbers represented in scientific format with a decimal point.
And what is highly important: all data are organized in columns, which eases post-processing with other tools.
Unfortunately the integrated ngspice simulator exports csv-data differently:

  1. all data are organized in lines/rows.
    This inhibits post-processing of bigger files (very long lines!) using exel and Matlab
  2. All values have the comma as decimal-point and semi-colon as separator, which requires manual post-processing additionally.

Today I tried importing big simulation files into Matlab: failed
Import into exel: failed due to too many colums.
Manual post-processing with kate(texteditor) failed: lines too long.

The gEDA-workflow (gschem, gnetlist, gspiceui, gaw) produces convenient, applicable data.
This should work out with KiCad either, which is my preferred PCB-tool,
whereas the spice capabilities can still be improved.

Would it be possible to spend some more emphasis to spice integration and fix these small issues?

kr, sepp2gl

This forum is a user-to-user support forum and not the right place to address feature enhancements to the KiCad developers.

Your request has been addressed some time ago at the bug/feature tracker There also has been discussed an intermediate solution:

By adding a .control section to the Eeschema circuit diagram, replacing the previous single line in a text box

.ac dec 10 1 1Meg

you may use the output commands offered by stand-alone ngspice. This is an example:

.ac dec 10 1 1Meg
* wait until simulation has finished
set controlswait
* cd into a directory with writing access
cd D:\Software\Spice\kicad\sallen_key
* set ouput format for cvs
set wr_vecnames
set wr_singlescale
option numdgt=7
* data to csv file
wrdata skey.csv  "/lowpass"
* data to ps file
set hcopydevtype = postscript
hardcopy db("/lowpass")
* gnuplot output (if gnuplot has been installed)
gnuplot db("/lowpass")
1 Like

Thanks, Holger for your very rapid response.
I have tried your proposal, it seems to be a good work-around for my issue.
Do you have a solution for exporting ALL nodes into the csv-file?
LG, sepp2gl

I am not sure, but does

wrdata skey.csv all

work? If not, there is no other way than listing all vectors.

Nope…unfortunately neither ‘all’ nor ‘“all”’ work out.
Nevertheless, you shew me the way to get on.
Thanks a lot.

But: I highly recommend to make this format the standard mainstream for csv-exports
in an up-coming release.

thanks again, sepp2gl

P.S.: I noticed, that the path for “cd …” is only interpreted in lower-case letter
independent from, what I wrote in the control-section.
So “cd ~/Projekte” was transformed into “cd ~/projekte” and consequently not found.
Do you know, how I can apply upper-case letters, too?
thx, sepp2gl

1 Like

This indeed is a ngspice bug. I will push a fix to ngspice git branch pre-master.

Thanks for the report.


A fix is pushed to ngspice git branch pre-master.

1 Like