51 #include <Xyce_config.h>
55 #include <N_UTL_Math.h>
64 #include <N_ERH_ErrorMgr.h>
66 #include <N_LAS_Matrix.h>
67 #include <N_LAS_Vector.h>
69 #include <N_UTL_Expression.h>
95 .setDescription(
"On resistance");
100 .setDescription(
"Off resistance");
105 .setDescription(
"On voltage");
110 .setDescription(
"Off voltage");
115 .setDescription(
"On current");
120 .setDescription(
"Off current");
125 .setDescription(
"On control value");
130 .setDescription(
"Off control value");
160 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
171 APosEquPosNodeOffset(-1),
172 APosEquNegNodeOffset(-1),
173 ANegEquPosNodeOffset(-1),
174 ANegEquNegNodeOffset(-1),
175 fPosEquPosNodePtr(0),
176 fPosEquNegNodePtr(0),
177 fNegEquPosNodePtr(0),
178 fNegEquNegNodePtr(0),
205 UserError0(*
this) <<
"Cannot specify both 'on' and off' for switch";
209 if (!
given(
"CONTROL"))
211 UserError0(*
this) <<
"Must specify 'control' for switch";
214 std::vector<Depend>::const_iterator d;
218 for (d = begin ; d != end ; ++d)
220 if (d->name ==
"CONTROL")
271 const std::vector<int> & extLIDVecRef)
306 li_ddt[i] = staLIDVecRef[i+1];
390 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
440 double current_state;
482 if (current_state >= 1.0)
489 else if ( current_state <= 0.0)
498 current_state = 2*current_state - 1;
500 0.25*
model_.
Lr*current_state*current_state*current_state);
627 :
DeviceModel(MB, configuration.getModelParameters(), factory_block),
639 else if (
getType() ==
"ISWITCH") {
642 else if (
getType() ==
"VSWITCH") {
699 if (del < 0 && del > -1e-12)
701 if (del >= 0 && del < 1e-12)
719 std::vector<Instance*>::iterator iter;
723 for (iter=first; iter!=last; ++iter)
725 (*iter)->processParams();
741 std::vector<Instance*>::iterator iter;
745 for (iter=first; iter!=last; ++iter)
759 std::vector<Instance*>::const_iterator iter;
765 os <<
" name model name Parameters" << std::endl;
766 for (i=0, iter=first; iter!=last; ++iter, ++i)
768 os <<
" " << i <<
": " << (*iter)->getName() <<
" ";
770 os <<
" R = " << (*iter)->R;
771 os <<
" G = " << (*iter)->G;
772 os <<
" State = " << (*iter)->SW_STATE;
797 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
815 bool bsuccess =
true;
822 bsuccess = bsuccess && btmp;
846 double current_state;
884 if (current_state >= 1.0)
891 else if ( current_state <= 0.0)
900 current_state = 2*current_state - 1;
902 0.25*si.
getModel().
Lr*current_state*current_state*current_state);
923 bool Master::loadDAEVectors (
double * solVec,
double * fVec,
double *qVec,
double * bVec,
double * storeLeadF,
double * storeLeadQ,
double * leadF,
double * leadQ,
double * junctionV)
954 #ifndef Xyce_NONPOINTER_MATRIX_LOAD
998 .registerDevice(
"s", 1)
1000 #ifdef Xyce_OLD_SWITCH
1001 .registerModelType(
"sw", 1)
1003 .registerModelType(
"switch", 1)
1004 .registerModelType(
"iswitch", 1)
1005 .registerModelType(
"vswitch", 1)
const InstanceName & getName() const
static void loadModelParameters(ParametricData< Model > &model_parameters)
double * nextStaDerivVectorRawPtr
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
bool updateDependentParameters()
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
const DeviceOptions & deviceOptions_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
virtual bool updateSecondaryState(double *staDeriv, double *stoVec)
Updates the devices secondary state information.
bool given(const std::string ¶meter_name) const
Pure virtual class to augment a linear system.
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.
bool updateSecondaryState()
InstanceVector::const_iterator getInstanceEnd() const
Returns an iterator to the ending of the vector of all instances created for this device...
std::vector< double > myVarVals
const std::vector< Depend > & getDependentParams()
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
std::vector< int > APosEquControlNodeOffset
std::vector< double * > fPosEquControlNodePtr
int getNumStoreVars() const
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.
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
double * daeFVectorRawPtr
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
std::vector< double > ddtVals
std::vector< std::vector< int > > jacStamp
bool updatePrimaryState()
std::vector< Instance * > instanceContainer
double * nextStoVectorRawPtr
virtual bool updateState(double *solVec, double *staVec, double *stoVec)
Updates the devices state information.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &SWiter, const FactoryBlock &factory_block)
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
double * fPosEquNegNodePtr
Linear::Matrix * dFdxMatrixPtr
double * fNegEquNegNodePtr
std::vector< double > expVarDerivs
std::vector< int > li_ddt
The Device class is an interface for device implementations.
void addStoreNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
virtual bool loadDAEMatrices(Linear::Matrix &dFdx, Linear::Matrix &dQdx)
Populates the device's Jacobian object with these pointers.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
const SolverState & solverState_
Class Configuration contains device configuration data.
bool updateIntermediateVars()
Util::Expression * Exp_ptr
double * fPosEquPosNodePtr
std::vector< int > ANegEquControlNodeOffset
const SolverState & getSolverState() const
void registerStoreLIDs(const std::vector< int > &stoLIDVecRef)
virtual std::ostream & printOutInstances(std::ostream &os) const
double * nextStaVectorRawPtr
const std::vector< std::vector< int > > & jacobianStamp() const
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
const std::string & getType() const
double * fNegEquPosNodePtr
virtual void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
std::vector< double * > fNegEquControlNodePtr
const ExternData & extData
bool processParams()
processParams
ModelBlock represents a .MODEL line from the netlist.
Parameter may be specified as a solution dependent expression from netlist.
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
std::vector< Param > params
Linear::Matrix * dQdxMatrixPtr
const std::vector< std::string > & getDepSolnVars()
bool processInstanceParams()
processInstanceParams
virtual const std::vector< std::string > & getDepSolnVars()
const SolverState & getSolverState() const
Returns the solver state given during device construction.
void setModParams(const std::vector< Param > ¶ms)
double * nextSolVectorRawPtr
int numLeadCurrentStoreVars