#include <SECircuitCalculator.h>
Inherits Loggable.
◆ SECircuitCalculator()
template<CIRCUIT_CALCULATOR_TEMPLATE >
SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::SECircuitCalculator |
( |
const CapacitanceUnit & |
c, |
|
|
const FluxUnit & |
f, |
|
|
const InductanceUnit & |
i, |
|
|
const PotentialUnit & |
p, |
|
|
const QuantityUnit & |
q, |
|
|
const ResistanceUnit & |
r, |
|
|
Logger * |
logger |
|
) |
| |
◆ ~SECircuitCalculator()
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ CalculateFluxes()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Calculate and set all Path Flux values.
Set fluxes that were given for Flux Sources. Set fluxes that were directly solved for Potential Sources. Calculate and set Fluxes for Paths with other Elements.
◆ CalculateQuantities()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Calculate and set all Path Quantities.
Calculate and set the Quantitys for all Paths with Compliance Elements. You need a compliance because quantity can't change in a rigid pipe.
◆ CheckAndModifyValves()
template<CIRCUIT_CALCULATOR_TEMPLATE >
bool SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::CheckAndModifyValves |
( |
bool |
solverPassed | ) |
|
|
protectedvirtual |
Check if the solutions meets all Valve criteria, and modify a Valve state if not.
- Returns
- true if the solution meets all Valve criteria, false if not
The solution passes if: 1) There is a path with a valve and flux in the wrong direction. 2) Check reverse bias (i.e. voltage must be positive at the cathode). Look at the potentials to ensure flux would be going against the diode if the "switch" (ideal diode is modeled as a switch) was closed. Since flux goes from low to high potential, the potential at the Target must be higher or equal to the Source for negative flux (against valve).
If it does not pass, change the state (Open/Close) of the first Valve that fails. The circuit will be re-solved with the new Valve state, and will iterate until a solution is found.
◆ IsCurrentValveStateUnique()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Check if the current Valve state combination has already been analyzed.
- Returns
- true if the Valve combination is unique, false if it is not.
Loop through all of the previously analyzed Valve combinations this time-step and check if the current combination is the same. If this combination is unique, store it in a vector for the next go-round to check. Valve combinations are stored as integers that use their index and state (Open = 0, Closed = 1) to calculate a unique value for every combination. The total number of possible combinations (i.e. highest value possible) is 2^(# of Valves in the Circuit). For example, if all open will be 0, no matter how many Valves are in the circuit
The lower bits are used to represent the states of the non-polarized valves. In the lexicographic ordering of all state representations, all non-polarized valve combinations are enumerated first before the polarized element combinations. This is the order in which we want to evaluate the states so this bit order is important.
◆ ParseIn()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Set up the equations to solve the circuit.
Define the state-space system, by creating the A matrix and b solution vector (Ax=b). We do all of the Modified Nodal Analysis setup steps all at once below. There are (using electrical terminology): 1) Select a reference node 2) Assign a name to the current through each voltage source. We will use the convention that the current fluxes from the positive node to the negative node of the source. 3) Apply Kirchoff's current law to each node. We will take currents out of the node to be positive. 4) Write an equation for the voltage each voltage source. 5) Solve the system of n-1 unknowns.
◆ ParseInPotentialSources()
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ ParseOut()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Assign the Solver solution vector values to the appropriate places.
Set all Node Potentials. Set Potential Source Fluxes.
◆ PopulateAMatrix()
template<CIRCUIT_CALCULATOR_TEMPLATE >
void SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::PopulateAMatrix |
( |
NodeType & |
n, |
|
|
PathType & |
p, |
|
|
double |
dMultiplier, |
|
|
bool |
hasPotentialSource = false |
|
) |
| |
|
protectedvirtual |
Add a value to the appropriate location in the A matrix.
- Parameters
-
n | The Node that is currently being analyzed. |
p | The Path that is currently being analyzed. |
dMultiplier | The value to insert in the A matrix. |
hasPotentialSource | True if the path has a Potential Source. |
Each row in the square A matrix is for the KCL analysis of a single Node. Each column is for the variables (i.e. other Nodes) in that KCL equation, and is in the same order as the rows. These should include all of the multipliers on the left side of the KCL equations.
◆ PostProcess()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Advances time.
- Parameters
-
Circuit | The circuit in question. |
vSubstances | List with the substances that are currently present in the circuit |
Move the Next circuit values to Current, and sets the Next values to the Baselines. This effectively advances time for the circuit
◆ Process()
template<CIRCUIT_CALCULATOR_TEMPLATE >
void SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::Process |
( |
CircuitType & |
circuit, |
|
|
double |
timeStep_s |
|
) |
| |
|
virtual |
Calculates the Next circuit values.
- Parameters
-
Circuit | The circuit in question. |
Take the Element values and calculate the Node and Path variables for the Next time-step.
◆ SetEigenSolver() [1/2]
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ SetEigenSolver() [2/2]
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ Solve()
template<CIRCUIT_CALCULATOR_TEMPLATE >
Solve for unknowns.
Use the Eigen solver to find the unknowns. Make sure the solution is correct.
◆ Verbose()
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ _eigen
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_blackBoxPotentialSources
template<CIRCUIT_CALCULATOR_TEMPLATE >
std::map<NodeType*, size_t> SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::m_blackBoxPotentialSources |
|
protected |
◆ m_CapacitanceUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_circuit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_currentTime_s
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_dT_s
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_FluxUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_InductanceUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_potentialSources
template<CIRCUIT_CALCULATOR_TEMPLATE >
std::map<PathType*, size_t> SECircuitCalculator< CIRCUIT_CALCULATOR_TEMPLATE >::m_potentialSources |
|
protected |
◆ m_PotentialUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_QuantityUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_refPotential
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_ResistanceUnit
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_solver
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_ss
template<CIRCUIT_CALCULATOR_TEMPLATE >
◆ m_valveStates
template<CIRCUIT_CALCULATOR_TEMPLATE >