Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aims profile update #313

Merged
merged 26 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
35246d6
update constructing aims profile if command or species dir are given
gelzinyte Jun 4, 2024
4853594
fix typos
gelzinyte Jun 4, 2024
0dcc924
"profile" can also be provided among kwargs, no overwritting
gelzinyte Jun 4, 2024
a1f22d8
typo in variable name
gelzinyte Jun 4, 2024
955bb92
typos
gelzinyte Jun 5, 2024
084861d
resotre util function that is used by other calculators than aims
gelzinyte Jun 5, 2024
ffd4b36
trial asev3.23 test and dropping modification of ase keywords
gelzinyte Jun 5, 2024
72f9777
update aims tests to work with ase's config file
gelzinyte Jun 10, 2024
9af635b
add xfails until qe is upated
gelzinyte Jun 10, 2024
499e593
update CI tests to use latest pip ase version
gelzinyte Jun 10, 2024
0637dcd
bug fixes in unit tests
gelzinyte Jun 10, 2024
bd28478
partial docs update
gelzinyte Jun 10, 2024
a8e08f9
finish doc updates
gelzinyte Jun 10, 2024
43962cc
undo removing ace fitting docs
gelzinyte Jun 10, 2024
5d379ec
debug github CI
gelzinyte Jun 10, 2024
8615ed8
docs typos
gelzinyte Jun 11, 2024
7dcd9fb
specify ase version for CI
gelzinyte Jun 11, 2024
736a943
specify a dummy aims command directly, not via an ase configuration
gelzinyte Jun 11, 2024
8caa60f
move wst test to a subdirectory
gelzinyte Jun 12, 2024
6f5a235
change my mind about the name
gelzinyte Jun 12, 2024
2ed00fc
more specific name to the test configuration
gelzinyte Jun 12, 2024
7a62831
rename/move local test scripts
gelzinyte Jun 12, 2024
c730f0c
remove imported unused warnings
gelzinyte Jun 13, 2024
699172e
update ase version and docs
gelzinyte Jun 14, 2024
3728749
Tweak text on wfl-ase version compatibility in README and top level d…
bernstei Jun 14, 2024
c185f6d
typos
gelzinyte Jun 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions wfl/calculators/aims.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""

import shlex
import warnings
gelzinyte marked this conversation as resolved.
Show resolved Hide resolved

from copy import deepcopy
import numpy as np
Expand All @@ -15,7 +16,6 @@
AimsProfile = None

from .wfl_fileio_calculator import WFLFileIOCalculator
from .utils import parse_genericfileio_profile_argv

# NOMAD compatible, see https://nomad-lab.eu/prod/rae/gui/uploads
_default_keep_files = ["control.in", "geometry.in", "aims.out"]
Expand Down Expand Up @@ -65,19 +65,13 @@ def __init__(self, keep_files="default", rundir_prefix="run_Aims_", workdir=None
scratchdir=None, calculator_exec=None, **kwargs):

kwargs_command = deepcopy(kwargs)
if calculator_exec is not None:
if "command" in kwargs:
raise ValueError("Cannot specify both calculator_exec and command")
if AimsProfile is None:
# older syntax
kwargs_command["command"] = f"{calculator_exec} > aims.out"
else:
argv = shlex.split(calculator_exec)
try:
kwargs_command["profile"] = AimsProfile(argv=argv)
except TypeError:
binary, parallel_info = parse_genericfileio_profile_argv(argv)
kwargs_command["profile"] = AimsProfile(binary=binary, parallel_info=parallel_info)

if AimsProfile is None:
# old syntax
warnings.warn("Support for ASE 3.22-style calculator interfase will soon be depreciated")
kwargs_command["aims_command"] = calculator_exec
elif "profile" not in kwargs_command:
kwargs_command["profile"] = construct_aims_profile(calculator_exec, kwargs_command)
gelzinyte marked this conversation as resolved.
Show resolved Hide resolved

# WFLFileIOCalculator is a mixin, will call remaining superclass constructors for us
super().__init__(keep_files=keep_files, rundir_prefix=rundir_prefix,
Expand Down Expand Up @@ -143,3 +137,27 @@ def _setup_calc_params(self):
or param_i in ['relax_unit_cell', 'external_pressure']]
for param_i in rm_parameters:
self.parameters.pop(param_i)


def construct_aims_profile(calculator_exec, kwargs_command):
if calculator_exec is not None and "command" in kwargs:
raise ValueError("Cannot specify both calculator_exec and command")

# AimsProfile takes "command" and "defult_species_directory"
if calculator_exec is not None:
command = calculator_exec
else:
command = kwargs_command.pop("command", None)

if "default_species_directory" in kwargs_command and "species_dir" in kwargs_command:
raise ValueError("Cannot specify both default_species_directory and species_dir")
default_species_directory = kwargs_command.pop("default_species_directory", None)
if default_species_directory is None:
assert "species_dir" in kwargs_command

if command is None and default_species_directory is None:
return None
else:
return AimsProfile(command=command, default_species_directory=default_species_directory)


26 changes: 0 additions & 26 deletions wfl/calculators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,5 @@ def clean_rundir(rundir, keep_files, default_keep_files, calculation_succeeded):
else:
clean_dir(rundir, keep_files, force=False)

def parse_genericfileio_profile_argv(argv):
bernstei marked this conversation as resolved.
Show resolved Hide resolved
"""Parse a command provided as a conventional argv into the separate
structures that generic file-io calculators use to construct their Profile

Parameters
----------
argv: list(str)
command to execute, split into separate arguments (e.g. using shlex.split?)

Returns
-------
binary: str binary to execute
parallel_info: dict with parallel info, in particular "binary" for mpirun/mpiexec/srun etc,
and additional fields to reconstruct rest of command line (all fake, depending
on details of how ASE constructs the final command line
"""
binary = argv[-1]
parallel_info = None
if len(argv) > 1:
# assume earlier arguments are parallel execution dependent, in particular
# mpirun/mpiexec/srun [other mpi argument] pw_executable
parallel_info = {"binary": argv[0]}
for arg in argv[1:-1]:
# add additional arguments, faked into a dict that ASE will convert into
# a proper command line
parallel_info[arg] = True

return binary, parallel_info
Loading