*** asrcacld.c Fri Feb 3 01:28:56 1995 --- asrcacld.c.orig Fri Feb 3 01:28:25 1995 *************** *** 30,36 **** register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; ! int i, j; double *derivs; double rhs; --- 30,36 ---- register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; ! int i, v_first, j; double *derivs; double rhs; *************** *** 48,60 **** * entries of the jacobian. */ j=0; - if( here->ASRCtype == ASRC_VOLTAGE){ - *(here->ASRCposptr[j++]) += 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) += 1.0; - } derivs = here->ASRCacValues; rhs = (here->ASRCacValues)[here->ASRCtree->numVars]; --- 48,55 ---- * entries of the jacobian. */ + v_first = 1; j=0; derivs = here->ASRCacValues; rhs = (here->ASRCacValues)[here->ASRCtree->numVars]; *************** *** 62,83 **** switch(here->ASRCtree->varTypes[i]){ case IF_INSTANCE: if( here->ASRCtype == ASRC_VOLTAGE){ ! /* CCVS */ ! *(here->ASRCposptr[j++]) -= derivs[i]; } else{ ! /* CCCS */ ! *(here->ASRCposptr[j++]) += derivs[i]; ! *(here->ASRCposptr[j++]) -= derivs[i]; } break; case IF_NODE: if(here->ASRCtype == ASRC_VOLTAGE){ ! /* VCVS */ ! *(here->ASRCposptr[j++]) -= derivs[i]; } else { ! /*VCCS*/ ! *(here->ASRCposptr[j++]) += derivs[i]; ! *(here->ASRCposptr[j++]) -= derivs[i]; } break; default: --- 57,92 ---- switch(here->ASRCtree->varTypes[i]){ case IF_INSTANCE: if( here->ASRCtype == ASRC_VOLTAGE){ ! /* CCVS */ ! if(v_first){ ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) += 1.0; ! v_first = 0; ! } ! *(here->ASRCposptr[j++]) -= derivs[i]; } else{ ! /* CCCS */ ! *(here->ASRCposptr[j++]) += derivs[i]; ! *(here->ASRCposptr[j++]) -= derivs[i]; } break; case IF_NODE: if(here->ASRCtype == ASRC_VOLTAGE){ ! /* VCVS */ ! if( v_first){ ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) += 1.0; ! v_first = 0; ! } ! *(here->ASRCposptr[j++]) -= derivs[i]; } else { ! /*VCCS*/ ! *(here->ASRCposptr[j++]) += derivs[i]; ! *(here->ASRCposptr[j++]) -= derivs[i]; } break; default: *** asrcitf.h Fri Feb 3 01:47:28 1995 --- asrcitf.h.orig Fri Feb 3 01:47:26 1995 *************** *** 51,57 **** NULL, #endif /* DELETES */ NULL, ! ASRCask, NULL, #ifdef AN_pz ASRCpzLoad, --- 51,57 ---- NULL, #endif /* DELETES */ NULL, ! NULL, NULL, #ifdef AN_pz ASRCpzLoad, *** asrcload.c Fri Feb 3 01:26:41 1995 --- asrcload.c.orig Thu Feb 2 23:44:57 1995 *************** *** 30,36 **** register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; ! int i, j, branch; int node_num; int size; double rhs; --- 30,36 ---- register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; ! int i, v_first, j, branch; int node_num; int size; double rhs; *************** *** 49,54 **** --- 49,55 ---- /* * Get the function and its derivatives evaluated */ + v_first = 1; i = here->ASRCtree->numVars; if (asrc_nvals < i) { if (asrc_nvals) { *************** *** 60,65 **** --- 61,68 ---- asrc_derivs = NEWN(double, i); } + j=0; + /* * Fill the vector of values from the previous solution */ *************** *** 113,126 **** } } - - j=0; - if( here->ASRCtype == ASRC_VOLTAGE){ - *(here->ASRCposptr[j++]) += 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) += 1.0; - } for(i=0; i < here->ASRCtree->numVars; i++) { rhs -= (asrc_vals[i] * asrc_derivs[i]); switch(here->ASRCtree->varTypes[i]){ --- 116,121 ---- *************** *** 127,132 **** --- 122,134 ---- case IF_INSTANCE: if( here->ASRCtype == ASRC_VOLTAGE){ /* CCVS */ + if(v_first){ + *(here->ASRCposptr[j++]) += 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + *(here->ASRCposptr[j++]) += 1.0; + v_first = 0; + } *(here->ASRCposptr[j++]) -= asrc_derivs[i]; } else{ /* CCCS */ *************** *** 138,143 **** --- 140,152 ---- case IF_NODE: if(here->ASRCtype == ASRC_VOLTAGE) { /* VCVS */ + if( v_first){ + *(here->ASRCposptr[j++]) += 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + *(here->ASRCposptr[j++]) -= 1.0; + *(here->ASRCposptr[j++]) += 1.0; + v_first = 0; + } *(here->ASRCposptr[j++]) -= asrc_derivs[i]; } else { /*VCCS*/ *** asrcpzld.c Fri Feb 3 01:31:24 1995 --- asrcpzld.c.orig Fri Feb 3 01:30:28 1995 *************** *** 27,33 **** register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; double value; ! int i, j, branch; int node_num; /* loop through all the Arbitrary source models */ --- 27,33 ---- register ASRCmodel *model = (ASRCmodel*)inModel; register ASRCinstance *here; double value; ! int i, v_first, j, branch; int node_num; /* loop through all the Arbitrary source models */ *************** *** 37,43 **** --- 37,45 ---- for (here = model->ASRCinstances; here != NULL ; here=here->ASRCnextInstance) { + j = 0; /* Get the function evaluated and the derivatives too */ + v_first = 1; i = here->ASRCtree->numVars; if (asrc_nvals < i) { if (asrc_nvals) { *************** *** 61,74 **** } } - j = 0; - if(here->ASRCtype == ASRC_VOLTAGE){ - *(here->ASRCposptr[j++]) += 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) -= 1.0; - *(here->ASRCposptr[j++]) += 1.0; - } - if( (*(here->ASRCtree->IFeval))(here->ASRCtree, ckt->CKTgmin, &value, asrc_vals, asrc_derivs) == OK){ for(i=0; i < here->ASRCtree->numVars; i++){ --- 63,68 ---- *************** *** 76,82 **** case IF_INSTANCE: if( here->ASRCtype == ASRC_VOLTAGE){ /* CCVS */ ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; } else { /* CCCS */ *(here->ASRCposptr[j++]) += asrc_derivs[i]; --- 70,85 ---- case IF_INSTANCE: if( here->ASRCtype == ASRC_VOLTAGE){ /* CCVS */ ! if(v_first){ ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; ! v_first = 0; ! } else { ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; ! } } else { /* CCCS */ *(here->ASRCposptr[j++]) += asrc_derivs[i]; *************** *** 86,92 **** case IF_NODE: if(here->ASRCtype == ASRC_VOLTAGE){ /* VCVS */ ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; } else { /* VCCS */ *(here->ASRCposptr[j++]) += asrc_derivs[i]; --- 89,104 ---- case IF_NODE: if(here->ASRCtype == ASRC_VOLTAGE){ /* VCVS */ ! if( v_first){ ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) -= 1.0; ! *(here->ASRCposptr[j++]) += 1.0; ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; ! v_first = 0; ! } else { ! *(here->ASRCposptr[j++]) -= asrc_derivs[i]; ! } } else { /* VCCS */ *(here->ASRCposptr[j++]) += asrc_derivs[i]; *** asrcset.c Fri Feb 3 01:24:18 1995 --- asrcset.c.orig Thu Feb 2 23:35:31 1995 *************** *** 30,35 **** --- 30,36 ---- register ASRCinstance *here; register ASRCmodel *model = (ASRCmodel*)inModel; int error, i, j; + int v_first; CKTnode *tmp; /* loop through all the user models*/ *************** *** 39,44 **** --- 40,48 ---- for (here = model->ASRCinstances; here != NULL ; here=here->ASRCnextInstance) { + here->ASRCposptr = (double **)MALLOC(0); + j=0; /* index of the array holding ptrs to SMP */ + v_first = 1; if( here->ASRCtype == ASRC_VOLTAGE){ if(here->ASRCbranch==0) { error = CKTmkCur(ckt,&tmp,here->ASRCname,"branch"); *************** *** 64,79 **** in the vector of the positions of the SMP */ if (!here->ASRCtree) return E_PARMVAL; - j=0; /* index of the array holding ptrs to SMP */ - if( here->ASRCtype == ASRC_VOLTAGE){ - here->ASRCposptr = (double **)MALLOC(sizeof(double *) * 4); - TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCbranch); - TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCbranch); - TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCnegNode); - TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCposNode); - } else - here->ASRCposptr = (double **)MALLOC(0); - for( i=0; i < here->ASRCtree->numVars; i++){ switch(here->ASRCtree->varTypes[i]){ case IF_INSTANCE: --- 68,73 ---- *************** *** 89,97 **** } if( here->ASRCtype == ASRC_VOLTAGE){ /* CCVS */ ! here->ASRCposptr = (double **) ! REALLOC(here->ASRCposptr, (sizeof(double *)*(j+1))); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br); } else if(here->ASRCtype == ASRC_CURRENT){ /* CCCS */ here->ASRCposptr = (double **) --- 83,102 ---- } if( here->ASRCtype == ASRC_VOLTAGE){ /* CCVS */ ! if(v_first){ ! here->ASRCposptr = (double **) ! REALLOC(here->ASRCposptr, (sizeof(double *)*(j+5))); ! TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCbranch); ! TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCbranch); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCnegNode); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCposNode); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br); ! v_first = 0; ! } else{ ! here->ASRCposptr = (double **) ! REALLOC(here->ASRCposptr, (sizeof(double *)*(j+1))); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCcont_br); ! } } else if(here->ASRCtype == ASRC_CURRENT){ /* CCCS */ here->ASRCposptr = (double **) *************** *** 105,113 **** case IF_NODE: if( here->ASRCtype == ASRC_VOLTAGE){ /* VCVS */ ! here->ASRCposptr = (double **) REALLOC(here->ASRCposptr, (sizeof(double *) * (j+1))); MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue); } else if(here->ASRCtype == ASRC_CURRENT){ /* VCCS */ here->ASRCposptr = (double **) --- 110,129 ---- case IF_NODE: if( here->ASRCtype == ASRC_VOLTAGE){ /* VCVS */ ! if(v_first){ ! here->ASRCposptr = (double **) ! REALLOC(here->ASRCposptr, (sizeof(double *) * (j+5))); ! TSTALLOC(ASRCposptr[j++],ASRCposNode,ASRCbranch); ! TSTALLOC(ASRCposptr[j++],ASRCnegNode,ASRCbranch); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCnegNode); ! TSTALLOC(ASRCposptr[j++],ASRCbranch,ASRCposNode); ! MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue); ! v_first = 0; ! } else{ ! here->ASRCposptr = (double **) REALLOC(here->ASRCposptr, (sizeof(double *) * (j+1))); MY_TSTALLOC(ASRCposptr[j++],ASRCbranch,here->ASRCtree->vars[i].nValue); + } } else if(here->ASRCtype == ASRC_CURRENT){ /* VCCS */ here->ASRCposptr = (double **)