Skip to content

Commit 36cbd46

Browse files
committed
Added the complex absorbing potential in DVR calculations
1 parent b943d92 commit 36cbd46

File tree

5 files changed

+43
-12
lines changed

5 files changed

+43
-12
lines changed

src/dyn/wfcgrid2/Wfcgrid2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ void Wfcgrid2::allocate(){
114114

115115
Hdia = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< diabatic Hamiltoninans for all the Npts points
116116
Hadi = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< adiabatic Hamiltoninans for all the Npts points
117+
Vcomplex = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< complex absorbing potential
117118
U = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< |adi> = |dia> * U : diabatic-to-adiabatic transformation for all the Npts points
118119
expH = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< exponent of the diabatic Hamiltoninans for all the Npts points
119120
expK = vector<CMATRIX>(Npts, CMATRIX(nstates, nstates)); ///< exponent of the kinetic energy propagator for all the Npts points

src/dyn/wfcgrid2/Wfcgrid2.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class Wfcgrid2{
134134
/// Hamiltonian and Propagator
135135
vector<CMATRIX> Hdia; ///< diabatic Hamiltoninans for all the Npts points
136136
vector<CMATRIX> Hadi; ///< adiabatic Hamiltoninans for all the Npts points
137+
vector<CMATRIX> Vcomplex; ///< complex absorbing potential that will be added to the real-space propagator
137138
vector< vector<CMATRIX> > NAC1; ///< 1-st order NACS: NAC1[ipt][alpha].get(i,j) = <psi_i| nabla_alpha | psi_j>
138139
vector< vector<CMATRIX> > NAC2; ///< 2-nd order NACS: NAC2[ipt][alpha].get(i,j) = <psi_i| nabla_alpha^2 | psi_j>
139140
vector<CMATRIX> U; ///< |adi> = |dia> * U : diabatic-to-adiabatic transformation for all the Npts points
@@ -231,6 +232,7 @@ class Wfcgrid2{
231232
///< Precompute Hamiltonian on the grid
232233
void update_Hamiltonian(bp::object py_funct, bp::object params, int rep);
233234

235+
234236
///< Convert diabatic and adiabatic wfc into one another
235237
void update_adiabatic();
236238
void update_diabatic();

src/dyn/wfcgrid2/Wfcgrid2_SOFT.cpp

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,40 +36,59 @@ using namespace libmeigen;
3636

3737
void Wfcgrid2::update_propagator_H(double dt){
3838
/**
39-
\brief Update the Hamiltonian for nd-D grid
39+
\brief Update the exp(-i*dt*Hamiltonian) for nd-D grid
4040
4141
Should have called ```update_Hamiltonian``` prior to this
4242
43+
H * U = U * E => H = U * E * U^+
44+
45+
exp(-i*dt*H) = U * exp(-i*dt*E) * U^+
46+
47+
exp(-i*dt*E) = exp(-i * dt * [Re(E)+i*Im(E)]) = exp(-i*dt*Re(E)) * exp(dt*Im(E))
48+
----- ex ------- ---- scl ----
49+
50+
ex = cos(dt*Re(E)) - i * sin(dt*Re(E))
4351
*/
4452

4553
int nst, nst1;
4654

4755
CMATRIX S(nstates, nstates); S.Init_Unit_Matrix(1.0);
48-
CMATRIX si(nstates, nstates); // sin(-dt*E), where E is adiabatic Ham.
49-
CMATRIX cs(nstates, nstates); // cos(-dt*E), where E is adiabatic Ham.
56+
// CMATRIX si(nstates, nstates); // sin(dt*E), where E is adiabatic Ham.
57+
// CMATRIX cs(nstates, nstates); // cos(dt*E), where E is adiabatic Ham.
58+
// CMATRIX ex(nstates, nstates); // exp()
5059

5160
complex<double> one(1.0, 0.0);
5261
complex<double> eye(0.0, 1.0);
62+
//complex<double> ex(0.0, 0.0);
63+
double scl = 1.0;
64+
double si, cs;
5365

5466
// For all grid points
5567
for(int npt1=0; npt1<Npts; npt1++){
5668

5769
// Transformation to adiabatic basis
5870
// Hdia * U = S * U * Hadi
5971
solve_eigen(Hdia[npt1], S, Hadi[npt1], U[npt1], 0);
60-
61-
cs = 0.0; si = 0.0;
72+
73+
// cs = 0.0; si = 0.0;
6274
for(int nst=0;nst<nstates;nst++){
63-
cs.set(nst, nst, std::cos(-dt*Hadi[npt1].get(nst, nst)) * one );
64-
si.set(nst, nst, std::sin(-dt*Hadi[npt1].get(nst, nst)) * one );
75+
//cs.set(nst, nst, std::cos(dt*Hadi[npt1].get(nst, nst)) * one );
76+
//si.set(nst, nst, std::sin(dt*Hadi[npt1].get(nst, nst)) * one );
77+
cs = std::cos( dt*( Hadi[npt1].get(nst, nst).real() + Vcomplex[npt1].get(nst, nst).real() ) );
78+
si = std::sin( dt*( Hadi[npt1].get(nst, nst).real() + Vcomplex[npt1].get(nst, nst).real() ) );
79+
scl = std::exp(dt*( Hadi[npt1].get(nst, nst).imag() + Vcomplex[npt1].get(nst, nst).imag() ) );
80+
81+
complex<double> ex(cs, -si);
82+
expH[npt1].set(nst, nst, scl * ex);
6583
}
6684

6785
// Transform cs and si according to matrix U:
68-
cs = U[npt1] * cs * U[npt1].H();
69-
si = U[npt1] * si * U[npt1].H();
86+
//cs = U[npt1] * cs * U[npt1].H();
87+
//si = U[npt1] * si * U[npt1].H();
88+
expH[npt1] = U[npt1] * expH[npt1] * U[npt1].H();
7089

7190
// Finally construct complex exp(-i*dt*H) matrix from the cs and si matrices
72-
expH[npt1] = cs + eye*si;
91+
//expH[npt1] = cs - eye*si;
7392

7493

7594
}// for npt1
@@ -78,6 +97,7 @@ void Wfcgrid2::update_propagator_H(double dt){
7897

7998

8099

100+
81101
void Wfcgrid2::update_propagator_K(double dt, vector<double>& mass){
82102
/**
83103
\brief Update reciprocal-space propagators for nd-D grid

src/dyn/wfcgrid2/Wfcgrid2_updates.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*********************************************************************************
2-
* Copyright (C) 2019 Alexey V. Akimov
2+
* Copyright (C) 2019-2022 Alexey V. Akimov
33
*
44
* This file is distributed under the terms of the GNU General Public License
5-
* as published by the Free Software Foundation, either version 2 of
5+
* as published by the Free Software Foundation, either version 3 of
66
* the License, or (at your option) any later version.
77
* See the file LICENSE in the root directory of this distribution
88
* or <http://www.gnu.org/licenses/>.
@@ -58,6 +58,11 @@ void Wfcgrid2::update_Hamiltonian(bp::object py_funct, bp::object params, int re
5858
bp::object obj = py_funct(bp::object(q), params);
5959

6060

61+
// Try extract the adiabatic Hamiltonian
62+
has_attr = (int)hasattr(obj,"v_complex");
63+
if(has_attr){ Vcomplex[npt1] = extract<CMATRIX>(obj.attr("v_complex")); }
64+
65+
6166
if(rep==0){
6267

6368
// Try to extract the diabatic Hamiltonian
@@ -90,6 +95,8 @@ void Wfcgrid2::update_Hamiltonian(bp::object py_funct, bp::object params, int re
9095

9196

9297

98+
99+
93100
void Wfcgrid2::update_adiabatic(){
94101
/**
95102
Update the adiabatic wfc from the diabatic: DIA -> ADI

src/dyn/wfcgrid2/libwfcgrid2.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ void export_Wfcgrid2_objects(){
151151

152152
.def_readwrite("Hdia", &Wfcgrid2::Hdia)
153153
.def_readwrite("Hadi", &Wfcgrid2::Hadi)
154+
.def_readwrite("Vcomplex", &Wfcgrid2::Vcomplex)
154155
.def_readwrite("NAC1", &Wfcgrid2::NAC1)
155156
.def_readwrite("NAC2", &Wfcgrid2::NAC2)
156157
.def_readwrite("U", &Wfcgrid2::U)

0 commit comments

Comments
 (0)