Git Product home page Git Product logo

aiida-castep's Introduction

AiiDA plugin for working with CASTEP

Docs status

pipeline status Binder

A plugin for AiiDA to work with plane-wave pseudopotential DFT code CASTEP. CASTEP has a single binary executable and calculation is primarily controlled by the task keyword. The generic CastepCalculation should work with all tasks, at least in terms of generating input files. Likewise a generic CastepParser class is implemented and can handle parsing most information we are interested in singlepoint, geometryoptimisation, bandstructure/spectral tasks. Most output files are retrieved if present, and it is possible to explicitly request retrieval from the remote computer. The goal of this plugin is not to provide a comprehensive parser of the CASTEP results, but to build a graph of calculations performed for provenance preservation and workflow automation. Input and output of a simple calculation:

Asingle calculation

or a series of operations and automated calculations:

A series of calculations

The raw files can always be extracted from the database and analysed by the post-processing tools of choice. Even better, such tools may be integrated with the AiiDA framework and have the analysis appended to the provenance graph.

Highlights of available features:

  • Storing usp/recpot as UspData (sub-class of SingleFileData) in AiiDA database and create/use of pseudo family groups.
  • Store OTFG generating strings as OTFGData in AiiDA. Create of family/group are also supported. OTFG library (such as "C19") are represented as a OTFG string works for all elements.
  • Preparation of CASTEP input files. Writing cell and parameters files are both supported. Tags in positions_abs block file should also work, e.g LABEL, SPIN, MIXTURE.
  • Parsing energy, force, stress from output .castep file and .geom file
  • Parsing trajectory from .geom, .ts, .md files.
  • Checking errors in .param and .cell files before submitting, using dictionaries shipped from built from CASTEP executable.
  • Extra KpointData input node for BS, SEPCTRAL and PHONON tasks.
  • Preparing transition state search calculations
  • A create_restart function for easy creation of continuation/restart calculations. Input can be altered using param_update and param_delete keyword arguments. Automatic copying/linking of remote check files by AiiDA.
  • A get_castep_inputs_summary function to print a summary of inputs of a calculations.
  • A compare_with method to compare the inputs of two calculations.

Documentation

Quick glimpse into how to use the plugin for running calculations:

Documentation is hosted at Read the Docs: dev version master version

Dependencies

The primary dependency is the aiida_core package. The dependencies are:

  • The plugin version 2.0 and above support only aiida_core>=2.0.
  • The plugin version 1.0 and above support only aiida_core>=1.0.0b6, <2.
  • The plugin version 0.3 support only aiida_core 0.12.x versions.

There is only minor API changes in the aiida_core between v1 and v2, scripts written should be compatible between the two.

Todos and nice-to-haves

  • Methods for importing existing calculations
  • Support for submitting file based CASTEP calculations.
  • At the moment there is no enforcement on the type in Dict input node. For example, setting smearing_width to 0.1 and "0.1" is equivalent, but they will store differently in the database.

How to test

The tests uses the pytest framework. First, install with the dependencies

pip install aiida_core[testing]
pip install aiida-castep[testing]

Then you can run the command pytest from the project directory.

aiida-castep's People

Contributors

asamli avatar ml-evs avatar zhubonan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

aiida-castep's Issues

pasing metadata.options to `CastepBaseWorkChain` for `CastepCalculation`

metadata.options contains the information regarding the operation of the CastepCalculation. Two approaches may be used:

  1. Expose the input port from CastepCalculation. This enables automatic checking and tab completion, but renders get_builder_restart difficult to use for CastepBaseWorkChain.
  2. Wrap everything in the Dict. This is the way VaspWorkChain handles it. It allows get_builder_restart to be used. However, any problem with the options supports.

The plan was to migrate from 1 to 2, but 2 is not really good as it does not use the mechanism in aiida-core - so more like a workaround. The key problem is the metadata.options is a non-db input, e.g. plain python dictionary, but it is needed for creating a workchian level restart builder.

The alternative is to implement custom methods for performing the restart. However, it is not possible to, in general, recover the metadata.options from the called calculations, but cause what was stored may be the results from modifications.
To support 1., CastepBaseWorkChain can implement a method to store the metadata.options inside the extras of the underlying WorkChainNode. This way, the original inputs may be recovered for manual restart.

Migrate from GitLab

Migrate the repository from https://gitlab.com/bz1/aiida-castep/. The following steps are needed:

  • Migrate the CI/CD
  • Check all issues are copied over
  • Change project url in the metadata and setup.json
  • Archive the old project
  • Propagate change in the next release

Write WorkChain tests

Should check with aiida-vasp and aiida-quantumespresso and others how to test WorkChains

improve controlling mock via MOCK_CODE_BASE

Allow multiple repository pass to be passed in the environmental variable.

For example:

export MOCK_CODE_BASE=<path>:$MOCK_CODE_BASE

Also, since aiida-castep might not be the only plugin that uses this funtionality (e.g. having aiida-castep and aiida-vasp both installed), the environmental variable should be probably be renamed as CASTEP_MOCK_CODE_BASE.

