Eclipse SUMO - Simulation of Urban MObility
Circuit Class Reference

#include <Circuit.h>

Public Types

enum  alphaFlag { ALPHA_NOT_APPLIED = 0 , ALPHA_CURRENT_LIMITS , ALPHA_VOLTAGE_LIMITS , ALPHA_NOT_CONVERGING }
 Flag of alpha scaling parameter. More...
 

Public Member Functions

ElementaddElement (std::string name, double value, Node *pNode, Node *nNode, Element::ElementType et)
 
NodeaddNode (std::string name)
 
bool checkCircuit (std::string substationId="")
 
 Circuit ()
 
 Circuit (double currentLimit)
 Constructor with user-specified current limit parameter. More...
 
void cleanUpSP ()
 
void descreaseLastId ()
 
void eraseElement (Element *element)
 
void eraseNode (Node *node)
 
double getAlphaBest ()
 return alphaBest variable, the best alpha scaling value More...
 
alphaFlag getAlphaReason ()
 return the reason why alpha scaling value has been used More...
 
double getCurrent (std::string name)
 
double getCurrentLimit ()
 @ brief Get the electric current limit of this circuit. More...
 
std::string & getCurrentsOfCircuitSource (std::string &currents)
 List of currents of voltage sources as a string. More...
 
std::vector< Element * > * getCurrentSources ()
 
ElementgetElement (std::string name)
 
int getLastId ()
 
NodegetNode (int id)
 
NodegetNode (std::string name)
 
int getNumVoltageSources ()
 
double getResistance (std::string name)
 
double getTotalCurrentOfCircuitSources ()
 The sum of voltage source currents in the circuit. More...
 
double getTotalPowerOfCircuitSources ()
 The sum of voltage source powers in the circuit. More...
 
double getVoltage (std::string name)
 
ElementgetVoltageSource (int id)
 
void lock ()
 
void replaceAndDeleteNode (Node *unusedNode, Node *newNode)
 
void setCurrentLimit (double myCurrentLimit)
 Set the electric current limit of this circuit. More...
 
void unlock ()
 

Private Member Functions

void deployResults (double *vals, std::vector< int > *removable_ids)
 
void detectRemovableNodes (std::vector< int > *removable_ids)
 
ElementgetElement (int id)
 

Private Attributes

double alphaBest
 Best alpha scaling value. More...
 
alphaFlag alphaReason
 
double circuitCurrentLimit
 The electric current limit of the voltage sources. More...
 
std::vector< Element * > * elements
 
bool iscleaned
 
int lastId
 
std::vector< Node * > * nodes
 
std::vector< Element * > * voltageSources
 

Detailed Description

All interactions will be through this class, the user will know nothing about the other classes, and will interact only through the names of the elements/nodes.

Definition at line 61 of file Circuit.h.

Member Enumeration Documentation

◆ alphaFlag

Flag of alpha scaling parameter.

returns ALPHA_NOT_APPLIED => alpha shoud be 1 returns ALPHA_CURRENT_LIMITS => alpha is lower than one due to electric current limits of the substation returns ALPHA_VOLTAGE_LIMITS => alpha is not one due to inability of network to transfer requested power due to overhead wire resistance returns ALPHA_NOT_CONVERGING => number of allowed iterations exceeded

Enumerator
ALPHA_NOT_APPLIED 

The scaling alpha is not applied (is one)

ALPHA_CURRENT_LIMITS 

The scaling alpha is applied (is not one) due to current limits.

ALPHA_VOLTAGE_LIMITS 

The scaling alpha is applied (is not one] due to voltage limits.

ALPHA_NOT_CONVERGING 

The Newton-Rhapson method has reached maximum iterations and no solution of circuit has been found with actual value of alpha.

Definition at line 95 of file Circuit.h.

Constructor & Destructor Documentation

◆ Circuit() [1/2]

Circuit::Circuit ( )

Definition at line 597 of file Circuit.cpp.

References circuitCurrentLimit, elements, iscleaned, lastId, nodes, and voltageSources.

◆ Circuit() [2/2]

Circuit::Circuit ( double  currentLimit)

Constructor with user-specified current limit parameter.

Definition at line 606 of file Circuit.cpp.

References circuitCurrentLimit, elements, iscleaned, lastId, nodes, and voltageSources.

