1 #ifndef _SINUSOIDALVOLTAGESOURCE_INC_
2 #define _SINUSOIDALVOLTAGESOURCE_INC_
23 const size_t currentSolutionIndex, T timestep)
const {
29 stamp.
G(n1p, stamp.
sizeG_A + currentIndexp) += 1;
30 stamp.
G(stamp.
sizeG_A + currentIndexp, n1p) += 1;
34 stamp.
G(n2p, stamp.
sizeG_A + currentIndexp) += -1;
35 stamp.
G(stamp.
sizeG_A + currentIndexp, n2p) += -1;
39 stamp.
s(stamp.
sizeG_A + currentIndexp,
41 currentSolutionIndex * timestep +
44 stamp.
s(stamp.
sizeG_A + currentIndexp,
46 currentSolutionIndex * timestep +
52 const size_t currentSolutionIndex, T timestep,
57 size_t numCurrents)
const {
63 size_t & numNodes,
size_t & numCurrents,
size_t & numDCCurrents) {
71 std::regex_match(line, matches, sinusoidalVoltageSourceRegex);
76 voltageSource.
n1 = std::stoi(matches.str(2));
77 voltageSource.
n2 = std::stoi(matches.str(3));
79 numNodes = std::max(numNodes, std::stoull(matches.str(2)));
80 numNodes = std::max(numNodes, std::stoull(matches.str(3)));
82 if constexpr (std::is_same_v<T, double> || std::is_same_v<T, float>) {
83 voltageSource.
V = std::stod(matches.str(4));
85 static_assert(
"Unsupported Type");
88 if (matches.size() > 4 && matches.str(5) !=
"") {
89 voltageSource.
frequency = std::stod(matches.str(5));
92 if (matches.size() > 5 && matches.str(6) !=
"") {
93 voltageSource.
offset = std::stod(matches.str(6));
96 if (matches.size() > 6 && matches.str(7) !=
"") {
97 voltageSource.
phase = std::stod(matches.str(7));
102 elements.dynamicElements.emplace_back(
105 {{voltageSource.
n1,
elements.dynamicElements.back()},
106 {voltageSource.
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.
A matrix class with support for LU-decomposition, and left division.
A sinusoidal voltage source model.
static void addToElements(const std::string &line, CircuitElements< T > &elements, size_t &numNodes, size_t &numCurrents, size_t &numDCCurrents)
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.
A helper struct to store the preallocated stamps for MNA.