[Top][All Lists]

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

Re: [Help-gnucap] Stochastic current inputs

From: al davis
Subject: Re: [Help-gnucap] Stochastic current inputs
Date: Tue, 4 Dec 2007 01:49:06 -0500
User-agent: KMail/1.9.7

On Thursday 29 November 2007, Chinasaur wrote:
> At the moment the only analyses I need to run are operating
> points.  The task is, given a network of cells with resistive
> connections between them, get the operating points under a
> series of stationary, stochastic input currents.

> Any advice on more sophisticated approaches to this problem? 
> I read through the documentation on behavioral modeling but
> didn't see any methods for designating stochastic current
> sources.  Are there SPICE variants with relevant
> functionality?

If you get the development snapshot, and are willing to do some 
programming, you should be able to hack a plugin that will do 
what you want.

One thought ... 

Define two params for each you want ,,,

.param foo_const=13

now we will hold _foo constant, and tinker with foo

Make a new command "rparam" ....
Here's how to use it:

.rparam  foo  foo_const  .1

..sets "foo" to a number within .1*foo_const of foo_const
and gives you a new number every time.

I hacked out this plugin:
#include "c_comand.h"
#include "globals.h"

class CMD_RPARAM: public CMD {
  void do_it(CS& cmd, CARD_LIST* scope)
    std::string  var_name, base_name;
    double tolerance;
    cmd >> var_name >> base_name >> tolerance;
    double base = scope->params()->deep_lookup(base_name);
    double random = (rand()-RAND_MAX/2.) / (RAND_MAX/2.);
    double value = base + base * tolerance * random;
    command("param " + var_name + '=' + to_string(value), 
} p0;
DISPATCHER<CMD>::INSTALL d0(&command_dispatcher, "rparam", &p0);

Compile it ...
g++ -I <path_to_gnucap_src> -fPIC -shared -o

Run gnucap, attach it with the command:
attach ./

Now there is a new command "rparam"....

> I thought this would be more efficient as it 
> only loads the architecture of the resistive network once and
> then just overwrites the current source parameters each time.
>  But it seems there's some leak because the more times the
> parameters are reassigned, the slower everything runs.  Is
> this the behavior expected?

It should be more efficient.  If it gets slower there is 
something wrong. There is a spot where I think the problem is.  
There is even a comment in the code saying so.  

Can you send a sample file that demonstrates the problem,so I 
can verify it and then verify the fix?

reply via email to

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