Member Function Documentation

◆ addElement()

◆ addNode()

Node * Circuit::addNode ( std::string  name)

◆ checkCircuit()

bool Circuit::checkCircuit ( std::string  substationId = "")

there used to be == 1 which was probably a typo ... check!

Definition at line 918 of file Circuit.cpp.

References elements, Node::getElements(), Node::getId(), getNode(), getNumVoltageSources(), Node::isGround(), nodes, toString(), voltageSources, WRITE_ERROR, and WRITE_WARNING.

◆ cleanUpSP()

void Circuit::cleanUpSP ( )

Definition at line 905 of file Circuit.cpp.

References elements, iscleaned, and voltageSources.

◆ deployResults()

◆ descreaseLastId()

void Circuit::descreaseLastId ( )
inline

Definition at line 244 of file Circuit.h.

References lastId.

Referenced by MSDevice_ElecHybrid::deleteVehicleFromCircuit(), and replaceAndDeleteNode().

Here is the caller graph for this function:

◆ detectRemovableNodes()

void Circuit::detectRemovableNodes ( std::vector< int > *  removable_ids)
private

Select removable nodes, i.e. nodes that are NOT the ground of the circuit and that have exactly two resistor elements connected. Ids of those removable nodes are added into the internal vector removable_ids.

Definition at line 777 of file Circuit.cpp.

References nodes.

◆ eraseElement()

void Circuit::eraseElement ( Element element)

Definition at line 847 of file Circuit.cpp.

References circuit_lock, elements, Node::eraseElement(), Element::getNegNode(), and Element::getPosNode().

Referenced by MSDevice_ElecHybrid::deleteVehicleFromCircuit(), and MSOverheadWire::~MSOverheadWire().

Here is the caller graph for this function:

◆ eraseNode()

void Circuit::eraseNode ( Node node)

Definition at line 75 of file Circuit.cpp.

References circuit_lock, and nodes.

Referenced by MSDevice_ElecHybrid::deleteVehicleFromCircuit(), replaceAndDeleteNode(), and MSOverheadWire::~MSOverheadWire().

Here is the caller graph for this function:

◆ getAlphaBest()

double Circuit::getAlphaBest ( )
inline

return alphaBest variable, the best alpha scaling value

Definition at line 126 of file Circuit.h.

References alphaBest.

Referenced by MSDevice_ElecHybrid::getCircuitAlpha(), and MSTractionSubstation::solveCircuit().

Here is the caller graph for this function:

◆ getAlphaReason()

alphaFlag Circuit::getAlphaReason ( )
inline

return the reason why alpha scaling value has been used

Definition at line 131 of file Circuit.h.

References alphaReason.

Referenced by MSTractionSubstation::solveCircuit().

Here is the caller graph for this function:

◆ getCurrent()

double Circuit::getCurrent ( std::string  name)

Definition at line 81 of file Circuit.cpp.

References Element::getCurrent(), and getElement().

◆ getCurrentLimit()

double Circuit::getCurrentLimit ( )
inline

@ brief Get the electric current limit of this circuit.

Definition at line 255 of file Circuit.h.

References circuitCurrentLimit.

◆ getCurrentsOfCircuitSource()

std::string & Circuit::getCurrentsOfCircuitSource ( std::string &  currents)

List of currents of voltage sources as a string.

Definition at line 178 of file Circuit.cpp.

References toString(), and voltageSources.

Referenced by MSTractionSubstation::addChargeValueForOutput().

Here is the caller graph for this function:

◆ getCurrentSources()

std::vector< Element * > * Circuit::getCurrentSources ( )

Definition at line 191 of file Circuit.cpp.

References elements.

◆ getElement() [1/2]

Element * Circuit::getElement ( int  id)
private

Definition at line 143 of file Circuit.cpp.

References elements, and getVoltageSource().

◆ getElement() [2/2]

Element * Circuit::getElement ( std::string  name)

Definition at line 129 of file Circuit.cpp.

References elements, and voltageSources.

Referenced by addElement(), deployResults(), getCurrent(), getResistance(), getVoltage(), and MSDevice_ElecHybrid::notifyMove().

Here is the caller graph for this function:

◆ getLastId()

int Circuit::getLastId ( )
inline

Definition at line 239 of file Circuit.h.

References lastId.

