From c5d8ad792ead0eaa98f47a6793cb0add96b9c0c5 Mon Sep 17 00:00:00 2001 From: rlar Date: Mon, 15 Jan 2018 19:01:15 +0100 Subject: [PATCH] analysis/acsetp.c, ac analysis, allow frequency=0 --- src/spicelib/analysis/acsetp.c | 8 ++++---- tests/regression/misc/Makefile.am | 2 +- tests/regression/misc/ac-zero.cir | 27 +++++++++++++++++++++++++++ tests/regression/misc/ac-zero.out | 1 + 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 tests/regression/misc/ac-zero.cir create mode 100644 tests/regression/misc/ac-zero.out diff --git a/src/spicelib/analysis/acsetp.c b/src/spicelib/analysis/acsetp.c index d6571d7a0..7f6d79ebc 100644 --- a/src/spicelib/analysis/acsetp.c +++ b/src/spicelib/analysis/acsetp.c @@ -22,8 +22,8 @@ ACsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value) switch(which) { case AC_START: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid for AC start"); + if (value->rValue < 0.0) { + errMsg = copy("Frequency of < 0 is invalid for AC start"); job->ACstartFreq = 1.0; return(E_PARMVAL); } @@ -32,8 +32,8 @@ ACsetParm(CKTcircuit *ckt, JOB *anal, int which, IFvalue *value) break; case AC_STOP: - if (value->rValue <= 0.0) { - errMsg = copy("Frequency of 0 is invalid for AC stop"); + if (value->rValue < 0.0) { + errMsg = copy("Frequency of < 0 is invalid for AC stop"); job->ACstartFreq = 1.0; return(E_PARMVAL); } diff --git a/tests/regression/misc/Makefile.am b/tests/regression/misc/Makefile.am index 6dd123faf..acd352b45 100644 --- a/tests/regression/misc/Makefile.am +++ b/tests/regression/misc/Makefile.am @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in -TESTS = bugs-1.cir bugs-2.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir alter-vec.cir test-noise-2.cir test-noise-3.cir +TESTS = bugs-1.cir bugs-2.cir dollar-1.cir empty-1.cir resume-1.cir log-functions-1.cir alter-vec.cir test-noise-2.cir test-noise-3.cir ac-zero.cir TESTS_ENVIRONMENT = ngspice_vpath=$(srcdir) $(SHELL) $(top_srcdir)/tests/bin/check.sh $(top_builddir)/src/ngspice diff --git a/tests/regression/misc/ac-zero.cir b/tests/regression/misc/ac-zero.cir new file mode 100644 index 000000000..2ecbbf8c8 --- /dev/null +++ b/tests/regression/misc/ac-zero.cir @@ -0,0 +1,27 @@ +* whether .ac works for freq=0 +* +* (exec-spice "ngspice -b %s" t) + +v1 1 0 dc=0 ac=1 +r1 1 2 1k +l1 2 3 1uH +r3 3 0 1k +c3 3 0 1uF + +.control + +ac lin 1 0Hz 0Hz + +let v3_gold = 0.5 + +let err = abs(v(3)/v3_gold - 1) + +if err > 1e-15 + echo "ERROR: test failed, excessive error, err = $&err" + quit 1 +else + echo "INFO: success" + quit 0 +end + +.endc diff --git a/tests/regression/misc/ac-zero.out b/tests/regression/misc/ac-zero.out new file mode 100644 index 000000000..8e9036969 --- /dev/null +++ b/tests/regression/misc/ac-zero.out @@ -0,0 +1 @@ +INFO: success