SECircuitCalculator.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5#include "cdm/utils/SmartEnum.h"
6
7#define CIRCUIT_CALCULATOR_TEMPLATE typename CircuitType, typename NodeType, typename PathType, \
8 typename CapacitanceUnit, typename FluxUnit, typename InductanceUnit, \
9 typename PotentialUnit, typename QuantityUnit, typename ResistanceUnit
10#define CIRCUIT_CALCULATOR_TYPES CircuitType,NodeType,PathType,CapacitanceUnit,FluxUnit,InductanceUnit,PotentialUnit,QuantityUnit,ResistanceUnit
11
12class eigen; // Encapsulate eigen in pimpl pattern
13
14// These are the Eigen Solvers we can use for solving our circuits
15struct CDM_DECL EigenCircuitSolver
16{
17 enum Type { Direct, PartialPivLu, FullPivLu, JacobiSvd, HouseholderQr, Ldlt, Llt, SparseLU, SparseQR, BiCGSTAB, ConjugateGradient };
19 static char const* Value(size_t idx);
20};
21
22template<CIRCUIT_CALCULATOR_TEMPLATE>
23class CDM_DECL SECircuitCalculator : public Loggable
24{
25public:
26 SECircuitCalculator(const CapacitanceUnit& c, const FluxUnit& f, const InductanceUnit& i, const PotentialUnit& p, const QuantityUnit& q, const ResistanceUnit& r, Logger* logger);
27 virtual ~SECircuitCalculator();
28
29 virtual void SetEigenSolver(EigenCircuitSolver s){ m_solver = s; };
30 virtual void SetEigenSolver(EigenCircuitSolver::Type t) { m_solver.set(t); };
31
32 // Analysis of the Circuit dynamics
33 virtual void Process(CircuitType& circuit, double timeStep_s);
34 virtual void PostProcess(CircuitType& circuit);
35
36protected:
37 virtual void ParseIn();
38 virtual bool Solve();
39 virtual void ParseOut();
40 virtual void CalculateFluxes();
41 virtual void CalculateQuantities();
42
43 virtual void ParseInPotentialSources();
44
45 virtual void Verbose(std::string location);
46
47 // Valve Support
48 virtual bool CheckAndModifyValves(bool solverPassed);
49 virtual bool IsCurrentValveStateUnique();
50 // Eigen Support
51 virtual void PopulateAMatrix(NodeType& nKCL, PathType& p, double dMultiplier, bool hasPotentialSource = false);
52 // These are all transient and cleared/set at the start of the process call
53
54 std::stringstream m_ss;
55
56 double m_dT_s;
59 CircuitType* m_circuit;
61 std::set<uint64_t> m_valveStates;
62 std::map<PathType*, size_t> m_potentialSources;
63 std::map<NodeType*, size_t> m_blackBoxPotentialSources;
64
65 const CapacitanceUnit &m_CapacitanceUnit;
66 const FluxUnit &m_FluxUnit;
67 const InductanceUnit &m_InductanceUnit;
68 const PotentialUnit &m_PotentialUnit;
69 const QuantityUnit &m_QuantityUnit;
70 const ResistanceUnit &m_ResistanceUnit;
71
72private:
74};
Definition: Logger.h:23
Definition: Logger.h:71
Definition: SECircuitCalculator.h:24
std::map< NodeType *, size_t > m_blackBoxPotentialSources
Definition: SECircuitCalculator.h:63
double m_refPotential
Definition: SECircuitCalculator.h:58
std::map< PathType *, size_t > m_potentialSources
Definition: SECircuitCalculator.h:62
double m_currentTime_s
Definition: SECircuitCalculator.h:57
virtual void SetEigenSolver(EigenCircuitSolver::Type t)
Definition: SECircuitCalculator.h:30
const PotentialUnit & m_PotentialUnit
Definition: SECircuitCalculator.h:68
virtual void SetEigenSolver(EigenCircuitSolver s)
Definition: SECircuitCalculator.h:29
std::set< uint64_t > m_valveStates
Definition: SECircuitCalculator.h:61
std::stringstream m_ss
Definition: SECircuitCalculator.h:54
const InductanceUnit & m_InductanceUnit
Definition: SECircuitCalculator.h:67
const QuantityUnit & m_QuantityUnit
Definition: SECircuitCalculator.h:69
const FluxUnit & m_FluxUnit
Definition: SECircuitCalculator.h:66
double m_dT_s
Definition: SECircuitCalculator.h:56
const ResistanceUnit & m_ResistanceUnit
Definition: SECircuitCalculator.h:70
const CapacitanceUnit & m_CapacitanceUnit
Definition: SECircuitCalculator.h:65
CircuitType * m_circuit
Definition: SECircuitCalculator.h:59
eigen * _eigen
Definition: SECircuitCalculator.h:73
EigenCircuitSolver m_solver
Definition: SECircuitCalculator.h:60
Definition: SECircuitCalculator.cpp:30
Definition: SECircuitCalculator.h:16
SMART_ENUM(EigenCircuitSolver, Type, 11)
Type
Definition: SECircuitCalculator.h:17
@ BiCGSTAB
Definition: SECircuitCalculator.h:17

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.