⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mifconvt.c

📁 ngspice又一个电子CAD仿真软件代码.功能更全
💻 C
字号:
/*============================================================================FILE    MIFconvTest.cMEMBER OF process XSPICECopyright 1991Georgia Tech Research CorporationAtlanta, Georgia 30332All Rights ReservedPROJECT A-8503AUTHORS    9/12/91  Bill KuhnMODIFICATIONS    <date> <person name> <nature of modifications>SUMMARY    This file contains the function used to check that internal    states of a code model have converged.  These internal states    are typically integration states.INTERFACES    MIFconvTest()REFERENCED FILES    None.NON-STANDARD FEATURES    None.============================================================================*//* #include "prefix.h" */#include "ngspice.h"#include <stdio.h>#include "cktdefs.h"#include "sperror.h"//#include "util.h"#include "devdefs.h"//#include "CONST.h"#include "trandefs.h"#include <math.h>#include "mifproto.h"#include "mifparse.h"#include "mifdefs.h"#include "mifcmdat.h"/* #include "suffix.h"  *//*MIFconvTestThis function is called by the CKTconvTest() driver function tocheck convergence of any states owned by instances of aparticular code model type.  It loops through all models of thattype and all instances of each model.  For each instance, itlooks in the instance structure to determine if any variablesallocated by cm_analog_alloc() have been registered by a call tocm_analog_converge() to have their convergence tested.  If so, the valueof the function at the last iteration is compared with the valueat the current iteration to see if it has converged to within thesame delta amount used in node convergence checks (as defined bySPICE 3C1).*/int MIFconvTest(    GENmodel   *inModel,   /* The head of the model list */    CKTcircuit *ckt)       /* The circuit structure */{    MIFmodel    *model;    MIFinstance *here;    int         i;    double      value;    double      last_value;    char        *byte_aligned_double_ptr;    double      *double_ptr;    double      tol;    Mif_Boolean_t  gotone = MIF_FALSE;    /* Setup for access into MIF specific model data */    model = (MIFmodel *) inModel;    /* loop through all models of this type */    for( ; model != NULL; model = model->MIFnextModel) {        /* Loop through all instances of this model */        for(here = model->MIFinstances; here != NULL; here = here->MIFnextInstance) {            /* Loop through all items registered for convergence */            for(i = 0; i < here->num_conv; i++) {                /* Get the current value and the last value */                byte_aligned_double_ptr = (char *) ckt->CKTstate0;                byte_aligned_double_ptr += here->conv[i].byte_index;                double_ptr = (double *) byte_aligned_double_ptr;                value = *double_ptr;                last_value = here->conv[i].last_value;                /* If none have failed so far, check convergence */                if(! gotone) {                    tol = ckt->CKTreltol * MAX(fabs(value), fabs(last_value))                                         + ckt->CKTabstol;                    if (fabs(value - last_value) > tol) {                        if(ckt->enh->conv_debug.report_conv_probs) {                            ENHreport_conv_prob(ENH_ANALOG_INSTANCE,                                                (char *) here->MIFname,                                                "");                        }                        ckt->CKTnoncon++;                        gotone = MIF_TRUE;                    }                }                /* Rotate the current value to last_value */                here->conv[i].last_value = value;            } /* end for number of conv items */        } /* end for all instances */    }  /* end for all models of this type */    return(OK);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -