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

📄 ltraload.c

📁 spice中支持多层次元件模型仿真的可单独运行的插件源码
💻 C
📖 第 1 页 / 共 2 页
字号:
		      *(here->LTRAv1 + isaved + 1),		      v1d);		  fprintf(stdout, "	timepoints are: %1.8g %1.8g %1.8g %1.8g\n", t1, t2, t3, ckt->CKTtime - model->LTRAtd);#endif		} else {		  v1d = *(here->LTRAv1 + isaved) * lf2		      + *(here->LTRAv1 + isaved + 1) *		      lf3;		}	      }	      if ((isaved != 0) &&		  ((model->LTRAhowToInterp ==			  LTRA_MOD_QUADINTERP) ||		      (model->LTRAhowToInterp ==			  LTRA_MOD_MIXEDINTERP))) {		i1d = *(here->LTRAi1 + isaved - 1) * qf1		    + *(here->LTRAi1 + isaved) * qf2		    + *(here->LTRAi1 + isaved + 1) * qf3;		max = MAX(*(here->LTRAi1 + isaved - 1),		    *(here->LTRAi1 + isaved));		max = MAX(max, *(here->LTRAi1 + isaved + 1));		min = MIN(*(here->LTRAi1 + isaved - 1),		    *(here->LTRAi1 + isaved));		min = MIN(min, *(here->LTRAi1 + isaved + 1));	      }	      if ((model->LTRAhowToInterp ==		      LTRA_MOD_LININTERP) || (isaved == 0) ||		  ((isaved != 0) &&		      ((model->LTRAhowToInterp ==			      LTRA_MOD_QUADINTERP) ||			  (model->LTRAhowToInterp ==			      LTRA_MOD_MIXEDINTERP)) &&		      ((i1d > max) || (i1d < min)))) {		if ((isaved != 0) &&		    (model->LTRAhowToInterp ==			LTRA_MOD_QUADINTERP)) {#ifdef LTRADEBUG		  fprintf(stdout, "LTRAload: warning: interpolated i1 is out of range after timepoint %d\n", ckt->CKTtimeIndex);		  fprintf(stdout, "	values: %1.8g %1.8g %1.8g; interpolated: %1.8g\n",		      *(here->LTRAi1 + isaved - 1),		      *(here->LTRAi1 + isaved),		      *(here->LTRAi1 + isaved + 1),		      i1d);		  fprintf(stdout, "	timepoints are: %1.8g %1.8g %1.8g %1.8g\n", t1, t2, t3, ckt->CKTtime - model->LTRAtd);#endif		} else {		  i1d = *(here->LTRAi1 + isaved) * lf2		      + *(here->LTRAi1 + isaved + 1) *		      lf3;		}	      }	      if ((isaved != 0) &&		  ((model->LTRAhowToInterp ==			  LTRA_MOD_QUADINTERP) ||		      (model->LTRAhowToInterp ==			  LTRA_MOD_MIXEDINTERP))) {		v2d = *(here->LTRAv2 + isaved - 1) * qf1		    + *(here->LTRAv2 + isaved) * qf2		    + *(here->LTRAv2 + isaved + 1) * qf3;		max = MAX(*(here->LTRAv2 + isaved - 1),		    *(here->LTRAv2 + isaved));		max = MAX(max, *(here->LTRAv2 + isaved + 1));		min = MIN(*(here->LTRAv2 + isaved - 1),		    *(here->LTRAv2 + isaved));		min = MIN(min, *(here->LTRAv2 + isaved + 1));	      }	      if ((model->LTRAhowToInterp ==		      LTRA_MOD_LININTERP) || (isaved == 0) ||		  ((isaved != 0) &&		      ((model->LTRAhowToInterp ==			      LTRA_MOD_QUADINTERP) ||			  (model->LTRAhowToInterp ==			      LTRA_MOD_MIXEDINTERP)) &&		      ((v2d > max) || (v2d < min)))) {		if ((isaved != 0) &&		    (model->LTRAhowToInterp ==			LTRA_MOD_QUADINTERP)) {#ifdef LTRADEBUG		  fprintf(stdout, "LTRAload: warning: interpolated v2 is out of range after timepoint %d\n", ckt->CKTtimeIndex);		  fprintf(stdout, "	values: %1.8g %1.8g %1.8g; interpolated: %1.8g\n",		      *(here->LTRAv2 + isaved - 1),		      *(here->LTRAv2 + isaved),		      *(here->LTRAv2 + isaved + 1),		      v2d);		  fprintf(stdout, "	timepoints are: %1.8g %1.8g %1.8g %1.8g\n", t1, t2, t3, ckt->CKTtime - model->LTRAtd);#endif		} else {		  v2d = *(here->LTRAv2 + isaved) * lf2		      + *(here->LTRAv2 + isaved + 1) *		      lf3;		}	      }	      if ((isaved != 0) &&		  ((model->LTRAhowToInterp ==			  LTRA_MOD_QUADINTERP) ||		      (model->LTRAhowToInterp ==			  LTRA_MOD_MIXEDINTERP))) {		i2d = *(here->LTRAi2 + isaved - 1) * qf1		    + *(here->LTRAi2 + isaved) * qf2		    + *(here->LTRAi2 + isaved + 1) * qf3;		max = MAX(*(here->LTRAi2 + isaved - 1),		    *(here->LTRAi2 + isaved));		max = MAX(max, *(here->LTRAi2 + isaved + 1));		min = MIN(*(here->LTRAi2 + isaved - 1),		    *(here->LTRAi2 + isaved));		min = MIN(min, *(here->LTRAi2 + isaved + 1));	      }	      if ((model->LTRAhowToInterp ==		      LTRA_MOD_LININTERP) || (isaved == 0) ||		  ((isaved != 0) &&		      ((model->LTRAhowToInterp ==			      LTRA_MOD_QUADINTERP) ||			  (model->LTRAhowToInterp ==			      LTRA_MOD_MIXEDINTERP)) &&		      ((i2d > max) || (i2d < min)))) {		if ((isaved != 0) &&		    (model->LTRAhowToInterp ==			LTRA_MOD_QUADINTERP)) {#ifdef LTRADEBUG		  fprintf(stdout, "LTRAload: warning: interpolated i2 is out of range after timepoint %d\n", ckt->CKTtimeIndex);		  fprintf(stdout, "	values: %1.8g %1.8g %1.8g; interpolated: %1.8g\n",		      *(here->LTRAi2 + isaved - 1),		      *(here->LTRAi2 + isaved),		      *(here->LTRAi2 + isaved + 1),		      i2d);		  fprintf(stdout, "	timepoints are: %1.8g %1.8g %1.8g %1.8g\n", t1, t2, t3, ckt->CKTtime - model->LTRAtd);#endif		} else {		  i2d = *(here->LTRAi2 + isaved) * lf2		      + *(here->LTRAi2 + isaved + 1) *		      lf3;		}	      }	    }	    /* interpolation done */	    break;	  case LTRA_MOD_RC:	    break;	  default:	    return (E_BADPARM);	  }	  switch (model->LTRAspecialCase) {	  case LTRA_MOD_RLC:	    /* begin convolution parts */	    /* convolution of h1dash with v1 and v2 */	    /* the matrix has already been loaded above */	    dummy1 = dummy2 = 0.0;	    for (i = /* model->LTRAh1dashIndex */ ckt->CKTtimeIndex; i > 0; i--) {	      if (*(model->LTRAh1dashCoeffs + i) != 0.0) {		dummy1 += *(model->LTRAh1dashCoeffs		    + i) * (*(here->LTRAv1 + i) -		    here->LTRAinitVolt1);		dummy2 += *(model->LTRAh1dashCoeffs		    + i) * (*(here->LTRAv2 + i) -		    here->LTRAinitVolt2);	      }	    }	    dummy1 += here->LTRAinitVolt1 *		model->LTRAintH1dash;	    dummy2 += here->LTRAinitVolt2 *		model->LTRAintH1dash;	    dummy1 -= here->LTRAinitVolt1 *		model->LTRAh1dashFirstCoeff;	    dummy2 -= here->LTRAinitVolt2 *		model->LTRAh1dashFirstCoeff;	    here->LTRAinput1 -= dummy1 * model->LTRAadmit;	    here->LTRAinput2 -= dummy2 * model->LTRAadmit;	    /* end convolution of h1dash with v1 and v2 */	    /* convolution of h2 with i2 and i1 */	    dummy1 = dummy2 = 0.0;	    if (tdover) {	      /* the term for ckt->CKTtime - model->LTRAtd */	      dummy1 = (i2d - here->LTRAinitCur2) *		  model->LTRAh2FirstCoeff;	      dummy2 = (i1d - here->LTRAinitCur1) *		  model->LTRAh2FirstCoeff;	      /* the rest of the convolution */	      for (i = /* model->LTRAh2Index */ model->LTRAauxIndex; i > 0; i--) {		if (*(model->LTRAh2Coeffs + i) != 0.0) {		  dummy1 += *(model->LTRAh2Coeffs		      + i) * (*(here->LTRAi2 + i) -		      here->LTRAinitCur2);		  dummy2 += *(model->LTRAh2Coeffs		      + i) * (*(here->LTRAi1 + i) -		      here->LTRAinitCur1);		}	      }	    }	    /* the initial-condition terms */	    dummy1 += here->LTRAinitCur2 *		model->LTRAintH2;	    dummy2 += here->LTRAinitCur1 *		model->LTRAintH2;	    here->LTRAinput1 += dummy1;	    here->LTRAinput2 += dummy2;	    /* end convolution of h2 with i2 and i1 */	    /* convolution of h3dash with v2 and v1 */	    /* the term for ckt->CKTtime - model->LTRAtd */	    dummy1 = dummy2 = 0.0;	    if (tdover) {	      dummy1 = (v2d - here->LTRAinitVolt2) *		  model->LTRAh3dashFirstCoeff;	      dummy2 = (v1d - here->LTRAinitVolt1) *		  model->LTRAh3dashFirstCoeff;	      /* the rest of the convolution */	      for (i = /* model->LTRAh3dashIndex */ model->LTRAauxIndex; i > 0; i--) {		if (*(model->LTRAh3dashCoeffs + i) != 0.0) {		  dummy1 += *(model->LTRAh3dashCoeffs		      + i) * (*(here->LTRAv2 + i) -		      here->LTRAinitVolt2);		  dummy2 += *(model->LTRAh3dashCoeffs		      + i) * (*(here->LTRAv1 + i) -		      here->LTRAinitVolt1);		}	      }	    }	    /* the initial-condition terms */	    dummy1 += here->LTRAinitVolt2 *		model->LTRAintH3dash;	    dummy2 += here->LTRAinitVolt1 *		model->LTRAintH3dash;	    here->LTRAinput1 += model->LTRAadmit * dummy1;	    here->LTRAinput2 += model->LTRAadmit * dummy2;	    /* end convolution of h3dash with v2 and v1 */	  case LTRA_MOD_LC:	    /* begin lossless-like parts */	    if (!tdover) {	      here->LTRAinput1 += model->LTRAattenuation *		  (here->LTRAinitVolt2 * model->LTRAadmit +		  here->LTRAinitCur2);	      here->LTRAinput2 += model->LTRAattenuation *		  (here->LTRAinitVolt1 * model->LTRAadmit +		  here->LTRAinitCur1);	    } else {	      here->LTRAinput1 += model->LTRAattenuation *		  (v2d * model->LTRAadmit + i2d);	      here->LTRAinput2 += model->LTRAattenuation *		  (v1d * model->LTRAadmit + i1d);	    }	    /* end lossless-like parts */	    break;	  case LTRA_MOD_RC:	    /* begin convolution parts */	    /* convolution of h1dash with v1 and v2 */	    /* the matrix has already been loaded above */	    dummy1 = 0.0;	    dummy2 = 0.0;	    for (i = ckt->CKTtimeIndex; i > 0; i--) {	      if (*(model->LTRAh1dashCoeffs + i) != 0.0) {		dummy1 += *(model->LTRAh1dashCoeffs		    + i) * (*(here->LTRAv1 + i) -		    here->LTRAinitVolt1);		dummy2 += *(model->LTRAh1dashCoeffs		    + i) * (*(here->LTRAv2 + i) -		    here->LTRAinitVolt2);	      }	    }	    /* the initial condition terms */	    dummy1 += here->LTRAinitVolt1 *		model->LTRAintH1dash;	    dummy2 += here->LTRAinitVolt2 *		model->LTRAintH1dash;	    /*	     * the constant contributed by the init condition and the latest	     * timepoint	     */	    dummy1 -= here->LTRAinitVolt1 *		model->LTRAh1dashFirstCoeff;	    dummy2 -= here->LTRAinitVolt2 *		model->LTRAh1dashFirstCoeff;	    here->LTRAinput1 -= dummy1;	    here->LTRAinput2 -= dummy2;	    /* end convolution of h1dash with v1 and v2 */	    /* convolution of h2 with i2 and i1 */	    dummy1 = dummy2 = 0.0;	    for (i = ckt->CKTtimeIndex; i > 0; i--) {	      if (*(model->LTRAh2Coeffs + i) != 0.0) {		dummy1 += *(model->LTRAh2Coeffs		    + i) * (*(here->LTRAi2 + i) -		    here->LTRAinitCur2);		dummy2 += *(model->LTRAh2Coeffs		    + i) * (*(here->LTRAi1 + i) -		    here->LTRAinitCur1);	      }	    }	    /* the initial-condition terms */	    dummy1 += here->LTRAinitCur2 *		model->LTRAintH2;	    dummy2 += here->LTRAinitCur1 *		model->LTRAintH2;	    dummy1 -= here->LTRAinitCur2 *		model->LTRAh2FirstCoeff;	    dummy2 -= here->LTRAinitCur1 *		model->LTRAh2FirstCoeff;	    here->LTRAinput1 += dummy1;	    here->LTRAinput2 += dummy2;	    /* end convolution of h2 with i2 and i1 */	    /* convolution of h3dash with v2 and v1 */	    dummy1 = dummy2 = 0.0;	    for (i = ckt->CKTtimeIndex; i > 0; i--) {	      if (*(model->LTRAh3dashCoeffs + i) != 0.0) {		dummy1 += *(model->LTRAh3dashCoeffs		    + i) * (*(here->LTRAv2 + i) -		    here->LTRAinitVolt2);		dummy2 += *(model->LTRAh3dashCoeffs		    + i) * (*(here->LTRAv1 + i) -		    here->LTRAinitVolt1);	      }	    }	    /* the initial-condition terms */	    dummy1 += here->LTRAinitVolt2 *		model->LTRAintH3dash;	    dummy2 += here->LTRAinitVolt1 *		model->LTRAintH3dash;	    dummy1 -= here->LTRAinitVolt2 *		model->LTRAh3dashFirstCoeff;	    dummy2 -= here->LTRAinitVolt1 *		model->LTRAh3dashFirstCoeff;	    here->LTRAinput1 += dummy1;	    here->LTRAinput2 += dummy2;	    /* end convolution of h3dash with v2 and v1 */	    break;	  default:	    return (E_BADPARM);	  }	}	/* load the RHS - done every time this routine is called */	*(ckt->CKTrhs + here->LTRAbrEq1) += here->LTRAinput1;	*(ckt->CKTrhs + here->LTRAbrEq2) += here->LTRAinput2;      }    }  }  return (OK);}

⌨️ 快捷键说明

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