void CNetwork::AddToSystemPrimary( CEqSystem &rSystem )
{
// Add all vertices and components to the system.
CVertexList::iterator itVertex;
for ( itVertex = m_lVertices.begin();
itVertex != m_lVertices.end();
itVertex++ )
{
(*itVertex)->AddToSystemPrimary(rSystem);
}
CComponentList::iterator itComponent;
for ( itComponent = m_lComponents.begin();
itComponent != m_lComponents.end();
itComponent++ )
{
(*itComponent)->AddToSystemPrimary(rSystem);
}
}
void CVertex::AddToSystemPrimary( CEqSystem &rSystem )
{
ASSUMING ( !m_lLegs.empty() )
{
// Add unknowns for EMF and all but the last current.
// The last current is calculated to enforce
// Kirchhoff's first law.
rSystem.AddUnknown( this ); // for EMF.
LegStruct *pLastLeg = m_lLegs.back();
LegStructList::iterator itLegStruct;
for ( itLegStruct = m_lLegs.begin();
*itLegStruct != pLastLeg;
itLegStruct++ )
{
rSystem.AddUnknown( *itLegStruct );
}
}
}
void CComponentUnary::AddToSystemPrimary( CEqSystem &rSystem )
{
// A unary component adds only one equation to the system.
rSystem.AddEquation( this );
}
void CComponentBinary::AddToSystemPrimary( CEqSystem &rSystem )
{
// Add two equations, one for Kirchhoff's first
// law and another specific to the component type.
rSystem.AddEquation( (IEqEquationKirchhoff *)this );
rSystem.AddEquation( (IEqEquationEMF *)this );
}