npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
HeatEq1DNeumannBoundary.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_HEATEQ1DNEUMANNBOUNDARY_HH_
2 #define NPSTAT_HEATEQ1DNEUMANNBOUNDARY_HH_
3 
4 /*!
5 // \file HeatEq1DNeumannBoundary.hh
6 //
7 // \brief Solution of 1-d heat equation with Neumann boundary conditions
8 // (no heat transfer through the boundaries). Useful mainly for
9 // generating doubly stochastic matrices.
10 //
11 // Author: I. Volobouev
12 //
13 // January 2020
14 */
15 
16 #include <vector>
17 
18 #include "npstat/nm/Matrix.hh"
19 
20 namespace npstat {
22  {
23  public:
24  /**
25  // The number of spatial discretization points, nx, must be
26  // at least 3
27  */
28  HeatEq1DNeumannBoundary(const double* thermalDiffusivity, unsigned nx,
29  double spatialStep, double dt);
30 
31  //@{
32  /** A simple inspector of object properties */
33  inline double dt() const {return dt_;}
34  inline double time() const {return dt_*cnt_;}
35  inline unsigned nCoords() const {return nx_;}
36  inline double intervalWidth() const {return intervalWidth_;}
37  //@}
38 
39  /** Evolve the system by time dt */
40  void step();
41 
42  /** Number of time steps made so far */
43  inline unsigned long nSteps() const {return cnt_;}
44 
45  /**
46  // GF standard deviation for the given coordinate index.
47  // The index should be smaller than the "nx" argument
48  // provided in the constructor.
49  */
50  double gfWidth(unsigned index) const;
51 
52  /**
53  // Note that the matrix representing the Green's Function
54  // changes after each step. To get the solution of the
55  // heat equation, multiply the GF matrix by the column of
56  // intitial conditions.
57  */
58  Matrix<double> GF() const;
59 
60  /** Transposed Green's function */
62 
63  /**
64  // Doubly stochastic approximation to the Green's function.
65  // Arguments "tol" and "maxIter" will be passed to the
66  // "makeCopulaSteps" method of the ArrayND class used to
67  // build the approximation. If "maxIter" is 0, a less reliable
68  // non-iterative method will be used that can produce some
69  // negative entries in the matrix.
70  */
71  Matrix<double> doublyStochasticGF(double tol, unsigned maxIter) const;
72 
73  /**
74  // Doubly stochastic approximation to the transposed Green's
75  // function. Arguments "tol" and "maxIter" will be passed to
76  // the "makeCopulaSteps" method of the ArrayND class used to
77  // build the approximation. If "maxIter" is 0, a less reliable
78  // non-iterative method will be used that can produce some
79  // negative entries in the matrix.
80  */
81  Matrix<double> doublyStochasticGFT(double tol, unsigned maxIter) const;
82 
83  /**
84  // Matrix representing the differencing scheme. Note that
85  // this code is rather slow as it requires O(nx^3) operations.
86  */
88 
89  /**
90  // Maximum absolute eigenvalue of the differencing scheme
91  // matrix (for use in stability analysis). Note that this
92  // code is rather slow as it requires O(nx^3) operations.
93  */
94  double maxAbsEigen() const;
95 
96  private:
98 
99  std::vector<lapack_double> gammas_;
100  std::vector<lapack_double> D_;
101  std::vector<lapack_double> DL_;
102  std::vector<lapack_double> DU_;
103  std::vector<lapack_double> DU2_;
106  std::vector<int> IPIV_;
107  double dt_;
108  double intervalWidth_;
109  unsigned long cnt_;
110  unsigned nx_;
111  };
112 }
113 
114 #endif // NPSTAT_HEATEQ1DNEUMANNBOUNDARY_HH_
Template matrix class.
Definition: HeatEq1DNeumannBoundary.hh:22
unsigned long nSteps() const
Definition: HeatEq1DNeumannBoundary.hh:43
double gfWidth(unsigned index) const
Matrix< double > GFT() const
double dt() const
Definition: HeatEq1DNeumannBoundary.hh:33
Matrix< double > GF() const
HeatEq1DNeumannBoundary(const double *thermalDiffusivity, unsigned nx, double spatialStep, double dt)
Matrix< double > doublyStochasticGFT(double tol, unsigned maxIter) const
Matrix< lapack_double > diffScheme() const
Matrix< double > doublyStochasticGF(double tol, unsigned maxIter) const
Definition: AbsArrayProjector.hh:14