Jspice3
ltramisc.c File Reference
#include "spice.h"
#include <math.h>
#include "ltradefs.h"
#include "util.h"
Include dependency graph for ltramisc.c:

Go to the source code of this file.

Macros

#define M_PI   3.14159265
 
#define SECONDDERIV(i, a, b, c)
 

Functions

static double intlinfunc ()
 
static double twiceintlinfunc ()
 
static double thriceintlinfunc ()
 
static double bessI0 ()
 
static double bessI1 ()
 
static double bessXX ()
 
static double bessI1xOverX ()
 
static double bessYY ()
 
static double bessZZ ()
 
static double ltra_rlcH1dashTwiceIntFunc ()
 
static double ltra_rlcH3dashIntFunc ()
 
static double ltra_rcH1dashTwiceIntFunc ()
 
static double ltra_rcH2TwiceIntFunc ()
 
void LTRArcCoeffsSetup (CKTcircuit *ckt, GENmodel *InModel)
 
void LTRArlcCoeffsSetup (CKTcircuit *ckt, GENmodel *InModel)
 
double LTRArlcH2Func (double time, GENmodel *InModel)
 
double LTRArlcH3dashFunc (double time, double T, double alpha, double beta)
 
int LTRAstraightLineCheck (double x1, double y1, double x2, double y2, double x3, double y3, double reltol, double abstol)
 
double LTRAlteCalculate (CKTcircuit *ckt, GENmodel *genmodel, GENinstance *geninstance, double curtime)
 
static double intlinfunc (double lolimit, double hilimit, double lovalue, double hivalue, double t1, double t2)
 
static double twiceintlinfunc (double lolimit, double hilimit, double otherlolimit, double lovalue, double hivalue, double t1, double t2)
 
static double thriceintlinfunc (double lolimit, double hilimit, double secondlolimit, double thirdlolimit, double lovalue, double hivalue, double t1, double t2)
 
static double bessI0 (double x)
 
static double bessXX (double x)
 
static double bessI1xOverX (double x)
 
static double bessYY (double x, double z)
 
static double bessZZ (double x, double z)
 
static double ltra_rlcH1dashTwiceIntFunc (double time, double beta)
 
static double ltra_rlcH3dashIntFunc (double time, double T, double beta)
 
static double ltra_rcH1dashTwiceIntFunc (double time, double cbyr)
 
static double ltra_rcH2TwiceIntFunc (double time, double rclsqr)
 

Macro Definition Documentation

#define M_PI   3.14159265

Definition at line 14 of file ltramisc.c.

#define SECONDDERIV (   i,
  a,
  b,
  c 
)
Value:
(oof = (i==ckt->CKTtimeIndex+1?curtime:\
*(ckt->CKTtimePoints+i)),\
(( c - b )/(oof-*(ckt->CKTtimePoints+i-1)) -\
( b - a )/(*(ckt->CKTtimePoints+i-1)-\
*(ckt->CKTtimePoints+i-2)))/(oof - \
*(ckt->CKTtimePoints+i-2)))
Definition: sced.h:120
Definition: cddefs.h:177

Definition at line 495 of file ltramisc.c.

Function Documentation

static double bessI0 ( )
static
static double bessI0 ( double  x)
static

Definition at line 908 of file ltramisc.c.

911 {
912  double ax,ans;
913  double y;
914 
915  if ((ax = fabs(x)) < 3.75) {
916  y = x/3.75;
917  y *= y;
918  ans = 1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
919  +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
920  }
921  else {
922  y = 3.75/ax;
923  ans = (exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1
924  +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
925  +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
926  +y*0.392377e-2))))))));
927  }
928  return (ans);
929 }
static double e
Definition: vectors.c:17
static double bessI1 ( )
static
static double bessI1xOverX ( )
static
static double bessI1xOverX ( double  x)
static

Definition at line 1000 of file ltramisc.c.

1003 {
1004  double ax,ans;
1005  double y;
1006 
1007  if ((ax = fabs(x)) < 3.75) {
1008  y = x/3.75;
1009  y *= y;
1010  ans = 0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934
1011  +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))));
1012  }
1013  else {
1014  y = 3.75/ax;
1015  ans = 0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1
1016  -y*0.420059e-2));
1017  ans = 0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2
1018  +y*(0.163801e-2+y*(-0.1031555e-1+y*ans))));
1019  ans *= (exp(ax)/(ax*sqrt(ax)));
1020  }
1021  return (ans);
1022 }
static double bessXX ( )
static
static double bessXX ( double  x)
static

Definition at line 963 of file ltramisc.c.

964 {
965  double ax = fabs(x);
966  if (ax < 3.75) {
967  double y = x/3.75;
968  y *= y;
969  double ans1 = 1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
970  +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
971  double ans2 = ax*(0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934
972  +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3))))));
973  if (x > 0)
974  ans1 += ans2;
975  else
976  ans1 -= ans2;
977  return (ans1 * exp(-x));
978  }
979  else {
980  double y = 3.75/ax;
981  double ans1 = (0.39894228+y*(0.1328592e-1
982  +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
983  +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
984  +y*0.392377e-2))))))));
985  double ans2 = 0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1
986  -y*0.420059e-2));
987  ans2 = 0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2
988  +y*(0.163801e-2+y*(-0.1031555e-1+y*ans2))));
989  if (x > 0)
990  ans1 += ans2;
991  else
992  ans1 -= ans2;
993  ans1 /= sqrt(ax);
994  return (ans1);
995  }
996 }
static double bessYY ( )
static
static double bessYY ( double  x,
double  z 
)
static

Definition at line 1026 of file ltramisc.c.

1027 {
1028  double ans, ax = fabs(x);
1029  if (ax < 3.75) {
1030  double y = x/3.75;
1031  y *= y;
1032  ans = 0.5+y*(0.87890594+y*(0.51498869+y*(0.15084934
1033  +y*(0.2658733e-1+y*(0.301532e-2+y*0.32411e-3)))));
1034  ans *= exp(z);
1035  }
1036  else {
1037  double y = 3.75/ax;
1038  ans = 0.2282967e-1+y*(-0.2895312e-1+y*(0.1787654e-1
1039  -y*0.420059e-2));
1040  ans = 0.39894228+y*(-0.3988024e-1+y*(-0.362018e-2
1041  +y*(0.163801e-2+y*(-0.1031555e-1+y*ans))));
1042  ans *= (exp(ax + z)/(ax*sqrt(ax)));
1043  }
1044  return (ans);
1045 }
static double bessZZ ( )
static
static double bessZZ ( double  x,
double  z 
)
static

Definition at line 1049 of file ltramisc.c.

1050 {
1051  double ans, ax = fabs(x);
1052  if (ax < 3.75) {
1053  double y = x/3.75;
1054  y *= y;
1055  ans = 1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
1056  +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
1057  ans *= exp(z);
1058  }
1059  else {
1060  double y = 3.75/ax;
1061  ans = (exp(ax + z)/sqrt(ax))*(0.39894228+y*(0.1328592e-1
1062  +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
1063  +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
1064  +y*0.392377e-2))))))));
1065  }
1066  return (ans);
1067 }
static double e
Definition: vectors.c:17
static double intlinfunc ( )
static
static double intlinfunc ( double  lolimit,
double  hilimit,
double  lovalue,
double  hivalue,
double  t1,
double  t2 
)
static

Definition at line 815 of file ltramisc.c.

818 {
819  double width, m;
820 
821  width = t2 - t1;
822  if (width == 0.0) return(0.0);
823  m = (hivalue - lovalue)/width;
824 
825  return ((hilimit-lolimit)*lovalue + 0.5*m*((hilimit-t1)*(hilimit-t1)
826  - (lolimit - t1)*(lolimit - t1)));
827 }
FILE * m
Definition: proc2mod.c:47
static double ltra_rcH1dashTwiceIntFunc ( )
static
static double ltra_rcH1dashTwiceIntFunc ( double  time,
double  cbyr 
)
static

Definition at line 1116 of file ltramisc.c.

1119 {
1120  return (sqrt(4*cbyr*time/M_PI));
1121 }
#define M_PI
Definition: ltramisc.c:14
static double ltra_rcH2TwiceIntFunc ( )
static
static double ltra_rcH2TwiceIntFunc ( double  time,
double  rclsqr 
)
static

Definition at line 1125 of file ltramisc.c.

1128 {
1129  double temp;
1130 
1131  if (time != 0.0) {
1132  temp = rclsqr/(4*time);
1133  return ((time + rclsqr*0.5)*erfc(sqrt(temp)) -
1134  sqrt(time*rclsqr/M_PI)*exp(-temp));
1135  }
1136  return(0.0);
1137 }
#define M_PI
Definition: ltramisc.c:14
double erfc()
static double ltra_rlcH1dashTwiceIntFunc ( )
static
static double ltra_rlcH1dashTwiceIntFunc ( double  time,
double  beta 
)
static

Definition at line 1075 of file ltramisc.c.

1078 {
1079  double arg, returnval;
1080 
1081  /* result = time * e^{- beta*time} * {I_0(beta*time) +
1082  * I_1(beta*time)} - time
1083  */
1084 
1085  if (beta == 0.0) return (time);
1086  arg = beta*time;
1087  if (arg == 0.0) return (0.0);
1088 
1089  returnval = (bessXX(arg)*time - time);
1090  return (returnval);
1091 }
static double bessXX()
static double ltra_rlcH3dashIntFunc ( )
static
static double ltra_rlcH3dashIntFunc ( double  time,
double  T,
double  beta 
)
static

Definition at line 1099 of file ltramisc.c.

1102 {
1103  double exparg, besselarg;
1104  double returnval;
1105 
1106  if (time <= T) return(0.0);
1107  if (beta == 0.0) return(0.0);
1108  exparg = -beta*time;
1109  besselarg = beta*sqrt(time*time - T*T);
1110  returnval = (bessZZ(besselarg, exparg) - exp(-beta*T));
1111  return (returnval);
1112 }
static double bessZZ()
double LTRAlteCalculate ( CKTcircuit ckt,
GENmodel genmodel,
GENinstance geninstance,
double  curtime 
)

Definition at line 509 of file ltramisc.c.

