Jspice3
Main Page
Data Structures
Files
File List
Globals
traload.c
Go to the documentation of this file.
1
/**********
2
Copyright 1990 Regents of the University of California. All rights reserved.
3
Author: 1985 Thomas L. Quarles
4
**********/
5
6
#include "
spice.h
"
7
#include <stdio.h>
8
#include "
tradefs.h
"
9
#include "
sperror.h
"
10
#include "
util.h
"
11
12
13
/*ARGSUSED*/
14
int
15
TRAload
(inModel,ckt)
16
17
GENmodel
*inModel;
18
CKTcircuit
*ckt;
19
/* actually load the current values into the
20
* sparse matrix previously provided
21
*/
22
{
23
TRAmodel
*
model
= (
TRAmodel
*)inModel;
24
TRAinstance
*here;
25
double
t1,t2,t3;
26
double
f1,f2,f3;
27
register
int
i;
28
29
/* loop through all the transmission line models */
30
for
( ; model !=
NULL
; model = model->
TRAnextModel
) {
31
32
/* loop through all the instances of the model */
33
for
(here = model->
TRAinstances
; here !=
NULL
;
34
here=here->
TRAnextInstance
) {
35
36
*(here->
TRApos1Pos1Ptr
) += here->
TRAconduct
;
37
*(here->
TRApos1Int1Ptr
) -= here->
TRAconduct
;
38
*(here->
TRAneg1Ibr1Ptr
) -= 1;
39
*(here->
TRApos2Pos2Ptr
) += here->
TRAconduct
;
40
*(here->
TRAneg2Ibr2Ptr
) -= 1;
41
*(here->
TRAint1Pos1Ptr
) -= here->
TRAconduct
;
42
*(here->
TRAint1Int1Ptr
) += here->
TRAconduct
;
43
*(here->
TRAint1Ibr1Ptr
) += 1;
44
*(here->
TRAint2Int2Ptr
) += here->
TRAconduct
;
45
*(here->
TRAint2Ibr2Ptr
) += 1;
46
*(here->
TRAibr1Neg1Ptr
) -= 1;
47
*(here->
TRAibr1Int1Ptr
) += 1;
48
*(here->
TRAibr2Neg2Ptr
) -= 1;
49
*(here->
TRAibr2Int2Ptr
) += 1;
50
*(here->
TRApos2Int2Ptr
) -= here->
TRAconduct
;
51
*(here->
TRAint2Pos2Ptr
) -= here->
TRAconduct
;
52
53
if
(ckt->
CKTmode
&
MODEDC
) {
54
*(here->
TRAibr1Pos2Ptr
) -= 1;
55
*(here->
TRAibr1Neg2Ptr
) += 1;
56
*(here->
TRAibr1Ibr2Ptr
) -= (1-ckt->
CKTgmin
)*here->
TRAimped
;
57
*(here->
TRAibr2Pos1Ptr
) -= 1;
58
*(here->
TRAibr2Neg1Ptr
) += 1;
59
*(here->
TRAibr2Ibr1Ptr
) -= (1-ckt->
CKTgmin
)*here->
TRAimped
;
60
}
else
{
61
if
(ckt->
CKTmode
&
MODEINITTRAN
) {
62
if
(ckt->
CKTmode
&
MODEUIC
) {
63
here->
TRAinput1
= here->
TRAinitVolt2
+ here->
TRAinitCur2
64
* here->
TRAimped
;
65
here->
TRAinput2
= here->
TRAinitVolt1
+ here->
TRAinitCur1
66
* here->
TRAimped
;
67
}
else
{
68
here->
TRAinput1
=
69
( *(ckt->
CKTrhsOld
+here->
TRAposNode2
)
70
- *(ckt->
CKTrhsOld
+here->
TRAnegNode2
) )
71
+ ( *(ckt->
CKTrhsOld
+here->
TRAbrEq2
)
72
*here->
TRAimped
);
73
here->
TRAinput2
=
74
( *(ckt->
CKTrhsOld
+here->
TRAposNode1
)
75
- *(ckt->
CKTrhsOld
+here->
TRAnegNode1
) )
76
+ ( *(ckt->
CKTrhsOld
+here->
TRAbrEq1
)
77
*here->
TRAimped
);
78
}
79
*(here->
TRAdelays
) = -2*here->
TRAtd
;
80
*(here->
TRAdelays
+3) = -here->
TRAtd
;
81
*(here->
TRAdelays
+6) = 0;
82
*(here->
TRAdelays
+1) = *(here->
TRAdelays
+4) =
83
*(here->
TRAdelays
+7) = here->
TRAinput1
;
84
*(here->
TRAdelays
+2) = *(here->
TRAdelays
+5) =
85
*(here->
TRAdelays
+8) = here->
TRAinput2
;
86
here->
TRAsizeDelay
= 2;
87
}
else
{
88
if
(ckt->
CKTmode
&
MODEINITPRED
) {
89
for
(i=2;(i<here->
TRAsizeDelay
) &&
90
(*(here->
TRAdelays
+3*i) <=
91
(ckt->
CKTtime
-here->
TRAtd
));i++) {;
/*loop does it*/
}
92
t1 = *(here->
TRAdelays
+ (3*(i-2)));
93
t2 = *(here->
TRAdelays
+ (3*(i-1)));
94
t3 = *(here->
TRAdelays
+ (3*(i )));
95
if
( (t2-t1)==0 || (t3-t2) == 0)
continue
;
96
f1 = (ckt->
CKTtime
- here->
TRAtd
- t2) *
97
(ckt->
CKTtime
- here->
TRAtd
- t3) ;
98
f2 = (ckt->
CKTtime
- here->
TRAtd
- t1) *
99
(ckt->
CKTtime
- here->
TRAtd
- t3) ;
100
f3 = (ckt->
CKTtime
- here->
TRAtd
- t1) *
101
(ckt->
CKTtime
- here->
TRAtd
- t2) ;
102
if
((t2-t1)==0) {
/* should never happen, but don't want
103
* to divide by zero, EVER... */
104
f1=0;
105
f2=0;
106
}
else
{
107
f1 /= (t1-t2);
108
f2 /= (t2-t1);
109
}
110
if
((t3-t2)==0) {
/* should never happen, but don't want
111
* to divide by zero, EVER... */
112
f2=0;
113
f3=0;
114
}
else
{
115
f2 /= (t2-t3);
116
f3 /= (t2-t3);
117
}
118
if
((t3-t1)==0) {
/* should never happen, but don't want
119
* to divide by zero, EVER... */
120
f1=0;
121
f2=0;
122
}
else
{
123
f1 /= (t1-t3);
124
f3 /= (t1-t3);
125
}
126
/*printf("at time %g, using %g, %g, %g\n",ckt->CKTtime,
127
t1,t2,t3);
128
printf("values %g, %g, %g \n",
129
*(here->TRAdelays + (3*(i-2))+1),
130
*(here->TRAdelays + (3*(i-1))+1),
131
*(here->TRAdelays + (3*(i ))+1) );
132
printf("and %g, %g, %g \n",
133
*(here->TRAdelays + (3*(i-2))+2),
134
*(here->TRAdelays + (3*(i-1))+2),
135
*(here->TRAdelays + (3*(i ))+2) );*/
136
here->
TRAinput1
= f1 * *(here->
TRAdelays
+ (3*(i-2))+1)
137
+ f2 * *(here->
TRAdelays
+ (3*(i-1))+1)
138
+ f3 * *(here->
TRAdelays
+ (3*(i ))+1);
139
here->
TRAinput2
= f1 * *(here->
TRAdelays
+ (3*(i-2))+2)
140
+ f2 * *(here->
TRAdelays
+ (3*(i-1))+2)
141
+ f3 * *(here->
TRAdelays
+ (3*(i ))+2);
142
}
143
}
144
*(ckt->
CKTrhs
+ here->
TRAbrEq1
) += here->
TRAinput1
;
145
*(ckt->
CKTrhs
+ here->
TRAbrEq2
) += here->
TRAinput2
;
146
}
147
}
148
}
149
return
(
OK
);
150
}
sTRAinstance::TRAibr1Neg1Ptr
double * TRAibr1Neg1Ptr
Definition:
tradefs.h:50
CKTcircuit::CKTtime
double CKTtime
Definition:
cktdefs.h:77
sTRAinstance::TRAnextInstance
struct sTRAinstance * TRAnextInstance
Definition:
tradefs.h:20
sTRAmodel::TRAinstances
TRAinstance * TRAinstances
Definition:
tradefs.h:89
sTRAinstance::TRAint1Pos1Ptr
double * TRAint1Pos1Ptr
Definition:
tradefs.h:60
sTRAinstance::TRAinitVolt2
double TRAinitVolt2
Definition:
tradefs.h:39
sTRAinstance::TRAbrEq1
int TRAbrEq1
Definition:
tradefs.h:46
sTRAmodel::TRAnextModel
struct sTRAmodel * TRAnextModel
Definition:
tradefs.h:87
MODEINITPRED
#define MODEINITPRED
Definition:
cktdefs.h:161
TRAload
int TRAload(GENmodel *inModel, CKTcircuit *ckt)
Definition:
traload.c:15
MODEDC
#define MODEDC
Definition:
cktdefs.h:149
sTRAinstance::TRAimped
double TRAimped
Definition:
tradefs.h:30
CKTcircuit
Definition:
cktdefs.h:62
sTRAinstance::TRAinitCur1
double TRAinitCur1
Definition:
tradefs.h:38
MODEINITTRAN
#define MODEINITTRAN
Definition:
cktdefs.h:160
sTRAinstance::TRApos2Pos2Ptr
double * TRApos2Pos2Ptr
Definition:
tradefs.h:69
sTRAinstance::TRAtd
double TRAtd
Definition:
tradefs.h:32
sTRAinstance::TRAsizeDelay
int TRAsizeDelay
Definition:
tradefs.h:44
sTRAinstance::TRApos1Pos1Ptr
double * TRApos1Pos1Ptr
Definition:
tradefs.h:67
sTRAinstance::TRAnegNode1
int TRAnegNode1
Definition:
tradefs.h:25
sTRAinstance::TRAint2Pos2Ptr
double * TRAint2Pos2Ptr
Definition:
tradefs.h:63
sTRAinstance::TRAposNode1
int TRAposNode1
Definition:
tradefs.h:24
sTRAinstance::TRAint1Int1Ptr
double * TRAint1Int1Ptr
Definition:
tradefs.h:59
tradefs.h
OK
#define OK
Definition:
iferrmsg.h:17
sTRAinstance::TRAibr2Ibr1Ptr
double * TRAibr2Ibr1Ptr
Definition:
tradefs.h:53
sTRAinstance::TRAibr2Neg2Ptr
double * TRAibr2Neg2Ptr
Definition:
tradefs.h:56
CKTcircuit::CKTrhsOld
double * CKTrhsOld
Definition:
cktdefs.h:98
sTRAinstance::TRAnegNode2
int TRAnegNode2
Definition:
tradefs.h:27
sTRAinstance::TRAinitVolt1
double TRAinitVolt1
Definition:
tradefs.h:37
sperror.h
sTRAinstance
Definition:
tradefs.h:18
sTRAinstance::TRAibr1Pos2Ptr
double * TRAibr1Pos2Ptr
Definition:
tradefs.h:52
NULL
#define NULL
Definition:
spdefs.h:121
sTRAinstance::TRAibr2Pos1Ptr
double * TRAibr2Pos1Ptr
Definition:
tradefs.h:57
sTRAinstance::TRAibr1Ibr2Ptr
double * TRAibr1Ibr2Ptr
Definition:
tradefs.h:48
sTRAinstance::TRAinput2
double TRAinput2
Definition:
tradefs.h:36
util.h
spice.h
sGENmodel
Definition:
gendefs.h:39
sTRAinstance::TRAibr1Int1Ptr
double * TRAibr1Int1Ptr
Definition:
tradefs.h:49
sTRAinstance::TRAibr2Neg1Ptr
double * TRAibr2Neg1Ptr
Definition:
tradefs.h:55
model
static char model[32]
Definition:
subckt.c:76
sTRAinstance::TRAneg1Ibr1Ptr
double * TRAneg1Ibr1Ptr
Definition:
tradefs.h:64
sTRAinstance::TRAconduct
double TRAconduct
Definition:
tradefs.h:31
sTRAinstance::TRAinitCur2
double TRAinitCur2
Definition:
tradefs.h:40
sTRAinstance::TRAinput1
double TRAinput1
Definition:
tradefs.h:35
sTRAinstance::TRAibr1Neg2Ptr
double * TRAibr1Neg2Ptr
Definition:
tradefs.h:51
sTRAinstance::TRAint2Ibr2Ptr
double * TRAint2Ibr2Ptr
Definition:
tradefs.h:61
sTRAmodel
Definition:
tradefs.h:85
CKTcircuit::CKTgmin
double CKTgmin
Definition:
cktdefs.h:190
sTRAinstance::TRApos1Int1Ptr
double * TRApos1Int1Ptr
Definition:
tradefs.h:66
sTRAinstance::TRAint2Int2Ptr
double * TRAint2Int2Ptr
Definition:
tradefs.h:62
sTRAinstance::TRAint1Ibr1Ptr
double * TRAint1Ibr1Ptr
Definition:
tradefs.h:58
sTRAinstance::TRAneg2Ibr2Ptr
double * TRAneg2Ibr2Ptr
Definition:
tradefs.h:65
sTRAinstance::TRApos2Int2Ptr
double * TRApos2Int2Ptr
Definition:
tradefs.h:68
sTRAinstance::TRAdelays
double * TRAdelays
Definition:
tradefs.h:43
sTRAinstance::TRAbrEq2
int TRAbrEq2
Definition:
tradefs.h:47
CKTcircuit::CKTmode
long CKTmode
Definition:
cktdefs.h:139
sTRAinstance::TRAposNode2
int TRAposNode2
Definition:
tradefs.h:26
CKTcircuit::CKTrhs
double * CKTrhs
Definition:
cktdefs.h:97
MODEUIC
#define MODEUIC
Definition:
cktdefs.h:166
sTRAinstance::TRAibr2Int2Ptr
double * TRAibr2Int2Ptr
Definition:
tradefs.h:54
src
lib
dev
tra
traload.c
Generated by
1.8.11