summaryrefslogtreecommitdiff
path: root/Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh
diff options
context:
space:
mode:
authorrahulp132020-03-03 05:31:58 +0530
committerrahulp132020-03-03 05:31:58 +0530
commitdfc268e0863c913a1b8726cd54eea3b40caf7c67 (patch)
tree1cd82634684da5ae86b558d44756189e080545d4 /Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh
parentfd62c52150c7d1f81da8060b2f5db6b94d174ccf (diff)
downloadeSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.tar.gz
eSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.tar.bz2
eSim-dfc268e0863c913a1b8726cd54eea3b40caf7c67.zip
upgrade ngspice to v31
Diffstat (limited to 'Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh')
-rw-r--r--Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh62
1 files changed, 62 insertions, 0 deletions
diff --git a/Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh b/Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh
new file mode 100644
index 00000000..6c74f5e6
--- /dev/null
+++ b/Windows/spice/examples/tclspice/tcl-testbench1/tcl-testbench1.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+# -*- mode: tcl -*- \
+ exec wish -f "$0" ${1+"$@"}
+
+# old name: analyse-20070504-0.tcl
+package require BLT
+load ../../../src/.libs/libspice.so
+
+# Test of virtual capacitore circuit
+# Vary the control voltage and log the resulting capacitance
+spice::source "testCapa.cir"
+
+set n 30
+set dv 0.2
+set vmax [expr $dv/2]
+set vmin [expr -1 * $dv/2]
+set pas [expr $dv/ $n]
+
+blt::vector create Ctmp
+blt::vector create Cim
+blt::vector create check
+
+blt::vector create Vcmd
+blt::graph .cimvd -title "Cim = f(Vd)"
+blt::graph .checkvd -title "Rim = f(Vd)"
+
+blt::vector create Iex
+blt::vector create freq
+blt::graph .freqanal -title "Analyse frequentielle"
+
+set v [expr {$vmin + $n * $pas / 4}]
+spice::alter vd = $v
+spice::op
+spice::ac dec 10 100 100k
+spice::vectoblt {Vex#branch} Iex
+spice::vectoblt {frequency} freq
+pack .freqanal
+.freqanal element create line1 -xdata freq -ydata Iex
+
+for {set i 0} {[expr $n - $i]} {incr i } {
+set v [expr {$vmin + $i * $pas}]
+spice::alter vd = $v
+spice::op
+spice::ac dec 10 100 100k
+
+
+spice::let Cim = real(mean(Vex#branch/(2*Pi*i*frequency*(V(5)-V(6)))))
+spice::vectoblt Cim Ctmp
+Cim append $Ctmp(0:end)
+spice::let err = real(mean(sqrt((Vex#branch-(2*Pi*i*frequency*Cim*V(5)-V(6)))^2)))
+spice::vectoblt err Ctmp
+check append $Ctmp(0:end)
+Vcmd append $v
+
+}
+
+pack .cimvd
+.cimvd element create line1 -xdata Vcmd -ydata Cim
+pack .checkvd
+.checkvd element create line1 -xdata Vcmd -ydata check
+
+