Referenced by MSDevice_ElecHybrid::deleteVehicleFromCircuit(), and replaceAndDeleteNode().

Here is the caller graph for this function:

◆ getNode() [1/2]

Node * Circuit::getNode ( int  id)

Definition at line 120 of file Circuit.cpp.

References nodes.

◆ getNode() [2/2]

◆ getNumVoltageSources()

int Circuit::getNumVoltageSources ( )

Definition at line 995 of file Circuit.cpp.

References voltageSources.

Referenced by checkCircuit(), and MSTractionSubstation::writeTractionSubstationOutput().

Here is the caller graph for this function:

◆ getResistance()

double Circuit::getResistance ( std::string  name)

Definition at line 103 of file Circuit.cpp.

References getElement(), and Element::getResistance().

◆ getTotalCurrentOfCircuitSources()

double Circuit::getTotalCurrentOfCircuitSources ( )

The sum of voltage source currents in the circuit.

Definition at line 169 of file Circuit.cpp.

References voltageSources.

Referenced by MSTractionSubstation::solveCircuit().

Here is the caller graph for this function:

◆ getTotalPowerOfCircuitSources()

double Circuit::getTotalPowerOfCircuitSources ( )

The sum of voltage source powers in the circuit.

Definition at line 161 of file Circuit.cpp.

References voltageSources.

Referenced by MSTractionSubstation::solveCircuit().

Here is the caller graph for this function:

◆ getVoltage()

double Circuit::getVoltage ( std::string  name)

Definition at line 89 of file Circuit.cpp.

References getElement(), getNode(), Element::getVoltage(), and Node::getVoltage().

Referenced by deployResults().

Here is the caller graph for this function:

◆ getVoltageSource()

Element * Circuit::getVoltageSource ( int  id)

Definition at line 152 of file Circuit.cpp.

References voltageSources.

Referenced by MSDevice_ElecHybrid::deleteVehicleFromCircuit(), getElement(), and replaceAndDeleteNode().

Here is the caller graph for this function:

◆ lock()

void Circuit::lock ( )

Definition at line 202 of file Circuit.cpp.

References circuit_lock.

Referenced by GUIOverheadWire::drawGL().

Here is the caller graph for this function:

◆ replaceAndDeleteNode()

void Circuit::replaceAndDeleteNode ( Node unusedNode,
Node newNode 
)

◆ setCurrentLimit()

void Circuit::setCurrentLimit ( double  myCurrentLimit)
inline

Set the electric current limit of this circuit.

RICE_CHECK: Is this identical to the current limit of a traction substation?

Definition at line 250 of file Circuit.h.

References circuitCurrentLimit.

◆ unlock()

void Circuit::unlock ( )

Definition at line 206 of file Circuit.cpp.

References circuit_lock.

Referenced by GUIOverheadWire::drawGL().

Here is the caller graph for this function:

Field Documentation

◆ alphaBest

double Circuit::alphaBest
private

Best alpha scaling value.

This parameter is used to scale down the power demands of current sources (vehicles that draw power from the circuit) so that a solution of the system can be found. Note: the system is nonlinear (quadratic), hence in some cases (typically too high power demands) a solution cannot be found. In that moment we decrease all power requirements by alpha and try to solve again, until we find alpha that ensures stable solution. This is then reported as alphaBest.

Definition at line 85 of file Circuit.h.

Referenced by getAlphaBest().

◆ alphaReason

alphaFlag Circuit::alphaReason
private

Definition at line 106 of file Circuit.h.

Referenced by getAlphaReason().

◆ circuitCurrentLimit

double Circuit::circuitCurrentLimit
private

The electric current limit of the voltage sources.

Definition at line 73 of file Circuit.h.

Referenced by Circuit(), getCurrentLimit(), and setCurrentLimit().

◆ elements

std::vector<Element*>* Circuit::elements
private

◆ iscleaned

bool Circuit::iscleaned
private

Definition at line 70 of file Circuit.h.

Referenced by Circuit(), and cleanUpSP().

◆ lastId

int Circuit::lastId
private

Definition at line 69 of file Circuit.h.

Referenced by addElement(), addNode(), Circuit(), descreaseLastId(), and getLastId().

◆ nodes

std::vector<Node*>* Circuit::nodes
private

◆ voltageSources


The documentation for this class was generated from the following files: