48 #include <Xyce_config.h>
55 #include <N_IO_DeviceBlock.h>
56 #include <N_IO_SpiceSeparatedFieldTool.h>
57 #include <N_UTL_BreakPoint.h>
58 #include <N_UTL_ExtendedString.h>
59 #include <N_UTL_FeatureTest.h>
60 #include <N_UTL_Math.h>
68 std::vector<Param> sourceFcnParamList;
71 sourceFcnParamList.resize(7);
72 sourceFcnParamList[0].set(
"V1", 0.0);
73 sourceFcnParamList[1].set(
"V2", 0.0);
74 sourceFcnParamList[2].set(
"TD", 0.0);
75 sourceFcnParamList[3].set(
"TR", 0.0);
76 sourceFcnParamList[4].set(
"TF", 0.0);
77 sourceFcnParamList[5].set(
"PW", 0.0);
78 sourceFcnParamList[6].set(
"PER", 0.0);
79 sourceFcnMap[
"PULSE" ] = sourceFcnParamList;
81 sourceFcnParamList.resize(6);
82 sourceFcnParamList[0].set(
"V0", 0.0);
83 sourceFcnParamList[1].set(
"VA", 0.0);
84 sourceFcnParamList[2].set(
"FREQ", 0.0);
85 sourceFcnParamList[3].set(
"TD", 0.0);
86 sourceFcnParamList[4].set(
"THETA", 0.0);
87 sourceFcnParamList[5].set(
"PHASE", 0.0);
88 sourceFcnMap[
"SIN" ] = sourceFcnParamList;
90 sourceFcnParamList.resize(6);
91 sourceFcnParamList[0].set(
"V1", 0.0);
92 sourceFcnParamList[1].set(
"V2", 0.0);
93 sourceFcnParamList[2].set(
"TD1", 0.0);
94 sourceFcnParamList[3].set(
"TAU1", 0.0);
95 sourceFcnParamList[4].set(
"TD2", 0.0);
96 sourceFcnParamList[5].set(
"TAU2", 0.0);
97 sourceFcnMap[
"EXP" ] = sourceFcnParamList;
99 sourceFcnParamList.resize(5);
100 sourceFcnParamList[0].set(
"V0", 0.0);
101 sourceFcnParamList[1].set(
"VA", 0.0);
102 sourceFcnParamList[2].set(
"FC", 0.0);
103 sourceFcnParamList[3].set(
"MDI", 0.0);
104 sourceFcnParamList[4].set(
"FS", 0.0);
105 sourceFcnMap[
"SFFM" ] = sourceFcnParamList;
109 sourceFcnParamList.clear();
110 sourceFcnMap[
"PWL" ] = sourceFcnParamList;
112 sourceFcnParamList.resize(8);
113 sourceFcnParamList[0].set(
"V1", 0.0);
114 sourceFcnParamList[1].set(
"V2", 0.0);
115 sourceFcnParamList[2].set(
"TD", 0.0);
116 sourceFcnParamList[3].set(
"TR", 0.0);
117 sourceFcnParamList[4].set(
"TF", 0.0);
118 sourceFcnParamList[5].set(
"PW", 0.0);
119 sourceFcnParamList[6].set(
"PER", 0.0);
120 sourceFcnParamList[7].set(
"SF", 0.0);
121 sourceFcnMap[
"SMOOTHPULSE" ] = sourceFcnParamList;
132 const std::vector<Param> &
134 const std::string & sourceFcn)
138 if (sourceFcnMap.empty())
141 DeviceParamMap::const_iterator it = sourceFcnMap.find(sourceFcn);
142 if (it == sourceFcnMap.end())
144 Report::DevelFatal() <<
"No such source function " << sourceFcn;
163 const std::string & sourceFcn)
166 else if (sourceFcn ==
"SIN")
return _SIN_DATA;
167 else if (sourceFcn ==
"EXP")
return _EXP_DATA;
168 else if (sourceFcn ==
"SFFM")
return _SFFM_DATA;
169 else if (sourceFcn ==
"PWL")
return _PWL_DATA;
170 else if (sourceFcn ==
"DC")
return _DC_DATA;
172 else if (sourceFcn ==
"AC")
return _AC_DATA;
190 defaultParamName_(
""),
193 initializeFlag_(false),
197 fastTimeScaleFlag_(false),
286 double tmpTime = 0.0;
295 Xyce::dout() <<
"SourceData::getTime. time = " << tmpTime << std::endl
318 #define FREQ (((here->VSRCfunctionOrder >=3) && (*(here->VSRCcoeffs+2)))? \
319 (*(here->VSRCcoeffs+2)):(1/ckt->CKTfinalTime))
324 const std::vector<Param> & paramRef,
341 std::vector<Param>::const_iterator iter = paramRef.begin();
342 std::vector<Param>::const_iterator last = paramRef.end();
344 for ( ; iter != last; ++iter)
346 const std::string & tmpname = iter->tag();
348 if (tmpname ==
"V0") {
V0 = iter->getImmutableValue<
double>();
V0given = iter->given();}
349 if (tmpname ==
"VA") {
VA = iter->getImmutableValue<
double>();
VAgiven = iter->given();}
350 if (tmpname ==
"FREQ") {
FREQ = iter->getImmutableValue<
double>();
FREQgiven = iter->given();}
351 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
352 if (tmpname ==
"THETA") {
THETA = iter->getImmutableValue<
double>();
THETAgiven = iter->given();}
353 if (tmpname ==
"PHASE") {
PHASE = iter->getImmutableValue<
double>();
PHASEgiven = iter->given();}
357 UserError(device) <<
"V0, VA and FREQ are required for the SIN source function";
409 Xyce::dout() <<
"SinData:\n";
410 Xyce::dout() <<
"V0 = " <<
V0 << std::endl;
411 Xyce::dout() <<
"VA = " <<
VA << std::endl;
412 Xyce::dout() <<
"FREQ = " <<
FREQ << std::endl;
413 Xyce::dout() <<
"TD = " <<
TD << std::endl;
414 Xyce::dout() <<
"THETA = " <<
THETA << std::endl;
415 Xyce::dout() <<
"PHASE = " <<
PHASE << std::endl;
438 bool bsuccess =
true;
510 if (
FREQ != params[3])
515 if (
THETA != params[4])
520 if (
PHASE != params[5])
543 const std::vector<Param> & paramRef,
561 std::vector<Param>::const_iterator iter = paramRef.begin();
562 std::vector<Param>::const_iterator last = paramRef.end();
564 for ( ; iter != last; ++iter)
566 const std::string & tmpname = iter->tag();
568 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
569 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
570 if (tmpname ==
"TD1") {
TD1 = iter->getImmutableValue<
double>();
TD1given = iter->given();}
571 if (tmpname ==
"TAU1") {
TAU1 = iter->getImmutableValue<
double>();
TAU1given = iter->given();}
572 if (tmpname ==
"TD2") {
TD2 = iter->getImmutableValue<
double>();
TD2given = iter->given();}
573 if (tmpname ==
"TAU2") {
TAU2 = iter->getImmutableValue<
double>();
TAU2given = iter->given();}
577 UserError(device) <<
"V1 and V2 are required for the EXP source function";
606 Xyce::dout() <<
"ExpData:\n";
608 Xyce::dout() <<
"V1 = " <<
V1 << std::endl;
609 Xyce::dout() <<
"V2 = " <<
V2 << std::endl;
611 Xyce::dout() <<
"TD1 = " <<
TD1 << std::endl;
612 Xyce::dout() <<
"TAU1 = " <<
TAU1 << std::endl;
614 Xyce::dout() <<
"TD2 = " <<
TD2 << std::endl;
615 Xyce::dout() <<
"TAU2 = " <<
TAU2 << std::endl;
662 bool bsuccess =
true;
729 if (
TD1 != params[2])
734 if (
TAU1 != params[3])
739 if (
TD2 != params[4])
744 if (
TAU2 != params[5])
767 const std::vector<Param> & paramRef,
788 std::vector<Param>::const_iterator iter = paramRef.begin();
789 std::vector<Param>::const_iterator last = paramRef.end();
791 for ( ; iter != last; ++iter)
793 const std::string & tmpname = iter->tag();
795 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
796 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
797 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
798 if (tmpname ==
"TR") {
TR = iter->getImmutableValue<
double>();
TRgiven = iter->given();}
799 if (tmpname ==
"TF") {
TF = iter->getImmutableValue<
double>();
TFgiven = iter->given();}
800 if (tmpname ==
"PW") {
PW = iter->getImmutableValue<
double>();
PWgiven = iter->given();}
801 if (tmpname ==
"PER") {
PER = iter->getImmutableValue<
double>();
PERgiven = iter->given();}
831 Xyce::dout() << std::endl;
832 Xyce::dout() <<
" PulseData::printOutParams\n";
833 Xyce::dout() <<
" V1 = " <<
V1 << std::endl;
834 Xyce::dout() <<
" V2 = " <<
V2 << std::endl;
836 Xyce::dout() <<
" TD = " <<
TD << std::endl;
837 Xyce::dout() <<
" TR = " <<
TR << std::endl;
838 Xyce::dout() <<
" TF = " <<
TF << std::endl;
839 Xyce::dout() <<
" PW = " <<
PW << std::endl;
840 Xyce::dout() <<
" PER = " <<
PER << std::endl;
841 Xyce::dout() << std::endl;
884 bool bsuccess =
true;
891 Xyce::dout() <<
" PulseData::updateSources\n";
899 Xyce::dout() <<
" Time = " <<
time << std::endl;
955 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
1000 if (
V2 != params[1])
1005 if (
TD != params[2])
1010 if (
TR != params[3])
1015 if (
TF != params[4])
1020 if (
PW != params[5])
1025 if (
PER != params[6])
1052 (std::vector<Util::BreakPoint> & breakPointTimes )
1054 bool bsuccess =
true;
1056 if (!initializeFlag_) bsuccess = initializeSource ();
1060 int currPeriodIndex = 0;
1063 double basetime = 0.0;
1065 time = getTime_() - TD;
1067 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1069 Xyce::dout() << std::endl;
1070 Xyce::dout() <<
" In PulseData::getBreakPoints\n";
1071 Xyce::dout() <<
" time = " << time << std::endl;
1072 Xyce::dout() <<
" TD = " << TD << std::endl;
1073 Xyce::dout() <<
" PER = " << PER << std::endl;
1081 currPeriodIndex = (
static_cast<int> (floor(time/PER)));
1082 basetime = PER * (
static_cast<double> (currPeriodIndex));
1087 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1089 Xyce::dout() <<
" time = " << time << std::endl;
1090 Xyce::dout() <<
" basetime = " << basetime << std::endl;
1091 Xyce::dout() <<
" currPeriodIndex = " << currPeriodIndex << std::endl;
1092 Xyce::dout() << std::endl;
1100 breakPointTimes.push_back(basetime+TD);
1101 breakPointTimes.push_back(basetime+TD+TR);
1102 breakPointTimes.push_back(basetime+TD+TR+PW);
1103 breakPointTimes.push_back(basetime+TD+TR+PW+TF);
1107 breakPointTimes.push_back(basetime+TD+PER);
1110 breakPointTimes.push_back(basetime+TD+PER+TR);
1111 breakPointTimes.push_back(basetime+TD+PER+TR+PW);
1112 breakPointTimes.push_back(basetime+TD+PER+TR+PW+TF);
1113 breakPointTimes.push_back(basetime+TD+PER+PER);
1134 if (
time <
TD) maxTimeStep = (0.1*
TD );
1135 else maxTimeStep = (0.1*
PER);
1139 Xyce::dout() <<
"\nIn PulseData::getMaxTimeStepSize. ";
1140 Xyce::dout() <<
" maxTimeStep = "<< maxTimeStep;
1141 Xyce::dout() <<
" TD = " <<
TD <<
" PER = " <<
PER;
1142 Xyce::dout() <<
" time = "<<
time << std::endl;
1160 const std::vector<Param> & paramRef,
1171 std::vector<Param>::const_iterator iter = paramRef.begin();
1172 std::vector<Param>::const_iterator last = paramRef.end();
1174 for ( ; iter != last; ++iter)
1176 const std::string & tmpname = iter->tag();
1177 const bool & tmpgiven = iter->given();
1179 if (tmpname ==
"NUM")
NUM = iter->getImmutableValue<
int>();
1180 if (tmpname ==
"R" && tmpgiven ==
true)
1183 REPEATTIME = iter->getImmutableValue<
double>();
1185 if (tmpname ==
"TD")
TD = iter->getImmutableValue<
double>();
1187 if ( tmpname ==
"T" && iter->given() )
1189 time = iter->getImmutableValue<
double>();
1199 TVVEC.push_back(std::pair<double,double>(0.0,iter->getImmutableValue<
double>()));
1203 TVVEC.push_back(std::pair<double,double>(
time, iter->getImmutableValue<
double>()));
1210 UserError(device) <<
"At least one time-voltage pair must be specified for the PWL source function";
1213 if (
REPEAT && (REPEATTIME < 0 || REPEATTIME >=
TVVEC[
NUM-1].first) )
1214 UserError(device) <<
"PWL source repeat value (R) must be >= 0 and < last value in time-voltage list";
1240 Xyce::dout() << std::endl;
1241 Xyce::dout() <<
" NUM = " <<
NUM << std::endl;
1242 Xyce::dout() <<
" REPEAT = " <<
REPEAT << std::endl;
1243 Xyce::dout() <<
" REPEATTIME = " <<
REPEATTIME << std::endl;
1244 Xyce::dout() <<
" TD = " <<
TD << std::endl;
1245 Xyce::dout() <<
" loc_ = " <<
loc_ << std::endl;
1246 Xyce::dout() <<
" starttime_ = " <<
starttime_ << std::endl;
1248 Xyce::dout() <<
" Time Voltage" << std::endl;
1249 for(
int i = 0; i <
NUM; ++i )
1250 Xyce::dout() <<
" " <<
TVVEC[i].first <<
" " <<
TVVEC[i].second << std::endl;
1252 Xyce::dout() << std::endl;
1268 bool bsuccess =
true;
1274 Xyce::dout() << std::endl;
1275 Xyce::dout() <<
" PWLinData::updateSource\n";
1283 Xyce::dout() << Xyce::section_divider << std::endl;
1284 Xyce::dout() <<
" Time = " <<
time << std::endl;
1287 double time1, time2, voltage1, voltage2;
1295 for(
int i = 0; i <
NUM; ++i )
1318 voltage1 = voltage2 =
TVVEC[
NUM-1].second;
1324 time -= looptime * floor(
time / looptime);
1327 for(
int i = 0; i <
NUM; ++i )
1335 voltage1 = voltage2 =
TVVEC[NUM-1].second;
1342 voltage1 =
TVVEC[NUM-1].second;
1355 if( time1 == time2 )
1359 double length = time2 - time1;
1366 Xyce::dout() <<
"time: " <<
time << std::endl;
1367 Xyce::dout() <<
"time1: " << time1 << std::endl;
1368 Xyce::dout() <<
"time2: " << time2 << std::endl;
1369 Xyce::dout() <<
"voltage1: " << voltage1 << std::endl;
1370 Xyce::dout() <<
"voltage2: " << voltage2 << std::endl;
1371 Xyce::dout() <<
"Src: " <<
SourceValue << std::endl;
1372 Xyce::dout() << Xyce::section_divider << std::endl;
1395 (std::vector<Util::BreakPoint> & breakPointTimes )
1397 bool bsuccess =
true;
1399 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1401 Xyce::dout() <<
" In PWLinData::getBreakPoints\n";
1404 if (!initializeFlag_) bsuccess = initializeSource ();
1406 time = solState_.currTime_;
1411 if (REPEAT && time >= TVVEC[NUM - 1].first)
1413 double loopBaseTime = 0.0;
1416 double looptime = TVVEC[NUM-1].first - REPEATTIME;
1417 loopBaseTime = looptime * (1.0 + floor((time - TVVEC[NUM - 1].first) / looptime));
1418 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1420 Xyce::dout() <<
"loopBaseTime: " << loopBaseTime << std::endl;
1421 Xyce::dout() <<
"floor function: " << floor((time - TVVEC[NUM - 1].first) / (TVVEC[NUM - 1].first - REPEATTIME)) << std::endl;
1424 for (
int i = 0; i < NUM; ++i)
1426 bp_time = TVVEC[i].first;
1427 if (bp_time >= REPEATTIME)
1429 breakPointTimes.push_back(bp_time + loopBaseTime + TD);
1430 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1432 Xyce::dout() <<
"bp_time + loopBaseTime + TD: " << bp_time + loopBaseTime + TD << std::endl;
1439 for (
int i = 0; i < NUM; ++i)
1441 double bp_time = TVVEC[i].first;
1442 breakPointTimes.push_back(bp_time+TD);
1443 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1445 Xyce::dout() <<
"bp_time + TD: " << bp_time + TD << std::endl;
1468 const std::vector<Param> & paramRef,
1484 std::vector<Param>::const_iterator iter = paramRef.begin();
1485 std::vector<Param>::const_iterator last = paramRef.end();
1487 for ( ; iter != last; ++iter)
1489 const std::string & tmpname = iter->tag();
1491 if (tmpname ==
"V0") {
V0 = iter->getImmutableValue<
double>();
V0given = iter->given(); }
1492 if (tmpname ==
"VA") {
VA = iter->getImmutableValue<
double>();
VAgiven = iter->given(); }
1493 if (tmpname ==
"FC") {
FC = iter->getImmutableValue<
double>();
FCgiven = iter->given(); }
1494 if (tmpname ==
"MDI") {
MDI = iter->getImmutableValue<
double>();
MDIgiven = iter->given(); }
1495 if (tmpname ==
"FS") {
FS = iter->getImmutableValue<
double>();
FSgiven = iter->given(); }
1499 UserError(device) <<
"V0 and VA are required for the SFFM source function";
1528 Xyce::dout() <<
"SFFMData:\n";
1529 Xyce::dout() <<
"V0 = " <<
V0 << std::endl;
1530 Xyce::dout() <<
"VA = " <<
VA << std::endl;
1531 Xyce::dout() <<
"FC = " <<
FC << std::endl;
1532 Xyce::dout() <<
"MDI = " <<
MDI << std::endl;
1533 Xyce::dout() <<
"FS = " <<
FS << std::endl;
1576 bool bsuccess =
true;
1584 MDI * sin (2 * mpi *
FS * time));
1621 if (
V0 != params[0])
1626 if (
VA != params[1])
1631 if (
FC != params[2])
1636 if (
MDI != params[3])
1641 if (
FS != params[4])
1663 const std::vector<Param> & paramRef,
1672 std::vector<Param>::const_iterator iter = paramRef.begin();
1673 std::vector<Param>::const_iterator last = paramRef.end();
1675 for ( ; iter != last; ++iter)
1677 const std::string & tmpname = iter->tag();
1679 if (tmpname ==
"ACMAG") {
ACMAG = iter->getImmutableValue<
double>();
ACMAGgiven = iter->given();}
1680 if (tmpname ==
"ACPHASE") {
ACPHASE = iter->getImmutableValue<
double>();
ACPHASEgiven = iter->given();}
1710 Xyce::dout() <<
"ACData:\n";
1711 Xyce::dout() <<
"ACMAG = " <<
ACMAG << std::endl;
1712 Xyce::dout() <<
"ACPHASE = " <<
ACPHASE << std::endl;
1727 bool bsuccess =
true;
1742 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
1744 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
1778 if (
ACMAG!= params[0])
1806 const std::vector<Param> & paramRef,
1812 std::vector<Param>::const_iterator iter = paramRef.begin();
1813 std::vector<Param>::const_iterator last = paramRef.end();
1815 for ( ; iter != last; ++iter)
1817 const std::string & tmpname = iter->tag();
1818 if (tmpname ==
"DCV0")
1820 V0 = iter->getImmutableValue<
double>();
1852 Xyce::dout() <<
"ConstData:\n";
1853 Xyce::dout() <<
"V0: " <<
V0 << std::endl;
1873 bool bsuccess =
true;
1910 if (
V0 != params[0])
1931 const std::vector<Param> & paramRef,
1942 riseScaleFactor_(0.0),
1943 fallScaleFactor_(0.0),
1944 functionScaleFactor_(20.0),
1952 functionScaleFactorGiven_(false)
1956 std::vector<Param>::const_iterator iter = paramRef.begin();
1957 std::vector<Param>::const_iterator last = paramRef.end();
1959 for ( ; iter != last; ++iter)
1961 const std::string & tmpname = iter->tag();
1963 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
1964 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
1965 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
1966 if (tmpname ==
"TR") {
TR = iter->getImmutableValue<
double>();
TRgiven = iter->given();}
1967 if (tmpname ==
"TF") {
TF = iter->getImmutableValue<
double>();
TFgiven = iter->given();}
1968 if (tmpname ==
"PW") {
PW = iter->getImmutableValue<
double>();
PWgiven = iter->given();}
1969 if (tmpname ==
"PER") {
PER = iter->getImmutableValue<
double>();
PERgiven = iter->given();}
2002 Xyce::dout() << std::endl;
2003 Xyce::dout() <<
" SmoothPulseData::printOutParams\n";
2004 Xyce::dout() <<
" V1 = " <<
V1 << std::endl;
2005 Xyce::dout() <<
" V2 = " <<
V2 << std::endl;
2007 Xyce::dout() <<
" TD = " <<
TD << std::endl;
2008 Xyce::dout() <<
" TR = " <<
TR << std::endl;
2009 Xyce::dout() <<
" TF = " <<
TF << std::endl;
2010 Xyce::dout() <<
" PW = " <<
PW << std::endl;
2011 Xyce::dout() <<
" PER = " <<
PER << std::endl;
2013 Xyce::dout() << std::endl;
2060 bool bsuccess =
true;
2064 double basetime = 0;
2068 Xyce::dout() <<
" SmoothPulseData::updateSources\n";
2076 Xyce::dout() <<
" Time = " <<
time << std::endl;
2106 else if (
time > 0 &&
2126 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
2166 if (
V1 != params[0])
2171 if (
V2 != params[1])
2176 if (
TD != params[2])
2181 if (
TR != params[3])
2186 if (
TF != params[4])
2191 if (
PW != params[5])
2196 if (
PER != params[6])
2221 (std::vector<Util::BreakPoint> & breakPointTimes )
2223 bool bsuccess =
true;
2225 if (!initializeFlag_) bsuccess = initializeSource ();
2245 if (
time <
TD) maxTimeStep = (0.1*
TD );
2246 else maxTimeStep = (0.1*
PER);
2250 Xyce::dout() <<
"\nIn SmoothPulseData::getMaxTimeStepSize. ";
2251 Xyce::dout() <<
" maxTimeStep = "<< maxTimeStep;
2252 Xyce::dout() <<
" TD = " <<
TD <<
" PER = " <<
PER;
2253 Xyce::dout() <<
" time = "<<
time << std::endl;
2272 const IO::TokenVector & parsed_line,
2273 const std::string & fieldToFind,
2276 size_t numFields = parsed_line.size();
2277 int fieldPosition = 0;
2279 if ( fieldToFind ==
"SOURCEFCN" )
2281 ExtendedString field(
"");
2282 for (
size_t i = startPosition; i < numFields; ++i )
2286 field = parsed_line[i].string_;
2298 ExtendedString field(
"");
2299 for (
size_t i = startPosition; i < numFields; ++i )
2301 field = parsed_line[i].string_;
2303 if ( field == fieldToFind )
2311 return fieldPosition;
2356 const IO::TokenVector & parsedInputLine,
2357 IO::DeviceBlock & device_block,
2358 const std::string & primaryDeviceParameter)
2360 int numFields = parsedInputLine.size();
2361 bool tranGiven=
false;
2366 device_block.extractNodes(parsedInputLine, -1, 0);
2369 Util::Param primaryParameter(
"",
"" );
2370 primaryParameter.setTag(primaryDeviceParameter);
2371 primaryParameter.setVal(
"0");
2375 int linePosition = device_block.getNumberOfNodes() + 1;
2383 if ( linePosition < numFields )
2385 ExtendedString field(parsedInputLine[linePosition].string_);
2393 field = parsedInputLine[linePosition].string_;
2403 if ( linePosition < numFields )
2405 primaryParameter.setVal( parsedInputLine[linePosition].string_ );
2409 if( !( primaryParameter.isNumeric() || primaryParameter.hasExpressionValue() ) )
2411 Report::UserError().at(device_block.getNetlistFilename(), device_block.getLineNumber())
2412 <<
"Invalid DC value \"" << primaryParameter.stringValue() <<
"\" for device " << device_block.getInstanceName();
2425 std::vector<std::string> fieldNames;
2426 std::vector<int> fieldPositions;
2429 if ( fieldPosition > 0 )
2431 fieldNames.push_back(
"AC" );
2432 fieldPositions.push_back( fieldPosition );
2439 if ( fieldPosition > 0 )
2441 fieldNames.push_back(
"DISTOF1" );
2442 fieldPositions.push_back( fieldPosition );
2446 if ( fieldPosition > 0 )
2448 fieldNames.push_back(
"DISTOF2" );
2449 fieldPositions.push_back( fieldPosition );
2453 if ( fieldPosition > 0 )
2455 fieldNames.push_back(
"SOURCEFCN" );
2456 fieldPositions.push_back( fieldPosition );
2457 ExtendedString field( parsedInputLine[fieldPosition].string_ );
2468 Util::Param tranSourceTypeParameter(
"TRANSIENTSOURCETYPE", tranSourceType );
2469 Util::Param acSourceTypeParameter(
"ACSOURCETYPE", (
int)
_AC_DATA);
2470 Util::Param dcSourceTypeParameter(
"DCSOURCETYPE", (
int)
_DC_DATA);
2476 int parameterStartPosition;
2477 int parameterEndPosition;
2478 device_block.extractInstanceParameters( parsedInputLine,
2480 parameterStartPosition,
2481 parameterEndPosition,
2483 fieldNames.push_back(
"PARAMS" );
2484 fieldPositions.push_back( parameterStartPosition );
2495 int len = fieldPositions.size();
2496 for (
int i = 1; i < len; i++)
2499 int temp = fieldPositions[j];
2500 std::string tmpName = fieldNames[j];
2501 while (j > 0 && (fieldPositions[j-1] > temp))
2503 fieldPositions[j] = fieldPositions[j-1];
2504 fieldNames[j] = fieldNames[j-1];
2507 fieldPositions[j] = temp;
2508 fieldNames[j] = tmpName;
2513 bool result =
extractSourceFields(parsedInputLine, device_block, fieldNames, fieldPositions );
2520 Param * parameterPtr;
2521 if ( primaryParameter.tag() !=
"" )
2523 parameterPtr = device_block.findInstanceParameter( primaryParameter );
2524 parameterPtr->setVal( primaryParameter );
2529 parameterPtr = device_block.findInstanceParameter( tranSourceTypeParameter );
2530 parameterPtr->setVal( tranSourceTypeParameter );
2531 parameterPtr->
setGiven( tranGiven );
2534 parameterPtr = device_block.findInstanceParameter( acSourceTypeParameter );
2535 parameterPtr->setVal( acSourceTypeParameter );
2539 parameterPtr = device_block.findInstanceParameter( dcSourceTypeParameter );
2540 parameterPtr->setVal( dcSourceTypeParameter );
2576 const IO::TokenVector & parsedInputLine,
2577 IO::DeviceBlock & device_block,
2578 const std::vector<std::string> & fieldNames,
2579 const std::vector<int> & fieldPositions )
2581 if ( fieldNames[0] ==
"PARAMS" )
2591 int numFields = fieldNames.size();
2592 for ( i = 0; i < numFields; ++i )
2596 if ( fieldNames[i] ==
"AC")
2601 Param phase(
"",
"");
2603 int numTerms = fieldPositions[i+1] - fieldPositions[i] - 1;
2605 std::string magName(fieldNames[i] +
"MAG");
2606 std::string phaseName(fieldNames[i] +
"PHASE");
2607 mag.set( magName,
"1.0" );
2608 phase.set( phaseName,
"0.0" );
2612 device_block.issueUnrecognizedParameterError(fieldNames[i]+
" Too Many Terms");
2615 if ( numTerms >= 1 )
2617 mag.setVal( parsedInputLine[fieldPositions[i]+1].string_ );
2621 if ( numTerms == 2 )
2623 phase.setVal( parsedInputLine[fieldPositions[i]+2].string_ );
2628 device_block.addInstanceParameter( mag );
2629 device_block.addInstanceParameter( phase );
2632 else if ( fieldNames[i] ==
"SOURCEFCN" )
2635 const std::string &sourceFunction = parsedInputLine[ fieldPositions[i] ].string_;
2640 int sourceFunctionParamStart;
2641 int sourceFunctionParamEnd;
2645 while (fieldPositions[i] + offset < parsedInputLine.size() && parsedInputLine[ fieldPositions[i] + offset ].string_ ==
"(" )
2650 sourceFunctionParamStart = fieldPositions[i] + offset;
2651 sourceFunctionParamEnd = fieldPositions[i + 1] - offset;
2653 if (!equal_nocase(sourceFunction,
"PWL"))
2661 size_t numInputSourceFunctionParams = sourceFunctionParamEnd - sourceFunctionParamStart + 1;
2665 for (
size_t k = 0; k < sourceFunctionParameters.size(); ++k )
2667 if ( k < numInputSourceFunctionParams )
2669 Param parameter(sourceFunctionParameters[k].uTag(), 0.0);
2670 parameter.setVal( parsedInputLine[sourceFunctionParamStart + k].string_ );
2672 device_block.addInstanceParameter( parameter );
2678 if ( parsedInputLine.size() <= sourceFunctionParamStart )
2682 Report::UserError().at(device_block.getNetlistFilename(), parsedInputLine[0].lineNumber_)
2683 <<
"PWL device missing source parameters: " << device_block.getInstanceName();
2687 ExtendedString field(parsedInputLine[sourceFunctionParamStart].string_);
2688 if (field.toUpper() !=
"FILE")
2697 int timeValPairStart = sourceFunctionParamStart;
2698 while ( parsedInputLine[timeValPairStart].string_ ==
"R" || parsedInputLine[timeValPairStart].string_ ==
"TD" )
2700 timeValPairStart += 3;
2703 if (timeValPairStart >= parsedInputLine.size()) {
break;}
2711 if ( sourceFunctionParamEnd < timeValPairStart )
2714 sourceFunctionParamEnd =
static_cast<int> (parsedInputLine.size()) - 1;
2715 if ( parsedInputLine[sourceFunctionParamEnd].string_ ==
")" )
2717 --sourceFunctionParamEnd;
2725 Param time(
"T",
"" );
2727 int numTimeValuePairs = 0;
2728 int i = timeValPairStart;
2729 while ( i < sourceFunctionParamEnd )
2731 ++numTimeValuePairs;
2733 time.setVal( parsedInputLine[i].string_ );
2735 device_block.addInstanceParameter( time );
2738 value.setVal( parsedInputLine[i].string_ );
2740 device_block.addInstanceParameter( value );
2745 if ( i < sourceFunctionParamEnd )
2747 if ( parsedInputLine[i].string_ ==
"," ) ++i;
2751 if ( numTimeValuePairs > 0 )
2753 Param * parameterPtr = device_block.findInstanceParameter(
Param(
"NUM",
"") );
2754 assert(parameterPtr != NULL);
2755 parameterPtr->setVal( numTimeValuePairs );
2763 Report::UserError().at(device_block.getNetlistFilename(), parsedInputLine[0].lineNumber_)
2764 <<
"Could not parse time/value pairs for piecewise linear function in device: " << device_block.getInstanceName();
2771 std::string tvFileNameIN(parsedInputLine[sourceFunctionParamStart+1].string_);
2774 std::string tvFileName;
2775 if (tvFileNameIN[0] ==
'"' &&
2776 tvFileNameIN[tvFileNameIN.length()-1] ==
'"')
2778 tvFileName = tvFileNameIN.substr(1, tvFileNameIN.length()-2);
2781 std::ifstream tvDataIn;
2782 tvDataIn.open(tvFileName.c_str(), std::ios::in);
2783 if ( !tvDataIn.is_open() )
2785 Report::UserError().at(device_block.getNetlistFilename(), parsedInputLine[0].lineNumber_)
2786 <<
"Could not find file " << tvFileName;
2789 Param time(
"T",
"" );
2792 int numTimeValuePairs = 0;
2795 while (tvDataIn >> timeIn)
2800 if (tvDataIn >> valueIn)
2802 ++numTimeValuePairs;
2804 time.setVal(timeIn);
2806 device_block.addInstanceParameter(time);
2808 value.setVal(valueIn);
2810 device_block.addInstanceParameter(value);
2814 Report::UserError() <<
"Problem reading " << tvFileName << std::endl
2815 <<
"File format must be comma, tab or space separated value. There should be no extra spaces or tabs "
2816 <<
"around the comma if it is used as the separator.";
2822 if ( numTimeValuePairs > 0 )
2824 Param* parameterPtr = device_block.findInstanceParameter(
Param(
"NUM",
"") );
2825 assert(parameterPtr != NULL);
2826 parameterPtr->setVal( numTimeValuePairs );
2832 Report::UserError() <<
"Failed to successfully read " << tvFileName;
double functionScaleFactor_
bool extractSourceFields(const IO::TokenVector &parsedInputLine, IO::DeviceBlock &device_block, const std::vector< std::string > &fieldNames, const std::vector< int > &fieldPositions)
virtual bool updateSource()
virtual bool updateSource()
virtual bool updateSource()
virtual void printOutParams()
Pure virtual class to augment a linear system.
bool functionScaleFactorGiven_
virtual bool updateSource()
double startingTimeStep_
SourceData devices.
std::vector< std::pair< double, double > > TVVEC
const T & value(const ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
double finalTime_
Analysis final time, SourceData devices.
const DeviceOptions & devOptions_
double bpTol_
Break point tolerance, SourceData devices, Neuron devices.
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
int findSourceFieldPosition(const IO::TokenVector &parsed_line, const std::string &fieldToFind, int startPosition)
virtual double getMaxTimeStepSize()
SFFMData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
ExpData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
ACData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
std::string getSourceTypeName()
std::map< std::string, std::vector< Param >, LessNoCase > DeviceParamMap
bool extractSourceData(const IO::TokenVector &parsedInputLine, IO::DeviceBlock &device_block, const std::string &primaryDeviceParameter)
SinData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
PWLinData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
SmoothPulseData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
virtual bool updateSource()
virtual bool initializeSource()
void setGiven(bool is_given)
ConstData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
double defaultMaxTimeStep
mosfet homotopy:
virtual bool updateSource()
double getMaxTimeStepSize()
virtual bool updateSource()
const std::vector< Param > & getSourceFunctionParameters(const std::string &sourceFcn)
const SolverState & solState_
virtual bool updateSource()
double getMaxTimeStepSize()
std::string defaultParamName_
PulseData(const DeviceEntity &device, const std::vector< Param > ¶mRef, const SolverState &ss1, const DeviceOptions &do1)
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
double currFastTime_
Source devices,.
int getSourceFunctionID(const std::string &sourceFcn)
void sourceFunctionMetadata(DeviceParamMap &map)