1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./style.css" />
6 <link rel=
"stylesheet" media=
"screen" type=
"text/css" href=
"./design.css" />
7 <link rel=
"stylesheet" media=
"print" type=
"text/css" href=
"./print.css" />
9 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
14 <em>Translations of this page are also available in the following languages:
</em> <a href=
"geda-circuit_simulation_improvements.ru.html" class=
"wikilink1" title=
"geda-circuit_simulation_improvements.ru.html">Русский
</a>.
17 <h1 class=
"sectionedit1" id=
"circuit_simulation_improvements_in_gschem">Circuit simulation improvements in gschem
</h1>
21 <!-- EDIT1 SECTION "Circuit simulation improvements in gschem" [134-190] -->
22 <h2 class=
"sectionedit2" id=
"rationale">Rationale
</h2>
26 Using gschem as a circuit simulation (ngspice or gnucap) frontend is not easy for novice users. A new user would like to do the following things inside gschem:
29 <li class=
"level1"><div class=
"li"> specify what kinds of simulations should be run
</div>
31 <li class=
"level1"><div class=
"li"> specify which voltages and currents should be plotted
</div>
33 <li class=
"level1"><div class=
"li"> start the simulation
</div>
38 The simulation runs and the postprocessing may be in an external program that is triggered by IPC.
42 There are some graphical frontends around but they can
't solve all of the above problems
45 <li class=
"level1"><div class=
"li"> <a href=
"http://www.geda.seul.org/tools/gspiceui/index.html" class=
"urlextern" title=
"http://www.geda.seul.org/tools/gspiceui/index.html" rel=
"nofollow">gspiceui
</a></div>
47 <li class=
"level1"><div class=
"li"> <a href=
"http://www.comefly.us/" class=
"urlextern" title=
"http://www.comefly.us/" rel=
"nofollow">kjwaves
</a></div>
49 <li class=
"level1"><div class=
"li"> <a href=
"http://easy-spice.sourceforge.net/" class=
"urlextern" title=
"http://easy-spice.sourceforge.net/" rel=
"nofollow">easyspice
</a></div>
54 All frontends have the problem that you can not point to the net you
'd like to see. You need to know the netname of the node.
58 <!-- EDIT2 SECTION "Rationale" [191-987] -->
59 <h2 class=
"sectionedit3" id=
"draft">Draft
</h2>
63 Let
's assume we only want to make tiny changes to gschem and libgeda so that we can at least set some probes and ran a simulation.
67 <!-- EDIT3 SECTION "Draft" [988-1137] -->
68 <h3 class=
"sectionedit4" id=
"the_probes">The probes
</h3>
72 <strong>Current probes
</strong> can be ordinary dc voltage sources with
0V. The easy way to insert that probe would be a symbol with two pins like an normal ampere meter.
73 If we
'd like to set a current probe to an end of a pin we need a netlister that detects that current probe and replaces it with our “ampere meter”.
74 If we use a voltage source as an ampere meter the netlister does not need to know the netnames inside the schematic. All
0V voltage sources with a special device name are current probes.
78 <strong>Voltage probes
</strong> may be current sources with
0A. The second pin of the current source is tied to GND with a net attribute. Thus again the netlister does not need to know the netnames as it can use that net that is connected with that special current sources.
79 Like above a voltage source could be a special (graphical) symbol that is detected by a netlister.
83 <!-- EDIT4 SECTION "The probes" [1138-2013] -->
84 <h3 class=
"sectionedit5" id=
"voltage_and_current_sources">Voltage and current sources
</h3>
88 Specifying the parameters of sources is not that easy. Currently they are stored inside the “value” attribute of the symbol.
89 e.g. “value=pulse
0 1 10n
10n
100n
1u 2u”. These settings needs to match the spice attributes “pulse(V1 V2 TD TR TF PW PER)”.
93 A dialog would be nice that prompts the user for the named attributes and not only for the value string.
97 A modified edit attribute (
<kbd>E
</kbd><kbd>E
</kbd>) command could take care of voltage and current source devices and trigger a different property dialog for that sources. Currently the multiattrib edit dialog is triggered.
101 <!-- EDIT5 SECTION "Voltage and current sources" [2014-2635] -->
102 <h3 class=
"sectionedit6" id=
"the_simulations">The simulations
</h3>
106 How can we store a simulation inside gschem.
110 To store one simulation we can use a symbol with the device name “SIMULATION”.
111 All options that define one simulation are stored as attributes attached to that object.
114 <li class=
"level1"><div class=
"li"> kind of simulation (dc, ac, tran, …)
</div>
116 <li class=
"level1"><div class=
"li"> simulator options
</div>
118 <li class=
"level1"><div class=
"li"> the simulator? (can we run the same circuit with two simulators in one step?)
</div>
120 <li class=
"level1"><div class=
"li"> simulation parameters (global parameters, temperature, …)
</div>
123 <pre class=
"code">v
20061020 1
124 C
41500 49200 1 0 0 spice-directive-
1.sym
126 device=spice_simulation_block
128 simulation_name=random name
130 simulation_type=DC
0V
1V
0.1V
131 parametric_simulation1=V1 lin
0 5 0.1
132 parametric_simulation2=R1.value lin
10k
100k
10k
140 There may be many simulation objects inside a single schematic.
144 To store additional libraries we can either use an include card or using a “LIBRARY” symbol that contains all libraries either as:
147 <li class=
"level1"><div class=
"li"> a multiline attribute
</div>
149 <li class=
"level1"><div class=
"li"> multiple attached library attributes to the LIBRARY symbol
</div>
154 There should be a distinction between global, user and local libs.
155 global and user libs may be specified by a gafrc or a new spicerc configuration file.
159 <!-- EDIT6 SECTION "The simulations" [2636-3883] -->
160 <h3 class=
"sectionedit7" id=
"creating_a_simulation_dialog_inside_gschem">Creating a simulation dialog inside gschem
</h3>
164 Lets assume anything we need to add simulation support to gschem is a single dialog.
167 <li class=
"level1"><div class=
"li"> It would have a list of simulations (listview with enable/disable buttons and simulation names)
</div>
169 <li class=
"level1"><div class=
"li"> It would have some icons to add the probes.
</div>
171 <li class=
"level1"><div class=
"li"> It may have buttons for the most common symbols: resistor, capacitor, inductor, diode, … [R,C,L,D,M,E,F,G,H..]
</div>
173 <li class=
"level1"><div class=
"li"> It would have some dialog elements to do the spice settings
</div>
175 <li class=
"level1"><div class=
"li"> It would have a simulate and a close button
</div>
177 <li class=
"level1"><div class=
"li"> Some additional buttons like: Copy simulation, Remove simulation, general options…
</div>
182 When creating that dialog all simulation objects are collected into the simulation list (listview with enable/disable checkbutton)
186 When changing the settings the attributes of the associated simulation object are changed.
190 <!-- EDIT7 SECTION "Creating a simulation dialog inside gschem" [3884-4714] -->
191 <h3 class=
"sectionedit8" id=
"the_option_dialog">The option dialog
</h3>
195 What kind of options do we need for that dialog? And Why?
199 The probes that we have placed can be used to tell the simulator the variables that we like to save or tell the plotting application which plots we
'd like to see. This is something completely different, we need an option for that:
202 <li class=
"level1"><div class=
"li"> plot all marks and only save the corresponding node voltages
</div>
204 <li class=
"level1"><div class=
"li"> plot all marks but save all node voltages and currents (through voltage sources)
</div>
206 <li class=
"level1"><div class=
"li"> only save voltage nodes of the current schematic level or store subcircuit node voltages, too.
</div>
211 <!-- EDIT8 SECTION "The option dialog" [4715-5282] -->
212 <h3 class=
"sectionedit9" id=
"invoking_the_simulation">Invoking the simulation
</h3>
216 The simulation button of the dialog should lead to the following actions:
219 <li class=
"level1"><div class=
"li"> save the schematic (ask the user or use a temporary file?)
</div>
221 <li class=
"level1"><div class=
"li"> create a netlist using gnetlist
</div>
223 <li class=
"level1"><div class=
"li"> create simulation files and include the netlist (can this be done with gnetlist too?)
</div>
225 <li class=
"level1"><div class=
"li"> execute the simulation startup script (guile, sh, …)
</div>
230 That startup script may even call a scheduler that can take lots of large simulations.
234 <!-- EDIT9 SECTION "Invoking the simulation" [5283-5727] -->
235 <h2 class=
"sectionedit10" id=
"appendix">Appendix
</h2>
239 <!-- EDIT10 SECTION "Appendix" [5728-5748] -->
240 <h3 class=
"sectionedit11" id=
"a_voltage_probe_symbol_draft">A voltage probe symbol (draft)
</h3>
243 <dt><a href=
"/./_export/code/:geda:circuit_simulation_improvements.txt?codeblock=1" title=
"Download Snippet" class=
"mediafile mf_sym">voltage_probe.sym
</a></dt>
244 <dd><pre class=
"code gschem-symbol">v
20061020 1
247 T
100 0 5 10 0 1 0 0 1
249 T
0 100 5 10 0 1 0 0 1
251 T
0 100 5 10 0 1 0 0 1
253 T
0 100 5 10 0 1 0 0 1
256 V
300 300 150 3 10 0 0 -
1 -
1 0 -
1 -
1 -
1 -
1 -
1
257 L
300 200 240 360 3 10 0 0 -
1 -
1
258 L
300 200 360 360 3 10 0 0 -
1 -
1
259 T
0 500 9 10 0 0 0 0 1
261 T
200 50 9 6 1 1 0 0 1
263 T
0 700 9 10 0 0 0 0 1
265 T
0 900 9 10 0 0 0 0 1
270 <!-- EDIT11 SECTION "A voltage probe symbol (draft)" [5749-6270] -->
271 <h3 class=
"sectionedit12" id=
"a_current_probe_symbol_draft">A current probe symbol (draft)
</h3>
274 <dt><a href=
"/./_export/code/:geda:circuit_simulation_improvements.txt?codeblock=2" title=
"Download Snippet" class=
"mediafile mf_sym">current_probe.sym
</a></dt>
275 <dd><pre class=
"code gschem-symbol">v
20061020 1
276 P
0 200 150 200 1 0 0
278 T -
150 50 5 10 0 1 0 0 1
280 T
50 250 5 10 0 1 0 0 1
282 T
50 250 5 10 0 1 0 0 1
284 T
50 250 5 10 0 1 0 0 1
287 V
300 200 150 3 10 0 0 -
1 -
1 0 -
1 -
1 -
1 -
1 -
1
288 L
300 300 380 140 3 10 0 0 -
1 -
1
289 L
300 300 220 140 3 10 0 0 -
1 -
1
290 T
0 500 9 10 0 0 0 0 1
292 T
200 370 9 6 1 1 0 0 1
294 P
600 200 450 200 1 0 0
296 T
500 50 5 10 0 1 0 0 1
298 T
500 250 5 10 0 1 0 0 1
300 T
500 250 5 10 0 1 0 0 1
302 T
500 250 5 10 0 1 0 0 1
305 L
240 180 360 180 3 10 0 0 -
1 -
1
306 T
0 700 9 10 0 0 0 0 1
311 <!-- EDIT12 SECTION "A current probe symbol (draft)" [6271-6971] -->
312 <h3 class=
"sectionedit13" id=
"another_current_probe_symbol_used_by_kurt_peters">Another current probe symbol used by Kurt Peters
</h3>
315 <dt><a href=
"/./_export/code/:geda:circuit_simulation_improvements.txt?codeblock=3" title=
"Download Snippet" class=
"mediafile mf_sym">ammeter.sym
</a></dt>
316 <dd><pre class=
"code gschem-symbol">v
20061020 1
317 T
700 650 8 10 1 1 0 0 1
319 T
700 850 5 10 1 1 0 0 1
321 T
700 1050 5 10 0 0 0 0 1
323 T
700 1250 5 10 0 0 0 0 1
325 T
700 1450 5 10 0 0 0 0 1
326 description=ammeter for spice
327 P
300 1200 300 900 1 0 0
329 T
350 1000 5 8 1 1 0 0 1
331 T
350 1000 5 8 0 1 0 2 1
333 T
400 850 9 8 1 1 0 5 1
335 T
300 700 5 8 0 1 0 5 1
338 P
300 0 300 300 1 0 0
340 T
350 100 5 8 1 1 0 0 1
342 T
350 100 5 8 0 1 0 2 1
344 T
300 500 5 8 0 1 0 3 1
346 T
300 300 5 10 1 1 0 0 1
349 L
300 400 400 500 3 0 0 0 -
1 -
1
350 L
200 500 300 400 3 0 0 0 -
1 -
1
351 T
700 450 5 10 0 1 0 0 1
353 L
300 400 300 800 3 0 0 0 -
1 -
1
354 L
100 800 500 400 3 0 0 0 -
1 -
1
355 B
0 300 600 600 3 0 0 0 -
1 -
1 0 -
1 -
1 -
1 -
1 -
1
356 L
200 800 100 800 3 0 0 0 -
1 -
1
357 L
100 700 100 800 3 0 0 0 -
1 -
1</pre>
361 <!-- EDIT13 SECTION "Another current probe symbol used by Kurt Peters" [6972-] --></body>