48 #include <Xyce_config.h>
61 #include <N_ERH_ErrorMgr.h>
63 #include <N_LAS_Vector.h>
64 #include <N_LAS_Matrix.h>
66 #include <N_UTL_BreakPoint.h>
67 #include <N_UTL_FeatureTest.h>
91 .setDescription(
"Rise Time");
95 .setDescription(
"Fall Time");
99 .setDescription(
"Resistance");
103 .setDescription(
"Inductance");
107 .setDescription(
"Capacitance");
112 .setDescription(
"Flag for transitional breakpoints");
148 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
161 ABraEquPosNodeOffset(-1),
162 ABraEquNegNodeOffset(-1),
163 APosEquBraVarOffset(-1),
164 ANegEquBraVarOffset(-1)
220 const std::vector<int> & extLIDVecRef)
225 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
227 Xyce::dout() << std::endl << section_divider << std::endl;
228 Xyce::dout() <<
" DACInstance::registerLIDs" << std::endl;
229 Xyce::dout() <<
" name = " <<
getName() << std::endl;
242 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
243 Xyce::dout() <<
" li_Pos = " <<
li_Pos << std::endl;
247 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
248 Xyce::dout() <<
" li_Neg = " <<
li_Neg << std::endl;
252 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
253 Xyce::dout() <<
" li_Bra = " <<
li_Bra << std::endl;
255 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
256 Xyce::dout() << section_divider << std::endl;
324 bool bsuccess =
true;
349 bool bsuccess =
true;
364 bool bsuccess =
true;
378 std::vector< std::pair<double, double> >
const & newPairsIn )
380 int i, last, newStart;
381 double transitionTime;
382 bool bsuccess =
true;
383 std::vector< std::pair<double,double> >::iterator itVec, itVec_end;
384 std::vector< std::pair<double, double> > newPairs;
385 std::vector< std::pair<double,double> >::const_iterator const_itVec;
386 std::map<double, double> tv;
387 std::map<double, double>::iterator tv_i, tv_end;
389 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
391 Xyce::dout() <<
"In device " <<
getName() << std::endl
393 <<
", at beginning of Instance::updateTVVEC():\n"
395 <<
" TVVEC loc = " <<
loc_ <<
"\n"
396 <<
" TVVEC contents:\n" ;
397 itVec =
TVVEC.begin();
398 itVec_end =
TVVEC.end();
399 for( ; itVec != itVec_end; ++itVec )
401 Xyce::dout() <<
" " << (*itVec).first
402 <<
"s, " << (*itVec).second
405 Xyce::dout() << newPairsIn.size() <<
" New pairs:" << std::endl;
406 for ( const_itVec = newPairsIn.begin() ; const_itVec != newPairsIn.end() ; ++const_itVec )
407 Xyce::dout() << (*const_itVec).first <<
" " << (*const_itVec).second << std::endl;
412 itVec =
TVVEC.begin();
413 itVec_end =
TVVEC.end();
414 for( ; itVec != itVec_end; ++itVec )
415 tv[(*itVec).first] = (*itVec).second;
417 if (!newPairsIn.empty())
422 if (newPairsIn.size() > 0)
423 TVVEC.push_back(std::pair<double,double>(0,(*(newPairsIn.end()-1)).second));
424 if (newPairsIn.size() > 1 && (*(newPairsIn.end()-1)).first >
TVVEC[0].first)
425 TVVEC.push_back(*(newPairsIn.end()-1));
430 std::vector< std::pair<double, double> >::const_iterator n_i, n_end;
431 std::vector< std::pair<double, double> >::iterator t_i, t_end;
432 n_i = newPairsIn.begin();
433 n_end = newPairsIn.end();
434 for ( ; n_i != n_end ; ++n_i)
436 if ((*n_i).first < 0)
438 double d = -(*n_i).first;
439 tv_i = lower_bound(tv.begin(), tv.end(), std::pair<const double, double>(d,0));
440 tv.erase(tv_i,tv.end());
443 n_i = newPairsIn.begin();
444 for ( ; n_i != n_end ; ++n_i)
449 if (transitionTime > 0) {
450 tv_i = lower_bound(tv.begin(), tv.end(), std::pair<const double, double>((*n_i).first,0));
451 if (tv_i != tv.begin())
454 if ((*n_i).second < (*tv_i).second)
457 tv[(*n_i).first] = (*tv_i).second;
459 tv[(*n_i).first + transitionTime] = (*n_i).second;
465 if (tv_i != tv.begin())
467 tv.erase(tv.begin(), tv_i);
468 double lastTimeEntry = -1;
472 for ( ; tv_i != tv_end ; ++tv_i)
474 if ((*tv_i).first - lastTimeEntry > 1e-15)
476 TVVEC.push_back(std::pair<double, double>((*tv_i).first,(*tv_i).second));
477 lastTimeEntry = (*tv_i).first;
482 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
484 Xyce::dout() <<
"Instance::updateTVVEC():\n"
486 <<
" TVVEC loc = " <<
loc_ <<
"\n"
487 <<
" TVVEC contents:\n" ;
488 std::vector< std::pair<double, double> >::iterator tv_i =
TVVEC.begin();
489 for( ; tv_i !=
TVVEC.end(); ++tv_i )
491 Xyce::dout() <<
" " << (*tv_i).first
492 <<
"s, " << (*tv_i).second
510 bool bsuccess =
true;
512 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
514 Xyce::dout() << std::endl;
515 Xyce::dout() <<
" DACInstance::updateVoltage\n";
516 Xyce::dout() << Xyce::section_divider << std::endl;
517 Xyce::dout() <<
" Time = " << time << std::endl;
522 Xyce::dout() <<
" TVVEC[numTVpairs_-1].first = "
526 Xyce::dout() <<
TVVEC[i].first <<
" :: " <<
TVVEC[i].second << std::endl;
529 if( numTVpairs_ > 0 && time >=
TVVEC[0].first )
531 if( time <
TVVEC[numTVpairs_-1].first )
533 for(
int i = 0; i < numTVpairs_ - 1; ++i )
535 if( time >=
TVVEC[i].first && time <=
TVVEC[i+1].first)
537 double time1 =
TVVEC[i].first;
538 double voltage1 =
TVVEC[i].second;
540 double time2 =
TVVEC[i+1].first;
541 double voltage2 =
TVVEC[i+1].second;
543 voltage_ = voltage1 + (voltage2 - voltage1) * (time - time1) / (time2 - time1);
556 Xyce::dout() <<
" voltage_ = " <<
voltage_ << std::endl;
557 Xyce::dout() << Xyce::section_divider << std::endl;
577 bool bsuccess =
true;
604 bool bsuccess =
true;
631 bool bsuccess =
true;
633 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
635 Xyce::dout() <<
"In ::getInstanceBreakPoints " << std::endl;
636 Xyce::dout() <<
" I want breakpoints. Current time is " << currentTime << std::endl;
648 breakPointTimes.push_back(Util::BreakPoint(
TVVEC[i].first, Util::BreakPoint::SIMPLE));
652 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
654 Xyce::dout() <<
"DAC ----------------------------------------" << std::endl;
655 Xyce::dout() <<
"DAC getInstanceBreakPoints " << std::endl;
656 Xyce::dout() <<
"DAC Debug output. name = " <<
getName() << std::endl;
657 Xyce::dout() <<
"DAC setting breakpoints at currentTime = " << currentTime << std::endl;
658 Xyce::dout() <<
"DAC breakpoints: " << std::endl;
660 std::vector< Util::BreakPoint >::iterator beg = breakPointTimes.begin();
661 std::vector< Util::BreakPoint >::iterator end = breakPointTimes.end();
662 std::vector< Util::BreakPoint >::iterator itBP = beg;
663 for (;itBP!=end;++itBP)
665 Util::BreakPoint & bp = *itBP;
666 Xyce::dout() <<
"DAC breakpoint: " << bp.value() << std::endl;
669 Xyce::dout() <<
"DAC ----------------------------------------" << std::endl;
696 myState->
data.resize(vsize*2);
697 for (i=0;i<vsize;++i)
718 int dsize=state.
data.size();
720 if (
getName().getEncodedName() != state.
ID)
722 Report::DevelFatal().in(
"DAC::Instance::setInternal") <<
"ID(" << state.
ID <<
") from restart does not match my name (" <<
getName() <<
")";
728 UserError(*
this) <<
"Data size from restart (" << dsize <<
" not a multiple of 2!";
735 for (i=0;i<vsize;++i)
755 varTypeVec.resize(1);
783 std::vector<Instance*>::iterator iter;
787 for (iter=first; iter!=last; ++iter)
789 (*iter)->processParams();
807 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
813 includeTransitionBP_(true)
842 std::vector<Instance*>::iterator iter;
846 for (iter=first; iter!=last; ++iter)
862 std::vector<Instance*>::const_iterator iter;
868 os <<
" name\t\tmodelName\tParameters" << std::endl;
870 for (i = 0, iter = first; iter != last; ++iter, ++i)
872 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
874 os <<
"\t\tfile = " << (*iter)->file;
899 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
931 Xyce::dout() <<
"DAC ----------------------------------------" << std::endl;
932 Xyce::dout() <<
"DAC Debug output. name = " << di.
getName() << std::endl;
933 Xyce::dout() <<
"DAC v_pos = " << di.
v_pos <<std::endl;
934 Xyce::dout() <<
"DAC v_neg = " << di.
v_neg <<std::endl;
935 Xyce::dout() <<
"DAC i_bra = " << di.
i_bra <<std::endl;
936 Xyce::dout() <<
"DAC vDrop = " << di.
vDrop <<std::endl;
937 Xyce::dout() <<
"DAC voltage_ = " << di.
voltage_ <<std::endl;
938 Xyce::dout() <<
"DAC ----------------------------------------" << std::endl;
966 bool Master::loadDAEVectors (
double * solVec,
double * fVec,
double *qVec,
double * bVec,
double * storeLeadF,
double * storeLeadQ,
double * leadF,
double * leadQ,
double * junctionV)
1016 .registerDevice(
"dac", 1)
1017 .registerModelType(
"dac", 1);
const InstanceName & getName() const
static void loadModelParameters(ParametricData< Model > &model_parameters)
bool updateTVVEC(std::vector< std::pair< double, double > > const &newPairs)
bool includeTransitionBP_
bool updateVoltage(double)
std::vector< std::pair< double, double > > TVVEC
bool updateDependentParameters()
bool setInternalState(const DeviceState &state)
const DeviceOptions & deviceOptions_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
std::vector< Instance * > instanceContainer
bool processInstanceParams()
processInstanceParams
Pure virtual class to augment a linear system.
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
const std::string & getEncodedName() const
Return the instance name encoded as: [s:]*xname [s:]*Ytype!name [s:]*Utype!name!count.
bool updateIntermediateVars()
InstanceVector::const_iterator getInstanceEnd() const
Returns an iterator to the ending of the vector of all instances created for this device...
bool getInstanceBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
static std::vector< std::vector< int > > jacStamp
bool updateSecondaryState()
virtual bool updateSecondaryState(double *staDeriv, double *stoVec)
Updates the devices secondary state information.
InstanceVector::const_iterator getInstanceBegin() const
Returns an iterator to the beginning of the vector of all instances created for this device...
std::vector< Param > params
Parameters from the line.
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
virtual bool loadDAEVectors(double *solVec, double *fVec, double *qVec, double *bVec, double *storeLeadF, double *storeLeadQ, double *leadF, double *leadQ, double *junctionV)
Populates the device's ExternData object with these pointers.
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
double * daeFVectorRawPtr
bool processParams()
processParams
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
bool updatePrimaryState()
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &DACiter, const FactoryBlock &factory_block)
The Device class is an interface for device implementations.
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
std::vector< double > data
const SolverState & solverState_
Class Configuration contains device configuration data.
const SolverState & getSolverState() const
const std::vector< std::vector< int > > & jacobianStamp() const
DeviceState * getInternalState()
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
void varTypes(std::vector< char > &varTypeVec)
double acceptedTime_
DeviceMgr::acceptStep(), DAC (for habanero)
const ExternData & extData
ModelBlock represents a .MODEL line from the netlist.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
double currTime_
DeviceEntity for expression time, breakpoints DeviceMgr for dependent parameters, breakpoints...
std::vector< Param > params
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
virtual std::ostream & printOutInstances(std::ostream &os) const
const SolverState & getSolverState() const
Returns the solver state given during device construction.
void setModParams(const std::vector< Param > ¶ms)
double * nextSolVectorRawPtr