Closed betty2310 closed 3 months ago
@marcin-golebiowski Hi, sorry for mention without permission but can you please help?
Hi, Following snippet works for me:
var netlistText = string.Join(
Environment.NewLine,
"Diode circuit",
"D1 OUT 0 1N914",
"V1 OUT 0 0",
".model 1N914 D(Is=2.52e-9 Rs=0.568 N=1.752 Cjo=4e-12 M=0.4 tt=20e-9)",
".DC V1 -1 1 10e-3",
".SAVE i(V1)",
".END");
// Parsing part
var parser = new SpiceNetlistParser();
var parseResult = parser.ParseNetlist(netlistText);
var netlist = parseResult.FinalModel;
// Translating netlist model to SpiceSharp
var reader = new SpiceSharpReader();
var spiceSharpModel = reader.Read(netlist);
// Simulation using SpiceSharp
var simulation = spiceSharpModel.Simulations.Single();
var export = spiceSharpModel.Exports.Find(e => e.Name == "i(V1)");
simulation.ExportSimulationData += (sender, args) => Console.WriteLine(export.Extract());
simulation.Run(spiceSharpModel.Circuit);
I use SpiceSharp (3.1.8) and latest SpiceSharpParser
@marcin-golebiowski
Hi, thanks for your reply.
As I mentioned, I get problem when export node is v(OUT)
. If export i(V1)
, it's work fine.
I try to export voltage at node
out
in the netlist provided on README
I've found the issue. Below is working example.
var netlistText = string.Join( Environment.NewLine, "Diode circuit", "D1 OUT 0 1N914", "V1 OUT 0 0", ".model 1N914 D(Is=2.52e-9 Rs=0.568 N=1.752 Cjo=4e-12 M=0.4 tt=20e-9)", ".DC V1 -1 1 10e-3", ".SAVE i(V1) v(OUT,0)", ".END");
// Parsing part var parser = new SpiceNetlistParser(); var parseResult = parser.ParseNetlist(netlistText); var netlist = parseResult.FinalModel;
// Translating netlist model to SpiceSharp var reader = new SpiceSharpReader(); var spiceSharpModel = reader.Read(netlist);
// Simulation using SpiceSharp var simulation = spiceSharpModel.Simulations.Single(); var export = spiceSharpModel.Exports.Find(e => e.Name == "v(OUT,0)"); simulation.ExportSimulationData += (sender, args) => Console.WriteLine(export.Extract()); simulation.Run(spiceSharpModel.Circuit);
I try to export voltage at node
out
in the netlist provided on READMEBut I get this error
Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'key')
Here is full exception message
My enviroinment: