From d3f4c39757c54ab87333fc20ac300d4ecd0f9ea2 Mon Sep 17 00:00:00 2001 From: Sebastian Mai Date: Mon, 19 Aug 2024 07:39:54 +0200 Subject: [PATCH 1/4] SHARC_ORCA.py: added dotrans option (for ORCA 5, singlets only) --- bin/SHARC_ORCA.py | 92 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/bin/SHARC_ORCA.py b/bin/SHARC_ORCA.py index 1f09f98..a403ca7 100755 --- a/bin/SHARC_ORCA.py +++ b/bin/SHARC_ORCA.py @@ -2179,7 +2179,8 @@ def readQMin(QMinfilename): 'unrestricted_triplets': False, 'qmmm': False, 'cobramm': False, - 'picture_change': False + 'picture_change': False, + 'dotrans': False } strings = {'basis': '6-31G', 'auxbasis': '', @@ -2375,6 +2376,9 @@ def readQMin(QMinfilename): if len(QMin['states']) >= 3 and QMin['states'][2] > 0: print('Request "SOC" is not compatible with "unrestricted_triplets"!') sys.exit(64) + if QMin['template']['dotrans'] and 'soc' in QMin: + print('dotrans and SOC not compatible (in ORCA 5).') + sys.exit(64) # if QMin['template']['cosmo'] and 'grad' in QMin: TODO # print('COSMO is not compatible with gradient calculations!') # sys.exit(65) @@ -3175,7 +3179,8 @@ def ORCAinput_string(QMin): if restr and 'soc' in QMin: string += 'dosoc true\n' string += 'printlevel 3\n' - # string+="dotrans all\n" #TODO + if 'dm' in QMin and QMin['template']['dotrans']: + string+="dotrans all\n" #TODO if dograd: if multigrad: if singgrad: @@ -4261,7 +4266,7 @@ def runTHEODORE(WORKDIR, THEODIR): sys.stdout.flush() os.chdir(prevdir) if runerror >0 and os.path.isfile(os.path.join(THEODIR,'bin','theodore')): - sys.stdout.write('Error code is not 0 for TheoDORE 3.x. Please make sure to use at least TheoDORE 3.2 with SHARC_ORCA.py. ' + sys.stdout.write('Error code is not 0 for TheoDORE 3.x. Please make sure to use at least TheoDORE 3.2 with SHARC_ORCA.py. ') return runerror # =============================================================================================== # @@ -4497,6 +4502,8 @@ def getQMout(QMin): for job in joblist: logfile = os.path.join(QMin['scratchdir'], 'master_%i/ORCA.log' % (job)) dipoles = gettdm(logfile, job, QMin) + if QMin['template']['dotrans']: + tdms = get_e2e_tdm(logfile, job, QMin) mults = QMin['multmap'][-job] if 3 in mults and QMin['OrcaVersion'] < (4, 1): mults = [3] @@ -4531,6 +4538,16 @@ def getQMout(QMin): elif s2 == 1: for ixyz in range(3): QMout['dm'][ixyz][i][j] = dipoles[(m1, s1)][ixyz] + elif QMin['template']['dotrans'] and m1 == m2 == 1: + if (i,j) in tdms: + for ixyz in range(3): + QMout['dm'][ixyz][i][j] = tdms[(i, j)][ixyz] + QMout['dm'][ixyz][j][i] = tdms[(i, j)][ixyz] + elif (j,i) in tdms: + for ixyz in range(3): + QMout['dm'][ixyz][i][j] = tdms[(j, i)][ixyz] + QMout['dm'][ixyz][j][i] = tdms[(j, i)][ixyz] + # Gradients @@ -4951,6 +4968,75 @@ def gettdm(logfile, ijob, QMin): # print dipoles return dipoles +# ======================================================================= # + +def get_e2e_tdm(logfile, ijob, QMin): + + # open file + f = readfile(logfile) + if PRINT: + print('e2e Dipoles: ' + shorten_DIR(logfile)) + + # figure out the excited state settings + mults = QMin['jobs'][ijob]['mults'] + if not 1 in mults: + return {} + restr = QMin['jobs'][ijob]['restr'] + gsmult = mults[0] + estates_to_extract = deepcopy(QMin['states']) + estates_to_extract[gsmult - 1] -= 1 + for imult in range(len(estates_to_extract)): + if not imult + 1 in mults: + estates_to_extract[imult] = 0 + + + dipoles = {} + for imult in mults: + if not imult == gsmult: + continue + nstates = estates_to_extract[imult - 1] + if nstates == 0: + continue + iline = 0 + while True: + line = f[iline] + if 'TRANSIENT TD-DFT/TDA-EXCITATION SPECTRA' in line: + break + iline += 1 + + for istate in range(1,nstates): + while True: + iline += 1 + line = f[iline] + if 'Transitions starting from IROOT' in line: + state = int(line.replace(':','').split()[-1]) + print(iline,state) + if state == istate: + break + for jstate in range(1+istate,1+nstates): + line = f[iline+7-istate+jstate] + #print(line) + dm = [ float(i) for i in line.split()[5:8] ] + dipoles[ (istate,jstate) ] = dm + + #print(dipoles) +# for iline, line in enumerate(f): +# if ' ABSORPTION SPECTRUM VIA TRANSITION ELECTRIC DIPOLE MOMENTS' in line: +# # print line +# for istate in range(nstates): +# shift = 5 + istate +# s = f[iline + shift].split() +# dm = [float(i) for i in s[5:8]] +# dipoles[(imult, istate + 1 + (gsmult == imult))] = dm + # print dipoles + return dipoles + + + + + + + # ======================================================================= # From baf6149ea3b353a914f2f4d5be130125e83544e3 Mon Sep 17 00:00:00 2001 From: Sebastian Mai Date: Wed, 21 Aug 2024 09:03:59 +0200 Subject: [PATCH 2/4] Test scripts_setup_traj: fixed --- tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj | 3 +++ tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input | 5 ++++- tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj b/tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj index 5d97933..7b29267 100644 --- a/tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj +++ b/tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj @@ -7,12 +7,15 @@ #Number of trajectories: [1] 1234 #RNG Seed: [!] 3 #Interface number: + #Method: [1] #Simulation time (fs): [1000.0] #Simulation timestep (fs): [0.5] + #Integrator: [2 #Nsubsteps: [25] #Do you want to prematurely terminate trajectories? [False] #SHARC dynamics? [True] #Coupling number: [3] + #GradCorrect: [1] #EkinCorrect: [2] #Reflect frustrated: [1] #Decoherence scheme: [2] diff --git a/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input b/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input index 369c3ce..68e7d35 100644 --- a/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input +++ b/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input @@ -8,13 +8,15 @@ nstates 2 actstates 2 state 2 diag coeff auto -rngseed 30569 +rngseed 24999 ezero -329.5062895400 tmax 1000.000000 stepsize 0.500000 nsubsteps 25 +integrator fvv +method tsh surf diagonal coupling overlap nogradcorrect @@ -25,6 +27,7 @@ decoherence_param 0.1 hopping_procedure sharc grad_select eselect 0.001000 +select_directly nospinorbit write_overlap output_format ascii diff --git a/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh b/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh index 494d50e..007fd2e 100755 --- a/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh +++ b/tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh @@ -1,10 +1,10 @@ #!/bin/bash -#$-N traj_00001 +# $-N traj_00001 -PRIMARY_DIR=/user/mai/Documents/NewSHARC/SHARC_2.1/TESTS/pysharc/RUNNING_TESTS/scripts_setup_traj/State_2/TRAJ_00001/ +PRIMARY_DIR=/global/mai/SHARC_3.0_tests/tests/RUNNING_TESTS/scripts_setup_traj/State_2/TRAJ_00001/ cd $PRIMARY_DIR From 9e7b4e7f798c3e88058d50edb097a16c188442a5 Mon Sep 17 00:00:00 2001 From: Sebastian Mai Date: Wed, 21 Aug 2024 09:04:27 +0200 Subject: [PATCH 3/4] setup_traj.py: fixed bug related to qmmm --- bin/setup_traj.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/setup_traj.py b/bin/setup_traj.py index d325d2f..666fa68 100755 --- a/bin/setup_traj.py +++ b/bin/setup_traj.py @@ -2634,7 +2634,7 @@ def check_MOLCAS_qmmm(filename): data = f.readlines() f.close() for line in data: - if 'qmmm' in line.lower(): + if 'qmmm' in re.sub('#.*$', '', line).strip().lower(): return True return False From f9b2ad4d17dd9f9b9eea7db0fa02781f8caa8697 Mon Sep 17 00:00:00 2001 From: Sebastian Mai Date: Wed, 21 Aug 2024 09:04:49 +0200 Subject: [PATCH 4/4] QMout_print.py: fixed file name default --- bin/QMout_print.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/QMout_print.py b/bin/QMout_print.py index 25f0b99..3180db5 100755 --- a/bin/QMout_print.py +++ b/bin/QMout_print.py @@ -298,7 +298,10 @@ def main(): qminfile = options.i initial = options.S - 1 target = options.t - qmoutfile = args[0] + if len(args)<1: + qmoutfile = 'QM.out' + else: + qmoutfile = args[0] QMin = {'states': 1, 'natom': options.n} if qminfile != '':