gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnucap-devel] discontinuities. was: traces


From: Felix Salfelder
Subject: [Gnucap-devel] discontinuities. was: traces
Date: Mon, 13 Jan 2014 12:52:23 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hi Al.

On Sun, Jan 12, 2014 at 12:09:12PM +0100, Felix Salfelder wrote:
> i will try find a real example within the test suite...

actually, the impact on the test suite is less spectacular than i have
suggested. some examples run with insignificantly more or less steps.
which may be as well due to other changes, or just numerical noise.

however, it is no surprise, that an euler in the right spot reduces
ringing. the difficult part is when to do a fallback. i have decided to
fallback if an adjacent node knows about a discontinuity. the current
implementation is experimental and probably still buggy. but results are
clearly visible.

"""
spice
v1 n1 0 pulse iv=0 pv=1 delay=1 rise=1m
r1 n1 n2 1k
c1 n2 0 10n

.print tran v(nodes) i(r1) method(c1) hidden(0)
* dis(n*) v(r1)
.tran 0 10 10 trace=a
.stat notime
.end
"""

vanilla gnucap computes

"""
#Time       v(n1)      v(n2)      i(r1)      method(c1) hidden(0) 
 0.         0.         0.         0.         2.         1.        
 0.1        0.         0.         0.         2.         1.        
 0.2        0.         0.         0.         2.         1.        
 0.3        0.         0.         0.         2.         1.        
 0.4        0.         0.         0.         2.         1.        
 0.5        0.         0.         0.         2.         1.        
 1.         0.         0.         0.         2.         1.        
 1.001      1.         0.98039    19.608u    2.         1.        
 1.006      1.         1.0195    -19.452u    2.         2.        
 1.0069     1.         0.98135    18.647u    2.         2.        
 1.0079     1.         1.0179    -17.876u    2.         1.        
 1.0088     1.         0.98286    17.137u    2.         1.        
 1.0098     1.         1.0164    -16.429u    2.         1.        
 1.0107     1.         0.98425    15.749u    2.         1.        
 1.0117     1.         1.0151    -15.098u    2.         1.        
 1.0126     1.         0.98553    14.474u    2.         1.        
 1.0136     1.         1.0139    -13.875u    2.         1.        
 1.0145     1.         0.9867     13.302u    2.         1.        
[..]
 6.2732     1.         1.0023    -2.3202u    2.         1.        
 7.0186     1.         0.99768    2.3201u    2.         1.        
 8.0124     1.         1.0023    -2.32u      2.         1.        
 9.0062     1.         0.99768    2.3199u    2.         1.        
 10.        1.         1.0023    -2.3198u    2.         1.        
Gnucap   System status
iterations: op=0, dc=0, tran=397, fourier=0, total=498
transient timesteps: accepted=99, rejected=2, total=101
nodes: user=2, subckt=0, model=0, total=2
dctran density=100.0%, ac density=100.0%
"""

and gnucap-uf gives

"""
#Time       v(n1)      v(n2)      i(r1)      method(c1) hidden(0) 
 0.         0.         0.         0.        -1.         1.        
 0.1        0.         0.         0.         1.         1.        
 0.2        0.         0.         0.         2.         1.        
 0.3        0.         0.         0.         2.         1.        
 0.4        0.         0.         0.         2.         1.        
 0.5        0.         0.         0.         2.         1.        
 1.         0.         0.         0.         2.         1.        
 1.001      1.         0.98039    19.608u    2.         1.         < no 
rejection, no fallback to euler
 1.0011     1.         0.99817    1.8258u    1.         4.         < rejection
                                                                     => 
discontinuity propagation through r1
                                                                                
                                                                                
                        => fallback to euler
 1.0012     1.         1.0012    -1.2037u    2.         1.        
 1.0015     1.         0.99897    1.0297u    2.         2.        
 1.0017     1.         1.0009    -880.89n    2.         1.        
 1.0021     1.         0.9992     795.04n    2.         1.        
 1.0027     1.         1.0007    -746.46n    2.         1.        
 1.0034     1.         0.9993     700.85n    2.         1.        
 1.0047     1.         1.0007    -679.82n    2.         1.        
[..]
 3.5767     1.         0.99937    631.76n    2.         1.        
 4.8613     1.         1.0006    -631.74n    2.         1.        
 6.5742     1.         0.99937    631.73n    2.         1.        
 8.2871     1.         1.0006    -631.71n    2.         1.        
 10.        1.         0.99937    631.7n     2.         1.        
Gnucap   System status
iterations: op=0, dc=0, tran=149, fourier=0, total=188
transient timesteps: accepted=35, rejected=4, total=39
nodes: user=2, subckt=0, model=0, total=2
dctran density=100.0%, ac density=100.0%
"""

to me, the second result looks better.

as a side remark, verilog-a provides semantics for discontinuities.  if
sometimes, verilog devices may register them, some other times, they only
simulate well if bm_pulse does. for example, here is a circuit that was not
capable to simulate without discontinuities in pulse (and it doesn't work with
vanilla gnucap currently).

"""
load lang_adms.so
adms
`include "discipline.h"
module pid(sp,sn,cp,cn);
   inout sp,sn,cp,cn;
   electrical sp,sn,cp,cn;

   parameter real p = 1 from [0:inf);
   parameter real i = 1 from [0:inf);
   parameter real d = 1 from [0:inf);

   analog begin
      V(sp,sn) <+ p * V(cp,cn);
      V(sp,sn) <+ i * idt(V(cp,cn));
      V(sp,sn) <+ d * ddt(V(cp,cn));
   end
endmodule
endadms

paramset mypid pid;
   .p=1;
   .i=1;
   .d=10m;
endparamset

mypid pid1 (nr, 0, n1, 0);
spice

V1 n1 0 pulse iv=0 pv=1 rise=2m delay=0 width=4m period=12m fall=1m

.print dc v(nodes)
.dc

.print tran v(nodes)
.tran 0 10m .5m basic trace=n
.end
"""

regards
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]