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 PowerGridTransformer {
80 .setDescription(
"Analysis Type");
85 .setDescription(
"Resistance");
90 .setDescription(
"Reactance");
95 .setDescription(
"Transformer Turns Ratio");
100 .setDescription(
"Phase Shift");
124 :
DeviceInstance(IB, configuration.getInstanceParameters(), factory_block),
126 analysisTypeStr_(
"PQP"),
133 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
135 Xyce::dout() << std::endl <<
"In device constructor for " <<
getName() << std::endl;
138 std::vector<Param>::const_iterator iter = IB.
params.begin();
139 std::vector<Param>::const_iterator last = IB.
params.end();
141 for ( ; iter != last; ++iter)
143 const std::string & tmpname = iter->tag();
144 const bool & tmpgiven = iter->given();
147 if (tmpname ==
"AT" && tmpgiven ==
true)
149 ExtendedString atStr(iter->stringValue());
156 else if ( atStr ==
"PQR" )
161 else if ( atStr ==
"PQP" )
168 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
171 if (tmpname ==
"R" && tmpgiven ==
true)
175 if (tmpname ==
"X" && tmpgiven ==
true)
177 reactance_ = iter->getImmutableValue<
double>();
179 if (tmpname ==
"TR" && tmpgiven ==
true)
183 if (tmpname ==
"PS" && tmpgiven ==
true)
195 std::complex<double> zVal;
203 y12 = (-1./zVal) * invTurnsRatio;
204 y21 = (-1./zVal) * invTurnsRatio;
207 y11 = (1./zVal)*invTurnsRatio*invTurnsRatio;
221 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
223 Xyce::dout() <<
getName() <<
" G's and B's without the phase shift correction are:"
224 << Util::push << std::endl
225 <<
"(g11,b11) = (" <<
g11 <<
" , " <<
b11 <<
")" << std::endl
226 <<
"(g12,b12) = (" <<
g12 <<
" , " <<
b12 <<
")" << std::endl
227 <<
"(g21,b21) = (" <<
g21 <<
" , " <<
b21 <<
")" << std::endl
228 <<
"(g22,b22) = (" <<
g22 <<
" , " <<
b22 <<
")" << std::endl
242 double prevG12 =
g12;
243 double prevG21 =
g21;
251 if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
253 Xyce::dout() <<
getName() <<
": for " <<
analysisTypeStr_ <<
" analysis, G's and B's after phase shift correction are:"
254 << Util::push << std::endl
255 <<
"(g11,b11) = (" <<
g11 <<
" , " <<
b11 <<
")" << std::endl
256 <<
"(g12,b12) = (" <<
g12 <<
" , " <<
b12 <<
")" << std::endl
257 <<
"(g21,b21) = (" <<
g21 <<
" , " <<
b21 <<
")" << std::endl
258 <<
"(g22,b22) = (" <<
g22 <<
" , " <<
b22 <<
")" << std::endl
321 const std::vector<int> & extLIDVecRef )
340 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LIDS))
342 Xyce::dout() <<
getName() <<
" LIDs"
343 << Util::push << std::endl
344 <<
"li_VR1 = " <<
li_VR1 << std::endl
345 <<
"li_VI1 = " <<
li_VI1 << std::endl
346 <<
"li_VR2 = " <<
li_VR2 << std::endl
347 <<
"li_VI2 = " <<
li_VI2 << std::endl
358 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LIDS))
360 Xyce::dout() <<
getName() <<
" LIDs"
361 << Util::push << std::endl
362 <<
"li_Theta1 = " <<
li_Theta1 << std::endl
363 <<
"li_VM1 = " <<
li_VM1 << std::endl
364 <<
"li_Theta2 = " <<
li_Theta2 << std::endl
365 <<
"li_VM2 = " <<
li_VM2 << std::endl
371 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
449 if (DEBUG_DEVICE && (isActive(Diag::DEVICE_JACSTAMP) || isActive(Diag::DEVICE_LIDS)))
451 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
484 if (DEBUG_DEVICE && (isActive(Diag::DEVICE_JACSTAMP) || isActive(Diag::DEVICE_LIDS)))
486 Xyce::dout() <<
getName() <<
": In registerJacLIDs, the offsets are:" << std::endl
534 solVec[li_VI1]*(
g12*solVec[
li_VR2] -
b12*solVec[li_VI2]) -
538 solVec[li_VI2]*(
g21*solVec[
li_VR1] -
b21*solVec[li_VI1]) -
559 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
618 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LOAD_VECTOR))
620 Xyce::dout() <<
getName() <<
": F Vector Load info is: (P1,P2,Q1,Q2) load is: (" <<
P1 <<
" , "
621 <<
P2 <<
" , " <<
Q1 <<
" , " <<
Q2 <<
")" << std::endl << std::endl;
626 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
736 if (DEBUG_DEVICE && isActive(Diag::DEVICE_LOAD_VECTOR))
738 Xyce::dout() <<
getName() <<
": dFdx info is: " << std::endl
739 <<
"(dSin12,dSin21,dCos12,dCos21 = (" << dSin12 <<
" , " << dSin21
740 <<
" , " << dCos12 <<
" , " << dCos21 <<
")" << std::endl
741 <<
"(solVec[li_Theta1],solVec[li_Theta2]) = (" << solVec[
li_Theta1]
742 <<
" , " << solVec[
li_Theta2] <<
")" << std::endl
743 <<
"(solVec[li_VM1],solVec[li_VM2]) = (" << solVec[
li_VM1]
744 <<
" , " << solVec[
li_VM2] <<
")" << std::endl;
773 UserError0(*
this) <<
"Analysis Type must be IV, PQR or PQP in power grid device: " <<
getName();
832 :
DeviceModel(MB, configuration.getModelParameters(), factory_block)
846 std::vector<Instance*>::iterator iter;
850 for (iter=first; iter!=last; ++iter)
866 std::vector<Instance*>::const_iterator iter;
872 os <<
" name model name Parameters" << std::endl;
873 for (i=0, iter=first; iter!=last; ++iter, ++i)
875 os <<
" " << i <<
": " << (*iter)->getName() <<
" ";
901 for (std::vector<Instance *>::const_iterator it = instanceContainer.begin(); it != instanceContainer.end(); ++it)
915 .registerDevice(
"PowerGridTransformer", 1)
916 .registerDevice(
"PGTR", 1)
917 .registerModelType(
"PowerGridTransformer", 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.
virtual void registerJacLIDs(const JacobianStamp &jacLIDVec)
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.
Linear::Matrix * dFdxMatrixPtr
The Device class is an interface for device implementations.
Class Configuration contains device configuration data.
const SolverState & getSolverState() const
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.
std::vector< Param > params
double * nextSolVectorRawPtr