@@ -248,7 +248,7 @@ CMATRIX transform_amplitudes(int rep_in, int rep_out, CMATRIX& C, nHamiltonian&
248
248
249
249
250
250
// vector<CMATRIX> compute_St(nHamiltonian& ham, CMATRIX** Uprev){
251
- vector<CMATRIX> compute_St (nHamiltonian& ham, vector<CMATRIX>& Uprev){
251
+ vector<CMATRIX> compute_St (nHamiltonian& ham, vector<CMATRIX>& Uprev, int isNBRA ){
252
252
/* *
253
253
This function computes the time-overlap matrices for all trajectories
254
254
@@ -258,16 +258,26 @@ vector<CMATRIX> compute_St(nHamiltonian& ham, vector<CMATRIX>& Uprev){
258
258
int ntraj = ham.children .size ();
259
259
260
260
vector<CMATRIX> St (ntraj, CMATRIX (nst, nst));
261
-
261
+ if (isNBRA==1 ){
262
+ St[0 ] = Uprev[0 ].H () * ham.children [0 ]->get_basis_transform ();
263
+ }
264
+ else {
262
265
for (int traj=0 ; traj<ntraj; traj++){
263
266
St[traj] = Uprev[traj].H () * ham.children [traj]->get_basis_transform ();
264
267
}
265
-
268
+ }
266
269
return St;
267
270
268
271
}
269
272
270
- vector<CMATRIX> compute_St (nHamiltonian& ham){
273
+ vector<CMATRIX> compute_St (nHamiltonian& ham, vector<CMATRIX>& Uprev){
274
+
275
+ int is_nbra = 0 ;
276
+ return compute_St (ham, Uprev, is_nbra);
277
+
278
+ }
279
+
280
+ vector<CMATRIX> compute_St (nHamiltonian& ham, int isNBRA){
271
281
/* *
272
282
This function computes the time-overlap matrices for all trajectories
273
283
@@ -277,16 +287,23 @@ vector<CMATRIX> compute_St(nHamiltonian& ham){
277
287
int ntraj = ham.children .size ();
278
288
279
289
vector<CMATRIX> St (ntraj, CMATRIX (nst, nst));
280
-
290
+ if (isNBRA==1 ){
291
+ St[0 ] = ham.children [0 ]->get_time_overlap_adi ();
292
+ }
293
+ else {
281
294
for (int traj=0 ; traj<ntraj; traj++){
282
295
St[traj] = ham.children [traj]->get_time_overlap_adi ();
283
296
}
284
-
297
+ }
285
298
return St;
286
299
287
300
}
288
301
302
+ vector<CMATRIX> compute_St (nHamiltonian& ham){
303
+ int is_nbra = 1 ;
289
304
305
+ return compute_St (ham, is_nbra);
306
+ }
290
307
291
308
292
309
void apply_afssh (dyn_variables& dyn_var, CMATRIX& C, vector<int >& act_states, MATRIX& invM,
@@ -487,20 +504,20 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
487
504
488
505
489
506
490
-
491
507
dyn_control_params prms;
492
508
prms.set_parameters (dyn_params);
493
509
494
510
int i,j;
495
511
int cdof;
496
512
int ndof = q.n_rows ;
497
513
int ntraj = q.n_cols ;
514
+ int ntraj1;
498
515
int nst = C.n_rows ;
499
516
int traj, dof, idof;
500
517
int n_therm_dofs;
501
518
int num_el = prms.num_electronic_substeps ;
502
519
double dt_el = prms.dt / num_el;
503
-
520
+ // cout << "Flag 1 isNBRA " << prms.isNBRA << endl;
504
521
505
522
// dyn_variables dyn_var(nst, nst, ndof, ntraj);
506
523
@@ -510,11 +527,22 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
510
527
vector<int > project_out_states (ntraj); // for DISH
511
528
512
529
vector<CMATRIX> Uprev;
513
- vector<CMATRIX> St (ntraj, CMATRIX (nst, nst));
514
- vector<CMATRIX> Eadi (ntraj, CMATRIX (nst, nst));
515
- vector<MATRIX> decoherence_rates (ntraj, MATRIX (nst, nst));
516
- vector<double > Ekin (ntraj, 0.0 );
517
- vector<MATRIX> prev_ham_dia (ntraj, MATRIX (nst, nst));
530
+ // Defining ntraj1 as a reference for making these matrices
531
+ // ntraj is defined as q.n_cols as since it would be large in NBRA
532
+ // we can define another variable like ntraj1 and build the matrices based on that.
533
+ // We can make some changes where q is generated but this seems to be a bit easier
534
+ if (prms.isNBRA ==1 ){
535
+ ntraj1 = 1 ;
536
+ }
537
+ else {
538
+ ntraj1 = ntraj;
539
+ }
540
+ // Defining matrices based on ntraj1
541
+ vector<CMATRIX> St (ntraj1, CMATRIX (nst, nst));
542
+ vector<CMATRIX> Eadi (ntraj1, CMATRIX (nst, nst));
543
+ vector<MATRIX> decoherence_rates (ntraj1, MATRIX (nst, nst));
544
+ vector<double > Ekin (ntraj1, 0.0 );
545
+ vector<MATRIX> prev_ham_dia (ntraj1, MATRIX (nst, nst));
518
546
MATRIX gamma (ndof, ntraj);
519
547
MATRIX p_traj (ndof, 1 );
520
548
vector<int > t1 (ndof, 0 ); for (dof=0 ;dof<ndof;dof++){ t1[dof] = dof; }
@@ -535,13 +563,14 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
535
563
}
536
564
537
565
538
-
539
- if (prms.tsh_method == 3 ){ // DISH
540
- for (traj=0 ; traj<ntraj; traj++){
566
+ if (prms.tsh_method == 3 ){ // DISH
567
+ // prev_ham_dia[0] = ham.children[0]->get_ham_dia().real();
568
+ // }
569
+ // else{
570
+ for (traj=0 ; traj<ntraj1; traj++){
541
571
prev_ham_dia[traj] = ham.children [traj]->get_ham_dia ().real ();
542
572
}
543
573
}
544
-
545
574
// ============ Update the Hamiltonian object =============
546
575
// In case, we may need phase correction & state reordering
547
576
// prepare the temporary files
@@ -562,13 +591,12 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
562
591
563
592
// ============== Electronic propagation ===================
564
593
// Evolve electronic DOFs for all trajectories
594
+ // Adding the prms.isNBRA to the propagate electronic
565
595
for (i=0 ; i<num_el; i++){
566
- propagate_electronic (0.5 *dt_el, C, projectors, ham.children , prms.rep_tdse );
596
+ propagate_electronic (0.5 *dt_el, C, projectors, ham.children , prms.rep_tdse , prms. isNBRA );
567
597
}
568
598
569
-
570
599
// ============== Nuclear propagation ===================
571
-
572
600
// NVT dynamics
573
601
if (prms.ensemble ==1 ){
574
602
for (idof=0 ; idof<n_therm_dofs; idof++){
@@ -578,9 +606,7 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
578
606
}// traj
579
607
}// idof
580
608
}
581
-
582
609
p = p + aux_get_forces (prms, C, projectors, act_states, ham) * 0.5 * prms.dt ;
583
-
584
610
// Kinetic constraint
585
611
for (cdof = 0 ; cdof < prms.constrained_dofs .size (); cdof++){
586
612
p.scale (prms.constrained_dofs [cdof], -1 , 0.0 );
@@ -591,7 +617,6 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
591
617
if (prms.entanglement_opt ==22 ){
592
618
gamma = ETHD3_friction (q, p, invM, prms.ETHD3_alpha , prms.ETHD3_beta );
593
619
}
594
-
595
620
// Update coordinates of nuclei for all trajectories
596
621
for (traj=0 ; traj<ntraj; traj++){
597
622
for (dof=0 ; dof<ndof; dof++){
@@ -615,9 +640,10 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
615
640
616
641
if (prms.state_tracking_algo > 0 || prms.do_phase_correction ){
617
642
618
- if (prms.time_overlap_method ==0 ){ St = compute_St (ham, Uprev); }
619
- else if (prms.time_overlap_method ==1 ){ St = compute_St (ham); }
620
-
643
+ if (prms.time_overlap_method ==0 ){
644
+ St = compute_St (ham, Uprev, prms.isNBRA );
645
+ }
646
+ else if (prms.time_overlap_method ==1 ){ St = compute_St (ham, prms.isNBRA ); }
621
647
Eadi = get_Eadi (ham); // these are raw properties
622
648
update_projectors (prms, projectors, Eadi, St, rnd);
623
649
@@ -645,7 +671,6 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
645
671
p.scale (prms.constrained_dofs [cdof], -1 , 0.0 );
646
672
}
647
673
648
-
649
674
// NVT dynamics
650
675
if (prms.ensemble ==1 ){
651
676
for (idof=0 ; idof<n_therm_dofs; idof++){
@@ -656,13 +681,13 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
656
681
}// idof
657
682
}
658
683
659
-
660
684
// ============== Electronic propagation ===================
661
685
// Evolve electronic DOFs for all trajectories
662
686
update_Hamiltonian_p (prms, ham, p, invM);
663
687
for (i=0 ; i<num_el; i++){
664
- propagate_electronic (0.5 *dt_el, C, projectors, ham.children , prms.rep_tdse );
688
+ propagate_electronic (0.5 *dt_el, C, projectors, ham.children , prms.rep_tdse , prms. isNBRA );
665
689
}
690
+ CMATRIX Hvib (ham.children [0 ]->nadi , ham.children [0 ]->nadi ); Hvib = ham.children [0 ]->get_hvib_adi ();
666
691
667
692
668
693
// ============== Begin the TSH part ===================
@@ -684,27 +709,25 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
684
709
}
685
710
686
711
687
-
688
712
// ================= Update decoherence rates & times ================
689
713
// MATRIX decoh_rates(*prms.decoh_rates);
690
714
// exit(0);
691
-
692
715
if (prms.decoherence_times_type ==-1 ){
693
- for (traj=0 ; traj<ntraj ; traj++){ decoherence_rates[traj] = 0.0 ; }
716
+ for (traj=0 ; traj<ntraj1 ; traj++){ decoherence_rates[traj] = 0.0 ; }
694
717
}
695
718
696
719
// / mSDM
697
720
// / Just use the plain times given from the input, usually the
698
721
// / mSDM formalism
699
722
else if (prms.decoherence_times_type ==0 ){
700
- for (traj=0 ; traj<ntraj ; traj++){ decoherence_rates[traj] = *prms.decoherence_rates ; }
723
+ for (traj=0 ; traj<ntraj1 ; traj++){ decoherence_rates[traj] = *prms.decoherence_rates ; }
701
724
}
702
725
703
726
// / Compute the dephasing rates according the original energy-based formalism
704
727
else if (prms.decoherence_times_type ==1 ){
705
728
Eadi = get_Eadi (ham);
706
729
Ekin = compute_kinetic_energies (p, invM);
707
- decoherence_rates = edc_rates (Eadi, Ekin, prms.decoherence_C_param , prms.decoherence_eps_param );
730
+ decoherence_rates = edc_rates (Eadi, Ekin, prms.decoherence_C_param , prms.decoherence_eps_param , prms. isNBRA );
708
731
}
709
732
710
733
else if (prms.decoherence_times_type ==2 ){
@@ -720,14 +743,13 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
720
743
if (prms.dephasing_informed ==1 ){
721
744
Eadi = get_Eadi (ham);
722
745
MATRIX ave_gaps (*prms.ave_gaps );
723
- dephasing_informed_correction (decoherence_rates, Eadi, ave_gaps);
746
+ dephasing_informed_correction (decoherence_rates, Eadi, ave_gaps, prms. isNBRA );
724
747
}
725
748
726
-
727
749
// ============ Apply decoherence corrections ==================
728
750
// SDM and alike methods
729
751
if (prms.decoherence_algo ==0 ){
730
- Coeff = sdm (Coeff, prms.dt , act_states, decoherence_rates, prms.sdm_norm_tolerance );
752
+ Coeff = sdm (Coeff, prms.dt , act_states, decoherence_rates, prms.sdm_norm_tolerance , prms. isNBRA );
731
753
}
732
754
// BCSH
733
755
else if (prms.decoherence_algo ==3 ){
@@ -737,7 +759,7 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
737
759
738
760
else if (prms.decoherence_algo ==4 ){
739
761
// MATRIX decoh_rates(ndof, ntraj);
740
- Coeff = mfsd (p, Coeff, invM, prms.dt , decoherence_rates, ham, rnd);
762
+ Coeff = mfsd (p, Coeff, invM, prms.dt , decoherence_rates, ham, rnd, prms. isNBRA );
741
763
}
742
764
743
765
// exit(0);
@@ -801,6 +823,7 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
801
823
802
824
// / New version, as of 8/3/2020
803
825
vector<int > old_states (act_states);
826
+ // cout << "Flag before dish" << endl;
804
827
act_states = dish (prms, q, p, invM, Coeff, projectors, ham, act_states, coherence_time, decoherence_rates, rnd);
805
828
806
829
// / Velocity rescaling
@@ -841,7 +864,6 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
841
864
}
842
865
843
866
// exit(0);
844
-
845
867
St.clear ();
846
868
Eadi.clear ();
847
869
decoherence_rates.clear ();
@@ -852,13 +874,13 @@ void compute_dynamics(MATRIX& q, MATRIX& p, MATRIX& invM, CMATRIX& C, vector<CMA
852
874
853
875
854
876
// exit(0);
855
-
856
877
}
857
878
858
879
859
880
860
881
861
882
883
+
862
884
}// namespace libdyn
863
885
}// liblibra
864
886
0 commit comments