1 #ifndef _RESISTOR_HPP_INC_
2 #define _RESISTOR_HPP_INC_
27 T conductance = 1 /
value;
30 stamp.
G(n1p, n1p) += conductance;
33 stamp.
G(n2p, n2p) += conductance;
36 stamp.
G(n1p, n2p) += -conductance;
37 stamp.
G(n2p, n1p) += -conductance;
41 stamp.
G(n1p, stamp.
sizeG_A + currentIndexp) += 1;
42 stamp.
G(stamp.
sizeG_A + currentIndexp, n1p) += 1;
45 stamp.
G(n2p, stamp.
sizeG_A + currentIndexp) += -1;
46 stamp.
G(stamp.
sizeG_A + currentIndexp, n2p) += -1;
49 stamp.
G(stamp.
sizeG_A + currentIndexp,
55 size_t numCurrents)
const {
61 size_t & numNodes,
size_t & numCurrents,
size_t & numDCCurrents) {
69 std::regex_match(line, matches, resistorRegex);
74 resistor.
n1 = std::stoi(matches.str(2));
75 resistor.
n2 = std::stoi(matches.str(3));
77 numNodes = std::max(numNodes, std::stoull(matches.str(2)));
78 numNodes = std::max(numNodes, std::stoull(matches.str(3)));
80 if constexpr (std::is_same_v<T, double> || std::is_same_v<T, float>) {
81 resistor.
value = std::stod(matches.str(4));
83 static_assert(
"Unsupported Type");
86 if (matches.size() < 6 && matches.str(5) !=
"") {
93 elements.staticElements.emplace_back(
97 {{resistor.
n1,
elements.staticElements.back()},
98 {resistor.
n2,
elements.staticElements.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.
A matrix class with support for LU-decomposition, and left division.
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)
void addStaticStampTo(Stamp< T > &stamp) const
Adds this component's static stamp to the target stamp.
A helper struct to store the preallocated stamps for MNA.