Skip to content

Commit

Permalink
Updated Tests: Trsh and Gaussian
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinp0 committed Aug 19, 2024
1 parent 7c34922 commit 73cafbe
Show file tree
Hide file tree
Showing 2 changed files with 223 additions and 3 deletions.
155 changes: 153 additions & 2 deletions arc/job/adapters/gaussian_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,76 @@ def setUpClass(cls):
args=args
)

# Gaussian MaxOptCycles error - Part 1
# Intend to troubleshoot a MaxOptCycles error by adding opt=(maxcycle=200) to the input file
job_status = {'keywords': ['MaxOptCycles']}
ess_trsh_methods = ['']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
args = {'keyword': {}, 'block': {}}
if trsh_keyword:
args['trsh'] = {'trsh': trsh_keyword}
cls.job_22 = GaussianAdapter(execution_type='local',
job_type='opt',
level=Level(method='wb97xd'),
fine=True,
ess_trsh_methods=ess_trsh_methods,
project='test',
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_GaussianAdapter'),
species=[spc_11],
testing=True,
args=args
)

# Gaussian MaxOptCycles error - Part 2
# Intend to troubleshoot a MaxOptCycles error by adding opt=(RFO) to the input file
job_status = {'keywords': ['MaxOptCycles']}
ess_trsh_methods = ['opt=(maxcycle=200)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
args = {'keyword': {}, 'block': {}}
if trsh_keyword:
args['trsh'] = {'trsh': trsh_keyword}
cls.job_23 = GaussianAdapter(execution_type='local',
job_type='opt',
level=Level(method='wb97xd'),
fine=True,
ess_trsh_methods=ess_trsh_methods,
project='test',
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_GaussianAdapter'),
species=[spc_11],
testing=True,
args=args
)

# Gaussian MaxOptCycles error - Part 3
# Intend to troubleshoot a MaxOptCycles error by adding opt=(GDIIS) and removing opt=(RFO) to the input file
job_status = {'keywords': ['MaxOptCycles']}
ess_trsh_methods = ['opt=(maxcycle=200)', 'opt=(RFO)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)

args = {'keyword': {}, 'block': {}}
if trsh_keyword:
args['trsh'] = {'trsh': trsh_keyword}
cls.job_24 = GaussianAdapter(execution_type='local',
job_type='opt',
level=Level(method='wb97xd'),
fine=True,
ess_trsh_methods=ess_trsh_methods,
project='test',
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_GaussianAdapter'),
species=[spc_11],
testing=True,
args=args
)


def test_set_cpu_and_mem(self):
"""Test assigning number of cpu's and memory"""
Expand Down Expand Up @@ -868,7 +938,7 @@ def test_trsh_write_input_file(self):
%mem=14336mb
%NProcShared=8
#P opt=(cartesian) integral=(grid=ultrafine, Acc2E=14) guess=INDO wb97xd IOp(2/9=2000) nosymm scf=(NDamp=30,NoDIIS,direct,tight,xqc)
#P opt=(cartesian) integral=(grid=ultrafine, Acc2E=14) guess=INDO wb97xd IOp(2/9=2000) nosymm scf=(Fermi,NDamp=30,NoDIIS,NoVarAcc,Noincfock,direct,tight,xqc)
ethanol
Expand Down Expand Up @@ -947,7 +1017,7 @@ def test_trsh_write_input_file(self):
%mem=14336mb
%NProcShared=8
#P opt=(calcfc,maxstep=5,tight) guess=mix wb97xd integral=(grid=ultrafine, Acc2E=14) IOp(2/9=2000) nosymm scf=(NDamp=30,NoDIIS,direct,tight,xqc)
#P opt=(calcfc,maxstep=5,tight) guess=mix wb97xd integral=(grid=ultrafine, Acc2E=14) IOp(2/9=2000) nosymm scf=(Fermi,NDamp=30,NoDIIS,NoVarAcc,Noincfock,direct,tight,xqc)
ethanol
Expand Down Expand Up @@ -1020,6 +1090,87 @@ def test_trsh_write_input_file(self):

self.assertEqual(content_21, job_21_expected_input_file)

self.job_22.write_input_file()
with open(os.path.join(self.job_22.local_path, input_filenames[self.job_22.job_adapter]), 'r') as f:
content_22 = f.read()
job_22_expected_input_file = """%chk=check.chk
%mem=14336mb
%NProcShared=8
#P opt=(calcfc,maxcycle=200,maxstep=5,tight) guess=mix wb97xd integral=(grid=ultrafine, Acc2E=14) IOp(2/9=2000) scf=(direct,tight)
ethanol
0 1
C 1.16582100 -0.40435500 0.00000000
C 0.00000000 0.55180500 0.00000000
O -1.18946000 -0.21419400 0.00000000
H -1.94125800 0.37518500 0.00000000
H 2.10540200 0.14511600 0.00000000
H 1.13062400 -1.03878500 0.88303200
H 1.13062400 -1.03878500 -0.88303200
H 0.04768200 1.19305700 0.88359100
H 0.04768200 1.19305700 -0.88359100
"""

self.assertEqual(content_22, job_22_expected_input_file)

self.job_23.write_input_file()
with open(os.path.join(self.job_23.local_path, input_filenames[self.job_23.job_adapter]), 'r') as f:
content_23 = f.read()
job_23_expected_input_file = """%chk=check.chk
%mem=14336mb
%NProcShared=8
#P opt=(RFO,calcfc,maxcycle=200,maxstep=5,tight) guess=mix wb97xd integral=(grid=ultrafine, Acc2E=14) IOp(2/9=2000) scf=(direct,tight)
ethanol
0 1
C 1.16582100 -0.40435500 0.00000000
C 0.00000000 0.55180500 0.00000000
O -1.18946000 -0.21419400 0.00000000
H -1.94125800 0.37518500 0.00000000
H 2.10540200 0.14511600 0.00000000
H 1.13062400 -1.03878500 0.88303200
H 1.13062400 -1.03878500 -0.88303200
H 0.04768200 1.19305700 0.88359100
H 0.04768200 1.19305700 -0.88359100
"""

self.assertEqual(content_23, job_23_expected_input_file)

self.job_24.write_input_file()
with open(os.path.join(self.job_24.local_path, input_filenames[self.job_24.job_adapter]), 'r') as f:
content_24 = f.read()
job_24_expected_input_file = """%chk=check.chk
%mem=14336mb
%NProcShared=8
#P opt=(GDIIS,calcfc,maxcycle=200,maxstep=5,tight) guess=mix wb97xd integral=(grid=ultrafine, Acc2E=14) IOp(2/9=2000) scf=(direct,tight)
ethanol
0 1
C 1.16582100 -0.40435500 0.00000000
C 0.00000000 0.55180500 0.00000000
O -1.18946000 -0.21419400 0.00000000
H -1.94125800 0.37518500 0.00000000
H 2.10540200 0.14511600 0.00000000
H 1.13062400 -1.03878500 0.88303200
H 1.13062400 -1.03878500 -0.88303200
H 0.04768200 1.19305700 0.88359100
H 0.04768200 1.19305700 -0.88359100
"""

self.assertEqual(content_24, job_24_expected_input_file)


@classmethod
def tearDownClass(cls):
Expand Down
71 changes: 70 additions & 1 deletion arc/job/trsh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_determine_ess_status(self):
output_path=path, species_label="Zr2O4H", job_type="opt"
)
self.assertEqual(status, "errored")
self.assertEqual(keywords, ["MaxOptCycles", "GL9999", "SCF"])
self.assertEqual(keywords, ["MaxOptCycles", "GL9999",])
self.assertEqual(error, "Maximum optimization cycles reached.")
self.assertIn("Number of steps exceeded", line)

Expand Down Expand Up @@ -476,7 +476,76 @@ def test_trsh_ess_job(self):
self.assertIn('scf=(NoVarAcc)', ess_trsh_methods)
self.assertIn('guess=INDO', ess_trsh_methods)

# Gaussian: test 9 - part 1
# 'MaxOptCycles', 'GL9999'
# Adding maxcycle=200 to opt
job_status = {'keywords': ['MaxOptCycles', 'GL9999']}
ess_trsh_methods = ['int=(Acc2E=14)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
self.assertFalse(couldnt_trsh)
self.assertIn('opt=(maxcycle=200)', ess_trsh_methods)

# Gaussian: test 9 - part 2
# 'MaxOptCycles', 'GL9999'
# Adding RFO to opt
job_status = {'keywords': ['MaxOptCycles', 'GL9999']}
ess_trsh_methods = ['int=(Acc2E=14)', 'opt=(maxcycle=200)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
self.assertFalse(couldnt_trsh)
self.assertIn('opt=(maxcycle=200)', ess_trsh_methods)
self.assertIn('opt=(RFO)', ess_trsh_methods)
self.assertIn('opt=(maxcycle=200,RFO)', trsh_keyword)

# Gaussian: test 9 - part 3
# 'MaxOptCycles', 'GL9999'
# Adding GDIIS to opt
# Removing RFO from opt
job_status = {'keywords': ['MaxOptCycles', 'GL9999']}
ess_trsh_methods = ['int=(Acc2E=14)', 'opt=(maxcycle=200)', 'opt=(RFO)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
self.assertFalse(couldnt_trsh)
self.assertIn('opt=(maxcycle=200)', ess_trsh_methods)
self.assertIn('opt=(RFO)', ess_trsh_methods)
self.assertIn('opt=(GDIIS)', ess_trsh_methods)
self.assertIn('opt=(maxcycle=200,GDIIS)', trsh_keyword)

# Gaussian: test 9 - part 4
# 'MaxOptCycles', 'GL9999'
# Adding GEDIIS to opt
# Removing RFO from opt
# Removing GDIIS from opt
job_status = {'keywords': ['MaxOptCycles', 'GL9999']}
ess_trsh_methods = ['int=(Acc2E=14)', 'opt=(maxcycle=200)', 'opt=(RFO)', 'opt=(GDIIS)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
self.assertFalse(couldnt_trsh)
self.assertIn('opt=(maxcycle=200)', ess_trsh_methods)
self.assertIn('opt=(RFO)', ess_trsh_methods)
self.assertIn('opt=(GDIIS)', ess_trsh_methods)
self.assertIn('opt=(GEDIIS)', ess_trsh_methods)
self.assertIn('opt=(maxcycle=200,GEDIIS)', trsh_keyword)

# Gaussian: test 9 - part 5
# 'MaxOptCycles', 'GL9999'
# Final test to ensure that it cannot troubleshoot the job further
job_status = {'keywords': ['MaxOptCycles', 'GL9999']}
ess_trsh_methods = ['int=(Acc2E=14)', 'opt=(maxcycle=200)', 'opt=(RFO)', 'opt=(GDIIS)', 'opt=(GEDIIS)']
output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \
memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status,
job_type, software, fine, memory_gb,
num_heavy_atoms, cpu_cores, ess_trsh_methods)
self.assertTrue(couldnt_trsh)

# Test Q-Chem
software = "qchem"
Expand Down

0 comments on commit 73cafbe

Please sign in to comment.