Skip to content

Commit

Permalink
dev: implement temporary fix for handling ion files
Browse files Browse the repository at this point in the history
  • Loading branch information
ahkole committed Dec 20, 2023
1 parent 74b0ff0 commit 8840991
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions aiida_siesta/calculations/siesta.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def define(cls, spec):
required=False,
)
spec.input_namespace('ions', valid_type=IonData, help='Input ion file', dynamic=True, required=False)
spec.input('ions_folder', valid_type=orm.RemoteData, required=False, help='Folder to copy ion files from')

# Input namespace for Lua-related material.
# Parameters are in a separate dictionary to enable a reduced set of 'universal' scripts for particular uses.
Expand Down Expand Up @@ -439,6 +440,11 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-statements
else:
parent_calc_folder = None

if 'ions_folder' in self.inputs:
ions_folder = self.inputs.ions_folder
else:
ions_folder = None

lua_inputs = self.inputs.lua

if 'script' in lua_inputs:
Expand Down Expand Up @@ -511,6 +517,7 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-statements

# ----------------------------ATOMIC_SPECIES & PSEUDOS/IONS-------------------------------
atomic_species_card_list = []
ion_file_list = []
# Dictionary to get the atomic number of a given element
datmn = {v['symbol']: k for k, v in elements.items()}
spind = {}
Expand All @@ -533,8 +540,11 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-statements
# Since no subfolder is present in Siesta for pseudos, filename == relativedestpath.
if isinstance(psp_or_ion, IonData):
file_name = kind.name + ".ion"
with folder.open(file_name, 'w', encoding='utf8') as handle:
handle.write(psp_or_ion.get_content_ascii_format())
if ions_folder is not None:
ion_file_list.append(os.path.join('./', file_name))
else:
with folder.open(file_name, 'w', encoding='utf8') as handle:
handle.write(psp_or_ion.get_content_ascii_format())
if isinstance(psp_or_ion, PsfData):
local_copy_list.append((psp_or_ion.uuid, psp_or_ion.filename, kind.name + ".psf"))
if isinstance(psp_or_ion, PsmlData):
Expand Down Expand Up @@ -629,6 +639,11 @@ def prepare_for_submission(self, folder): # pylint: disable=too-many-statements
# to the current calculation's working folder.
# ISSUE: Is this mechanism flexible enough? An alternative would be to
# pass the information about which file(s) to copy in the metadata.options dictionary
if ions_folder is not None:
for path in ion_file_list:
remote_copy_list.append((
ions_folder.computer.uuid, os.path.join(ions_folder.get_remote_path(), path), self._restart_copy_to
))
if parent_calc_folder is not None:
remote_copy_list.append((
parent_calc_folder.computer.uuid,
Expand Down

0 comments on commit 8840991

Please sign in to comment.