dptran robustness: damped pseudo-transient on the failing tanh ring

* (exec-spice "ngspice -b %s")

* Same circuit as pstran-2.cir, solved with the damped variant.
b1 n2 0 v = 0.9 - 0.89*tanh(200*(v(n1)-0.9))
b2 n3 0 v = 0.9 - 0.89*tanh(200*(v(n2)-0.9))
b3 n1 0 v = 0.9 - 0.89*tanh(200*(v(n3)-0.9))
r1 n1 0 1meg

.option dptran

.control

define mismatch(a,b,err) abs(a-b)>err

optran 1 1 1 0 0 0
op

let fail_count = 0
if mismatch(v(n1), 0.9, 1e-6)
  let v_test = v(n1)
  echo "ERROR, v(n1) = $&v_test but should be 0.9"
  let fail_count = fail_count + 1
end
if mismatch(v(n2), 0.9, 1e-6)
  let v_test = v(n2)
  echo "ERROR, v(n2) = $&v_test but should be 0.9"
  let fail_count = fail_count + 1
end
if mismatch(v(n3), 0.9, 1e-6)
  let v_test = v(n3)
  echo "ERROR, v(n3) = $&v_test but should be 0.9"
  let fail_count = fail_count + 1
end

if fail_count > 0
  echo "ERROR: $&fail_count of 3 tests failed"
  quit 1
else
  echo "INFO: $&fail_count of 3 tests failed"
  quit 0
end

.endc

.end
