Skip to content

Commit

Permalink
Fix the molpro input file memory (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinp0 committed Jun 5, 2023
2 parents 9120fee + 7369084 commit 04dabba
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 10 additions & 4 deletions arc/job/adapters/molpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import math
import os
from typing import TYPE_CHECKING, List, Optional, Tuple, Union
import socket

from mako.template import Template

Expand Down Expand Up @@ -319,13 +320,18 @@ def set_input_file_memory(self) -> None:
"""
Set the input_file_memory attribute.
"""
# Molpro's memory is per cpu core and in MW (mega word; 1 MW ~= 8 MB; 1 GB = 128 MW)
# Molpro's memory is per cpu core and in MW (mega word; 1000 MW = 7.45 GB on a 64-bit machine)
# The conversion from mW to GB was done using this (https://deviceanalytics.com/words-to-bytes-converter/)
# specifying a 64-bit architecture.
#
# See also:
# https://www.molpro.net/pipermail/molpro-user/2010-April/003723.html
# In the link, they describe the conversion of 100,000,000 Words (100Mword) is equivalent to
# 800,000,000 bytes (800 mb).
# Formula - (100,000,000 [Words]/( 800,000,000 [Bytes] / (job mem in gb * 1000,000,000 [Bytes])))/ 1000,000 [Words -> MegaWords]
# 800,000,000 bytes (800 mb).
# Formula - (100,000,000 [Words]/( 800,000,000 [Bytes] / (job mem in gb * 1000,000,000 [Bytes])))/ 1000,000 [Words -> MegaWords]
# The division by 1E6 is for converting into MWords
self.input_file_memory = math.ceil((1E8/(8E8 /(self.job_memory_gb * 1E9)))/1E6)
# Due to Zeus's configuration, there is only 1 nproc so the memory should not be divided by cpu_cores.
self.input_file_memory = math.ceil(self.job_memory_gb / (7.45e-3 * self.cpu_cores)) if 'zeus' not in socket.gethostname() else math.ceil(self.job_memory_gb / (7.45e-3))

def execute_incore(self):
"""
Expand Down
19 changes: 16 additions & 3 deletions arc/job/adapters/molpro_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,29 @@ def test_set_cpu_and_mem(self):

def test_set_input_file_memory(self):
"""Test setting the input_file_memory argument"""
expected_memory = math.ceil((1E8/(8E8 /(14 * 1E9)))/1E6)
self.assertEqual(self.job_1.input_file_memory, expected_memory)
self.job_1.input_file_memory = None
self.job_1.cpu_cores = 48
self.job_1.set_input_file_memory()
self.assertEqual(self.job_1.input_file_memory, 40)

self.job_1.cpu_cores = 8
self.job_1.set_input_file_memory()
self.assertEqual(self.job_1.input_file_memory, 235)

self.job_1.input_file_memory = None
self.job_1.cpu_cores = 1
self.job_1.set_input_file_memory()
self.assertEqual(self.job_1.input_file_memory, 1880)

def test_write_input_file(self):
"""Test writing Gaussian input files"""
self.job_1.cpu_cores = 48
self.job_1.set_input_file_memory()
self.job_1.write_input_file()
with open(os.path.join(self.job_1.local_path, input_filenames[self.job_1.job_adapter]), 'r') as f:
content_1 = f.read()
job_1_expected_input_file = """***,spc1
memory,1750,m;
memory,40,m;
file,1,file1.int !allocate permanent integral file
file,2,file2.wfu !allocate permanent wave-function (dump) file
Expand Down

0 comments on commit 04dabba

Please sign in to comment.