tests/regression/sens, add some tests for "sensitivity" analysis
This commit is contained in:
parent
77380219d8
commit
5522bfd814
|
|
@ -1178,6 +1178,7 @@ AC_CONFIG_FILES([Makefile
|
|||
tests/regression/func/Makefile
|
||||
tests/regression/model/Makefile
|
||||
tests/regression/misc/Makefile
|
||||
tests/regression/sens/Makefile
|
||||
tests/regression/temper/Makefile
|
||||
tests/regression/pz/Makefile
|
||||
tests/sensitivity/Makefile
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = lib-processing parser subckt-processing func model misc temper pz
|
||||
SUBDIRS = lib-processing parser subckt-processing func model misc sens temper pz
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
|
||||
TESTS = sens-ac-1.cir sens-ac-2.cir sens-dc-1.cir sens-dc-2.cir
|
||||
|
||||
TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(TESTS) \
|
||||
$(TESTS:.cir=.out)
|
||||
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
* test "sens ac"
|
||||
|
||||
i1 0 1 dc=1.27 ac=42mA
|
||||
r1 1 0 1k
|
||||
c1 1 0 100p
|
||||
|
||||
.control
|
||||
|
||||
* express our "golden" expectations:
|
||||
setplot new
|
||||
set gold = $curplot
|
||||
let s = (0,2) * pi * 1e6
|
||||
let i1_acmag = 1 / (s*100p + 1/1k)
|
||||
let r1 = 42mA / (1 + s*100p * 1k)^2
|
||||
let c1_c = - 42mA * s / (s*100p + 1/1k)^2
|
||||
|
||||
* run a "sens" analysis
|
||||
sens v(1) ac lin 1 1e6 1.1e6
|
||||
|
||||
strcmp __flag $curplot $gold
|
||||
if $__flag = 0
|
||||
echo "ERROR: sens failed to execute"
|
||||
quit 1
|
||||
end
|
||||
|
||||
* compare results with "golden" expectation
|
||||
|
||||
define mismatch(a,b,err) abs(a-b)>err*abs(b)
|
||||
|
||||
let total_count = 0
|
||||
let fail_count = 0
|
||||
|
||||
foreach n i1_acmag c1_c r1
|
||||
set n_test = "$n"
|
||||
set n_gold = "{$gold}.$n"
|
||||
if mismatch($n_test, $n_gold, 1e-3)
|
||||
let s_test = $n_test
|
||||
let s_gold = $n_gold
|
||||
echo "ERROR, test failure, s[$n] = $&s_test but should be $&s_gold"
|
||||
let fail_count = fail_count + 1
|
||||
end
|
||||
let total_count = total_count + 1
|
||||
end
|
||||
|
||||
if fail_count > 0
|
||||
echo "ERROR: $&fail_count of $&total_count tests failed"
|
||||
quit 1
|
||||
else
|
||||
echo "INFO: $&fail_count of $&total_count tests failed"
|
||||
quit 0
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Circuit: * test "sens ac"
|
||||
|
||||
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
|
||||
|
||||
INFO: 0 of 3 tests failed
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
* test "sens ac"
|
||||
|
||||
v1 1 0 dc=1.27 ac=42mA
|
||||
r1 1 2 68.0
|
||||
c2 2 0 1.5n
|
||||
l3 2 3 12u
|
||||
c4 3 0 1.8n
|
||||
r5 3 0 100.0
|
||||
|
||||
.control
|
||||
|
||||
* express our "golden" expectations:
|
||||
setplot new
|
||||
set gold = $curplot
|
||||
let s = (0,2) * pi * 1e6
|
||||
let v1_acmag = ( 0.1258214312760609, -0.5915026769337883 )
|
||||
let r1 = ( -38.77993150952251u, 196.2381768346785u )
|
||||
let c2_c = ( -4912987.937722201, -1131146.799006112 )
|
||||
let l3 = ( -1670.021661737812, -453.4103177577211 )
|
||||
let c4_c = ( -7419488.478291172, -1226939.0306441 )
|
||||
let r5 = ( 1.952734115993878E-5, -1.180848266533405E-4 )
|
||||
|
||||
* run a "sens" analysis
|
||||
sens v(3) ac lin 1 1e6 1.1e6
|
||||
|
||||
strcmp __flag $curplot $gold
|
||||
if $__flag = 0
|
||||
echo "ERROR: sens failed to execute"
|
||||
quit 1
|
||||
end
|
||||
|
||||
* compare results with "golden" expectation
|
||||
|
||||
define mismatch(a,b,err) abs(a-b)>err*abs(b)
|
||||
|
||||
let total_count = 0
|
||||
let fail_count = 0
|
||||
|
||||
foreach n v1_acmag r1 c2_c l3 c4_c r5
|
||||
set n_test = "$n"
|
||||
set n_gold = "{$gold}.$n"
|
||||
if mismatch($n_test, $n_gold, 1e-3)
|
||||
let s_test = $n_test
|
||||
let s_gold = $n_gold
|
||||
echo "ERROR, test failure, s[$n] = $&s_test but should be $&s_gold"
|
||||
let fail_count = fail_count + 1
|
||||
end
|
||||
let total_count = total_count + 1
|
||||
end
|
||||
|
||||
if fail_count > 0
|
||||
echo "ERROR: $&fail_count of $&total_count tests failed"
|
||||
quit 1
|
||||
else
|
||||
echo "INFO: $&fail_count of $&total_count tests failed"
|
||||
quit 0
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Circuit: * test "sens ac"
|
||||
|
||||
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
|
||||
|
||||
INFO: 0 of 6 tests failed
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
* test "sens dc"
|
||||
|
||||
* The "sens" analysis does express "sensitivity" as
|
||||
* S = (d out) / (d parameter)
|
||||
* instead of the normalized
|
||||
* S = ((d out)/out) / ((d parameter)/parameter)
|
||||
*
|
||||
* here:
|
||||
* v(1) = (R / m_R) * (m_i1 * i1)
|
||||
*
|
||||
* S[R] = (d v(1))/(d R) = m_i1 * i1 / m_R = 42m
|
||||
* S[i1] = (d v(1))/(d i1) = m_i1 * R1 / m_R = 1k
|
||||
* S[m_R] = (d v(1))/(d m_R) = -R * i1 *m_i1/m_R^2 = -42
|
||||
* S[m_i1] = (d v(1))/(d m_i1) = R * i1 / m_R = 42
|
||||
|
||||
i1 0 1 dc=42mA
|
||||
r1 1 0 1k
|
||||
|
||||
.control
|
||||
|
||||
* express our "golden" expectations:
|
||||
setplot new
|
||||
set gold = $curplot
|
||||
let i1 = 1k
|
||||
let i1_m = 42.0
|
||||
let r1 = 42m
|
||||
let r1_m = -42.0
|
||||
let r1_scale = 42.0
|
||||
|
||||
* run a "sens" analysis
|
||||
sens v(1) dc
|
||||
|
||||
strcmp __flag $curplot $gold
|
||||
if $__flag = 0
|
||||
echo "ERROR: sens failed to execute"
|
||||
quit 1
|
||||
end
|
||||
|
||||
* compare results with "golden" expectation
|
||||
|
||||
define mismatch(a,b,err) abs(a-b)>err*abs(b)
|
||||
|
||||
let total_count = 0
|
||||
let fail_count = 0
|
||||
|
||||
foreach n i1 i1_m r1 r1_m r1_scale
|
||||
set n_test = "$n"
|
||||
set n_gold = "{$gold}.$n"
|
||||
if mismatch($n_test, $n_gold, 1e-3)
|
||||
let s_test = $n_test
|
||||
let s_gold = $n_gold
|
||||
echo "ERROR, test failure, s[$n] = $&s_test but should be $&s_gold"
|
||||
let fail_count = fail_count + 1
|
||||
end
|
||||
let total_count = total_count + 1
|
||||
end
|
||||
|
||||
if fail_count > 0
|
||||
echo "ERROR: $&fail_count of $&total_count tests failed"
|
||||
quit 1
|
||||
else
|
||||
echo "INFO: $&fail_count of $&total_count tests failed"
|
||||
quit 0
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Circuit: * test "sens dc"
|
||||
|
||||
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
|
||||
|
||||
INFO: 0 of 5 tests failed
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
* test "sens dc"
|
||||
|
||||
v1 1 0 dc=42
|
||||
r1 1 2 1k
|
||||
r2 2 3 1.5k
|
||||
r3 3 0 2.2k
|
||||
r4 3 4 3.3k
|
||||
r5 4 0 1.8k
|
||||
rx 2 4 2.7k
|
||||
|
||||
.control
|
||||
|
||||
* express our "golden" expectations:
|
||||
setplot new
|
||||
set gold = $curplot
|
||||
|
||||
let v1 = 0.2933065931311105
|
||||
let r1 = - 0.004104514242490192
|
||||
let r2 = - 2.954317312283796E-4
|
||||
let r3 = 0.001129248920024266
|
||||
let r4 = - 2.00582596465584E-4
|
||||
let r5 = 0.003755608696037442
|
||||
let rx = - 0.001494392173796886
|
||||
|
||||
* run a "sens" analysis
|
||||
sens v(4) dc
|
||||
|
||||
strcmp __flag $curplot $gold
|
||||
if $__flag = 0
|
||||
echo "ERROR: sens failed to execute"
|
||||
quit 1
|
||||
end
|
||||
|
||||
* compare results with "golden" expectation
|
||||
|
||||
define mismatch(a,b,err) abs(a-b)>err*abs(b)
|
||||
|
||||
let total_count = 0
|
||||
let fail_count = 0
|
||||
|
||||
foreach n v1 r1 r2 r3 r4 r5 rx
|
||||
set n_test = "$n"
|
||||
set n_gold = "{$gold}.$n"
|
||||
if mismatch($n_test, $n_gold, 1e-3)
|
||||
let s_test = $n_test
|
||||
let s_gold = $n_gold
|
||||
echo "ERROR, test failure, s[$n] = $&s_test but should be $&s_gold"
|
||||
let fail_count = fail_count + 1
|
||||
end
|
||||
let total_count = total_count + 1
|
||||
end
|
||||
|
||||
if fail_count > 0
|
||||
echo "ERROR: $&fail_count of $&total_count tests failed"
|
||||
quit 1
|
||||
else
|
||||
echo "INFO: $&fail_count of $&total_count tests failed"
|
||||
quit 0
|
||||
end
|
||||
|
||||
.endc
|
||||
|
||||
.end
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
Circuit: * test "sens dc"
|
||||
|
||||
Doing analysis at TEMP = 27.000000 and TNOM = 27.000000
|
||||
|
||||
INFO: 0 of 7 tests failed
|
||||
Loading…
Reference in New Issue