515 {
516  LTRAmodel *model = (LTRAmodel *) genmodel;
517  LTRAinstance *instance = (LTRAinstance *) geninstance;
518  double h1dashTfirstCoeff;
519  double h2TfirstCoeff;
520  double h3dashTfirstCoeff;
521  double dashdash;
522  double oof;
523  double hilimit1, lolimit1, hivalue1, lovalue1, f1i, g1i;
524  double eq1LTE = 0.0, eq2LTE = 0.0;
525  int auxindex, tdover, i, exact;
526 
527  switch(model->LTRAspecialCase) {
528 
529  case LTRA_MOD_LC:
530  case LTRA_MOD_RG:
531  return(0.0);
532 
533  case LTRA_MOD_RLC:
534 
535  if (curtime > model->LTRAtd) {
536  tdover = 1;
537 
538  exact = 0;
539  for (i = ckt->CKTtimeIndex ; i>= 0; i--) {
540  if (curtime - *(ckt->CKTtimePoints + i) ==
541  model->LTRAtd) {
542  exact = 1;
543  break;
544  }
545  if (curtime - *(ckt->CKTtimePoints + i)
546  > model->LTRAtd)
547  break;
548  }
549 
550 #ifdef LTRADEBUG
551  if ((i < 0) || ((i==0) && (exact==1)))
552  printf("LTRAlteCalculate: i <= 0: some mistake!\n");
553 #endif
554 
555  if (exact == 1) {
556  auxindex = i-1;
557  }
558  else {
559  auxindex = i;
560  }
561 
562  }
563  else {
564  tdover = 0;
565  }
566 
567  hilimit1 = curtime - *(ckt->CKTtimePoints + ckt->CKTtimeIndex);
568  lolimit1 = 0.0;
569  hivalue1 = ltra_rlcH1dashTwiceIntFunc(hilimit1,model->LTRAbeta);
570  lovalue1 = 0.0;
571 
572  f1i = hivalue1;
573  g1i = intlinfunc(lolimit1,hilimit1,lovalue1,hivalue1,
574  lolimit1,hilimit1);
575  h1dashTfirstCoeff = 0.5 * f1i *
576  (curtime - *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
577 
578  if (tdover) {
579  hilimit1 = curtime - *(ckt->CKTtimePoints + auxindex);
580  lolimit1 = *(ckt->CKTtimePoints + ckt->CKTtimeIndex) -
581  *(ckt->CKTtimePoints + auxindex);
582  lolimit1 = MAX(model->LTRAtd,lolimit1);
583 
584  /* are the following really doing the operations in the
585  write-up? */
586  hivalue1 = LTRArlcH2Func(hilimit1,(GENmodel*)model);
587  lovalue1 = LTRArlcH2Func(lolimit1,(GENmodel*)model);
588  f1i = twiceintlinfunc(lolimit1,hilimit1,lolimit1,lovalue1,
589  hivalue1,lolimit1,hilimit1);
590  g1i = thriceintlinfunc(lolimit1,hilimit1,lolimit1,lolimit1,
591  lovalue1,hivalue1,lolimit1,hilimit1);
592  h2TfirstCoeff = 0.5*f1i*(curtime-model->LTRAtd -
593  *(ckt->CKTtimePoints+auxindex)) - g1i;
594 
595  hivalue1 = ltra_rlcH3dashIntFunc(hilimit1,model->LTRAtd,
596  model->LTRAbeta);
597  lovalue1 = ltra_rlcH3dashIntFunc(lolimit1,model->LTRAtd,
598  model->LTRAbeta);
599  f1i = intlinfunc(lolimit1,hilimit1,lovalue1,hivalue1,
600  lolimit1,hilimit1);
601  g1i = twiceintlinfunc(lolimit1,hilimit1,lolimit1,lovalue1,
602  hivalue1,lolimit1,hilimit1);
603  h3dashTfirstCoeff = 0.5*f1i*(curtime - model->LTRAtd -
604  *(ckt->CKTtimePoints+auxindex)) - g1i;
605  }
606 
607 
608  /* LTEs for convolution with v1 */
609  /* get divided differences for v1 (2nd derivative estimates) */
610 
611  /*
612  * no need to subtract operating point values because
613  * taking differences anyway
614  */
615 
616  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
617  *(instance->LTRAv1+ckt->CKTtimeIndex-1),
618  *(instance->LTRAv1+ckt->CKTtimeIndex),
619  *(ckt->CKTrhsOld + instance->LTRAposNode1) -
620  *(ckt->CKTrhsOld + instance->LTRAnegNode1));
621  eq1LTE += model->LTRAadmit*FABS(dashdash *
622  h1dashTfirstCoeff);
623 
624  /* not bothering to interpolate since everything is approximate
625  anyway */
626 
627  if (tdover) {
628 
629  dashdash = SECONDDERIV(auxindex+1,
630  *(instance->LTRAv1 + auxindex - 1),
631  *(instance->LTRAv1 + auxindex),
632  *(instance->LTRAv1 + auxindex + 1)) ;
633 
634  eq2LTE += model->LTRAadmit*FABS(dashdash *
635  h3dashTfirstCoeff);
636  }
637  /* end LTEs for convolution with v1 */
638 
639  /* LTEs for convolution with v2 */
640  /* get divided differences for v2 (2nd derivative estimates) */
641 
642  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
643  *(instance->LTRAv2+ckt->CKTtimeIndex-1),
644  *(instance->LTRAv2+ckt->CKTtimeIndex),
645  *(ckt->CKTrhsOld + instance->LTRAposNode2) -
646  *(ckt->CKTrhsOld + instance->LTRAnegNode2));
647 
648  eq2LTE += model->LTRAadmit*FABS(dashdash *
649  h1dashTfirstCoeff);
650 
651 
652  if (tdover) {
653  dashdash = SECONDDERIV(auxindex+1,
654  *(instance->LTRAv2 + auxindex - 1),
655  *(instance->LTRAv2 + auxindex),
656  *(instance->LTRAv2 + auxindex + 1)) ;
657 
658  eq1LTE += model->LTRAadmit*FABS(dashdash *
659  h3dashTfirstCoeff);
660  }
661 
662  /* end LTEs for convolution with v2 */
663 
664  /* LTE for convolution with i1 */
665  /* get divided differences for i1 (2nd derivative estimates) */
666 
667  if (tdover) {
668  dashdash = SECONDDERIV(auxindex+1,
669  *(instance->LTRAi1 + auxindex - 1),
670  *(instance->LTRAi1 + auxindex),
671  *(instance->LTRAi1 + auxindex + 1)) ;
672 
673  eq2LTE += FABS(dashdash * h2TfirstCoeff);
674  }
675  /* end LTE for convolution with i1 */
676 
677  /* LTE for convolution with i2 */
678  /* get divided differences for i2 (2nd derivative estimates) */
679 
680  if (tdover) {
681  dashdash = SECONDDERIV(auxindex+1,
682  *(instance->LTRAi2 + auxindex - 1),
683  *(instance->LTRAi2 + auxindex),
684  *(instance->LTRAi2 + auxindex + 1)) ;
685 
686  eq1LTE += FABS(dashdash * h2TfirstCoeff);
687  }
688  /* end LTE for convolution with i1 */
689 
690  break;
691 
692  case LTRA_MOD_RC:
693 
694  hilimit1 = curtime - *(ckt->CKTtimePoints + ckt->CKTtimeIndex);
695  lolimit1 = 0.0;
696 
697  hivalue1 = ltra_rcH1dashTwiceIntFunc(hilimit1,model->LTRAcByR);
698  lovalue1 = 0.0;
699 
700  f1i = hivalue1;
701  g1i = intlinfunc(lolimit1,hilimit1,lovalue1,hivalue1,lolimit1,
702  hilimit1);
703 /*
704  h1dashTfirstCoeff = 0.5*f1i*(curtime -
705  *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
706 */
707  h2TfirstCoeff = 0.5*f1i*(curtime -
708  *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
709 
710  hivalue1 = ltra_rcH2TwiceIntFunc(hilimit1,model->LTRArclsqr);
711  lovalue1 = 0.0;
712 
713  f1i = hivalue1;
714  g1i = intlinfunc(lolimit1,hilimit1,lovalue1,hivalue1,lolimit1,
715  hilimit1);
716  h1dashTfirstCoeff = 0.5*f1i*(curtime -
717  *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
718 
719  hivalue1 = ltra_rcH2TwiceIntFunc(hilimit1,model->LTRArclsqr);
720  lovalue1 = 0.0;
721 
722  f1i = hivalue1;
723  g1i = intlinfunc(lolimit1,hilimit1,lovalue1,
724  hivalue1,lolimit1,hilimit1);
725 /*
726  h1dashTfirstCoeff = 0.5*f1i*(curtime -
727  *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
728 */
729  h3dashTfirstCoeff = 0.5*f1i*(curtime -
730  *(ckt->CKTtimePoints+ckt->CKTtimeIndex)) - g1i;
731 
732 
733  /* LTEs for convolution with v1 */
734  /* get divided differences for v1 (2nd derivative estimates) */
735 
736  /*
737  * no need to subtract operating point values because
738  * taking differences anyway
739  */
740 
741  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
742  *(instance->LTRAv1+ckt->CKTtimeIndex-1),
743  *(instance->LTRAv1+ckt->CKTtimeIndex),
744  *(ckt->CKTrhsOld + instance->LTRAposNode1) -
745  *(ckt->CKTrhsOld + instance->LTRAnegNode1));
746  eq1LTE += FABS(dashdash * h1dashTfirstCoeff);
747  eq2LTE += FABS(dashdash * h3dashTfirstCoeff);
748 
749  /* end LTEs for convolution with v1 */
750 
751  /* LTEs for convolution with v2 */
752  /* get divided differences for v2 (2nd derivative estimates) */
753 
754  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
755  *(instance->LTRAv2+ckt->CKTtimeIndex-1),
756  *(instance->LTRAv2+ckt->CKTtimeIndex),
757  *(ckt->CKTrhsOld + instance->LTRAposNode2) -
758  *(ckt->CKTrhsOld + instance->LTRAnegNode2));
759 
760  eq2LTE += FABS(dashdash * h1dashTfirstCoeff);
761  eq1LTE += FABS(dashdash * h3dashTfirstCoeff);
762 
763  /* end LTEs for convolution with v2 */
764 
765  /* LTE for convolution with i1 */
766  /* get divided differences for i1 (2nd derivative estimates) */
767 
768  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
769  *(instance->LTRAi1 + ckt->CKTtimeIndex - 1),
770  *(instance->LTRAi1 + ckt->CKTtimeIndex),
771  *(ckt->CKTrhsOld + instance->LTRAbrEq1));
772 
773  eq2LTE += FABS(dashdash * h2TfirstCoeff);
774 
775  /* end LTE for convolution with i1 */
776 
777  /* LTE for convolution with i2 */
778  /* get divided differences for i2 (2nd derivative estimates) */
779 
780  dashdash = SECONDDERIV(ckt->CKTtimeIndex+1,
781  *(instance->LTRAi2 + ckt->CKTtimeIndex - 1),
782  *(instance->LTRAi2 + ckt->CKTtimeIndex),
783  *(ckt->CKTrhsOld + instance->LTRAbrEq2));
784 
785  eq1LTE += FABS(dashdash * h2TfirstCoeff);
786 
787  /* end LTE for convolution with i1 */
788 
789  break;
790 
791  default:
792  return (1);
793  }
794 
795 #ifdef LTRADEBUG
796  fprintf(stdout,"%s: LTE/input for Eq1 at time %g is: %g\n",
797  instance->LTRAname, curtime, eq1LTE/instance->LTRAinput1);
798  fprintf(stdout,"%s: LTE/input for Eq2 at time %g is: %g\n",
799  instance->LTRAname, curtime, eq2LTE/instance->LTRAinput1);
800  fprintf(stdout,"\n");
801 #endif
802 
803  return (FABS(eq1LTE) + FABS(eq2LTE));
804 }
static double intlinfunc()
static double ltra_rlcH1dashTwiceIntFunc()
#define MAX(a, b)
Definition: spdefs.h:135
#define LTRA_MOD_RG
Definition: ltradefs.h:163
int LTRAnegNode1
Definition: ltradefs.h:26
double LTRAinput1
Definition: ltradefs.h:31
static double ltra_rcH1dashTwiceIntFunc()
static double thriceintlinfunc()
#define LTRA_MOD_LC
Definition: ltradefs.h:164
static double ltra_rcH2TwiceIntFunc()
double * LTRAi2
Definition: ltradefs.h:42
double * CKTrhsOld
Definition: cktdefs.h:98
int CKTtimeIndex
Definition: cktdefs.h:223
double LTRArlcH2Func(double time, GENmodel *InModel)
Definition: ltramisc.c:396
IFuid LTRAname
Definition: ltradefs.h:23
double * LTRAv2
Definition: ltradefs.h:41
int LTRAbrEq1
Definition: ltradefs.h:29
double LTRAcByR
Definition: ltradefs.h:117
int LTRAposNode1
Definition: ltradefs.h:25
double * LTRAi1
Definition: ltradefs.h:40
static char model[32]
Definition: subckt.c:76
double LTRAbeta
Definition: ltradefs.h:115
#define FABS(a)
Definition: util.h:41
int LTRAnegNode2
Definition: ltradefs.h:28
double LTRArclsqr
Definition: ltradefs.h:118
double * CKTtimePoints
Definition: cktdefs.h:218
double LTRAtd
Definition: ltradefs.h:111
static double ltra_rlcH3dashIntFunc()
double LTRAadmit
Definition: ltradefs.h:113
#define LTRA_MOD_RLC
Definition: ltradefs.h:161
int LTRAbrEq2
Definition: ltradefs.h:30
static double twiceintlinfunc()
int LTRAposNode2
Definition: ltradefs.h:27
#define LTRA_MOD_RC
Definition: ltradefs.h:162
double * LTRAv1
Definition: ltradefs.h:39
#define SECONDDERIV(i, a, b, c)
Definition: ltramisc.c:495
int LTRAspecialCase
Definition: ltradefs.h:158
void LTRArcCoeffsSetup ( CKTcircuit ckt,
GENmodel InModel 
)

