Skip to content

Commit 0dd37b4

Browse files
committed
molpro test updates
Fixed local var min_mem_value Update core reduction logic test for MP
1 parent 0da0f62 commit 0dd37b4

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

arc/job/adapters/molpro.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,13 @@ def set_input_file_memory(self) -> None:
357357
if available_cores < current_cpu_cores:
358358
self.cpu_cores = available_cores
359359
logger.info(f'Changing the number of cpu_cores from {current_cpu_cores} to {self.cpu_cores}')
360-
# Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core)
361-
# And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory.
362-
# We will therefore, limit the MW to 4300 MW
363-
self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores))
364-
if self.cpu_cores == 1 and self.input_file_memory > min_memory_value:
365-
self.input_file_memory = min_memory_value
366-
logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro')
360+
# Situation may occur when the required memory per process by Molpro is only enough for 1 cpu core for us to use (for example, 4300 MW -> 32.04GB and if we have 64GB, we can only use 1 cpu core)
361+
# And this means that for 1 CPU, we may end up using all 64GB of memory which approximates to 8600 MW. We need to take precaution here and not use all the memory.
362+
# We will therefore, limit the MW to 4300 MW
363+
self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores))
364+
if self.cpu_cores == 1 and self.input_file_memory > min_memory_value:
365+
self.input_file_memory = min_memory_value
366+
logger.info(f'Changing the input_file_memory from {self.input_file_memory} to {min_memory_value} as the number of cpu_cores will be restricted to 1 due to the memory requirements of Molpro')
367367

368368
def execute_incore(self):
369369
"""

arc/job/adapters/molpro_test.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ def setUpClass(cls):
6464
job_memory_gb=64,
6565
)
6666

67+
cls.job_5 = MolproAdapter(execution_type='queue',
68+
job_type='opt',
69+
level=Level(method='CCSD(T)', basis='cc-pVQZ'),
70+
project='test',
71+
project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_MolproAdapter_2'),
72+
species=[ARCSpecies(label='spc1', xyz=['O 0 0 1'])],
73+
testing=True,
74+
ess_trsh_methods=['memory','cpu', 'molpro_memory: 2800 '],
75+
job_memory_gb=64,
76+
)
77+
6778
def test_set_cpu_and_mem(self):
6879
"""Test assigning number of cpu's and memory"""
6980
self.job_1.cpu_cores = 48
@@ -84,7 +95,6 @@ def test_memory_change(self):
8495
self.assertEqual(self.job_4.input_file_memory, 4300)
8596
self.assertEqual(self.job_4.cpu_cores, 1)
8697

87-
8898
def test_set_input_file_memory(self):
8999
"""Test setting the input_file_memory argument"""
90100
self.job_1.input_file_memory = None
@@ -165,6 +175,15 @@ def test_write_input_file(self):
165175
"""
166176
self.assertEqual(content_2, job_2_expected_input_file)
167177

178+
def test_core_reduction_logic(self):
179+
"""Test the core reduction logic"""
180+
181+
# Job 5 again to trigger the condition of the core reduction logic
182+
# Job 5 technically would be 3 CPUs prior to the reactive setting the input file memory.
183+
self.job_5.set_input_file_memory()
184+
self.assertEqual(self.job_5.input_file_memory, 4296)
185+
self.assertEqual(self.job_5.cpu_cores, 2)
186+
168187
def test_set_files(self):
169188
"""Test setting files"""
170189
job_1_files_to_upload = [{'file_name': 'submit.sub',

0 commit comments

Comments
 (0)