48 #include <Xyce_config.h>
65 #include <N_ERH_ErrorMgr.h>
67 #include <N_UTL_BreakPoint.h>
83 initializeFlag_(false),
90 defaultParamName_(
"") ,
91 fastTimeScaleFlag_(false),
106 : SourceValue (right.SourceValue),
107 initializeFlag_(right.initializeFlag_),
108 resetFlag_(right.resetFlag_),
109 solState_(right.solState_),
111 devOptions_(right.devOptions_),
112 typeName_(right.typeName_),
113 sourceName_(right.sourceName_),
114 defaultParamName_(right.defaultParamName_)
158 msg =
"SourceData::updateSource:\n";
159 msg +=
"\tAttempted to update the source for a source type that is not";
160 msg +=
" yet implemented";
161 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, msg);
194 #ifdef Xyce_DEBUG_DEVICE
203 void SourceData::printOutParams()
232 double tmpTime = 0.0;
241 #ifdef Xyce_DEBUG_DEVICE
245 Xyce::dout() <<
"SourceData::getTime. time = ";
246 Xyce::dout() << tmpTime << std::endl;
247 Xyce::dout() <<
"SourceData::getTime. currFastTime = ";
249 Xyce::dout() <<
"SourceData::getTime. currTime = ";
275 V0given(right.V0given),
276 VAgiven(right.VAgiven),
277 FREQgiven(right.FREQgiven),
278 TDgiven(right.TDgiven),
279 THETAgiven(right.THETAgiven),
280 PHASEgiven(right.PHASEgiven)
298 #define FREQ (((here->VSRCfunctionOrder >=3) && (*(here->VSRCcoeffs+2)))? \
299 (*(here->VSRCcoeffs+2)):(1/ckt->CKTfinalTime))
319 std::vector<Param>::const_iterator iter = paramRef.begin();
320 std::vector<Param>::const_iterator last = paramRef.end();
322 for ( ; iter != last; ++iter)
324 const std::string & tmpname = iter->tag();
326 if (tmpname ==
"V0") {
V0 = iter->getImmutableValue<
double>();
V0given = iter->given();}
327 if (tmpname ==
"VA") {
VA = iter->getImmutableValue<
double>();
VAgiven = iter->given();}
328 if (tmpname ==
"FREQ") {
FREQ = iter->getImmutableValue<
double>();
FREQgiven = iter->given();}
329 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
330 if (tmpname ==
"THETA") {
THETA = iter->getImmutableValue<
double>();
THETAgiven =
332 if (tmpname ==
"PHASE") {
PHASE = iter->getImmutableValue<
double>();
376 #ifdef Xyce_DEBUG_DEVICE
386 void SinData::printOutParams()
389 Xyce::dout() <<
"SinData:\n";
390 Xyce::dout() <<
"V0 = " <<
V0 << std::endl;
391 Xyce::dout() <<
"VA = " <<
VA << std::endl;
392 Xyce::dout() <<
"FREQ = " <<
FREQ << std::endl;
393 Xyce::dout() <<
"TD = " <<
TD << std::endl;
394 Xyce::dout() <<
"THETA = " <<
THETA << std::endl;
395 Xyce::dout() <<
"PHASE = " <<
PHASE << std::endl;
419 bool bsuccess =
true;
496 if (
FREQ != params[3])
501 if (
THETA != params[4])
506 if (
PHASE != params[5])
537 V1given (right.V1given),
538 V2given (right.V2given),
539 TD1given (right.TD1given),
540 TAU1given (right.TAU1given),
541 TD2given (right.TD2given),
542 TAU2given (right.TAU2given)
573 std::vector<Param>::const_iterator iter = paramRef.begin();
574 std::vector<Param>::const_iterator last = paramRef.end();
576 for ( ; iter != last; ++iter)
578 const std::string & tmpname = iter->tag();
580 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
581 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
582 if (tmpname ==
"TD1") {
TD1 = iter->getImmutableValue<
double>();
TD1given = iter->given();}
583 if (tmpname ==
"TAU1") {
TAU1 = iter->getImmutableValue<
double>();
TAU1given = iter->given();}
584 if (tmpname ==
"TD2") {
TD2 = iter->getImmutableValue<
double>();
TD2given = iter->given();}
585 if (tmpname ==
"TAU2") {
TAU2 = iter->getImmutableValue<
double>();
TAU2given = iter->given();}
607 #ifdef Xyce_DEBUG_DEVICE
616 void ExpData::printOutParams()
618 Xyce::dout() <<
"ExpData:\n";
620 Xyce::dout() <<
"V1 = " <<
V1 << std::endl;
621 Xyce::dout() <<
"V2 = " <<
V2 << std::endl;
623 Xyce::dout() <<
"TD1 = " <<
TD1 << std::endl;
624 Xyce::dout() <<
"TAU1 = " <<
TAU1 << std::endl;
626 Xyce::dout() <<
"TD2 = " <<
TD2 << std::endl;
627 Xyce::dout() <<
"TAU2 = " <<
TAU2 << std::endl;
675 bool bsuccess =
true;
747 if (
TD1 != params[2])
752 if (
TAU1 != params[3])
757 if (
TD2 != params[4])
762 if (
TAU2 != params[5])
793 V1given (right.V1given),
794 V2given (right.V2given),
795 TDgiven (right.TDgiven),
796 TRgiven (right.TRgiven),
797 TFgiven (right.TFgiven),
798 PWgiven (right.PWgiven),
799 PERgiven (right.PERgiven)
833 std::vector<Param>::const_iterator iter = paramRef.begin();
834 std::vector<Param>::const_iterator last = paramRef.end();
836 for ( ; iter != last; ++iter)
838 const std::string & tmpname = iter->tag();
840 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
841 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
842 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
843 if (tmpname ==
"TR") {
TR = iter->getImmutableValue<
double>();
TRgiven = iter->given();}
844 if (tmpname ==
"TF") {
TF = iter->getImmutableValue<
double>();
TFgiven = iter->given();}
845 if (tmpname ==
"PW") {
PW = iter->getImmutableValue<
double>();
PWgiven = iter->given();}
846 if (tmpname ==
"PER") {
PER = iter->getImmutableValue<
double>();
PERgiven = iter->given();}
868 #ifdef Xyce_DEBUG_DEVICE
877 void PulseData::printOutParams()
879 Xyce::dout() << std::endl;
880 Xyce::dout() <<
" PulseData::printOutParams\n";
881 Xyce::dout() <<
" V1 = " <<
V1 << std::endl;
882 Xyce::dout() <<
" V2 = " <<
V2 << std::endl;
884 Xyce::dout() <<
" TD = " <<
TD << std::endl;
885 Xyce::dout() <<
" TR = " <<
TR << std::endl;
886 Xyce::dout() <<
" TF = " <<
TF << std::endl;
887 Xyce::dout() <<
" PW = " <<
PW << std::endl;
888 Xyce::dout() <<
" PER = " <<
PER << std::endl;
889 Xyce::dout() << std::endl;
933 bool bsuccess =
true;
939 #ifdef Xyce_DEBUG_DEVICE
942 Xyce::dout() <<
" PulseData::updateSources\n";
953 #ifdef Xyce_DEBUG_DEVICE
956 Xyce::dout() <<
" Time = " <<
time << std::endl;
1011 #ifdef Xyce_DEBUG_DEVICE
1014 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
1056 if (
V1 != params[0])
1061 if (
V2 != params[1])
1066 if (
TD != params[2])
1071 if (
TR != params[3])
1076 if (
TF != params[4])
1081 if (
PW != params[5])
1086 if (
PER != params[6])
1115 (std::vector<N_UTL_BreakPoint> & breakPointTimes )
1117 bool bsuccess =
true;
1119 if (!initializeFlag_) bsuccess = initializeSource ();
1123 int currPeriodIndex = 0;
1126 double basetime = 0.0;
1129 time = getTime_() - TD;
1134 #ifdef Xyce_DEBUG_DEVICE
1135 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1137 Xyce::dout() << std::endl;
1138 Xyce::dout() <<
" In PulseData::getBreakPoints\n";
1139 Xyce::dout() <<
" time = " << time << std::endl;
1140 Xyce::dout() <<
" TD = " << TD << std::endl;
1141 Xyce::dout() <<
" PER = " << PER << std::endl;
1150 currPeriodIndex = (
static_cast<int> (floor(time/PER)));
1151 basetime = PER * (
static_cast<double> (currPeriodIndex));
1156 #ifdef Xyce_DEBUG_DEVICE
1157 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1159 Xyce::dout() <<
" time = " << time << std::endl;
1160 Xyce::dout() <<
" basetime = " << basetime << std::endl;
1161 Xyce::dout() <<
" currPeriodIndex = " << currPeriodIndex << std::endl;
1162 Xyce::dout() << std::endl;
1171 breakPointTimes.push_back(basetime+TD);
1172 breakPointTimes.push_back(basetime+TD+TR);
1173 breakPointTimes.push_back(basetime+TD+TR+PW);
1174 breakPointTimes.push_back(basetime+TD+TR+PW+TF);
1178 breakPointTimes.push_back(basetime+TD+PER);
1181 breakPointTimes.push_back(basetime+TD+PER+TR);
1182 breakPointTimes.push_back(basetime+TD+PER+TR+PW);
1183 breakPointTimes.push_back(basetime+TD+PER+TR+PW+TF);
1184 breakPointTimes.push_back(basetime+TD+PER+PER);
1209 if (
time <
TD) maxTimeStep = (0.1*
TD );
1210 else maxTimeStep = (0.1*
PER);
1212 #ifdef Xyce_DEBUG_DEVICE
1215 Xyce::dout() <<
"\nIn PulseData::getMaxTimeStepSize. ";
1216 Xyce::dout() <<
" maxTimeStep = "<< maxTimeStep;
1217 Xyce::dout() <<
" TD = " <<
TD <<
" PER = " <<
PER;
1218 Xyce::dout() <<
" time = "<<
time << std::endl;
1238 REPEAT(right.REPEAT),
1239 REPEATTIME(right.REPEATTIME),
1243 starttime_(right.starttime_)
1266 std::vector<Param>::const_iterator iter = paramRef.begin();
1267 std::vector<Param>::const_iterator last = paramRef.end();
1269 for ( ; iter != last; ++iter)
1271 const std::string & tmpname = iter->tag();
1273 if (tmpname ==
"NUM")
NUM = iter->getImmutableValue<
int>();
1274 if (tmpname ==
"REPEAT")
REPEAT = iter->getImmutableValue<
bool>();
1275 if (tmpname ==
"REPEATTIME")
REPEATTIME = iter->getImmutableValue<
double>();
1276 if (tmpname ==
"TD")
TD = iter->getImmutableValue<
double>();
1278 if ( tmpname ==
"T" && iter->given() )
1280 time = iter->getImmutableValue<
double>();
1283 TVVEC.push_back(std::pair<double,double>(
time, iter->getImmutableValue<
double>()));
1302 #ifdef Xyce_DEBUG_DEVICE
1311 void PWLinData::printOutParams()
1313 Xyce::dout() << std::endl;
1314 Xyce::dout() <<
" NUM = " <<
NUM << std::endl;
1315 Xyce::dout() <<
" REPEAT = " <<
REPEAT << std::endl;
1316 Xyce::dout() <<
" REPEATTIME = " <<
REPEATTIME << std::endl;
1317 Xyce::dout() <<
" TD = " <<
TD << std::endl;
1318 Xyce::dout() <<
" loc_ = " <<
loc_ << std::endl;
1319 Xyce::dout() <<
" starttime_ = " <<
starttime_ << std::endl;
1321 Xyce::dout() <<
" Time Voltage" << std::endl;
1322 for(
int i = 0; i <
NUM; ++i )
1323 Xyce::dout() <<
" " <<
TVVEC[i].first <<
" " <<
TVVEC[i].second << std::endl;
1325 Xyce::dout() << std::endl;
1342 bool bsuccess =
true;
1346 #ifdef Xyce_DEBUG_DEVICE
1349 Xyce::dout() << std::endl;
1350 Xyce::dout() <<
" PWLinData::updateSource\n";
1361 #ifdef Xyce_DEBUG_DEVICE
1364 Xyce::dout() << Xyce::section_divider << std::endl;
1365 Xyce::dout() <<
" Time = " <<
time << std::endl;
1369 double time1, time2, voltage1, voltage2;
1377 for(
int i = 0; i <
NUM; ++i )
1398 voltage1 = voltage2 =
TVVEC[NUM-1].second;
1405 time -= looptime * floor(
time / looptime);
1409 for(
int i = 0; i <
NUM; ++i )
1418 voltage1 = voltage2 =
TVVEC[NUM-1].second;
1425 voltage1 =
TVVEC[NUM-1].second;
1438 if( time1 == time2 )
1442 double length = time2 - time1;
1447 #ifdef Xyce_DEBUG_DEVICE
1450 Xyce::dout() <<
"time: " <<
time << std::endl;
1451 Xyce::dout() <<
"time1: " << time1 << std::endl;
1452 Xyce::dout() <<
"time2: " << time2 << std::endl;
1453 Xyce::dout() <<
"voltage1: " << voltage1 << std::endl;
1454 Xyce::dout() <<
"voltage2: " << voltage2 << std::endl;
1455 Xyce::dout() <<
"Src: " <<
SourceValue << std::endl;
1456 Xyce::dout() << Xyce::section_divider << std::endl;
1481 (std::vector<N_UTL_BreakPoint> & breakPointTimes )
1483 bool bsuccess =
true;
1485 #ifdef Xyce_DEBUG_DEVICE
1486 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1488 Xyce::dout() <<
" In PWLinData::getBreakPoints\n";
1492 if (!initializeFlag_) bsuccess = initializeSource ();
1494 time = solState_.currTime;
1499 if (REPEAT && time >= TVVEC[NUM - 1].first)
1501 double loopBaseTime = 0.0;
1504 double looptime = TVVEC[NUM-1].first - REPEATTIME;
1505 loopBaseTime = looptime * (1.0 + floor((time - TVVEC[NUM - 1].first) / looptime));
1506 #ifdef Xyce_DEBUG_DEVICE
1507 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1509 Xyce::dout() <<
"loopBaseTime: " << loopBaseTime << std::endl;
1510 Xyce::dout() <<
"floor function: " << floor((time - TVVEC[NUM - 1].first) / (TVVEC[NUM - 1].first - REPEATTIME)) << std::endl;
1514 for (
int i = 0; i < NUM; ++i)
1516 bp_time = TVVEC[i].first;
1517 if (bp_time >= REPEATTIME)
1519 breakPointTimes.push_back(bp_time + loopBaseTime);
1520 #ifdef Xyce_DEBUG_DEVICE
1521 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1523 Xyce::dout() <<
"bp_time + loopBaseTime: " << bp_time + loopBaseTime << std::endl;
1531 for (
int i = 0; i < NUM; ++i)
1533 double bp_time = TVVEC[i].first;
1534 breakPointTimes.push_back(bp_time);
1535 #ifdef Xyce_DEBUG_DEVICE
1536 if (devOptions_.debugLevel > 0 && solState_.debugTimeFlag)
1538 Xyce::dout() <<
"bp_time: " << bp_time << std::endl;
1567 V0given (right.V0given),
1568 VAgiven (right.VAgiven),
1569 FCgiven (right.FCgiven),
1570 MDIgiven (right.MDIgiven),
1571 FSgiven (right.FSgiven)
1601 std::vector<Param>::const_iterator iter = paramRef.begin();
1602 std::vector<Param>::const_iterator last = paramRef.end();
1604 for ( ; iter != last; ++iter)
1606 const std::string & tmpname = iter->tag();
1608 if (tmpname ==
"V0") {
V0 = iter->getImmutableValue<
double>();
V0given = iter->given(); }
1609 if (tmpname ==
"VA") {
VA = iter->getImmutableValue<
double>();
VAgiven = iter->given(); }
1610 if (tmpname ==
"FC") {
FC = iter->getImmutableValue<
double>();
FCgiven = iter->given(); }
1611 if (tmpname ==
"MDI") {
MDI = iter->getImmutableValue<
double>();
MDIgiven = iter->given(); }
1612 if (tmpname ==
"FS") {
FS = iter->getImmutableValue<
double>();
FSgiven = iter->given(); }
1634 #ifdef Xyce_DEBUG_DEVICE
1644 void SFFMData::printOutParams()
1646 Xyce::dout() <<
"SFFMData:\n";
1647 Xyce::dout() <<
"V0 = " <<
V0 << std::endl;
1648 Xyce::dout() <<
"VA = " <<
VA << std::endl;
1649 Xyce::dout() <<
"FC = " <<
FC << std::endl;
1650 Xyce::dout() <<
"MDI = " <<
MDI << std::endl;
1651 Xyce::dout() <<
"FS = " <<
FS << std::endl;
1695 bool bsuccess =
true;
1707 MDI * sin (2 * mpi *
FS * time));
1745 if (
V0 != params[0])
1750 if (
VA != params[1])
1755 if (
FC != params[2])
1760 if (
MDI != params[3])
1765 if (
FS != params[4])
1790 ACPHASE(right.ACPHASE),
1791 ACMAGgiven(right.ACMAGgiven),
1792 ACPHASEgiven(right.ACPHASEgiven)
1816 std::vector<Param>::const_iterator iter = paramRef.begin();
1817 std::vector<Param>::const_iterator last = paramRef.end();
1819 for ( ; iter != last; ++iter)
1821 const std::string & tmpname = iter->tag();
1823 if (tmpname ==
"ACMAG") {
ACMAG = iter->getImmutableValue<
double>();
ACMAGgiven = iter->given();}
1824 if (tmpname ==
"ACPHASE") {
ACPHASE = iter->getImmutableValue<
double>();
ACPHASEgiven = iter->given();}
1845 #ifdef Xyce_DEBUG_DEVICE
1855 void ACData::printOutParams()
1858 Xyce::dout() <<
"ACData:\n";
1859 Xyce::dout() <<
"ACMAG = " <<
ACMAG << std::endl;
1860 Xyce::dout() <<
"ACPHASE = " <<
ACPHASE << std::endl;
1876 bool bsuccess =
true;
1891 #ifdef Xyce_DEBUG_DEVICE
1894 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
1930 if (
ACMAG!= params[0])
1979 std::vector<Param>::const_iterator iter = paramRef.begin();
1980 std::vector<Param>::const_iterator last = paramRef.end();
1982 for ( ; iter != last; ++iter)
1984 const std::string & tmpname = iter->tag();
1985 if (tmpname ==
"DCV0")
1987 V0 = iter->getImmutableValue<
double>();
2009 #ifdef Xyce_DEBUG_DEVICE
2019 void ConstData::printOutParams()
2022 Xyce::dout() <<
"ConstData:\n";
2023 Xyce::dout() <<
"V0: " <<
V0 << std::endl;
2044 bool bsuccess =
true;
2082 if (
V0 != params[0])
2111 riseScaleFactor_(right.riseScaleFactor_),
2112 fallScaleFactor_(right.fallScaleFactor_),
2113 functionScaleFactor_(right.functionScaleFactor_),
2114 V1given (right.V1given),
2115 V2given (right.V2given),
2116 TDgiven (right.TDgiven),
2117 TRgiven (right.TRgiven),
2118 TFgiven (right.TFgiven),
2119 PWgiven (right.PWgiven),
2120 PERgiven (right.PERgiven),
2121 functionScaleFactorGiven_(right.functionScaleFactorGiven_)
2146 riseScaleFactor_(0.0),
2147 fallScaleFactor_(0.0),
2148 functionScaleFactor_(20.0),
2156 functionScaleFactorGiven_(false)
2160 std::vector<Param>::const_iterator iter = paramRef.begin();
2161 std::vector<Param>::const_iterator last = paramRef.end();
2163 for ( ; iter != last; ++iter)
2165 const std::string & tmpname = iter->tag();
2167 if (tmpname ==
"V1") {
V1 = iter->getImmutableValue<
double>();
V1given = iter->given();}
2168 if (tmpname ==
"V2") {
V2 = iter->getImmutableValue<
double>();
V2given = iter->given();}
2169 if (tmpname ==
"TD") {
TD = iter->getImmutableValue<
double>();
TDgiven = iter->given();}
2170 if (tmpname ==
"TR") {
TR = iter->getImmutableValue<
double>();
TRgiven = iter->given();}
2171 if (tmpname ==
"TF") {
TF = iter->getImmutableValue<
double>();
TFgiven = iter->given();}
2172 if (tmpname ==
"PW") {
PW = iter->getImmutableValue<
double>();
PWgiven = iter->given();}
2173 if (tmpname ==
"PER") {
PER = iter->getImmutableValue<
double>();
PERgiven = iter->given();}
2197 #ifdef Xyce_DEBUG_DEVICE
2207 void SmoothPulseData::printOutParams()
2210 Xyce::dout() << std::endl;
2211 Xyce::dout() <<
" SmoothPulseData::printOutParams\n";
2212 Xyce::dout() <<
" V1 = " <<
V1 << std::endl;
2213 Xyce::dout() <<
" V2 = " <<
V2 << std::endl;
2215 Xyce::dout() <<
" TD = " <<
TD << std::endl;
2216 Xyce::dout() <<
" TR = " <<
TR << std::endl;
2217 Xyce::dout() <<
" TF = " <<
TF << std::endl;
2218 Xyce::dout() <<
" PW = " <<
PW << std::endl;
2219 Xyce::dout() <<
" PER = " <<
PER << std::endl;
2221 Xyce::dout() << std::endl;
2269 bool bsuccess =
true;
2273 double basetime = 0;
2275 #ifdef Xyce_DEBUG_DEVICE
2278 Xyce::dout() <<
" SmoothPulseData::updateSources\n";
2285 #ifdef Xyce_DEBUG_DEVICE
2288 Xyce::dout() <<
" Time = " <<
time << std::endl;
2319 else if (
time > 0 &&
2337 #ifdef Xyce_DEBUG_DEVICE
2340 Xyce::dout() <<
" SourceValue = " <<
SourceValue << std::endl;
2382 if (
V1 != params[0])
2387 if (
V2 != params[1])
2392 if (
TD != params[2])
2397 if (
TR != params[3])
2402 if (
TF != params[4])
2407 if (
PW != params[5])
2412 if (
PER != params[6])
2439 (std::vector<N_UTL_BreakPoint> & breakPointTimes )
2441 bool bsuccess =
true;
2443 if (!initializeFlag_) bsuccess = initializeSource ();
2463 if (
time <
TD) maxTimeStep = (0.1*
TD );
2464 else maxTimeStep = (0.1*
PER);
2466 #ifdef Xyce_DEBUG_DEVICE
2469 Xyce::dout() <<
"\nIn SmoothPulseData::getMaxTimeStepSize. ";
2470 Xyce::dout() <<
" maxTimeStep = "<< maxTimeStep;
2471 Xyce::dout() <<
" TD = " <<
TD <<
" PER = " <<
PER;
2472 Xyce::dout() <<
" time = "<<
time << std::endl;