Skip to content

Commit feb8d86

Browse files
LeenFahoumalongd
authored andcommitted
Fix: enforce consistency between solvation method and solvent
Raise a ValueError when only one of solvation_method or solvent is defined. Both must be provided together or both must be None.
1 parent d91549a commit feb8d86

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

arc/job/adapters/xtb_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def setUpClass(cls):
9696
cls.job_9 = xTBAdapter(execution_type='queue',
9797
job_type='opt',
9898
project='test_9',
99-
level=Level(method='xtb', solvent='water'),
99+
level=Level(method='xtb', solvent='water', solvation_method="alpb"),
100100
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_xTBAdapter_9'),
101101
species=[ARCSpecies(label='spc2', smiles='CC[O]')],
102102
)

arc/level.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ def __init__(self,
8383
or solvation_scheme_level.solvation_scheme_level is not None):
8484
raise ValueError('Cannot represent a solvation_scheme_level which itself has solvation attributes.')
8585
self.solvation_scheme_level = solvation_scheme_level
86-
if self.solvation_method is not None and self.solvent is None:
87-
raise ValueError(f'Cannot represent a level of theory with a solvation method ("{self.solvation_method}") '
88-
f'that lacks a solvent.')
89-
86+
if (self.solvation_method is None) != (self.solvent is None):
87+
raise ValueError(
88+
'Both solvation method and solvent must be defined together, or both must be None. '
89+
f'Got solvation method = "{self.solvation_method}", solvent = "{self.solvent}".'
90+
)
9091
self.args = args or {'keyword': dict(), 'block': dict()}
9192

9293
if self.repr is not None:

0 commit comments

Comments
 (0)