missing NULL terminator in set_config_x
[geda-gaf.git] / docs / wiki / geda-circuit_simulation_improvements.html
blob08dcb9e2051dece4807ffabff0fb68ef67f7f914
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <head>
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" />
10 </head>
11 <body>
13 <p>
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>.
15 </p>
17 <h1 class="sectionedit1" id="circuit_simulation_improvements_in_gschem">Circuit simulation improvements in gschem</h1>
18 <div class="level1">
20 </div>
21 <!-- EDIT1 SECTION "Circuit simulation improvements in gschem" [134-190] -->
22 <h2 class="sectionedit2" id="rationale">Rationale</h2>
23 <div class="level2">
25 <p>
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:
27 </p>
28 <ul>
29 <li class="level1"><div class="li"> specify what kinds of simulations should be run</div>
30 </li>
31 <li class="level1"><div class="li"> specify which voltages and currents should be plotted</div>
32 </li>
33 <li class="level1"><div class="li"> start the simulation</div>
34 </li>
35 </ul>
37 <p>
38 The simulation runs and the postprocessing may be in an external program that is triggered by IPC.
39 </p>
41 <p>
42 There are some graphical frontends around but they can&#039;t solve all of the above problems
43 </p>
44 <ul>
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>
46 </li>
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>
48 </li>
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>
50 </li>
51 </ul>
53 <p>
54 All frontends have the problem that you can not point to the net you&#039;d like to see. You need to know the netname of the node.
55 </p>
57 </div>
58 <!-- EDIT2 SECTION "Rationale" [191-987] -->
59 <h2 class="sectionedit3" id="draft">Draft</h2>
60 <div class="level2">
62 <p>
63 Let&#039;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.
64 </p>
66 </div>
67 <!-- EDIT3 SECTION "Draft" [988-1137] -->
68 <h3 class="sectionedit4" id="the_probes">The probes</h3>
69 <div class="level3">
71 <p>
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&#039;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.
75 </p>
77 <p>
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.
80 </p>
82 </div>
83 <!-- EDIT4 SECTION "The probes" [1138-2013] -->
84 <h3 class="sectionedit5" id="voltage_and_current_sources">Voltage and current sources</h3>
85 <div class="level3">
87 <p>
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)”.
90 </p>
92 <p>
93 A dialog would be nice that prompts the user for the named attributes and not only for the value string.
94 </p>
96 <p>
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.
98 </p>
100 </div>
101 <!-- EDIT5 SECTION "Voltage and current sources" [2014-2635] -->
102 <h3 class="sectionedit6" id="the_simulations">The simulations</h3>
103 <div class="level3">
106 How can we store a simulation inside gschem.
107 </p>
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.
112 </p>
113 <ul>
114 <li class="level1"><div class="li"> kind of simulation (dc, ac, tran, …)</div>
115 </li>
116 <li class="level1"><div class="li"> simulator options</div>
117 </li>
118 <li class="level1"><div class="li"> the simulator? (can we run the same circuit with two simulators in one step?)</div>
119 </li>
120 <li class="level1"><div class="li"> simulation parameters (global parameters, temperature, …)</div>
121 </li>
122 </ul>
123 <pre class="code">v 20061020 1
124 C 41500 49200 1 0 0 spice-directive-1.sym
126 device=spice_simulation_block
127 refdes=A1
128 simulation_name=random name
129 simulation_active=1
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
133 option_TNOM=100 Deg
134 option_ABSTOL=1e-3
135 global_param1=???
136 global_param2=???
137 }</pre>
140 There may be many simulation objects inside a single schematic.
141 </p>
144 To store additional libraries we can either use an include card or using a “LIBRARY” symbol that contains all libraries either as:
145 </p>
146 <ul>
147 <li class="level1"><div class="li"> a multiline attribute</div>
148 </li>
149 <li class="level1"><div class="li"> multiple attached library attributes to the LIBRARY symbol</div>
150 </li>
151 </ul>
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.
156 </p>
158 </div>
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>
161 <div class="level3">
164 Lets assume anything we need to add simulation support to gschem is a single dialog.
165 </p>
166 <ul>
167 <li class="level1"><div class="li"> It would have a list of simulations (listview with enable/disable buttons and simulation names)</div>
168 </li>
169 <li class="level1"><div class="li"> It would have some icons to add the probes.</div>
170 </li>
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>
172 </li>
173 <li class="level1"><div class="li"> It would have some dialog elements to do the spice settings</div>
174 </li>
175 <li class="level1"><div class="li"> It would have a simulate and a close button</div>
176 </li>
177 <li class="level1"><div class="li"> Some additional buttons like: Copy simulation, Remove simulation, general options…</div>
178 </li>
179 </ul>
182 When creating that dialog all simulation objects are collected into the simulation list (listview with enable/disable checkbutton)
183 </p>
186 When changing the settings the attributes of the associated simulation object are changed.
187 </p>
189 </div>
190 <!-- EDIT7 SECTION "Creating a simulation dialog inside gschem" [3884-4714] -->
191 <h3 class="sectionedit8" id="the_option_dialog">The option dialog</h3>
192 <div class="level3">
195 What kind of options do we need for that dialog? And Why?
196 </p>
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&#039;d like to see. This is something completely different, we need an option for that:
200 </p>
201 <ul>
202 <li class="level1"><div class="li"> plot all marks and only save the corresponding node voltages</div>
203 </li>
204 <li class="level1"><div class="li"> plot all marks but save all node voltages and currents (through voltage sources)</div>
205 </li>
206 <li class="level1"><div class="li"> only save voltage nodes of the current schematic level or store subcircuit node voltages, too.</div>
207 </li>
208 </ul>
210 </div>
211 <!-- EDIT8 SECTION "The option dialog" [4715-5282] -->
212 <h3 class="sectionedit9" id="invoking_the_simulation">Invoking the simulation</h3>
213 <div class="level3">
216 The simulation button of the dialog should lead to the following actions:
217 </p>
218 <ul>
219 <li class="level1"><div class="li"> save the schematic (ask the user or use a temporary file?)</div>
220 </li>
221 <li class="level1"><div class="li"> create a netlist using gnetlist</div>
222 </li>
223 <li class="level1"><div class="li"> create simulation files and include the netlist (can this be done with gnetlist too?)</div>
224 </li>
225 <li class="level1"><div class="li"> execute the simulation startup script (guile, sh, …)</div>
226 </li>
227 </ul>
230 That startup script may even call a scheduler that can take lots of large simulations.
231 </p>
233 </div>
234 <!-- EDIT9 SECTION "Invoking the simulation" [5283-5727] -->
235 <h2 class="sectionedit10" id="appendix">Appendix</h2>
236 <div class="level2">
238 </div>
239 <!-- EDIT10 SECTION "Appendix" [5728-5748] -->
240 <h3 class="sectionedit11" id="a_voltage_probe_symbol_draft">A voltage probe symbol (draft)</h3>
241 <div class="level3">
242 <dl class="code">
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
245 P 0 0 200 200 1 0 0
247 T 100 0 5 10 0 1 0 0 1
248 pintype=pas
249 T 0 100 5 10 0 1 0 0 1
250 pinseq=1
251 T 0 100 5 10 0 1 0 0 1
252 pinnumber=1
253 T 0 100 5 10 0 1 0 0 1
254 pinlabel=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
260 device=VOLTAGE_PROBE
261 T 200 50 9 6 1 1 0 0 1
262 refdes=I_VP?
263 T 0 700 9 10 0 0 0 0 1
264 net=GND:2
265 T 0 900 9 10 0 0 0 0 1
266 value=DC 0A</pre>
267 </dd></dl>
269 </div>
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>
272 <div class="level3">
273 <dl class="code">
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
279 pintype=pas
280 T 50 250 5 10 0 1 0 0 1
281 pinseq=1
282 T 50 250 5 10 0 1 0 0 1
283 pinnumber=1
284 T 50 250 5 10 0 1 0 0 1
285 pinlabel=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
291 device=CURRENT_PROBE
292 T 200 370 9 6 1 1 0 0 1
293 refdes=V_IP?
294 P 600 200 450 200 1 0 0
296 T 500 50 5 10 0 1 0 0 1
297 pintype=pas
298 T 500 250 5 10 0 1 0 0 1
299 pinseq=2
300 T 500 250 5 10 0 1 0 0 1
301 pinnumber=2
302 T 500 250 5 10 0 1 0 0 1
303 pinlabel=2
305 L 240 180 360 180 3 10 0 0 -1 -1
306 T 0 700 9 10 0 0 0 0 1
307 value=DC 0V</pre>
308 </dd></dl>
310 </div>
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>
313 <div class="level3">
314 <dl class="code">
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
318 refdes=VAM?
319 T 700 850 5 10 1 1 0 0 1
320 device=Ammeter
321 T 700 1050 5 10 0 0 0 0 1
322 footprint=none
323 T 700 1250 5 10 0 0 0 0 1
324 numslots=0
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
330 pinnumber=1
331 T 350 1000 5 8 0 1 0 2 1
332 pinseq=1
333 T 400 850 9 8 1 1 0 5 1
334 pinlabel=+
335 T 300 700 5 8 0 1 0 5 1
336 pintype=pwr
338 P 300 0 300 300 1 0 0
340 T 350 100 5 8 1 1 0 0 1
341 pinnumber=2
342 T 350 100 5 8 0 1 0 2 1
343 pinseq=2
344 T 300 500 5 8 0 1 0 3 1
345 pintype=pwr
346 T 300 300 5 10 1 1 0 0 1
347 pinlabel=-
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
352 value=DC 0V
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>
358 </dd></dl>
360 </div>
361 <!-- EDIT13 SECTION "Another current probe symbol used by Kurt Peters" [6972-] --></body>
362 </html>