Scanning repository of codes does not make any sense.

parse structure with kindnames

CASTEP will displace the atoms as [SPECIES]:[LABEL] in both the castep file and geom file. These names should be parsed into element and kind names by the parser.

At the moment, calculation with tags (e.g kindname != symbol) will fail when trying to parse geometry optimisation results.

Add `WorkChain` tutorial

The tutorials for deploying calculations using CastepBaseWorkChain and CastepRelaxWorkChain are missing. They should be added to the online documentation.

add aiida-pseudos support

aiida-pseudos provides an interface for downloading and managing pseudopotentials.

CASTEP supports UPF format, and the UpfFamily should be supported already. This allows the pseudo-dojo potentials (NCP) to be used by CASTEP, in theory.

Should investigate the status of this, wether it is indeed supported and properly document it.

related to: #8

Inherit from BaseRestartWorkflow in AiiDA core

AiiDA core has a reference implementation of the BaseRestartWorkChain:

https://github.com/aiidateam/aiida-core/blob/develop/aiida/engine/processes/workchains/restart.py

The CastepBaseWorkChain implemented here in the plugin was based on an eariler version of this, but the exact implementation has now diverged to some extended. It allows handling some common errors such ionic relaxation convergence, out of walltimes and electronic convergence issues.

It would be useful to refector and make CastepBaseWorkChain inherit from BaseRestartWorkChain. Similar work has been done for the aiida-vasp plugin previously.

The advantage of the BaseRestartWorkChain is that it provides a framework for handling restarts as well as allowing customising the "handlers" at individual run level.

Issue when importing GroupTypeString

When I run (locally) the tests for the aiida-common-workflows, I get this:

_______________________________________ ERROR collecting tests/workflows/relax/test_castep.py ________________________________________
ImportError while importing test module '/Users/pizzi/git/aiida-common-workflows/tests/workflows/relax/test_castep.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/workflows/relax/test_castep.py:11: in <module>
    from aiida_castep.data.otfg import OTFGGroup
../../.virtualenvs/aiida-dev/lib/python3.8/site-packages/aiida_castep/data/__init__.py:8: in <module>
    from .otfg import OTFGData
../../.virtualenvs/aiida-dev/lib/python3.8/site-packages/aiida_castep/data/otfg.py:11: in <module>
    from .usp import UspData
../../.virtualenvs/aiida-dev/lib/python3.8/site-packages/aiida_castep/data/usp.py:9: in <module>
    from aiida.orm import GroupTypeString
E   ImportError: cannot import name 'GroupTypeString' from 'aiida.orm' (/Users/pizzi/git/aiida-core/aiida/orm/__init__.py)

that seems to come from your code.
Can you please fix it (if not done already)?

(AiiDA version 1.6.2, aiida-castep==1.2.0a5)

decide what to do for the options input port for CastepBaseWorkChain

At the moment this is used as the internal options, and in fact not passed to the actual calculation's metadata.options.
Should consider using this port for passing the metadata.options to the calculation for consistent restart behaviour.

Perhaps any field for metadata.options can be looked up and updated it is defined here.

More robust raw parser to support iprint > 1

The parser may break when iprint is > 1 causing the calculation in PARSINGFAILED state.
More robust methods should be implemented to separate SCF cycles and parse lines containing total energy and forces.

In particular, phonon calculations does not print much of the progress/force constants so the user may want to run with iprint=2 by default.

Test status with iprint = 2:

  • singlepoint
  • geometrt optimistaion
  • phonon
  • spectral
  • bandstructure
  • magres

The current parser should still work with iprint > 1, but it is not tested. It can get confused because more stuff are printed out.

Update the return codes

Need to update the return codes to comply with the latest AiiDA specification:

  • 0 - 99: Reserved for internal use by aiida-core
  • 100 - 199: Reserved for errors parsed from scheduler output of calculation jobs (note: this is not yet implemented)
  • 200 - 299: Suggested to be used for process input validation errors
  • 300 - 399: Suggested for critical process errors

Consider updating all processes.

Let pseudopotential families support mixing OTFG, usp and upf

At the moment each group can only contain one type of PP, despite that the CastepCalculation can handle a mixture of pseudopotentials types. The limitation can be lifted by creating a unified pseudopotential upload interface at the Data object level. A new type string may be created for this kind of mixed pseudopotential families.

Multiple efermi energy

CASTEP reports multipe eferemi for spin polarised systems. This should be handled properly.

Catch cases where CASTEP recovers from LAPACK error

The plugin detects the err files in the calculation folder and consider the calculation to be failed if they exist.
However, an err file may still be there is CASTEP detected an error but recovered it itself.
In this case, the calculation should not be treated as failed.

Example content of the file:

Warning, Castep has detected a problem with your maths libraries (LAPACK).
Attempting to work around the problem...
(Information for developers: zheevr diagonalisation error  0.727E-02; zheev error -0.247E-13; Hermitian error:  0.684E-15)
Work-around was successful, continuing with calculation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.