1 #ifndef _CAPACITOR_HPP_INC_
2 #define _CAPACITOR_HPP_INC_
21 const size_t currentSolutionIndex, T timestep)
const {
27 u0 = solutionMatrix(n1p, currentSolutionIndex - 1);
31 u0 -= solutionMatrix(n2p, currentSolutionIndex - 1);
39 G_eq = 2 *
value / timestep;
42 G_eq =
value / timestep;
43 I_eq =
value * u0 / timestep;
47 stamp.
G(n1p, n1p) += G_eq;
48 stamp.
s(n1p, 0) += I_eq;
52 stamp.
G(n2p, n2p) += G_eq;
53 stamp.
s(n2p, 0) += -I_eq;
57 stamp.
G(n1p, n2p) += -G_eq;
58 stamp.
G(n2p, n1p) += -G_eq;
63 const size_t currentSolutionIndex, T timestep,
71 u0 = solutionMatrix(n1p, currentSolutionIndex - 1);
72 u1 = solutionMatrix(n1p, currentSolutionIndex);
76 u0 -= solutionMatrix(n2p, currentSolutionIndex - 1);
77 u1 -= solutionMatrix(n2p, currentSolutionIndex);
80 T G_eq = 2 *
value / timestep;
86 size_t numCurrents)
const {
89 stamp.
G(
n1 - 1,
n1 - 1) += 1e-9;
92 stamp.
G(
n2 - 1,
n2 - 1) += 1e-9;
98 size_t & numNodes,
size_t & numCurrents,
size_t & numDCCurrents) {
104 std::regex_match(line, matches, capacitorRegex);
109 capacitor.
n1 = std::stoi(matches.str(2));
110 capacitor.
n2 = std::stoi(matches.str(3));
113 numNodes = std::max(numNodes, std::stoull(matches.str(2)));
114 numNodes = std::max(numNodes, std::stoull(matches.str(3)));
116 if constexpr (std::is_same_v<T, double> || std::is_same_v<T, float>) {
117 capacitor.
value = std::stod(matches.str(4));
119 static_assert(
"Unsupported Type");
122 elements.dynamicElements.emplace_back(
126 {{capacitor.
n1,
elements.dynamicElements.back()},
127 {capacitor.
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
An ideal capacitor model.
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 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.
void addDCAnalysisStampTo(Stamp< T > &stamp, const Matrix< T > &solutionVector, size_t numCurrents) const
adds this component's DC stamp to the target stamp.
static void addToElements(const std::string &line, CircuitElements< T > &elements, size_t &numNodes, size_t &numCurrents, size_t &numDCCurrents)
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.
A matrix class with support for LU-decomposition, and left division.
A helper struct to store the preallocated stamps for MNA.