Skip to content

Commit 334d449

Browse files
committed
Merge branch 'devel'
2 parents ac57c3e + a0ca30a commit 334d449

28 files changed

+1396
-271
lines changed

src/dyn/Dynamics.cpp

Lines changed: 224 additions & 56 deletions
Large diffs are not rendered by default.

src/dyn/Energy_and_Forces.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ void update_forces(dyn_control_params& prms, dyn_variables& dyn_vars, nHamiltoni
316316
prms.electronic_integrator==12 ){ option = 1; }
317317

318318
option = 0;
319-
*dyn_vars.f = ham.Ehrenfest_forces_adi(*dyn_vars.ampl_adi, 1, option, dyn_vars.proj_adi).real();
319+
//*dyn_vars.f = ham.Ehrenfest_forces_adi(*dyn_vars.ampl_adi, 1, option, dyn_vars.proj_adi).real();
320+
*dyn_vars.f = ham.Ehrenfest_forces_adi(*dyn_vars.ampl_adi, 1, option).real();
320321
/*
321322
CMATRIX& U = *ham.basis_transform;
322323
CMATRIX& C = *dyn_vars.ampl_adi;

src/dyn/dyn_control_params.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ dyn_control_params::dyn_control_params(){
5252
do_ssy = 0;
5353
do_phase_correction = 1;
5454
phase_correction_tol = 1e-3;
55-
state_tracking_algo = 2;
55+
state_tracking_algo = -1;
5656
MK_alpha = 0.0;
5757
MK_verbosity = 0;
5858
convergence = 0;
@@ -79,10 +79,14 @@ dyn_control_params::dyn_control_params(){
7979
collapse_option = 0;
8080
decoherence_rates = NULL;
8181
ave_gaps = NULL;
82-
wp_width = 0.1;
82+
wp_width = NULL;
83+
wp_v = NULL;
8384
coherence_threshold = 0.01;
85+
e_mask = 0.0001;
8486
use_xf_force = 0;
8587
project_out_aux = 0;
88+
tp_algo = 1;
89+
use_td_width = 0;
8690

8791
///================= Entanglement of trajectories ================================
8892
entanglement_opt = 0;
@@ -104,6 +108,7 @@ dyn_control_params::dyn_control_params(){
104108
dt = 41.0;
105109
num_electronic_substeps = 1;
106110
electronic_integrator = 0;
111+
ampl_transformation_method = 1;
107112
assume_always_consistent = 0;
108113

109114
thermally_corrected_nbra = 0;
@@ -158,10 +163,17 @@ dyn_control_params::dyn_control_params(const dyn_control_params& x){
158163
dephasing_informed = x.dephasing_informed;
159164
instantaneous_decoherence_variant = x.instantaneous_decoherence_variant;
160165
collapse_option = x.collapse_option;
161-
wp_width = x.wp_width;
166+
167+
wp_width = new MATRIX( x.wp_width->n_rows, x.wp_width->n_cols );
168+
*wp_width = *x.wp_width;
169+
wp_v = new MATRIX( x.wp_v->n_rows, x.wp_v->n_cols );
170+
*wp_v = *x.wp_v;
162171
coherence_threshold = x.coherence_threshold;
172+
e_mask = x.e_mask;
163173
use_xf_force = x.use_xf_force;
164174
project_out_aux = x.project_out_aux;
175+
tp_algo = x.tp_algo;
176+
use_td_width = x.use_td_width;
165177

166178
///================= Entanglement of trajectories ================================
167179
entanglement_opt = x.entanglement_opt;
@@ -184,6 +196,7 @@ dyn_control_params::dyn_control_params(const dyn_control_params& x){
184196
dt = x.dt;
185197
num_electronic_substeps = x.num_electronic_substeps;
186198
electronic_integrator = x.electronic_integrator;
199+
ampl_transformation_method = x.ampl_transformation_method;
187200
assume_always_consistent = x. assume_always_consistent;
188201

189202
decoherence_rates = new MATRIX(x.decoherence_rates->n_rows, x.decoherence_rates->n_cols);
@@ -206,6 +219,8 @@ dyn_control_params::~dyn_control_params() {
206219

207220
//cout<<"dyn_control_params destructor\n";
208221

222+
delete wp_width;
223+
delete wp_v;
209224
delete decoherence_rates;
210225
delete ave_gaps;
211226
delete schwartz_decoherence_inv_alpha;
@@ -215,7 +230,8 @@ dyn_control_params::~dyn_control_params() {
215230
void dyn_control_params::sanity_check(){
216231

217232
///=================== Options for state tracking ======================
218-
if(state_tracking_algo==0 || state_tracking_algo==1 ||
233+
if(state_tracking_algo==-1 ||
234+
state_tracking_algo==0 || state_tracking_algo==1 ||
219235
state_tracking_algo==2 || state_tracking_algo==3 ||
220236
state_tracking_algo==32 || state_tracking_algo==33){ ; ; }
221237
else{
@@ -343,10 +359,26 @@ void dyn_control_params::set_parameters(bp::dict params){
343359
for(int b=0;b<x.n_cols;b++){ ave_gaps->set(a, b, x.get(a,b)); }
344360
}
345361
}
346-
else if(key=="wp_width"){ wp_width = bp::extract<double>(params.values()[i]); }
362+
else if(key=="wp_width"){
363+
MATRIX x( bp::extract<MATRIX>(params.values()[i]) );
364+
wp_width = new MATRIX(x.n_rows, x.n_cols);
365+
for(int a=0;a<x.n_rows;a++){
366+
for(int b=0;b<x.n_cols;b++){ wp_width->set(a, b, x.get(a,b)); }
367+
}
368+
}
369+
else if(key=="wp_v"){
370+
MATRIX x( bp::extract<MATRIX>(params.values()[i]) );
371+
wp_v = new MATRIX(x.n_rows, x.n_cols);
372+
for(int a=0;a<x.n_rows;a++){
373+
for(int b=0;b<x.n_cols;b++){ wp_v->set(a, b, x.get(a,b)); }
374+
}
375+
}
347376
else if(key=="coherence_threshold"){ coherence_threshold = bp::extract<double>(params.values()[i]); }
377+
else if(key=="e_mask"){ e_mask = bp::extract<double>(params.values()[i]); }
348378
else if(key=="use_xf_force"){ use_xf_force = bp::extract<int>(params.values()[i]); }
349379
else if(key=="project_out_aux"){ project_out_aux = bp::extract<int>(params.values()[i]); }
380+
else if(key=="tp_algo"){ tp_algo = bp::extract<int>(params.values()[i]); }
381+
else if(key=="use_td_width"){ use_td_width = bp::extract<int>(params.values()[i]); }
350382

351383
///================= Entanglement of trajectories ================================
352384
else if(key=="entanglement_opt"){ entanglement_opt = bp::extract<int>(params.values()[i]); }
@@ -378,6 +410,7 @@ void dyn_control_params::set_parameters(bp::dict params){
378410
else if(key=="dt") { dt = bp::extract<double>(params.values()[i]); }
379411
else if(key=="num_electronic_substeps") { num_electronic_substeps = bp::extract<int>(params.values()[i]); }
380412
else if(key=="electronic_integrator"){ electronic_integrator = bp::extract<int>(params.values()[i]); }
413+
else if(key=="ampl_transformation_method"){ ampl_transformation_method = bp::extract<int>(params.values()[i]); }
381414
else if(key=="assume_always_consistent"){ assume_always_consistent = bp::extract<int>(params.values()[i]); }
382415

383416
else if(key=="thermally_corrected_nbra"){ thermally_corrected_nbra = bp::extract<int>(params.values()[i]); }

src/dyn/dyn_control_params.h

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ class dyn_control_params{
244244

245245
/**
246246
State tracking algorithm:
247+
- -1: use LD approach, it includes phase correction too [ default ]
247248
- 0: no state tracking
248249
- 1: method of Kosuke Sato (may fail by getting trapped into an infinite loop)
249-
- 2: Munkres-Kuhn (Hungarian) algorithm [ default ]
250+
- 2: Munkres-Kuhn (Hungarian) algorithm
250251
- 3: experimental stochastic algorithm, the original version with elimination (known problems)
251252
- 32: experimental stochastic algorithms with all permutations (too expensive)
252253
- 33: the improved stochastic algorithm with good scaling and performance, on par with the mincost
@@ -389,6 +390,7 @@ class dyn_control_params{
389390
- 5: SHXF of Min
390391
- 6: MQCXF
391392
- 7: DISH, rev2023
393+
- 8: diabatic IDA, experimental
392394
393395
*/
394396
double decoherence_algo;
@@ -464,8 +466,13 @@ class dyn_control_params{
464466
only used with decoherence_algo == 1
465467
466468
- 0: ID-S
467-
- 1: ID-A [default]
469+
- 1: ID-A [default] - if the proposed hop is not successful, we project back to the initial state
470+
if the proposed hop is accepted - we project onto that state
468471
- 2: ID-C - consistent ID - an experimental algorithm
472+
- 3: ID-A, new: if the proposed hop is not successful, we project out the proposed states
473+
if the proposed hop is accepted - we project onto that state
474+
- 4: ID-F, new: if the proposed hop is not successful, we project out the proposed states
475+
but we don't do anything if the hop is successful
469476
*/
470477
int instantaneous_decoherence_variant;
471478

@@ -496,31 +503,71 @@ class dyn_control_params{
496503

497504

498505
/**
499-
The width of frozen Gaussian for the decoherence from SHXF & MQCXF
500-
[ default : 0.1 ]
506+
MATRIX(ndof, 1) of (initial) wave packet widths for the decoherence from SHXF & MQCXF
507+
[ default : NULL ]
501508
*/
502-
double wp_width;
509+
MATRIX* wp_width;
510+
511+
512+
/**
513+
MATRIX(ndof, 1) of wave packet velocities for the decoherence from SHXF & MQCXF
514+
This value is applied when use_td_width = 1
515+
[ default : NULL ]
516+
*/
517+
MATRIX* wp_v;
503518

504519

505520
/**
506521
The criterion whether the electronic state is in a coherence
507522
[ default : 0.01 ]
508523
*/
509524
double coherence_threshold;
510-
525+
526+
527+
/**
528+
The masking parameter for computing nabla phase vectors in the MQCXF
529+
[ default : 0.0001 ]
530+
*/
531+
double e_mask;
532+
533+
511534
/**
512535
Whether to use the decoherence force in MQCXF
513536
The corresponding electronic propagation is adjusted for the energy conservation
514537
[ default : 0 ]
515538
*/
516539
int use_xf_force;
517540

541+
518542
/**
519543
Whether to project out the density on an auxiliary trajectory when its motion is classically forbidden
520544
[ default : 0 ]
521545
*/
522546
int project_out_aux;
523547

548+
549+
/**
550+
Turning-point algorithm for auxiliary trajectories
551+
552+
Options:
553+
- 0: no treatment of a turning point
554+
- 1: collapse to the active state [default]
555+
- 2: fix auxiliary positions of adiabatic states except for the active state
556+
- 3: keep auxiliary momenta of adiabatic states except for the active state
557+
*/
558+
int tp_algo;
559+
560+
561+
/**
562+
Whether to use the td Gaussian width for the nuclear wave packet approximation
563+
This option can be considered when it comes to unbounded systems.
564+
This approximation is based on a nuclear wave packet on a free surface:
565+
\sigma_x(t)=\sqrt[\sigma_x(0)^2 + (wp_v * t)^2]
566+
[ default : 0 ]
567+
*/
568+
int use_td_width;
569+
570+
524571
/**
525572
A flag for NBRA calculations. Since in NBRA, the Hamiltonian is the same for all the trajectories
526573
we can only compute the Hamiltonian related properties once for one trajectory and increase the speed of calculations.
@@ -695,6 +742,14 @@ class dyn_control_params{
695742
*/
696743
int electronic_integrator;
697744

745+
746+
/**
747+
Whether transform the amplitudes by the T transformation matrix
748+
0 - do not transform by the T matrix (naive, but potentially correct approach)
749+
1 - do transform it (as in LD, but maybe not needed if we directly transform basis)
750+
*/
751+
int ampl_transformation_method;
752+
698753

699754
/**
700755
If set to True (1), we will force the reprojection matrix T_new to be the identity matrix. This effectively

src/dyn/dyn_decoherence.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ void instantaneous_decoherence(CMATRIX& Coeff,
5454
vector<int>& accepted_states, vector<int>& proposed_states, vector<int>& initial_states,
5555
int instantaneous_decoherence_variant, int collapse_option);
5656

57+
void instantaneous_decoherence_dia(CMATRIX& Coeff, nHamiltonian& ham,
58+
vector<int>& accepted_states, vector<int>& proposed_states, vector<int>& initial_states,
59+
int instantaneous_decoherence_variant, int collapse_option);
5760

5861
CMATRIX afssh_dzdt(CMATRIX& dz, CMATRIX& Hvib, CMATRIX& F, CMATRIX& C, double mass, int act_state);
5962
void integrate_afssh_moments(CMATRIX& dR, CMATRIX& dP, CMATRIX& Hvib, CMATRIX& F, CMATRIX& C, double mass, int act_state, double dt, int nsteps);
@@ -72,13 +75,15 @@ CMATRIX mfsd(MATRIX& p, CMATRIX& Coeff, MATRIX& invM, double dt, vector<MATRIX>&
7275

7376
// Independent-trajectory XF methods
7477
void xf_hop_reset(dyn_variables& dyn_var, vector<int>& accepted_states, vector<int>& initial_states);
78+
void update_ham_xf(dyn_variables& dyn_var);
7579

7680
void shxf(dyn_variables& dyn_var, nHamiltonian& ham, nHamiltonian& ham_prev, dyn_control_params& prms); // For SHXF
7781
void mqcxf(dyn_variables& dyn_var, nHamiltonian& ham, nHamiltonian& ham_prev, dyn_control_params& prms); // For MQCXF
7882

7983
// XF propagation
84+
void rotate_nab_phase(dyn_variables& dyn_var, nHamiltonian& ham, dyn_control_params& prms);
8085
void update_forces_xf(dyn_variables& dyn_var, nHamiltonian& ham, nHamiltonian& ham_prev);
81-
void propagate_half_xf(dyn_variables& dyn_var, nHamiltonian& ham, dyn_control_params& prms, int do_rotation);
86+
void propagate_half_xf(dyn_variables& dyn_var, nHamiltonian& ham, dyn_control_params& prms);
8287
void XF_correction(CMATRIX& Ham, dyn_variables& dyn_var, CMATRIX& C, double wp_width, CMATRIX& T, int traj);
8388

8489
///================ In dyn_decoherence_time.cpp ===================================

0 commit comments

Comments
 (0)