Definition at line 60 of file ltramisc.c.

64 {
65  LTRAmodel *model = (LTRAmodel*)InModel;
66  double delta1, delta2;
67  double h1dummy1, h1dummy2;
68  double h2dummy1, h2dummy2;
69  double h3dummy1, h3dummy2;
70  double lolimit1, lolimit2, hilimit1, hilimit2;
71  double h1lovalue1, h1lovalue2, h1hivalue1, h1hivalue2;
72  double h2lovalue1, h2lovalue2, h2hivalue1, h2hivalue2;
73  double h3lovalue1, h3lovalue2, h3hivalue1, h3hivalue2;
74  double temp, temp2, temp3, temp4, temp5;
75  double h1relval, h2relval, h3relval;
76  int doh1 = 1, doh2 = 1, doh3 = 1;
77  int i, auxindex;
78 
79  auxindex = ckt->CKTtimeIndex;
80 
81  /* the first coefficients */
82 
83  delta1 = ckt->CKTtime - *(ckt->CKTtimePoints + auxindex);
84  lolimit1 = 0.0;
85  hilimit1 = delta1;
86 
87  h1lovalue1 = 0.0;
88  h1hivalue1 = sqrt(4*model->LTRAcByR*hilimit1/M_PI);
89  h1dummy1 = h1hivalue1/delta1;
90  h1relval = FABS(h1dummy1*model->LTRAchopReltol);
91  model->LTRAh1dashFirstCoeff = h1dummy1;
92 
93  temp = model->LTRArclsqr/(4*hilimit1);
94  temp2 = (temp >= 100.0 ? 0.0 : erfc(sqrt(temp)));
95  temp3 = exp(-temp);
96  temp4 = sqrt(model->LTRArclsqr);
97  temp5 = sqrt(model->LTRAcByR);
98 
99  h2lovalue1 = 0.0;
100  if (hilimit1 != 0.0)
101  h2hivalue1 = (hilimit1 + model->LTRArclsqr*0.5)*temp2 -
102  sqrt(hilimit1*model->LTRArclsqr/M_PI)*temp3;
103  else
104  h2hivalue1 = 0.0;
105 
106  h2dummy1 = h2hivalue1/delta1;
107  h2relval = FABS(h2dummy1*model->LTRAchopReltol);
108  model->LTRAh2FirstCoeff = h2dummy1;
109 
110  h3lovalue1 = 0.0;
111  if (hilimit1 != 0.0) {
112  temp = 2*sqrt(hilimit1/M_PI)*temp3 - temp4*temp2;
113  h3hivalue1 = temp5*temp;
114  }
115  else
116  h3hivalue1 = 0.0;
117 
118  h3dummy1 = h3hivalue1/delta1;
119  h3relval = FABS(h3dummy1*model->LTRAchopReltol);
120  model->LTRAh3dashFirstCoeff = h3dummy1;
121 
122  /* the coefficients for the rest of the timepoints */
123 
124  for (i = auxindex; i > 0; i--) {
125 
126  delta2 = delta1; /* previous delta1 */
127  lolimit2 = lolimit1; /* previous lolimit1 */
128  hilimit2 = hilimit1; /* previous hilimit1 */
129 
130  delta1 = *(ckt->CKTtimePoints + i) - *(ckt->CKTtimePoints + i - 1);
131  lolimit1 = hilimit2;
132  hilimit1 = ckt->CKTtime - *(ckt->CKTtimePoints + i - 1);
133 
134  if (doh1) {
135  h1lovalue2 = h1lovalue1; /* previous lovalue1 */
136  h1hivalue2 = h1hivalue1; /* previous hivalue1 */
137  h1dummy2 = h1dummy1; /* previous dummy1 */
138 
139  h1lovalue1 = h1hivalue2;
140  h1hivalue1 = sqrt(4*model->LTRAcByR*hilimit1/M_PI);
141  h1dummy1 = (h1hivalue1 - h1lovalue1)/delta1;
142  *(model->LTRAh1dashCoeffs + i) = h1dummy1 - h1dummy2;
143  if (FABS(*(model->LTRAh1dashCoeffs + i)) < h1relval) doh1 = 0;
144  }
145  else
146  *(model->LTRAh1dashCoeffs + i) = 0.0;
147 
148  if (doh2 || doh3) {
149  temp = model->LTRArclsqr/(4*hilimit1);
150  temp2 = (temp >= 100.0 ? 0.0 : erfc(sqrt(temp)));
151  temp3 = exp(-temp);
152  }
153 
154  if (doh2) {
155  h2lovalue2 = h2lovalue1; /* previous lovalue1 */
156  h2hivalue2 = h2hivalue1; /* previous hivalue1 */
157  h2dummy2 = h2dummy1; /* previous dummy1 */
158 
159  h2lovalue1 = h2hivalue2;
160  if (hilimit1 != 0.0)
161  h2hivalue1 = (hilimit1 + model->LTRArclsqr*0.5)*temp2 -
162  sqrt(hilimit1*model->LTRArclsqr/M_PI)*temp3;
163  else
164  h2hivalue1 = 0.0;
165  h2dummy1 = (h2hivalue1 - h2lovalue1)/delta1;
166  *(model->LTRAh2Coeffs + i) = h2dummy1 - h2dummy2;
167  if (FABS(*(model->LTRAh2Coeffs + i)) < h2relval) doh2 = 0;
168  }
169  else
170  *(model->LTRAh2Coeffs + i) = 0.0;
171 
172  if (doh3) {
173  h3lovalue2 = h3lovalue1; /* previous lovalue1 */
174  h3hivalue2 = h3hivalue1; /* previous hivalue1 */
175  h3dummy2 = h3dummy1; /* previous dummy1 */
176 
177  h3lovalue1 = h3hivalue2;
178  if (hilimit1 != 0.0) {
179  temp = 2*sqrt(hilimit1/M_PI)*temp3 - temp4*temp2;
180  h3hivalue1 = temp5*temp;
181  }
182  else
183  h3hivalue1 = 0.0;
184  h3dummy1 = (h3hivalue1 - h3lovalue1)/delta1;
185  *(model->LTRAh3dashCoeffs + i) = h3dummy1 - h3dummy2;
186  if (FABS(*(model->LTRAh3dashCoeffs + i)) < h3relval) doh3 = 0;
187  }
188  else
189  *(model->LTRAh3dashCoeffs + i) = 0.0;
190  }
191 }
double CKTtime
Definition: cktdefs.h:77
double LTRAchopReltol
Definition: ltradefs.h:129
double LTRAh3dashFirstCoeff
Definition: ltradefs.h:98
double LTRAh2FirstCoeff
Definition: ltradefs.h:96
#define M_PI
Definition: ltramisc.c:14
int CKTtimeIndex
Definition: cktdefs.h:223
double * LTRAh2Coeffs
Definition: ltradefs.h:102
double LTRAcByR
Definition: ltradefs.h:117
double erfc()
static char model[32]
Definition: subckt.c:76
#define FABS(a)
Definition: util.h:41
double LTRArclsqr
Definition: ltradefs.h:118
double * LTRAh3dashCoeffs
Definition: ltradefs.h:103
double * CKTtimePoints
Definition: cktdefs.h:218
double * LTRAh1dashCoeffs
Definition: ltradefs.h:101
double LTRAh1dashFirstCoeff
Definition: ltradefs.h:94
void LTRArlcCoeffsSetup ( CKTcircuit ckt,
GENmodel InModel 
)

