Skip to content

Commit

Permalink
Merge pull request #142 from sharc-md/sharc3preview
Browse files Browse the repository at this point in the history
Sharc3preview
  • Loading branch information
maisebastian authored Aug 21, 2024
2 parents d01d408 + f9b2ad4 commit 50fdac7
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 8 deletions.
5 changes: 4 additions & 1 deletion bin/QMout_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 != '':
Expand Down
92 changes: 89 additions & 3 deletions bin/SHARC_ORCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '',
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

# =============================================================================================== #
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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







# ======================================================================= #


Expand Down
2 changes: 1 addition & 1 deletion bin/setup_traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions tests/INPUT/scripts_setup_traj/KEYSTROKES.setup_traj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
5 changes: 4 additions & 1 deletion tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/input
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,6 +27,7 @@ decoherence_param 0.1
hopping_procedure sharc
grad_select
eselect 0.001000
select_directly
nospinorbit
write_overlap
output_format ascii
Expand Down
4 changes: 2 additions & 2 deletions tests/RESULTS/scripts_setup_traj/State_2/TRAJ_00001/run.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 50fdac7

Please sign in to comment.