48 #include <Xyce_config.h>
62 #include <N_ERH_ErrorMgr.h>
64 #include <N_LAS_Vector.h>
65 #include <N_LAS_Matrix.h>
66 #include <N_UTL_FeatureTest.h>
121 os <<
" XygraCoilData for: name = " << xcd.
getName() <<
170 bool bsuccess =
true;
188 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
229 int totalNumIntVars=0;
235 Xyce::dout() <<
" We were given a coil spec." << std::endl;
236 Xyce::dout() <<
" There were " <<
coilDataVec.size() <<
" coils." << std::endl;
245 UserError0(*
this) <<
"Xygra Device " <<
getName() <<
"has "<<
coilDataVec.size() <<
" coils and " <<
numExtVars <<
" external nodes. Number of external nodes should be twice number of coils.";
251 for (
int i = 0; i <
nCoils; ++i)
255 Xyce::dout() <<
" Coil["<< i <<
"] name is " <<
coilDataVec[i]->getName() <<
", has " <<
coilDataVec[i]->getNumWindings() <<
" windings. " << std::endl;
257 totalNumIntVars +=
coilDataVec[i]->getNumWindings() - 1;
265 Xyce::dout() <<
" We would have " << totalNumIntVars <<
" internal vars " << std::endl;
277 std::ostringstream ost;
279 ost <<
"Instance::Instance:";
280 ost <<
"Number of nodes given to device " <<
getName() <<
"is not even."
282 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str() );
331 for (
int i=0; i<numNodes; ++i)
334 for (
int j=0; j<numNodes; ++j)
353 if (cM.size() != numNodes)
355 std::ostringstream ost;
357 ost <<
"Instance::setConductances:";
358 ost <<
" Input matrix passed to device " <<
getName()
360 <<
") does not have number of rows required by netlist specification ("
361 << numNodes <<
")." << std::endl;
362 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
365 for (
int i=0; i<numNodes; ++i)
367 if (cM[i].size() != numNodes)
369 std::ostringstream ost;
371 ost <<
"Instance::setConductances:";
372 ost <<
" row " << i <<
"of matrix passed to device " <<
getName()
373 <<
" has " << cM[i].size()
374 <<
" columns instead of number required by netlist specification ("
375 << numNodes <<
")." << std::endl;
376 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
381 Xyce::dout() << std::endl << subsection_divider << std::endl;
383 Xyce::dout() << std::endl << subsection_divider << std::endl;
403 std::vector<std::vector<double> > * kPtr;
423 std::ostringstream ost;
425 ost <<
"Instance::setK:";
426 ost <<
" Input matrix passed to device " <<
getName()
428 <<
") does not have number of rows required by netlist specification ("
430 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
437 std::ostringstream ost;
439 ost <<
"Instance::setK:";
440 ost <<
" row " << i <<
"of matrix passed to device " <<
getName()
441 <<
" has " << kM[i].size()
442 <<
" columns instead of number required by netlist specification ("
443 << totalNumWindings <<
")." << std::endl;
444 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
461 Xyce::dout() << std::endl << subsection_divider << std::endl;
463 Xyce::dout() << std::endl << subsection_divider << std::endl;
491 for (
int coil=0; coil <
nCoils; ++coil)
494 for (
int winding=0; winding<
nWindings[coil]-1; ++winding)
498 nV[offset++] = (*solVectorPtr)[
li_Nodes_[coilExtStart[coil]+1]];
547 std::vector<double> * sPtr;
549 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
551 Xyce::dout() << std::endl << subsection_divider << std::endl;
552 Xyce::dout() <<
" Device " <<
getName() <<
" setSources called for time " <<
getSolverState().
currTime <<
" with value t= " << t << std::endl;
553 Xyce::dout() << std::endl << subsection_divider << std::endl;
561 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
563 Xyce::dout() <<
" setting source s0 for t=" << t << std::endl;
573 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
575 Xyce::dout() <<
" setting source s1 for t=" << t << std::endl;
582 std::ostringstream ost;
584 ost <<
"Instance::setSources:";
585 ost <<
" Input vector passed to device " <<
getName()
587 <<
") does not have number of rows required by netlist specification ("
589 N_ERH_ErrorMgr::report(N_ERH_ErrorMgr::DEV_FATAL, ost.str());
629 Xyce::dout() <<
" source vector is: " << std::endl;
630 Xyce::dout() <<
" s0["<<i<<
"] = " <<
s0_[i] << std::endl;
631 Xyce::dout() <<
" s1["<<i<<
"] = " <<
s1_[i] << std::endl;
632 Xyce::dout() <<
" fac = " << fac << std::endl;
666 const std::vector<int> & extLIDVecRef)
671 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
673 Xyce::dout() << std::endl << section_divider << std::endl;
674 Xyce::dout() <<
" Instance::registerLIDs" << std::endl;
675 Xyce::dout() <<
" name = " <<
getName() << std::endl;
691 for (
int coil=0; coil<
nCoils; ++coil)
699 for (
int coil=0; coil<
nCoils; ++coil)
713 for (
int coil=0; coil<
nCoils; ++coil)
715 for (
int coilWinding=0; coilWinding<
nWindings[coil]; coilWinding++)
727 if (coilWinding==nWindings[coil]-1)
735 windingNodes[globalWinding++] = std::pair<int,int>(posNode,negNode);
739 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
741 for (
int i=0; i<numNodes; ++i)
743 Xyce::dout() <<
" li_Nodes_[" <<i <<
"] = " <<
li_Nodes_[i] << std::endl;
748 Xyce::dout() <<
"Winding " << winding <<
" between node "
754 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) )
756 Xyce::dout() << section_divider << std::endl;
772 for (
int i = 0; i <
nCoils; ++i)
777 for (
int nodeOffset = 1; nodeOffset <
nWindings[i]; ++nodeOffset)
780 std::ostringstream ost;
781 ost <<
"coil" << i <<
"_Internal" << nodeOffset;
831 for (
int equ=0; equ < numNodes; ++equ)
834 for (
int node=0; node < numNodes; ++node)
852 bool bsuccess =
true;
854 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
856 Xyce::dout() <<
"Instance::updatePrimaryState" <<std::endl;
872 bool bsuccess =
true;
894 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
896 Xyce::dout() << subsection_divider << std::endl;
897 Xyce::dout() <<
"Instance::updateIntermediateVars "<<std::endl;
898 Xyce::dout() <<
" name = " <<
getName() << std::endl;
918 for (
int node=0 ; node<numNodes ; ++node)
925 dV[winding].resize(numNodes);
930 for (
int node=0; node<numNodes; ++node)
944 for (
int node=0; node<numNodes; ++node)
950 Xyce::dout() <<
"solutionVar[" << node <<
"] = " <<
solutionVars[node] << std::endl;
987 Xyce::dout() <<
"Winding " << winding <<
" adding " <<
windingCurrents[winding]
988 <<
"to contribution to node " << posNode <<
" and subtracting same "
989 <<
" from node " << negNode << std::endl;
997 Xyce::dout() <<
" Contributions for device " <<
getName() << std::endl;
998 for (
int node=0; node<numNodes; ++node)
1000 Xyce::dout() <<
" F[" << node <<
"] = " <<
fContributions[node] << std::endl;
1002 Xyce::dout() <<
"Winding potential drops and currents: " << std::endl;
1005 Xyce::dout() <<
" dV[" << winding <<
"] = " <<
dV[winding] << std::endl;
1006 Xyce::dout() <<
" I[" << winding <<
"] = " <<
windingCurrents[winding] << std::endl;
1030 bool bsuccess =
true;
1059 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1061 Xyce::dout() << subsection_divider << std::endl;
1062 Xyce::dout() <<
"Instance::loadDAEFVector "<<std::endl;
1063 Xyce::dout() <<
" name = " <<
getName() << std::endl;
1066 for (
int node=0; node<numNodes; ++node)
1071 Xyce::dout() <<
" fVec[" << node <<
"] += "
1073 Xyce::dout() <<
" loaded into local ID " << li_Nodes_[node] << std::endl;
1091 bool bsuccess =
true;
1114 bool bsuccess =
true;
1121 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
1123 Xyce::dout() << subsection_divider << std::endl;
1124 Xyce::dout() <<
"Instance::loadDAEdFdx "<<std::endl;
1125 Xyce::dout() <<
" name = " <<
getName() << std::endl;
1143 for (
int equ=0; equ < numNodes; ++equ)
1152 for (
int equ=0; equ < numNodes; ++equ)
1154 for (
int node=0; node < numNodes; ++node)
1160 Xyce::dout() <<
" dFdX[" << equ <<
"]["<<node<<
"] += "
1180 bool bsuccess =
true;
1209 if (cName ==
"COIL")
1213 return (static_cast<CompositeParam *> (xcd));
1218 "Instance::constructComposite: unrecognized composite name: ";
1220 N_ERH_ErrorMgr::report ( N_ERH_ErrorMgr::DEV_FATAL,msg);
1250 std::vector<Instance*>::iterator iter;
1254 for (iter=first; iter!=last; ++iter)
1256 (*iter)->processParams();
1274 :
DeviceModel(MB, configuration.getModelParameters(), factory_block)
1312 std::vector<Instance*>::iterator iter;
1316 for (iter=first; iter!=last; ++iter)
1335 std::vector<Instance*>::const_iterator iter;
1343 os <<
"Number of Xygra instances: " << isize << std::endl;
1344 os <<
" name=\t\tmodelName\tParameters" << std::endl;
1345 for (i=0, iter=first; iter!=last; ++iter, ++i)
1347 os <<
" " << i <<
": " << (*iter)->getName() <<
"\t";
1373 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1387 .registerDevice(
"xygra", 1)
1388 .registerModelType(
"xygra", 1);
const InstanceName & getName() const
virtual std::ostream & printOutInstances(std::ostream &os) const
std::vector< double > theSourceVector_
std::vector< XygraCoilData * > coilDataVec
std::vector< std::vector< double > > theConductanceMatrix_
std::vector< int > coilIntStart
bool updateDependentParameters()
const SolverState & solverState_
bool updateSecondaryState()
std::string getName() const
std::map< std::string, XygraCoilData * > coilDataMap
std::vector< int > li_Nodes_
Linear::Vector * nextSolVectorPtr
bool setK(const std::vector< std::vector< double > > &kMatrix, const double t=0)
static void loadModelParameters(ParametricData< Model > &model_parameters)
bool setSources(const std::vector< double > &sourceVector, const double t=0)
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)
static ParametricData< XygraCoilData > & getParametricData()
bool processParams()
processParams
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
int getNumWindings() const
std::vector< std::vector< int > > jacStamp_
std::vector< XygraFadType > windingCurrents
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
bool getVoltages(std::vector< double > &voltageValues)
void getCoilNames(std::vector< std::string > &coilNames)
CompositeParam * constructComposite(const std::string &, const std::string &)
std::vector< std::vector< double > > k1_
std::vector< Param > params
Parameters from the line.
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
std::vector< XygraFadType > dV
std::vector< XygraFadType > fContributions
std::vector< std::vector< double > > theKMatrix_
void addComposite(const char *comp_name, const ParametricData< U > &composite_pars, std::map< std::string, U * > V::*composite_map)
Adds a composite parameter to the parameter map.
std::vector< std::pair< int, int > > windingNodes
bool processInstanceParams()
processInstanceParams
const DeviceOptions & deviceOptions_
const std::vector< std::vector< int > > & jacobianStamp() const
Linear::Vector * nextStaVectorPtr
std::vector< std::vector< int > > A_Equ_NodeOffsets_
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
Linear::Matrix * dFdxMatrixPtr
std::vector< int > coilExtStart
The Device class is an interface for device implementations.
std::vector< Instance * > instanceContainer
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
void getCoilWindings(std::vector< int > &coilWindings)
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Class Configuration contains device configuration data.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
const SolverState & getSolverState() const
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
void processParams()
processParams post processes the parameters that have been set in the object of the derived class...
Linear::Vector * daeFVectorPtr
bool setConductances(const std::vector< std::vector< double > > &conductanceMatrix)
ParametricData()
Constructs the parameter data map.
bool updatePrimaryState()
void varTypes(std::vector< char > &varTypeVec)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
bool updateIntermediateVars()
const ExternData & extData
ModelBlock represents a .MODEL line from the netlist.
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
std::vector< Param > params
std::vector< double > s0_
std::vector< double > s1_
std::vector< std::vector< double > > k0_
bool updateTemperature(const double &temp_tmp)
std::vector< int > nWindings
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
std::vector< std::string > coilNames
void setModParams(const std::vector< Param > ¶ms)
std::ostream & operator<<(std::ostream &os, const Configuration &configuration)
std::vector< XygraFadType > solutionVars