49 #include <Xyce_config.h>
64 #include <N_LAS_Matrix.h>
65 #include <N_LAS_Vector.h>
67 #include <N_UTL_ExtendedString.h>
68 #include <N_UTL_FeatureTest.h>
69 #include <N_UTL_IndentStreamBuf.h>
73 namespace PowerGridGenBus {
82 .setDescription(
"Analysis Type");
87 .setDescription(
"Generator Output Power");
92 .setDescription(
"Voltage Magnitude");
97 .setDescription(
"Reactive Power Max Limit");
102 .setDescription(
"Reactive Power Min Limit");
107 .setDescription(
"Q-Limit Enforcement Delay");
131 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
133 analysisTypeStr_(
"PQP"),
141 QLimitEnforceDelay_(0),
142 holdQatLower_(false),
145 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
147 Xyce::dout() << std::endl <<
"In device constructor for " <<
getName() << std::endl;
150 std::vector<Param>::const_iterator iter = IB.
params.begin();
151 std::vector<Param>::const_iterator last = IB.
params.end();
153 for ( ; iter != last; ++iter)
155 const std::string & tmpname = iter->tag();
156 const bool & tmpgiven = iter->given();
159 if (tmpname ==
"AT" && tmpgiven ==
true)
161 ExtendedString atStr(iter->stringValue());
167 UserError0(*
this) <<
"Only PQP Analysis Type is supported for PowerGridGenBus device: " <<
getName();
171 else if ( atStr ==
"PQR" )
175 UserError0(*
this) <<
"Only PQP Analysis Type is supported for PowerGridGenBus device: " <<
getName();
179 else if ( atStr ==
"PQP" )
209 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
212 if (tmpname ==
"VM" && tmpgiven ==
true)
214 VMag_ = iter->getImmutableValue<
double>();
216 if (tmpname ==
"P" && tmpgiven ==
true)
218 power_ = iter->getImmutableValue<
double>();
220 if (tmpname ==
"QMAX" && tmpgiven ==
true)
222 QMax_ = iter->getImmutableValue<
double>();
225 if (tmpname ==
"QMIN" && tmpgiven ==
true)
227 QMin_ = iter->getImmutableValue<
double>();
230 if (tmpname ==
"QLED" && tmpgiven ==
true)
251 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
393 const std::vector<int> & extLIDVecRef )
413 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
415 Xyce::dout() <<
getName() <<
" LIDs"
416 << Util::push << std::endl
417 <<
"li_VR1 = " <<
li_VR1 << std::endl
418 <<
"li_VI1 = " <<
li_VI1 << std::endl
419 <<
"li_VR2 = " <<
li_VR2 << std::endl
420 <<
"li_VI2 = " <<
li_VI2 << std::endl
435 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
437 Xyce::dout() <<
getName() <<
" LIDs"
438 << Util::push << std::endl
439 <<
"li_VR1 = " <<
li_VR1 << std::endl
440 <<
"li_VI1 = " <<
li_VI1 << std::endl
441 <<
"li_VR2 = " <<
li_VR2 << std::endl
442 <<
"li_VI2 = " <<
li_VI2 << std::endl
456 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
458 Xyce::dout() <<
getName() <<
" LIDs"
459 << Util::push << std::endl
460 <<
"li_Theta1 = " <<
li_Theta1 << std::endl
461 <<
"li_VM1 = " <<
li_VM1 << std::endl
462 <<
"li_Theta2 = " <<
li_Theta2 << std::endl
463 <<
"li_VM2 = " <<
li_VM2 << std::endl
479 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
512 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
570 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
572 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
592 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
594 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
618 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
620 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
637 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
639 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
642 <<
" , " <<
Q_Q_Offset <<
")" << std::endl << std::endl;
653 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
655 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
657 <<
"Q offsets are (" <<
Q_Q_Offset <<
")" << std::endl
734 double signVal = (
srcBCI < 0) ? -1.0 : 1.0;
819 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
890 Xyce::dout() <<
getName() <<
": F Vector Load info is (P,Q): (" <<
power_ <<
","
892 <<
" (srcDropR,srcBCR,srcDropI,srcBCI: ("
894 <<
srcBCI <<
")"<< std::endl << std::endl
895 <<
" Solution Vector Currents are (P,Q): (" <<
Bran_CurrP <<
","
897 <<
" (VR1,VR2,VI1,VI2): ("
898 <<
VR1 <<
"," <<
VR2 <<
"," <<
VI1 <<
","
899 <<
VI2 <<
")"<< std::endl << std::endl;
935 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
937 Xyce::dout() <<
getName() <<
": F Vector Load info is (Q,QMax,Qmin): (" <<
Bran_CurrQ <<
938 "," <<
QMax_ <<
"," <<
QMin_ <<
")" << std::endl << std::endl;
947 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LOAD_VECTOR))
949 Xyce::dout() <<
"Bran_CurrQ = " <<
Bran_CurrQ << std::endl;
954 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
956 Xyce::dout() <<
getName() <<
": F Vector Load info is (P,Q,srcDropVM,srcBCVM): (" <<
power_ <<
" , "
976 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
1060 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
1117 Xyce::dout() <<
"Jacobian term = " << jacTerm << std::endl;
1177 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
1219 :
DeviceModel(MB, configuration.getModelParameters(), factory_block)
1233 std::vector<Instance*>::iterator iter;
1237 for (iter=first; iter!=last; ++iter)
1253 std::vector<Instance*>::const_iterator iter;
1259 os <<
" name model name Parameters" << std::endl;
1260 for (i=0, iter=first; iter!=last; ++iter, ++i)
1262 os <<
" " << i <<
": " << (*iter)->getName() <<
" ";
1288 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1302 .registerDevice(
"PowerGridGenBus", 1)
1303 .registerDevice(
"PGGB", 1)
1304 .registerModelType(
"PowerGridGenBus", 1);
const InstanceName & getName() const
const SolverState & solverState_
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
Pure virtual class to augment a linear system.
Parameter may be specified as time dependent expression from netlist.
void addInternalNode(Util::SymbolTable &symbol_table, int index, const InstanceName &instance_name, const std::string &lead_name)
std::vector< Instance * > instanceContainer
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
std::string analysisTypeStr_
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
void setParams(const std::vector< Param > ¶ms)
const std::string & getName() const
double * daeFVectorRawPtr
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
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.
static void loadModelParameters(ParametricData< Model > &model_parameters)
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.
bool updateIntermediateVars()
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
const SolverState & getSolverState() const
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Riter, const FactoryBlock &factory_block)
double * daeBVectorRawPtr
const std::vector< std::vector< int > > & jacobianStamp() const
bool updatePrimaryState()
const ExternData & extData
ModelBlock represents a .MODEL line from the netlist.
virtual std::ostream & printOutInstances(std::ostream &os) const
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
std::vector< Param > params
double * nextSolVectorRawPtr