Harmony
HARMONic stabilitY assessment of PE-penetrated power systems
Loading...
Searching...
No Matches
Constants.h
Go to the documentation of this file.
1
11#ifndef CONSTANTS_H
12#define CONSTANTS_H
13
14// SymEngine library for symbolic mathematics
15#include <symengine/basic.h>
16#include <symengine/symbol.h>
17#include <symengine/add.h>
18#include <symengine/mul.h>
19#include <symengine/pow.h>
20#include <symengine/real_double.h>
21#include <symengine/eval_double.h>
22#include <symengine/eval.h>
23#include <symengine/functions.h>
24#include <symengine/complex.h>
25#include <symengine/complex_double.h>
26#include <symengine/expression.h>
27#include <symengine/symengine_config.h>
28#include <symengine/matrix.h> // Ensure you include the necessary SymEngine headers
29#include <symengine/subs.h>
30#include <symengine/simplify.h>
31#include <symengine/matrices/identity_matrix.h> // identity matrix
32#include <symengine/matrices/matrix_mul.h> // matrix multiplications
33#include <symengine/matrices/matrix_add.h>
34#include <symengine/matrix_expressions.h>
35#include <symengine/matrices/immutable_dense_matrix.h>
36#include <symengine/polys/basic_conversions.h>
37#include <symengine/printers.h> // Correct header for printing
38#include <symengine/real_mpfr.h>
39
40// Eigen library for linear algebra
41#include <Eigen/Dense>
42#include <Eigen/Sparse>
43#include <unsupported/Eigen/MatrixFunctions>
44#include <unsupported/Eigen/NonLinearOptimization>
45#include <unsupported/Eigen/NumericalDiff>
46
47#define _USE_MATH_DEFINES
48#include <math.h>
49#include <string>
50#include <iostream>
51#include <fstream>
52#include <vector> // For handling matrices in multi-phase systems
53#include <complex>
54#include <stdexcept>
55#include <tuple>
56#include <variant>
57#include <algorithm>
58#include <sstream>
59#include <thread>
60#include <chrono>
61#include <any>
62#include <map>
63#include <cctype> // Include the header for std::tolower
64#include <regex>
65#include <memory>
66#include <unordered_map>
67#include <cmath>
68#include <functional>
69#include <iomanip>
70#include <filesystem>
71#include <set>
72#include <mutex>
73#include <atomic>
74#include <deque>
75#include <cstdlib>
76
77#include "gurobi_c++.h"
78
79using SymEngine::RCP;
80using SymEngine::Basic;
81using SymEngine::DenseMatrix;
82using SymEngine::integer;
83using SymEngine::mul;
84using SymEngine::symbol;
85using SymEngine::one;
86using SymEngine::ComplexDouble;
87using SymEngine::map_basic_basic;
88using SymEngine::real_double;
89using SymEngine::minus_one;
90using SymEngine::zero;
91using SymEngine::I;
92using SymEngine::complex_double;
93using SymEngine::vec_uint;
94using SymEngine::Symbol;
95using SymEngine::SymEngineException;
96using SymEngine::RealMPFR;
97
98using namespace std;
99using namespace std::complex_literals;
100using namespace Eigen;
101
113template<typename Table>
114Eigen::MatrixXd map2dense(const Table& tbl,
115 const std::vector<std::string>& colNames)
116{
117 const int nRow = static_cast<int>(tbl.size());
118 const int nCol = static_cast<int>(colNames.size());
119 Eigen::MatrixXd M(nRow, nCol);
120
121 for (const auto& [rowKey, colMap] : tbl)
122 {
123 int r = std::stoi(rowKey);
124 for (int c = 0; c < nCol; ++c)
125 {
126 auto it = colMap.find(colNames[c]);
127 M(r, c) = (it != colMap.end()) ? it->second : 0.0;
128 }
129 }
130 return M;
131}
132
133
134// Cross-platform OpenGL headers configuration (for Implot)
135#ifdef __APPLE__
136 #define GLFW_INCLUDE_GLCOREARB
137#endif
138
139// Implot
140#include <GLFW/glfw3.h>
141#include <imgui.h>
142#include <imgui_impl_glfw.h>
143#include <imgui_impl_opengl3.h>
144#include <implot.h>
145
146
147// SUNDIALS v7
148#include <sundials/sundials_types.h>
149#include <sundials/sundials_context.h>
150#include <cvode/cvode.h>
151#include <kinsol/kinsol.h>
152#include <nvector/nvector_serial.h>
153#include <sunmatrix/sunmatrix_dense.h>
154#include <sunlinsol/sunlinsol_dense.h>
155
156#endif // CONSTANTS_H
Eigen::MatrixXd map2dense(const Table &tbl, const std::vector< std::string > &colNames)
Convert a nested string-keyed table to a dense Eigen matrix.
Definition Constants.h:114