Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parsing ng-spice output #3

Open
hopewise opened this issue Aug 25, 2016 · 10 comments
Open

parsing ng-spice output #3

hopewise opened this issue Aug 25, 2016 · 10 comments

Comments

@hopewise
Copy link

As you have tried to parse ng-spice, I would like to ask please, do you think I can fully parse the ng-spice output to power a simulator features like this one as I would need to cast the current value for each component including wires, do you encourage me to start such a parser? Do you know any good ng-spice output parser library there?

@fahimkhan
Copy link
Owner

We are actually getting all node voltages and node current from ngspice. Our parser is capable to parse this value for ac,dc and tran analysis. The result we got from the parser is in the form of dictionary having key as node/branch name and value as list of voltage/current value for each iteration. You can easily use this dictionary in your plot.

Now this is up to you how you reflect it in your front end. You can just show the value or just plot branch current or node voltage. I am not aware of any other open source ngspice output parser library. But if you are planning to write your own parser then I would suggest to use rawfile generated in ngspice instead of content of 'print allv' and 'print alli'

By the way you can check https://www.circuitlab.com/ I think they are using ngspice at the backend.

@hopewise
Copy link
Author

Can you please refer to the dictionary in the source code in where you store the result?

Also, using rawfile generated in ngspice will not consume memory as ngspice will write to the rawfile directly?

@fahimkhan
Copy link
Owner

Yes, ngSpice will directly write it to the file. Just like 'print allv > file.txt' there is command for raw file as well.

We have written a parser in python which can be found under scripts directory. It takes the analysis,file details and after parsing ,it store the result in dictionary. We call this parser from nodeJS using python-shell module. Here is the code for calling parser.py from nodeJS.

`function parsePlotData(){
console.log("Ngspice netlist executed successfully "+fileName);
// console.log("Allv :"+plot_allv_file)
//socket.emit('serverMessage','Ngspice netlist executed successfully: ');
//var analysisInfo = grep('.tran|.dc|.ac', fileName); //Not reliable
var analysisInfo = getAnalysisInfo(fileName);
console.log("Analysis :"+analysisInfo)
var options = {
mode: 'json',
pythonPath: pyEnv,
pythonOptions: ['-u'],
scriptPath: scriptPath,
args: [analysisInfo, plot_allv_file, plot_alli_file]
};

        PythonShell.run('parser.py', options, function (err, results) {
        if (err) throw err;
            // results is an array consisting of messages collected during execution 
        // console.log('results: %j', results);
        var resultString = results[0];
        // console.log(resultString);
        //Emitting Data Points to client
        socket.emit('plotData',resultString);

        });
    }`  

@hopewise
Copy link
Author

Thanks Fahimkhan, is there any social network I can follow you on? Twitter maybe?

@fahimkhan
Copy link
Owner

Here is my twitter profile https://twitter.com/bitwisenoise

@hopewise
Copy link
Author

Thanks Fahim, but where is parser.py file?

@fahimkhan
Copy link
Owner

Its there under scripts directory.

@hopewise
Copy link
Author

Ah, sorry didn't notice!

@higuoxing
Copy link

Wow, thank you for all of your efforts! Much helpful! Such an useful project!

@higuoxing
Copy link

Hi, whatever, thanks for your efforts! I found that in ngspice27 there's a command wrdata v(in), which will write data as following

 8.24500000e-02  0.00000000e+00
 8.25500000e-02  0.00000000e+00
 8.26500000e-02  0.00000000e+00
 8.27500000e-02  0.00000000e+00
 8.28500000e-02  0.00000000e+00
 8.29500000e-02  0.00000000e+00
 8.30500000e-02  0.00000000e+00
 8.31500000e-02  0.00000000e+00
 8.32500000e-02  0.00000000e+00
 8.33500000e-02  0.00000000e+00

So, I think it's easier to parse :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants