From 2ccf0a7097d90fd2dfa2ff204ca2155a19e25802 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Thu, 30 May 2013 10:25:59 +0200 Subject: [PATCH] devices/cccs: implement multiplier `m' (F source) --- src/spicelib/devices/cccs/cccs.c | 1 + src/spicelib/devices/cccs/cccsask.c | 2 ++ src/spicelib/devices/cccs/cccsdefs.h | 4 ++++ src/spicelib/devices/cccs/cccspar.c | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/src/spicelib/devices/cccs/cccs.c b/src/spicelib/devices/cccs/cccs.c index 79560bfb1..a24ccf9f9 100644 --- a/src/spicelib/devices/cccs/cccs.c +++ b/src/spicelib/devices/cccs/cccs.c @@ -12,6 +12,7 @@ Author: 1987 Thomas L. Quarles IFparm CCCSpTable[] = { /* parameters */ IOPU("gain", CCCS_GAIN, IF_REAL ,"Gain of source"), IOPU("control", CCCS_CONTROL, IF_INSTANCE,"Name of controlling source"), + IOP ( "m", CCCS_M, IF_REAL , "Parallel multiplier"), IP("sens_gain",CCCS_GAIN_SENS,IF_FLAG, "flag to request sensitivity WRT gain"), OPU("neg_node", CCCS_NEG_NODE,IF_INTEGER, "Negative node of source"), OPU("pos_node", CCCS_POS_NODE,IF_INTEGER, "Positive node of source"), diff --git a/src/spicelib/devices/cccs/cccsask.c b/src/spicelib/devices/cccs/cccsask.c index 70303f095..bd0d65777 100644 --- a/src/spicelib/devices/cccs/cccsask.c +++ b/src/spicelib/devices/cccs/cccsask.c @@ -36,6 +36,8 @@ CCCSask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue * case CCCS_CONTROL: value->uValue = here->CCCScontName; return (OK); + case CCCS_M: + value->rValue = here->CCCSmValue; case CCCS_POS_NODE: value->iValue = here->CCCSposNode; return (OK); diff --git a/src/spicelib/devices/cccs/cccsdefs.h b/src/spicelib/devices/cccs/cccsdefs.h index 57e573871..9c2362001 100644 --- a/src/spicelib/devices/cccs/cccsdefs.h +++ b/src/spicelib/devices/cccs/cccsdefs.h @@ -30,11 +30,14 @@ typedef struct sCCCSinstance { double CCCScoeff; /* coefficient */ + double CCCSmValue; /* Parallel multiplier */ + double *CCCSposContBrptr; /* pointer to sparse matrix element at *(positive node, control branch eq)*/ double *CCCSnegContBrptr; /* pointer to sparse matrix element at *(negative node, control branch eq)*/ unsigned CCCScoeffGiven :1 ; /* flag to indicate coeff given */ + unsigned CCCSmGiven :1 ; /* flag to indicate multiplier given */ int CCCSsenParmNo; /* parameter # for sensitivity use; set equal to 0 if not a design parameter*/ @@ -62,6 +65,7 @@ typedef struct sCCCSmodel { /* model structure for a source */ #define CCCS_CURRENT 7 #define CCCS_POWER 8 #define CCCS_VOLTS 9 +#define CCCS_M 10 /* model parameters */ diff --git a/src/spicelib/devices/cccs/cccspar.c b/src/spicelib/devices/cccs/cccspar.c index 077d85f0e..4f10557ca 100644 --- a/src/spicelib/devices/cccs/cccspar.c +++ b/src/spicelib/devices/cccs/cccspar.c @@ -23,11 +23,17 @@ CCCSparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select) switch(param) { case CCCS_GAIN: here->CCCScoeff = value->rValue; + if (here->CCCSmGiven) + here->CCCScoeff *= here->CCCSmValue; here->CCCScoeffGiven = TRUE; break; case CCCS_CONTROL: here->CCCScontName = value->uValue; break; + case CCCS_M: + here->CCCSmValue = value->rValue; + here->CCCSmGiven = TRUE; + break; case CCCS_GAIN_SENS: here->CCCSsenParmNo = value->iValue; break;