Definition at line 195 of file ltramisc.c.

199 {
200  LTRAmodel *model = (LTRAmodel*)InModel;
201  unsigned exact;
202  double lolimit1, lolimit2, hilimit1, hilimit2;
203  double delta1, delta2;
204  double h1dummy1, h1dummy2;
205  double h1lovalue1, h1lovalue2, h1hivalue1, h1hivalue2;
206  double h2dummy1, h2dummy2;
207  double h2lovalue1, h2lovalue2, h2hivalue1, h2hivalue2;
208  double h3dummy1, h3dummy2;
209  double h3lovalue1, h3lovalue2, h3hivalue1, h3hivalue2;
210  double exparg, besselarg, bessi1overxterm, bessi0term;
211  double expbetaTterm, alphasqTterm;
212  double h1relval, h2relval, h3relval;
213  int doh1 = 1, doh2 = 1, doh3 = 1;
214  int i, auxindex;
215 
216  /*
217  * we assume a piecewise linear function, and we calculate the
218  * coefficients using this assumption in the integration of the
219  * function
220  */
221 
222  if (model->LTRAtd == 0.0) {
223  auxindex = ckt->CKTtimeIndex;
224  }
225  else {
226 
227  if (ckt->CKTtime - model->LTRAtd <= 0.0) {
228  auxindex = 0;
229  }
230  else {
231  exact = 0;
232  for (i = ckt->CKTtimeIndex; i >= 0; i--) {
233  if (ckt->CKTtime - *(ckt->CKTtimePoints + i) ==
234  model->LTRAtd) {
235  exact = 1;
236  break;
237  }
238  if (ckt->CKTtime - *(ckt->CKTtimePoints + i) >
239  model->LTRAtd) break;
240  }
241 
242 #ifdef LTRADEBUG
243  if ((i < 0) || ((i == 0) && (exact == 1)))
244  printf("LTRAcoeffSetup: i <= 0: some mistake!\n");
245 #endif
246 
247  if (exact == 1) {
248  auxindex = i-1;
249  }
250  else {
251  auxindex = i;
252  }
253  }
254  }
255  /* the first coefficient */
256 
257  if (auxindex != 0) {
258  lolimit1 = model->LTRAtd;
259  hilimit1 = ckt->CKTtime - *(ckt->CKTtimePoints + auxindex);
260  delta1 = hilimit1 - lolimit1;
261 
262  h2lovalue1 = LTRArlcH2Func(model->LTRAtd,(GENmodel*)model);
263  besselarg = (hilimit1 > model->LTRAtd) ?
264  model->LTRAalpha*sqrt(hilimit1*hilimit1 -
265  model->LTRAtd*model->LTRAtd) : 0.0;
266  exparg = -model->LTRAbeta*hilimit1;
267  bessi1overxterm = bessYY(besselarg, exparg);
268  alphasqTterm = model->LTRAalpha*model->LTRAalpha*model->LTRAtd;
269  h2hivalue1 =
270  ((model->LTRAalpha == 0.0) || (hilimit1 < model->LTRAtd)) ? 0.0:
271  alphasqTterm*bessi1overxterm;
272 
273  h2dummy1 = twiceintlinfunc(lolimit1,hilimit1,lolimit1,h2lovalue1,
274  h2hivalue1,lolimit1,hilimit1)/delta1;
275  model->LTRAh2FirstCoeff = h2dummy1;
276  h2relval = FABS(model->LTRAchopReltol*h2dummy1);
277 
278  h3lovalue1 = 0.0; /* E3dash should be consistent with this */
279  bessi0term = bessZZ(besselarg, exparg);
280  expbetaTterm = exp(-model->LTRAbeta*model->LTRAtd);
281  h3hivalue1 =
282  ((hilimit1 <= model->LTRAtd) || (model->LTRAbeta == 0.0)) ? 0.0:
283  bessi0term - expbetaTterm;
284  h3dummy1 = intlinfunc(lolimit1,hilimit1,h3lovalue1,
285  h3hivalue1,lolimit1,hilimit1)/delta1;
286  model->LTRAh3dashFirstCoeff = h3dummy1;
287  h3relval = FABS(h3dummy1*model->LTRAchopReltol);
288  }
289  else {
290  model->LTRAh2FirstCoeff = model->LTRAh3dashFirstCoeff = 0.0;
291  }
292 
293  lolimit1 = 0.0;
294  hilimit1 = ckt->CKTtime - *(ckt->CKTtimePoints + ckt->CKTtimeIndex);
295  delta1 = hilimit1 - lolimit1;
296  exparg = -model->LTRAbeta*hilimit1;
297 
298  h1lovalue1 = 0.0;
299  h1hivalue1 = (model->LTRAbeta == 0.0)? hilimit1:
300  ((hilimit1 == 0.0) ? 0.0 : bessXX(-exparg)*hilimit1 - hilimit1);
301  h1dummy1 = h1hivalue1/delta1;
302  model->LTRAh1dashFirstCoeff = h1dummy1;
303  h1relval = FABS(h1dummy1*model->LTRAchopReltol);
304 
305 
306  /* the coefficients for the rest of the timepoints */
307 
308  for (i = ckt->CKTtimeIndex; i > 0; i--) {
309 
310  if (doh1 || doh2 || doh3) {
311  lolimit2 = lolimit1; /* previous lolimit1 */
312  hilimit2 = hilimit1; /* previous hilimit1 */
313  delta2 = delta1; /* previous delta1 */
314 
315  lolimit1 = hilimit2;
316  hilimit1 = ckt->CKTtime - *(ckt->CKTtimePoints + i - 1);
317  delta1 =
318  *(ckt->CKTtimePoints + i) - *(ckt->CKTtimePoints + i - 1);
319 
320  exparg = -model->LTRAbeta*hilimit1;
321  }
322 
323  if (doh1) {
324  h1lovalue2 = h1lovalue1; /* previous lovalue1 */
325  h1hivalue2 = h1hivalue1; /* previous hivalue1 */
326  h1dummy2 = h1dummy1; /* previous dummy1 */
327 
328  h1lovalue1 = h1hivalue2;
329  h1hivalue1 = (model->LTRAbeta == 0.0)? hilimit1:
330  ((hilimit1 == 0.0) ? 0.0:
331  bessXX(-exparg)*hilimit1 - hilimit1);
332  h1dummy1 = (h1hivalue1 - h1lovalue1)/delta1;
333 
334  *(model->LTRAh1dashCoeffs + i) = h1dummy1 - h1dummy2;
335  if (FABS(*(model->LTRAh1dashCoeffs + i)) <= h1relval) doh1 = 0;
336  }
337  else
338  *(model->LTRAh1dashCoeffs + i) = 0.0;
339 
340  if (i <= auxindex) {
341 
342  if (doh2 || doh3)
343  besselarg = (hilimit1 > model->LTRAtd) ?
344  model->LTRAalpha*sqrt(hilimit1*hilimit1 -
345  model->LTRAtd*model->LTRAtd) : 0.0;
346 
347  if (doh2) {
348  h2lovalue2 = h2lovalue1; /* previous lovalue1 */
349  h2hivalue2 = h2hivalue1; /* previous hivalue1 */
350  h2dummy2 = h2dummy1; /* previous dummy1 */
351 
352  h2lovalue1 = h2hivalue2;
353  bessi1overxterm = bessYY(besselarg, exparg);
354  h2hivalue1 =
355  ((model->LTRAalpha == 0.0) ||
356  (hilimit1 < model->LTRAtd)) ? 0.0 :
357  alphasqTterm*bessi1overxterm;
358  h2dummy1 = twiceintlinfunc(lolimit1,hilimit1,lolimit1,
359  h2lovalue1,h2hivalue1,lolimit1,hilimit1)/delta1;
360 
361  *(model->LTRAh2Coeffs + i) = h2dummy1 - h2dummy2 +
362  intlinfunc(lolimit2,hilimit2,
363  h2lovalue2,h2hivalue2,lolimit2,hilimit2);
364  if (FABS(*(model->LTRAh2Coeffs + i)) <= h2relval) doh2 = 0;
365  }
366  else
367  *(model->LTRAh2Coeffs + i) = 0.0;
368 
369  if (doh3) {
370  h3lovalue2 = h3lovalue1; /* previous lovalue1 */
371  h3hivalue2 = h3hivalue1; /* previous hivalue1 */
372  h3dummy2 = h3dummy1; /* previous dummy1 */
373 
374  h3lovalue1 = h3hivalue2;
375  bessi0term = bessZZ(besselarg, exparg);
376  h3hivalue1 =
377  ((hilimit1 <= model->LTRAtd) ||
378  (model->LTRAbeta == 0.0)) ? 0.0 :
379  bessi0term - expbetaTterm;
380  h3dummy1 = intlinfunc(lolimit1,hilimit1,h3lovalue1,
381  h3hivalue1,lolimit1,hilimit1)/delta1;
382 
383  *(model->LTRAh3dashCoeffs + i) = h3dummy1 - h3dummy2;
384  if (FABS(*(model->LTRAh3dashCoeffs + i)) <= h3relval)
385  doh3 = 0;
386  }
387  else
388  *(model->LTRAh3dashCoeffs + i) = 0.0;
389  }
390  }
391  model->LTRAauxIndex = auxindex;
392 }
double CKTtime
Definition: cktdefs.h:77
static double intlinfunc()
double LTRAalpha
Definition: ltradefs.h:114
static double bessYY()
double LTRAchopReltol
Definition: ltradefs.h:129
double LTRAh3dashFirstCoeff
Definition: ltradefs.h:98
double LTRAh2FirstCoeff
Definition: ltradefs.h:96
int CKTtimeIndex
Definition: cktdefs.h:223
double LTRArlcH2Func(double time, GENmodel *InModel)
Definition: ltramisc.c:396
double * LTRAh2Coeffs
Definition: ltradefs.h:102
static char model[32]
Definition: subckt.c:76
double LTRAbeta
Definition: ltradefs.h:115
#define FABS(a)
Definition: util.h:41
double * LTRAh3dashCoeffs
Definition: ltradefs.h:103
double * CKTtimePoints
Definition: cktdefs.h:218
double LTRAtd
Definition: ltradefs.h:111
int LTRAauxIndex
Definition: ltradefs.h:127
static double twiceintlinfunc()
double * LTRAh1dashCoeffs
Definition: ltradefs.h:101
static double bessZZ()
static double bessXX()
double LTRAh1dashFirstCoeff
Definition: ltradefs.h:94
double LTRArlcH2Func ( double  time,
GENmodel InModel 
)

