Skip to content

Running espresso  #40

@kianpu34593

Description

@kianpu34593

Hi,

It seems like ase has updated their EspressoProfile. The current implementation in asimtools doesn't work anymore.

The current implementation:

def load_espresso_profile(calc_params):
    """Load Qunatum Espresso Calculator for ASE>3.22.1. If using older versions
    such as the ones available on PyPI or conda-forge, just load it as an ASE
    calculator. Until the new ASE version becomes an official release, we will
    have to have both for compatibility. The interface however remains that of 
    ASE <=3.22.1 within ASIMTools for consistency using the `command` keyword

    https://wiki.fysik.dtu.dk/ase/releasenotes.html

    :param calc_params: args to pass to loader
    :type calc_params: Dict
    :return: Espresso calculator
    :rtype: :class:`ase.calculators.espresso.Espresso`
    """
    from ase.calculators.espresso import Espresso, EspressoProfile

    if 'command' in calc_params['args']:
        command = calc_params['args'].pop('command')
        command = command.split()
        progind = command.index('pw.x')
        argv = command[:progind+1]
    else:
        argv = ['pw.x']

    try:
        calc = Espresso(
            **calc_params['args'],
            profile=EspressoProfile(argv=argv)
        )
    except Exception:
        logging.error("Failed to load MACE-OFF with parameters:\n %s", calc_params)
        raise

    return calc

The source of the bug is here:

calc = Espresso(
    **calc_params['args'],
    profile=EspressoProfile(argv=argv)
)

My attempt of fixing it:

if 'command' in calc_params['args']:
    command = calc_params['args'].pop('command')
    command = command.split()
    progind = command.index('pw.x')
    argv = command[:progind]
    it = iter(argv)
    argv = dict(zip(it, it))
else:
    argv = ['pw.x']
try:
    binary = calc_params['args'].pop("binary")
    pseudo_dir = calc_params['args'].pop("pseudo_dir")
    calc = Espresso(
        **calc_params['args'],
        profile=EspressoProfile(parallel_info=argv,binary=binary, pseudo_dir=pseudo_dir)
    )

Summary:

  • parallel_info needs to be a dict type. argv is a dict now. (e.g. {'srun':'--mpi=pmix'}.
  • binary is 'pw.x'
  • pseudo_dir is a path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions