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

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.