MURE
Loading...
Searching...
No Matches
CRAMSolver.hxx
Go to the documentation of this file.
1/*
2 This file is part of MURE,
3 Copyright (C) 2007-2021 MURE developers.
4
5 MURE is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MURE is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MURE. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef _CRAMSolver_
20#define _CRAMSolver_
21
27#include <cstdlib>
28#include <cstring>
29#include <complex>
30#include <vector>
31#include <map>
32#include <algorithm>
33#include <iosfwd>
34#include <new>
35#include <utility>
36
37#ifdef TEST
38#include <iostream>
39#else
40#include "MUREGlobal.hxx"
41#endif
42#include "BatemanSolver.hxx"
43#include "Timer.hxx"
44
45#include <Eigen/Sparse>
46#ifdef EIGEN_SuperLU_ColMajor
47 #include <Eigen/SuperLUSupport>
48 typedef Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor> t_SpMatrix;
49 typedef vector<Eigen::SuperLU<t_SpMatrix > > t_SpMat_SolverVector;
50#elif EIGEN_UmfPackLU_ColMajor
51 #include <Eigen/UmfPackSupport>
52 typedef Eigen::SparseMatrix<std::complex<double>, Eigen::ColMajor > t_SpMatrix;
53 typedef vector< Eigen::UmfPackLU<t_SpMatrix > > t_SpMat_SolverVector;
54#else
55 // EIGEN_BiCGSTAB_RowMajor
56 #include<Eigen/IterativeLinearSolvers>
57 typedef Eigen::SparseMatrix<std::complex<double>, Eigen::RowMajor > t_SpMatrix;
58 typedef vector< Eigen::BiCGSTAB<t_SpMatrix > > t_SpMat_SolverVector;
59#endif
60
61typedef Eigen::Triplet<double> t_triplet;
62
63using namespace std;
64
65//-----------------------------------------------------------------------------//
66
68{
70 double alpha0;
71 vector<complex<double> > theta;
72 vector<complex<double> > alpha;
73};
75// matrix exponential method
83//________________________________________________________________________
84
86{
87 public:
88 CRAMSolver(string type = "IPF", int order = 48, bool aut = true);
89 // CRAMSolver(const CRAMSolver& BS); //!< Copy constructor
90 // ~CRAMSolver(); //!< Destructor
91
96 void Solve(double *N0, double **Matrix, int N, double t1, double t2) override;
97 void SetTheMatrix(double **f)
98 {
99 fTheMatrix = f;
100 }
101 void printCoeffs(int order = 0);
103 void SetNSubsteps(int n)
104 {
105 nSubsteps = n;
106 automatic = false;
107 };
108 void SetOrder(int n)
109 {
110 CRAMOrder = n;
111 automatic = false;
112 };
113
114 protected:
115
116 private:
121 void BuildEqns(double *N0, double **Matrix);
122 t_CRAMCoeff GetCRAMCoefficients(int order = 0);
124 // void IterateForSubsteps(double* N0, double** fMatrix);
125 int GetNumberSubsteps(double &N0_i, double &A_ii, double dT, int order, double sigDigits);
126 double GetSignificantDigits(double &N0_i, double &A_ii, double dT, int order, int niter);
127 int GetNeededCRAMOrder(double &N0_i, double &A_ii, double dT, double sigDigits);
128 // void GetNumberSubsteps(double& N0_i, double& A_ii, int& numberSubsteps, int& order);
129 // int GetNumberSubsteps(double& N0_i, double& A_ii);
130 void SetOptimalStrategy(double *N0, double **fMatrix);
131 // int GetNeededCRAMOrder(double& N0_i, double& A_ii);
132 int GetNearestCRAMOrder(int order);
133 double GetLG10(double &n0, double &A_ii, double dT, int nT);
134 void CleanUp();
136
139 string CRAMType;
142 double **fTheMatrix;
146 Timer HPTimer; // high precision C++ timer
147 const double cutoff = 1e-20;
148 const double significantDigits = 10;
149 const int maxorder = 48;
150 bool automatic = false;
152 static const vector<int> fCramOrder;
153 static const vector<t_CRAMCoeff> CRAMCoeff;
154};
155#endif
Header file for BatemanSolver class.
Eigen::SparseMatrix< std::complex< double >, Eigen::RowMajor > t_SpMatrix
Definition CRAMSolver.hxx:57
vector< Eigen::BiCGSTAB< t_SpMatrix > > t_SpMat_SolverVector
Definition CRAMSolver.hxx:58
Eigen::Triplet< double > t_triplet
Definition CRAMSolver.hxx:61
Base class of Bateman-type solvers like Runge-Kutta or CRAM or any other.
Definition BatemanSolver.hxx:45
Base class of Bateman-type solvers like Runge-Kutta or CRAM or any other.
Definition CRAMSolver.hxx:86
int GetNearestCRAMOrder(int order)
Definition CRAMSolver.cxx:696
int nSubsteps
Definition CRAMSolver.hxx:145
void SetOrder(int n)
Definition CRAMSolver.hxx:108
void Solve(double *N0, double **Matrix, int N, double t1, double t2) override
Abstract method to Solve Bateman equation : must be overriden.
Definition CRAMSolver.cxx:467
void SetOptimalStrategy(double *N0, double **fMatrix)
Definition CRAMSolver.cxx:594
double ** fTheMatrix
The evolution Matrix.
Definition CRAMSolver.hxx:142
void CleanUp()
Definition CRAMSolver.cxx:516
double GetSignificantDigits(double &N0_i, double &A_ii, double dT, int order, int niter)
Definition CRAMSolver.cxx:648
string SparseSolver
Definition CRAMSolver.hxx:140
Timer HPTimer
Definition CRAMSolver.hxx:146
int CRAMOrder
Definition CRAMSolver.hxx:141
t_SpMat_SolverVector CRAMSpMatSolver
Definition CRAMSolver.hxx:137
int GetNumberSubsteps(double &N0_i, double &A_ii, double dT, int order, double sigDigits)
Definition CRAMSolver.cxx:655
t_CRAMCoeff GetCRAMCoefficients(int order=0)
Definition CRAMSolver.cxx:713
int GetNeededCRAMOrder(double &N0_i, double &A_ii, double dT, double sigDigits)
Definition CRAMSolver.cxx:639
bool automatic
Definition CRAMSolver.hxx:150
t_SpMat_SolverVector GetSparseLUSolvers()
Definition CRAMSolver.cxx:689
const double significantDigits
Definition CRAMSolver.hxx:148
double CRAMDeltaTsubstep
Definition CRAMSolver.hxx:144
t_CRAMCoeff CRAMCoefficients
Definition CRAMSolver.hxx:138
void SetNSubsteps(int n)
Definition CRAMSolver.hxx:103
void BuildEqns(double *N0, double **Matrix)
Setup Eigen3 solver, compute inverse matrices.
Definition CRAMSolver.cxx:521
static const vector< t_CRAMCoeff > CRAMCoeff
Definition CRAMSolver.hxx:153
void printCoeffs(int order=0)
Definition CRAMSolver.cxx:739
const int maxorder
Definition CRAMSolver.hxx:149
double GetLG10(double &n0, double &A_ii, double dT, int nT)
Definition CRAMSolver.cxx:664
void SetTheMatrix(double **f)
Definition CRAMSolver.hxx:97
static const vector< int > fCramOrder
Definition CRAMSolver.hxx:152
bool fBuildEqns
Definition CRAMSolver.hxx:151
string CRAMType
Definition CRAMSolver.hxx:139
double CRAMDeltaT
Definition CRAMSolver.hxx:143
const double cutoff
Definition CRAMSolver.hxx:147
Definition Timer.hxx:24
the namespace of the Standard C++
Definition CRAMSolver.hxx:68
double alpha0
Definition CRAMSolver.hxx:70
vector< complex< double > > alpha
Definition CRAMSolver.hxx:72
vector< complex< double > > theta
Definition CRAMSolver.hxx:71
int CramOrderDiv2
Definition CRAMSolver.hxx:69

MURE Project, documentation generated by Doxygen 1.9.7 - Fri Jan 19 2024