@@ -925,14 +925,6 @@ def run_dynamics(_q, _p, _iM, _Cdia, _Cadi, _projectors, _states, _dyn_params, c
925
925
decoherence_algo = dyn_params ["decoherence_algo" ]
926
926
is_nbra = dyn_params ["is_nbra" ]
927
927
928
- ndia = Cdia .num_of_rows
929
- nadi = Cadi .num_of_rows
930
- nnucl = q .num_of_rows
931
- ntraj = q .num_of_cols
932
-
933
- if (dyn_params ["quantum_dofs" ]== None ):
934
- dyn_params ["quantum_dofs" ] = list (range (nnucl ))
935
-
936
928
937
929
q = MATRIX (_q )
938
930
p = MATRIX (_p )
@@ -941,13 +933,23 @@ def run_dynamics(_q, _p, _iM, _Cdia, _Cadi, _projectors, _states, _dyn_params, c
941
933
Cadi = CMATRIX (_Cadi )
942
934
states = intList ()
943
935
projectors = CMATRIXList ()
936
+
937
+ ndia = Cdia .num_of_rows
938
+ nadi = Cadi .num_of_rows
939
+ nnucl = q .num_of_rows
940
+ ntraj = q .num_of_cols
941
+ nstates = len (_states )
942
+
943
+ if (dyn_params ["quantum_dofs" ]== None ):
944
+ dyn_params ["quantum_dofs" ] = list (range (nnucl ))
945
+
944
946
945
947
if is_nbra == 1 :
946
- for i in range (len ( _states ) ):
948
+ for i in range (nstates ):
947
949
states .append (_states [i ])
948
950
projectors .append (CMATRIX (_projectors [0 ]))
949
951
else :
950
- for i in range (len ( _states ) ):
952
+ for i in range (nstates ):
951
953
states .append (_states [i ])
952
954
projectors .append (CMATRIX (_projectors [i ]))
953
955
@@ -1024,8 +1026,8 @@ def run_dynamics(_q, _p, _iM, _Cdia, _Cadi, _projectors, _states, _dyn_params, c
1024
1026
elif rep_tdse == 1 :
1025
1027
ham .ampl_adi2dia (Cdia , Cadi , 0 , 1 )
1026
1028
1027
- dm_dia , dm_adi , dm_dia_raw , dm_adi_raw = tsh_stat .compute_dm (ham , Cdia , Cadi , projectors , rep_tdse , 1 , dyn_params [ "isNBRA" ] )
1028
- pops , pops_raw = tsh_stat .compute_sh_statistics (nadi , states , projectors , dyn_params [ "isNBRA" ] )
1029
+ dm_dia , dm_adi , dm_dia_raw , dm_adi_raw = tsh_stat .compute_dm (ham , Cdia , Cadi , projectors , rep_tdse , 1 , is_nbra )
1030
+ pops , pops_raw = tsh_stat .compute_sh_statistics (nadi , states , projectors , is_nbra )
1029
1031
# Energies
1030
1032
Ekin , Epot , Etot , dEkin , dEpot , dEtot = 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0
1031
1033
Etherm , E_NHC = 0.0 , 0.0
@@ -1161,49 +1163,56 @@ def generic_recipe(q, p, iM, _dyn_params, compute_model, _model_params, _init_el
1161
1163
1162
1164
"""
1163
1165
1164
- comn .check_input (_model_params , { }, [ "model0" ] )
1165
- comn .check_input (_dyn_params , { "rep_tdse" :1 }, [ ] )
1166
+ model_params = dict (_model_params )
1167
+ dyn_params = dict (_dyn_params )
1168
+ init_elec = dict (_init_elec )
1169
+
1170
+ comn .check_input ( model_params , { }, [ "model0" ] )
1171
+ comn .check_input ( dyn_params , { "rep_tdse" :1 , "is_nbra" :0 }, [ ] )
1166
1172
1173
+ is_nbra = dyn_params ["is_nbra" ]
1174
+
1175
+ init_elec .update ({"is_nbra" :is_nbra })
1167
1176
1168
1177
1169
1178
# Internal parameters
1170
1179
nnucl , ntraj = q .num_of_rows , q .num_of_cols
1171
1180
1172
1181
# Initialize electronic variables - either diabatic or adiabatic
1173
- Cdia , Cadi , projectors , states = init_electronic_dyn_var (_init_elec , _dyn_params [ "isNBRA" ] , rnd )
1182
+ Cdia , Cadi , projectors , states = init_electronic_dyn_var (init_elec , rnd )
1174
1183
ndia , nadi = Cdia .num_of_rows , Cadi .num_of_rows
1175
1184
1176
1185
1177
1186
# In case the initial conditions rep and the propagation rep are different,
1178
1187
# compute the diabatic-to-adiabatic transformation matrices and
1179
1188
# transform the amplitudes accordingly
1180
1189
ham = nHamiltonian (ndia , nadi , nnucl )
1181
- if _dyn_params [ "isNBRA" ] == 1 :
1190
+ if is_nbra == 1 :
1182
1191
ham .add_new_children (ndia , nadi , nnucl , 1 )
1183
1192
else :
1184
1193
ham .add_new_children (ndia , nadi , nnucl , ntraj )
1185
1194
ham .init_all (2 ,1 )
1186
1195
1187
- if _init_elec ["rep" ]== 0 :
1188
- if _dyn_params ["rep_tdse" ]== 1 :
1189
- model_params = dict (_model_params )
1190
- model_params .update ({"model" :_model_params ["model0" ]})
1191
- update_Hamiltonian_q ({"rep_tdse" :1 , "rep_ham" :0 }, q , projectors , ham , compute_model , model_params )
1196
+ if init_elec ["rep" ]== 0 :
1197
+ if dyn_params ["rep_tdse" ]== 1 :
1198
+ model_params1 = dict (model_params )
1199
+ model_params1 .update ({"model" :model_params ["model0" ]})
1200
+ update_Hamiltonian_q ({"rep_tdse" :1 , "rep_ham" :0 }, q , projectors , ham , compute_model , model_params1 )
1192
1201
1193
1202
Cadi = transform_amplitudes (0 , 1 , Cdia , ham )
1194
1203
1195
- elif _init_elec ["rep" ]== 1 :
1196
- if _dyn_params ["rep_tdse" ]== 0 :
1197
- model_params = dict (_model_params )
1198
- model_params .update ({"model" :_model_params ["model0" ]})
1199
- update_Hamiltonian_q ({"rep_tdse" :1 , "rep_ham" :0 }, q , projectors , ham , compute_model , model_params )
1204
+ elif init_elec ["rep" ]== 1 :
1205
+ if dyn_params ["rep_tdse" ]== 0 :
1206
+ model_params1 = dict (model_params )
1207
+ model_params1 .update ({"model" :model_params ["model0" ]})
1208
+ update_Hamiltonian_q ({"rep_tdse" :1 , "rep_ham" :0 }, q , projectors , ham , compute_model , model_params1 )
1200
1209
1201
1210
Cdia = transform_amplitudes (1 , 0 , Cdia , ham )
1202
1211
1203
1212
#if _dyn_params["isNBRA"]==1:
1204
1213
# res = run_dynamics_nbra(q, p, iM, Cdia, Cadi, projectors, states, _dyn_params, compute_model, _model_params, rnd)
1205
1214
#else:
1206
- res = run_dynamics (q , p , iM , Cdia , Cadi , projectors , states , _dyn_params , compute_model , _model_params , rnd )
1215
+ res = run_dynamics (q , p , iM , Cdia , Cadi , projectors , states , _dyn_params , compute_model , model_params , rnd )
1207
1216
1208
1217
return res
1209
1218
0 commit comments