Debian Codegraph @

avogadro/qtplugins/qtaim/qtaimlsodaintegrator.h

raw
1 /******************************************************************************
2
3 This source file is part of the Avogadro project.
4
5 Copyright (C) 2010 Eric C. Brown
6
7 This source code is released under the New BSD License, (the "License").
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14
15 ******************************************************************************/
16
17 #ifndef QTAIMLSODAINTEGRATOR_H
18 #define QTAIMLSODAINTEGRATOR_H
19
20 #include "qtaimwavefunctionevaluator.h"
21
22 #include <QDebug>
23 #include <QList>
24 #include <QPair>
25 #include <QVector3D>
26
27 #include <Eigen/Core>
28
29 #include <cmath>
30 #include <cstdio>
31
32 namespace Avogadro::QtPlugins {
33
34 class QTAIMLSODAIntegrator
35 {
36
37 public:
38 enum
39 {
40 SteepestAscentPathInElectronDensity = 0,
41 CMBPMinusThreeGradientInElectronDensity = 1,
42 CMBPMinusOneGradientInElectronDensity = 2,
43 CMBPPlusOneGradientInElectronDensity = 3,
44 CMBPPlusThreeGradientInElectronDensity = 4,
45 CMBPMinusThreeGradientInElectronDensityLaplacian = 5,
46 CMBPMinusOneGradientInElectronDensityLaplacian = 6,
47 CMBPPlusOneGradientInElectronDensityLaplacian = 7,
48 CMBPPlusThreeGradientInElectronDensityLaplacian = 8
49 };
50
51 explicit QTAIMLSODAIntegrator(QTAIMWavefunctionEvaluator& eval,
52 const qint64 mode);
53
54 QVector3D integrate(QVector3D x0y0z0);
55
56 qint64 status() const { return m_status; }
57 const QList<QVector3D> path() const { return m_path; }
58
59 void setBetaSpheres(QList<QPair<QVector3D, qreal>> betaSpheres)
60 {
61 m_betaSpheres = betaSpheres;
62 }
63 qint64 associatedSphere() const { return m_associatedSphere; }
64
65 private:
66 QTAIMWavefunctionEvaluator* m_eval;
67 qint64 m_mode;
68
69 qint64 m_status;
70 QList<QVector3D> m_path;
71
72 QList<QPair<QVector3D, qreal>> m_betaSpheres;
73 qint64 m_associatedSphere;
74
75 // LSODA integrator
76
77 void f(int neq, double t, double* y, double* ydot);
78
79 void daxpy(int n, double da, double* dx, int incx, double* dy, int incy);
80 double ddot(int n, double* dx, int incx, double* dy, int incy);
81 void dgefa(double** a, int n, int* ipvt, int* info);
82 void dgesl(double** a, int n, int* ipvt, double* b, int job);
83 void dscal(int n, double da, double* dx, int incx);
84 int idamax(int n, double* dx, int incx);
85
86 void terminate(int* istate);
87 void terminate2(double* y, double* t);
88 void successreturn(double* y, double* t, int itask, int ihit, double tcrit,
89 int* istate);
90 void lsoda(int neq, double* y, double* t, double tout, int itol, double* rtol,
91 double* atol, int itask, int* istate, int iopt, int jt, int iwork1,
92 int iwork2, int iwork5, int iwork6, int iwork7, int iwork8,
93 int iwork9, double rwork1, double rwork5, double rwork6,
94 double rwork7);
95 void stoda(int neq, double* y);
96 void ewset(int itol, double* rtol, double* atol, double* ycur);
97 void intdy(double t, int k, double* dky, int* iflag);
98 void cfode(int meth);
99 void scaleh(double* rh, double* pdh);
100 void prja(int neq, double* y);
101 double vmnorm(int n, double* v, double* w);
102 double fnorm(int n, double** a, double* w);
103 // double bnorm();
104 void correction(int neq, double* y, int* corflag, double pnorm, double* del,
105 double* delp, double* told, int* ncf, double* rh, int* m);
106 void corfailure(double* told, double* rh, int* ncf, int* corflag);
107 void solsy(double* y);
108 void methodswitch(double dsm, double pnorm, double* pdh, double* rh);
109 void endstoda();
110 void orderswitch(double* rhup, double dsm, double* pdh, double* rh,
111 int* orderflag);
112 void resetcoeff();
113 void freevectors();
114
115 /* newly added static variables */
116
117 int ml, mu, imxer;
118 int mord[3];
119 double sqrteta, *yp1, *yp2;
120 double sm1[13];
121
122 /* static variables for lsoda() */
123
124 double ccmax, el0, h, hmin, hmxi, hu, rc, tn;
125 int illin, init, mxstep, mxhnil, nhnil, ntrep, nslast, nyh, ierpj, iersl,
126 jcur, jstart, kflag, l, meth, miter, maxord, maxcor, msbp, mxncf, n, nq,
127 nst, nfe, nje, nqu;
128 double tsw, pdnorm;
129 int ixpr, jtyp, mused, mxordn, mxords;
130
131 /* no static variable for prja(), solsy() */
132 /* static variables for stoda() */
133
134 double conit, crate, el[14], elco[13][14], hold, rmax, tesco[13][4];
135 int ialth, ipup, lmax, meo, nslp;
136 double pdest, pdlast, ratio, cm1[13], cm2[6];
137 int icount, irflag;
138
139 /* static variable for block data */
140
141 int mesflg;
142
143 /* static variables for various vectors and the Jacobian. */
144
145 double **yh, **wm, *ewt, *savf, *acor;
146 int* ipvt;
147
148 int m_lenyh;
149 int m_nyh;
150 };
151
152 } // namespace Avogadro::QtPlugins
153
154 #endif // QTAIMLSODAINTEGRATOR_H