Definition at line 396 of file ltramisc.c.

400 {
401  LTRAmodel *model = (LTRAmodel*)InModel;
402  double besselarg, exparg, returnval;
403 
404  /*
405  * result = 0, time < T
406  * = (alpha*T*e^{-beta*time})/sqrt(t^2 - T^2) *
407  * I_1(alpha*sqrt(t^2 - T^2))
408  */
409 
410  if (model->LTRAalpha == 0.0) return(0.0);
411  if (time < model->LTRAtd) return(0.0);
412 
413  if (time != model->LTRAtd) {
414  besselarg = model->LTRAalpha*
415  sqrt(time*time - model->LTRAtd*model->LTRAtd);
416  }
417  else {
418  besselarg = 0.0;
419  }
420  exparg = -model->LTRAbeta*time;
421 
422  returnval = model->LTRAalpha*model->LTRAalpha*model->LTRAtd*
423  exp(exparg)*bessI1xOverX(besselarg);
424  return (returnval);
425 }
static double bessI1xOverX()
double LTRAalpha
Definition: ltradefs.h:114
static char model[32]
Definition: subckt.c:76
double LTRAbeta
Definition: ltradefs.h:115
double LTRAtd
Definition: ltradefs.h:111
double LTRArlcH3dashFunc ( double  time,
double  T,
double  alpha,
double  beta 
)

