47 #include <Xyce_config.h>
62 #include <N_LAS_Matrix.h>
63 #include <N_LAS_Vector.h>
65 #include <N_UTL_ExtendedString.h>
66 #include <N_UTL_FeatureTest.h>
67 #include <N_UTL_IndentStreamBuf.h>
71 namespace PowerGridBusShunt {
80 .setDescription(
"Analysis Type");
85 .setDescription(
"Shunt Conductance");
90 .setDescription(
"Shunt Susceptance");
114 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
116 analysisTypeStr_(
"PQP"),
118 shuntConductance_(1),
121 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
123 Xyce::dout() << std::endl <<
"In device constructor for " <<
getName() << std::endl;
126 std::vector<Param>::const_iterator iter = IB.
params.begin();
127 std::vector<Param>::const_iterator last = IB.
params.end();
129 for ( ; iter != last; ++iter)
131 const std::string & tmpname = iter->tag();
132 const bool & tmpgiven = iter->given();
135 if (tmpname ==
"AT" && tmpgiven ==
true)
137 ExtendedString atStr(iter->stringValue());
144 else if ( atStr ==
"PQR" )
149 else if ( atStr ==
"PQP" )
156 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
159 if (tmpname ==
"G" && tmpgiven ==
true)
163 if (tmpname ==
"B" && tmpgiven ==
true)
188 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
190 Xyce::dout() <<
getName() <<
" G's and B's are:"
191 << Util::push << std::endl
192 <<
"(g11,b11) = (" << g11 <<
" , " <<
b11 <<
")" << std::endl
193 <<
"(g12,b12) = (" <<
g12 <<
" , " <<
b12 <<
")" << std::endl
194 <<
"(g21,b21) = (" <<
g21 <<
" , " <<
b21 <<
")" << std::endl
195 <<
"(g22,b22) = (" <<
g22 <<
" , " <<
b22 <<
")" << std::endl
256 const std::vector<int> & extLIDVecRef )
275 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
277 Xyce::dout() <<
getName() <<
" LIDs"
278 << Util::push << std::endl
279 <<
"li_VR1 = " <<
li_VR1 << std::endl
280 <<
"li_VI1 = " <<
li_VI1 << std::endl
281 <<
"li_VR2 = " <<
li_VR2 << std::endl
282 <<
"li_VI2 = " <<
li_VI2 << std::endl
293 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
295 Xyce::dout() <<
getName() <<
" LIDs"
296 << Util::push << std::endl
297 <<
"li_Theta1 = " <<
li_Theta1 << std::endl
298 <<
"li_VM1 = " <<
li_VM1 << std::endl
299 <<
"li_Theta2 = " <<
li_Theta2 << std::endl
300 <<
"li_VM2 = " <<
li_VM2 << std::endl
306 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
384 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
386 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
419 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
421 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
465 solVec[li_VI1]*(
g12*solVec[
li_VR2] -
b12*solVec[li_VI2]) -
469 solVec[li_VI2]*(
g21*solVec[
li_VR1] -
b21*solVec[li_VI1]) -
475 double dSin21 = sin(solVec[li_Theta2]-solVec[
li_Theta1]);
476 double dCos12 = cos(solVec[li_Theta1]-solVec[li_Theta2]);
477 double dCos21 = cos(solVec[li_Theta2]-solVec[li_Theta1]);
486 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
503 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) &&
getSolverState().debugTimeFlag)
505 Xyce::dout() <<
"Instance::updatePrimaryState" <<std::endl;
550 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
552 Xyce::dout() <<
getName() <<
": F Vector Load info is: (P1,P2,Q1,Q2) load is: (" <<
P1 <<
" , "
553 <<
P2 <<
" , " <<
Q1 <<
" , " <<
Q2 <<
")" << std::endl << std::endl;
558 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
657 double dSin21 = sin(solVec[li_Theta2]-solVec[
li_Theta1]);
658 double dCos12 = cos(solVec[li_Theta1]-solVec[li_Theta2]);
659 double dCos21 = cos(solVec[li_Theta2]-solVec[li_Theta1]);
661 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
663 Xyce::dout() <<
getName() <<
": dFdx info is: " << std::endl
664 <<
"(dSin12,dSin21,dCos12,dCos21 = (" << dSin12 <<
" , " << dSin21
665 <<
" , " << dCos12 <<
" , " << dCos21 <<
")" << std::endl
666 <<
"(solVec[li_Theta1],solVec[li_Theta2]) = (" << solVec[
li_Theta1]
667 <<
" , " << solVec[
li_Theta2] <<
")" << std::endl
668 <<
"(solVec[li_VM1],solVec[li_VM2]) = (" << solVec[
li_VM1]
669 <<
" , " << solVec[
li_VM2] <<
")" << std::endl;
698 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
757 :
DeviceModel(MB, configuration.getModelParameters(), factory_block)
771 std::vector<Instance*>::iterator iter;
775 for (iter=first; iter!=last; ++iter)
791 std::vector<Instance*>::const_iterator iter;
797 os <<
" name model name Parameters" << std::endl;
798 for (i=0, iter=first; iter!=last; ++iter, ++i)
800 os <<
" " << i <<
": " << (*iter)->getName() <<
" ";
826 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
840 .registerDevice(
"PowerGridBusShunt", 1)
841 .registerDevice(
"PGBS", 1)
842 .registerModelType(
"PowerGridBusShunt", 1);
const InstanceName & getName() const
std::vector< Instance * > instanceContainer
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
const SolverState & solverState_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Pure virtual class to augment a linear system.
Parameter may be specified as time dependent expression from netlist.
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
virtual std::ostream & printOutInstances(std::ostream &os) const
bool updatePrimaryState()
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...
const DeviceOptions & deviceOptions_
static Config< T > & addConfiguration()
Adds the device to the Xyce device configuration.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Linear::Matrix * dFdxMatrixPtr
The Device class is an interface for device implementations.
static std::vector< std::vector< int > > jacStamp
Class Configuration contains device configuration data.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
bool updateIntermediateVars()
const SolverState & getSolverState() const
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
std::string analysisTypeStr_
const ExternData & extData
const std::vector< std::vector< int > > & jacobianStamp() const
ModelBlock represents a .MODEL line from the netlist.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
std::vector< Param > params
static void loadModelParameters(ParametricData< Model > &model_parameters)
double * nextSolVectorRawPtr