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");
126 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
128 analysisTypeStr_(
"PQP"),
135 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
137 Xyce::dout() << std::endl <<
"In device constructor for " <<
getName() << std::endl;
140 std::vector<Param>::const_iterator iter = IB.
params.begin();
141 std::vector<Param>::const_iterator last = IB.
params.end();
143 for ( ; iter != last; ++iter)
145 const std::string & tmpname = iter->tag();
146 const bool & tmpgiven = iter->given();
149 if (tmpname ==
"AT" && tmpgiven ==
true)
151 ExtendedString atStr(iter->stringValue());
156 UserError0(*
this) <<
"Only PQP Analysis Type is supported for PowerGridGenBus device: " <<
getName();
160 else if ( atStr ==
"PQR" )
163 UserError0(*
this) <<
"Only PQP Analysis Type is supported for PowerGridGenBus device: " <<
getName();
167 else if ( atStr ==
"PQP" )
174 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
177 if (tmpname ==
"VM" && tmpgiven ==
true)
179 VMag_ = iter->getImmutableValue<
double>();
181 if (tmpname ==
"P" && tmpgiven ==
true)
183 power_ = iter->getImmutableValue<
double>();
185 if (tmpname ==
"QMAX" && tmpgiven ==
true)
187 QMax_ = iter->getImmutableValue<
double>();
189 if (tmpname ==
"QMIN" && tmpgiven ==
true)
191 QMin_ = iter->getImmutableValue<
double>();
209 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
302 const std::vector<int> & extLIDVecRef )
323 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
325 Xyce::dout() <<
getName() <<
" LIDs"
326 << Util::push << std::endl
327 <<
"li_VR1 = " <<
li_VR1 << std::endl
328 <<
"li_VI1 = " <<
li_VI1 << std::endl
329 <<
"li_VR2 = " <<
li_VR2 << std::endl
330 <<
"li_VI2 = " <<
li_VI2 << std::endl
345 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
347 Xyce::dout() <<
getName() <<
" LIDs"
348 << Util::push << std::endl
349 <<
"li_VR1 = " <<
li_VR1 << std::endl
350 <<
"li_VI1 = " <<
li_VI1 << std::endl
351 <<
"li_VR2 = " <<
li_VR2 << std::endl
352 <<
"li_VI2 = " <<
li_VI2 << std::endl
366 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
368 Xyce::dout() <<
getName() <<
" LIDs"
369 << Util::push << std::endl
370 <<
"li_Theta1 = " <<
li_Theta1 << std::endl
371 <<
"li_VM1 = " <<
li_VM1 << std::endl
372 <<
"li_Theta2 = " <<
li_Theta2 << std::endl
373 <<
"li_VM2 = " <<
li_VM2 << std::endl
380 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
411 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
468 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
470 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
494 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
496 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
512 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
514 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
583 double signVal = (
srcBCI < 0) ? -1.0 : 1.0;
649 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
710 Xyce::dout() <<
getName() <<
": F Vector Load info is (P,Q): (" <<
power_ <<
","
712 <<
" (srcDropR,srcBCR,srcDropI,srcBCI: ("
714 <<
srcBCI <<
")"<< std::endl << std::endl
715 <<
" Solution Vector Currents are (P,Q): (" <<
Bran_CurrP <<
","
717 <<
" (VR1,VR2,VI1,VI2): ("
718 <<
VR1 <<
"," <<
VR2 <<
"," <<
VI1 <<
","
719 <<
VI2 <<
")"<< std::endl << std::endl;
746 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LOAD_VECTOR))
748 Xyce::dout() <<
"Bran_CurrQ = " <<
Bran_CurrQ << std::endl;
753 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
755 Xyce::dout() <<
getName() <<
": F Vector Load info is (P,Q,srcDropVM,srcBCVM): (" <<
power_ <<
" , "
761 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
816 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
860 Xyce::dout() <<
"Jacobian term = " << jacTerm << std::endl;
889 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
931 :
DeviceModel(MB, configuration.getModelParameters(), factory_block)
945 std::vector<Instance*>::iterator iter;
949 for (iter=first; iter!=last; ++iter)
965 std::vector<Instance*>::const_iterator iter;
971 os <<
" name model name Parameters" << std::endl;
972 for (i=0, iter=first; iter!=last; ++iter, ++i)
974 os <<
" " << i <<
": " << (*iter)->getName() <<
" ";
1000 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
1014 .registerDevice(
"PowerGridGenBus", 1)
1015 .registerDevice(
"PGGB", 1)
1016 .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