Definition at line 429 of file ltramisc.c.

432 {
433  double exparg, besselarg, returnval;
434 
435  /*
436  * result = 0, time < T
437  * = alpha*e^{-beta*time}*(t/sqrt(t^2-T^2)*
438  * I_1(alpha*sqrt(t^2-T^2)) - I_0(alpha*sqrt(t^2-T^2)))
439  */
440 
441  if (alpha == 0.0) return(0.0);
442  if (time < T) return(0.0);
443 
444  exparg = - beta*time;
445  if (time != T) {
446  besselarg = alpha*sqrt(time*time - T*T);
447  }
448  else {
449  besselarg = 0.0;
450  }
451 
452  returnval = alpha*time*bessI1xOverX(besselarg) - bessI0(besselarg);
453  returnval *= alpha*exp(exparg);
454  return (returnval);
455 }
static double bessI0()
static double bessI1xOverX()
int LTRAstraightLineCheck ( double  x1,
double  y1,
double  x2,
double  y2,
double  x3,
double  y3,
double  reltol,
double  abstol 
)

Definition at line 470 of file ltramisc.c.

473 {
474 double TRarea, QUADarea1,QUADarea2,QUADarea3, area;
475 
476  /* this should work if y1,y2,y3 all have the same sign and x1,x2,x3
477  * are in increasing order
478  */
479 
480  QUADarea1 = (FABS(y2)+FABS(y1))*0.5*FABS(x2-x1);
481  QUADarea2 = (FABS(y3)+FABS(y2))*0.5*FABS(x3-x2);
482  QUADarea3 = (FABS(y3)+FABS(y1))*0.5*FABS(x3-x1);
483  TRarea = FABS(QUADarea3 - QUADarea1 - QUADarea2);
484  area = QUADarea1 + QUADarea2;
485  if (area*reltol + abstol > TRarea)
486  return(1);
487  return(0);
488 }
#define FABS(a)
Definition: util.h:41
static double thriceintlinfunc ( )
static
static double thriceintlinfunc ( double  lolimit,
double  hilimit,
double  secondlolimit,
double  thirdlolimit,
double  lovalue,
double  hivalue,
double  t1,
double  t2 
)
static

