Пример #1
0
/**
 * Return the values of the vector block
 * @param values: pointer to vector values
 * @return: false if network component does not contribute
 *        vector element
 */
bool gridpack::resistor_grid::RGBus::vectorValues(ComplexType *values)
{
  if (!p_lead) {
    std::vector<boost::shared_ptr<BaseComponent> > branches;
    getNeighborBranches(branches);
    int size = branches.size();
    int i;
    gridpack::ComplexType ret(0.0,0.0);
    for (i=0; i<size; i++) {
      gridpack::resistor_grid::RGBranch *branch
        = dynamic_cast<gridpack::resistor_grid::RGBranch*>(branches[i].get());
      gridpack::resistor_grid::RGBus *bus1
        = dynamic_cast<gridpack::resistor_grid::RGBus*>(branch->getBus1().get());
      gridpack::resistor_grid::RGBus *bus2
        = dynamic_cast<gridpack::resistor_grid::RGBus*>(branch->getBus2().get());
      if (bus1 != this && bus1->isLead()) {
        ret += bus1->voltage()/branch->resistance();
      } else if (bus2 != this && bus2->isLead()) {
        ret += bus2->voltage()/branch->resistance();
      }
    }
    values[0] = ret;
    return true;
  } else {
    return false;
  }
}
Пример #2
0
/**
 * Return the values of for a diagonal matrix block. The values are
 * returned in row-major order
 * @param values: pointer to matrix block values
 * @return: false if network component does not contribute
 *        matrix element
 */
bool gridpack::resistor_grid::RGBus::matrixDiagValues(ComplexType *values)
{
  if (!p_lead) {
    gridpack::ComplexType ret(0.0,0.0);
    std::vector<boost::shared_ptr<BaseComponent> > branches;
    getNeighborBranches(branches);
    int size = branches.size();
    int i;
    for (i=0; i<size; i++) {
      gridpack::resistor_grid::RGBranch *branch
        = dynamic_cast<gridpack::resistor_grid::RGBranch*>(branches[i].get());
      ret += 1.0/branch->resistance();
    }
    values[0] = ret;
    return true;
  } else {
    return false;
  }
}
Пример #3
0
/**
 * Set values of YBus matrix. These can then be used in subsequent
 * calculations
 */
void gridpack::ymatrix::YMBus::setYBus(void)
{
  gridpack::ComplexType ret(0.0,0.0);
  std::vector<boost::shared_ptr<BaseComponent> > branches;
  getNeighborBranches(branches);
  int size = branches.size();
  int i;
  // HACK: Need to cast pointer, is there a better way?
  for (i=0; i<size; i++) {
    gridpack::ymatrix::YMBranch *branch
      = dynamic_cast<gridpack::ymatrix::YMBranch*>(branches[i].get());
    ret -= branch->getAdmittance();
    ret -= branch->getTransformer(this);
    ret += branch->getShunt(this);
  }
  if (p_shunt) {
    gridpack::ComplexType shunt(p_shunt_gs,p_shunt_bs);
    ret += shunt;
  }
  p_ybusr = real(ret);
  p_ybusi = imag(ret);
}