SpiceSharpParser icon indicating copy to clipboard operation
SpiceSharpParser copied to clipboard

Add specific SPICE evaluators / decoders

Open ewiebe1 opened this issue 6 years ago • 9 comments

Please add PSpice specific evaluator / decoder

If you add PSpice specific code, it will result in an error, e.g.:

V_V1 N14847 0 +PULSE 0V 5V 3.67us 40ns 40ns 3.255us 6.51us V_V2 N14651 0 5Vdc R_R1 N18055 N14538 2.2k TC=0,0 R_R2 N17129 N14555 2.2k TC=0,0 C_C1 N14538 N14569 1n TC=0,0 C_C2 N14555 N14581 330p TC=0,0 R_R3 N14677 N14651 1k TC=0,0 R_R4 N14677 0 1k TC=0,0 R_R5 N14538 N14569 68k TC=0,0 R_R6 N14555 N14581 120k TC=0,0 C_C3 N14569 N17129 10n TC=0,0 X_U6 N14677 N14538 N14651 0 N14569 MCP651 X_U7 N14677 N14555 N14651 0 N14581 MCP651 C_C4 N14847 N18055 100n TC=0,0 V_V3 M_UN0001 0 AC 0 +SIN 2.5V 2.06V 153600 0 0 0 ...

MCP651.txt

ewiebe1 avatar Sep 13 '18 19:09 ewiebe1

At the moment SpiceSharpParser is not able to parse PSpice specific netlist.

I need to add following features to make it work:

  • TABLE
  • POLY(1)/POLY(2)/POLY(3)
  • VALUE = {expression}
  • TC = TC1, TC2 for resistor

I will work on that but I estimate that I can take at least 2 months of work. Do you have any questions?

Kind regards Marcin

marcin-golebiowski avatar Sep 14 '18 08:09 marcin-golebiowski

@ewiebe1 I've started to work on that features.

marcin-golebiowski avatar Sep 24 '18 16:09 marcin-golebiowski

@ewiebe1 Following features have been implemented:

  • TABLE syntax (ABM)
  • POLY(n) syntax (ABM)
  • VALUE = {expression} (ABM)
  • TC = TC1, TC2 for resistor

I will continue to work on ability to parse and run PSpice netlists. I think in one month you will be able to parse the netlist you posted using SpiceSharpParser. Is there any special netlist that you would like to parse? Anything I could help?

Marcin

marcin-golebiowski avatar Oct 25 '18 21:10 marcin-golebiowski

Hello Marcin, many thanks for your work!

Today, I have made an other test: I have downloaded the current version of SpiceSharpParser and created a small Test Application. In this test application I go through all *.cir files from the examples folder of ngspice28. There were many Exceptions while parsing these files.

My code snippet: private void TestNetlist(string path_netlist) { try { SpiceParserSettings sps = new SpiceParserSettings(); sps.WorkingDirectory = path_netlist.Substring(0, path_netlist.LastIndexOf("\")); SpiceParser sp = new SpiceParser(sps); string netlist = File.ReadAllText(path_netlist); sp.ParseNetlist(netlist); } catch (Exception Ex) { AddLog("Error with " + path_netlist + " : " + Ex.Message); }
}

See attached files. Thank you for your work again!

parsing log of ngspice 28.txt

ngspice examples.zip

ewiebe1 avatar Nov 14 '18 09:11 ewiebe1

@ewiebe1 I will work also on ability to parse ngspice28 netlists. Thank you for examples. I will try my best, but It will take time to write all necessary features to SpiceSharpParser.

Regarding the netlist you posted (MCP651.txt) it's quite close to successful parsing. In the next release of SpiceSharp/SpiceSharpParser we are adding in particular:

  • TC1, TC2 for capacitor.
  • PWL waveform We also need to extend mosfet model to allow w and l parameters. However I think there is an error in MCP651.txt regarding brackets for TABLE (line 138).

marcin-golebiowski avatar Nov 14 '18 16:11 marcin-golebiowski

@ewiebe1 Do you have any other requests regarding SpiceSharpParser?

marcin-golebiowski avatar Feb 10 '19 20:02 marcin-golebiowski

I found out today that LTSpice uses also some special features in its SPICE netlists, like "A-Devices". See here: Undocumented LTSpice parser features

Perhaps the SpiceSharpParser should also be able to parse such special LTSpice netlists ?

ewiebe1 avatar Apr 08 '20 13:04 ewiebe1

@ewiebe1 I think it would be not difficult to parse that. However much harder is to simulate that components.

marcin-golebiowski avatar Apr 08 '20 16:04 marcin-golebiowski

I agree with @marcin-golebiowski . Supporting these custom models is difficult because they'd have to be reverse-engineered. Instead, it may be better to just roll out custom models.

I currently have my hands full with Spice# and Spice#.Behavioral v3, so I don't see this implemented in the near future.

svenboulanger avatar Apr 10 '20 17:04 svenboulanger