Definition at line 868 of file ltramisc.c.

873 {
874  double width, m, dummy;
875  double temp1, temp2, temp3, temp4;
876  double temp5, temp6, temp7, temp8, temp9, temp10;
877 
878  width = t2 - t1;
879  if (width == 0.0) return(0.0);
880  m = (hivalue - lovalue)/width;
881 
882  temp1 = hilimit - t1;
883  temp2 = lolimit - t1;
884  temp3 = secondlolimit - t1;
885  temp4 = thirdlolimit - t1;
886  temp5 = hilimit - thirdlolimit;
887  temp6 = lolimit - thirdlolimit;
888  temp7 = secondlolimit - thirdlolimit;
889  temp8 = hilimit - lolimit;
890  temp9 = hilimit - secondlolimit;
891  temp10 = lolimit - secondlolimit;
892  dummy = lovalue*((temp5*temp5*temp5 - temp6*temp6*temp6)/3 -
893  temp7*temp5*temp8);
894  dummy += m*(((temp1*temp1*temp1*temp1 - temp2*temp2*temp2*temp2)*0.25 -
895  temp3*temp3*temp3*temp8)/3 - temp4*temp4*0.5*(temp9*temp9 -
896  temp10*temp10));
897  return(dummy*0.5);
898 }
static void dummy()
Definition: mfbcursr.c:550
FILE * m
Definition: proc2mod.c:47
static double twiceintlinfunc ( )
static
static double twiceintlinfunc ( double  lolimit,
double  hilimit,
double  otherlolimit,
double  lovalue,
double  hivalue,
double  t1,
double  t2 
)
static

Definition at line 838 of file ltramisc.c.

841 {
842  double width, m, dummy;
843  double temp1, temp2, temp3;
844 
845  width = t2 - t1;
846  if (width == 0.0) return(0.0);
847  m = (hivalue - lovalue)/width;
848 
849  temp1 = hilimit - t1;
850  temp2 = lolimit - t1;
851  temp3 = otherlolimit - t1;
852  dummy = lovalue*((hilimit - otherlolimit)*(hilimit - otherlolimit) -
853  (lolimit - otherlolimit)*(lolimit - otherlolimit));
854  dummy += m*((temp1*temp1*temp1 - temp2*temp2*temp2)/3.0 -
855  temp3*temp3*(hilimit - lolimit));
856  return(dummy*0.5);
857 }
static void dummy()
Definition: mfbcursr.c:550
FILE * m
Definition: proc2mod.c:47