#include <elementset.h>
Collaboration diagram for ElementSet:

Public Member Functions | |
| ElementSet (Circuit *circuit, const int n, const int m) | |
| ~ElementSet () | |
| Circuit * | circuit () const |
| void | addElement (Element *e) |
| void | setCacheInvalidated () |
| Matrix * | matrix () const |
| QuickVector * | b () const |
| QuickVector * | x () const |
| void | set_x (QuickVector *x) |
| bool | containsNonLinear () const |
| void | doNonLinear (int maxIterations, double maxErrorV=1e-9, double maxErrorI=1e-12) |
| bool | doLinear (bool performLU) |
| CBranch * | cbranches (const unsigned i) |
| CNode * | cnodes (const unsigned i) |
| CNode * | ground () const |
| int | cnodeCount () const |
| int | cbranchCount () const |
| void | createMatrixMap () |
| void | displayEquations () |
| void | updateInfo () |
Steps in simulation of a set of elements: (1) Create this class with given number of nodes "n" and voltage sources "m" (2) Add the various elements with addElement. (3) Call performDC() (4) Get the nodal voltages and voltage currents with x() (5) Repeat steps 3 and 4 if necessary for further transient analysis.
This class shouldn't be confused with the Circuit class, but considered a helper class to Circuit. Circuit will handle the simulation of a set of components over time. This just finds the DC-operating point of the circuit for a given set of elements.
Definition at line 50 of file elementset.h.
| ElementSet::ElementSet | ( | Circuit * | circuit, | |
| const int | n, | |||
| const int | m | |||
| ) |
Create a new circuit, with "n" nodes and "m" voltage sources. After creating the circuit, you must call setGround to specify the ground nodes, before adding any elements.
Definition at line 25 of file elementset.cpp.
References CNode::isGround.
| ElementSet::~ElementSet | ( | ) |
Destructor. Note that only the matrix and supporting data is deleted. i.e. Any elements added to the circuit will not be deleted.
Definition at line 59 of file elementset.cpp.
| Matrix* ElementSet::matrix | ( | ) | const [inline] |
Returns the matrix in use. This is created once on the creation of the ElementSet class, and deleted in the destructor, so the pointer returned will never change.
Definition at line 71 of file elementset.h.
Referenced by Circuit::doNonLogic(), and Element::setElementSet().
| QuickVector* ElementSet::b | ( | ) | const [inline] |
Returns the vector for b (i.e. the independent currents & voltages)
Definition at line 75 of file elementset.h.
Referenced by Circuit::doNonLogic(), and Element::setElementSet().
| QuickVector* ElementSet::x | ( | ) | const [inline] |
Returns the vector for x (i.e. the currents & voltages at the branches and nodes)
Definition at line 79 of file elementset.h.
Referenced by Circuit::init(), and set_x().
| bool ElementSet::containsNonLinear | ( | ) | const [inline] |
Definition at line 84 of file elementset.h.
Referenced by Circuit::containsNonLinear(), and Circuit::doNonLogic().
| void ElementSet::doNonLinear | ( | int | maxIterations, | |
| double | maxErrorV = 1e-9, |
|||
| double | maxErrorI = 1e-12 | |||
| ) |
Solves for nonlinear elements, or just does linear if it doesn't contain any nonlinear.
Definition at line 127 of file elementset.cpp.
References Matrix::fbSub(), Matrix::multiply(), Matrix::performLU(), QuickVector::size(), and updateInfo().
Referenced by Circuit::doNonLogic().
| bool ElementSet::doLinear | ( | bool | performLU | ) |
Solves for linear and logic elements.
Definition at line 186 of file elementset.cpp.
References Matrix::fbSub(), Matrix::isChanged(), QuickVector::isChanged(), Matrix::multiply(), Matrix::performLU(), QuickVector::setUnchanged(), QuickVector::size(), and updateInfo().
Referenced by Circuit::doLogic(), and Circuit::doNonLogic().
| int ElementSet::cnodeCount | ( | ) | const [inline] |
Returns the number of nodes in the circuit (excluding ground 'nodes')
Definition at line 103 of file elementset.h.
Referenced by Element::b_v().
| int ElementSet::cbranchCount | ( | ) | const [inline] |
Returns the number of voltage sources in the circuit
Definition at line 108 of file elementset.h.
| void ElementSet::displayEquations | ( | ) |
Displays the matrix equations Ax=b and J(dx)=-r
Definition at line 246 of file elementset.cpp.
References Matrix::displayLU(), and Matrix::g().
Referenced by Circuit::displayEquations().
| void ElementSet::updateInfo | ( | ) |
Update the nodal voltages and branch currents from the x vector
Definition at line 217 of file elementset.cpp.
References CBranch::i, and CNode::v.
Referenced by Circuit::cacheAndUpdate(), doLinear(), doNonLinear(), and Circuit::initCache().
1.5.1