1 #ifndef _INDUCTOR_HPP_INC_
2 #define _INDUCTOR_HPP_INC_
23 const size_t currentSolutionIndex, T timestep)
const {
29 u0 = solutionMatrix(n1p, currentSolutionIndex - 1);
33 u0 -= solutionMatrix(n2p, currentSolutionIndex - 1);
41 G_eq = timestep / (2 *
value);
44 G_eq = timestep / timestep;
49 stamp.
G(n1p, n1p) += G_eq;
50 stamp.
s(n1p, 0) += -I_eq;
54 stamp.
G(n2p, n2p) += G_eq;
55 stamp.
s(n2p, 0) += I_eq;
59 stamp.
G(n1p, n2p) += -G_eq;
60 stamp.
G(n2p, n1p) += -G_eq;
65 const size_t currentSolutionIndex, T timestep,
72 u0 = solutionMatrix(n1p, currentSolutionIndex - 1);
73 u1 = solutionMatrix(n1p, currentSolutionIndex);
77 u0 -= solutionMatrix(n2p, currentSolutionIndex - 1);
78 u1 -= solutionMatrix(n2p, currentSolutionIndex);
82 T G_eq = timestep / (2 *
value);
85 T G_eq = timestep /
value;
96 size_t numCurrents)
const {
103 stamp.
G(n1p, stamp.
sizeG_A + numCurrents + dcCurrentIndexp) += 1;
104 stamp.
G(stamp.
sizeG_A + numCurrents + dcCurrentIndexp, n1p) += 1;
108 stamp.
G(n2p, stamp.
sizeG_A + numCurrents + dcCurrentIndexp) += -1;
109 stamp.
G(stamp.
sizeG_A + numCurrents + dcCurrentIndexp, n2p) += -1;
115 size_t & numNodes,
size_t & numCurrents,
size_t & numDCCurrents) {
121 std::regex_match(line, matches, inductorRegex);
126 inductor.
n1 = std::stoi(matches.str(2));
127 inductor.
n2 = std::stoi(matches.str(3));
131 numNodes = std::max(numNodes, std::stoull(matches.str(2)));
132 numNodes = std::max(numNodes, std::stoull(matches.str(3)));
134 if constexpr (std::is_same_v<T, double> || std::is_same_v<T, float>) {
135 inductor.
value = std::stod(matches.str(4));
137 static_assert(
"Unsupported Type");
140 elements.dynamicElements.emplace_back(
144 {{inductor.
n1,
elements.dynamicElements.back()},
145 {inductor.
n2,
elements.dynamicElements.back()}});
std::regex generateRegex(std::string indentifier, std::string simplifiedMatching, bool startAnchor=true, bool endAnchor=true)
a helper function to aid in the construction of regexes for parsing netlist files
common weighting for all matrix elements
a glorified container for the different types of components.
A template base class to define the fundamental things a component should define.
std::string designator
The designator as in the netlist for e.g.
static void addToElements(const std::string &line, CircuitElements< T > &elements, size_t &numNodes, size_t &numCurrents, size_t &numDCCurrents)
void addDCAnalysisStampTo(Stamp< T > &stamp, const Matrix< T > &solutionVector, size_t numCurrents) const
adds this component's DC stamp to the target stamp.
void updateStoredState(const Matrix< T > &solutionMatrix, const size_t currentSolutionIndex, T timestep, size_t sizeG_A)
Updates any stored state based on the current solution index.
void updateDCStoredState(const Matrix< T > &solutionVector, size_t sizeG_A, size_t numCurrents)
a function to update the stored state of a component based on a DC value
void addDynamicStampTo(Stamp< T > &stamp, const Matrix< T > &solutionMatrix, const size_t currentSolutionIndex, T timestep) const
Adds this component's dynamic stamp to the target stamp.
A matrix class with support for LU-decomposition, and left division.
A helper struct to store the preallocated stamps for MNA.