mirror of https://github.com/abinit/abipy.git
Code cleanup
This commit is contained in:
parent
ebb76bb807
commit
4e2c07c24a
|
@ -21,12 +21,12 @@ install:
|
|||
#- set -ev # exit on first error, print each command
|
||||
|
||||
# pip-based installation.
|
||||
#- travis_wait pip install -q -r requirements.txt
|
||||
#- travis_wait pip install -q -r requirements-optional.txt
|
||||
#- travis_wait pip install -r requirements.txt
|
||||
#- travis_wait pip install -r requirements-optional.txt
|
||||
|
||||
# Install conda https://conda.io/docs/travis.html
|
||||
- source dev_scripts/conda_installer.sh
|
||||
- source dev_scripts/conda_develop.sh
|
||||
- source dev_scripts/conda_get.sh
|
||||
- source dev_scripts/conda_install.sh
|
||||
- conda uninstall -y pymatgen
|
||||
|
||||
- if [[ "${PYTHON_VERSION}" == "2.7" ]]; then conda install mock; fi
|
||||
|
|
124
README.rst
124
README.rst
|
@ -12,7 +12,6 @@
|
|||
* - Documentation
|
||||
- |docs-stable| |docs-devel| |launch-nbviewer| |launch-binder|
|
||||
|
||||
|
||||
About
|
||||
=====
|
||||
|
||||
|
@ -24,28 +23,30 @@ ab-initio calculations and typical convergence studies.
|
|||
AbiPy is interfaced with pymatgen_ and this allows users to
|
||||
benefit from the different tools and python objects available in the pymatgen ecosystem.
|
||||
|
||||
The official documentation of the stable version available at the `abipy docpage`_.
|
||||
The official documentation of the stable version is available at the `abipy docpage`_.
|
||||
while the documentation of the **developmental** version is hosted on `github pages <http://abinit.github.io/abipy>`_.
|
||||
|
||||
AbiPy can be used in conjunction with matplotlib_, pandas_, scipy_, seaborn_, ipython_ and jupyter_ notebooks
|
||||
thus providing a powerful and user-friendly environment for data analysis and visualization.
|
||||
Check out the list of plotting scripts available in our
|
||||
`examples/plot <http://pythonhosted.org/abipy/examples/plot/index.html>`_ gallery.
|
||||
Check out our `gallery of plotting scripts <http://abinit.github.io/abipy/gallery/index.html>`_
|
||||
and the `gallery of AbiPy workflows <http://abinit.github.io/abipy/flow_gallery/index.html>`_.
|
||||
|
||||
To learn more about the integration between jupyter_ and AbiPy, visit `our collection of notebooks
|
||||
<https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb>`_
|
||||
|
||||
.. AbiPy supports both Python 2.7 as well as Python >= 3.4.
|
||||
.. Python 2.7 is more intensively tested than py3k especially at the level of workflows
|
||||
.. so we still recommend py2.7 if you plan to run automatic calculations with AbiPy.
|
||||
|
||||
Note that the majority of the post-processing tools available in AbiPy require output files in
|
||||
netcdf_ format so we strongly suggest to compile Abinit with netcdf support
|
||||
(use ``--with_trio_flavor="netcdf-fallback"`` at configure time to activate the internal netcdf library,
|
||||
to link Abinit against an external netcdf library please consult the configuration examples provided by abiconfig_).
|
||||
or click the **Launch Binder** badge to start a Docker image with Abinit, AbiPy and all the other python dependencies
|
||||
required to run the code inside the jupyter notebooks.
|
||||
The notebook will be opened in your browser after building.
|
||||
|
||||
AbiPy is free to use. However, we also welcome your help to improve this library by making your own contributions.
|
||||
Please report any bugs and issues at AbiPy's `Github page <https://github.com/abinit/abipy>`_.
|
||||
|
||||
.. important::
|
||||
|
||||
Note that the majority of the post-processing tools available in AbiPy require output files in
|
||||
netcdf_ format so we **strongly** suggest to compile Abinit with netcdf support
|
||||
(use ``--with_trio_flavor="netcdf-fallback"`` at configure time to activate the internal netcdf library,
|
||||
to link Abinit against an external netcdf library please consult the configuration examples provided by abiconfig_).
|
||||
|
||||
Getting AbiPy
|
||||
=============
|
||||
|
||||
|
@ -64,48 +65,75 @@ and then follow the instructions in `our howto <http://pythonhosted.org/abipy/in
|
|||
|
||||
The installation process is greatly simplified if you install the required
|
||||
python packages through `Anaconda <https://continuum.io/downloads>`_.
|
||||
We routinely use conda_ to test new developments with multiple versions of Python and multiple virtual environments.
|
||||
The anaconda distribution already provides the most critical dependencies (matplotlib_, scipy_, numpy_)
|
||||
in the form of pre-compiled packages and netcdf4-python_ can be easily installed with::
|
||||
We routinely use conda_ to test new developments with multiple Python versions and multiple virtual environments.
|
||||
The anaconda distribution already provides the most critical dependencies (matplotlib_, scipy_, numpy_, netcdf4-python_)
|
||||
in the form of pre-compiled packages that can be easily installed with e.g.::
|
||||
|
||||
conda install netcdf4
|
||||
conda install numpy scipy netcdf4
|
||||
|
||||
To install AbiPy with conda, download the `minconda installer <https://conda.io/miniconda.html>`_
|
||||
(select python3.6 and the version corresponding to your operating system).
|
||||
Create a new conda_ environment (``abipy3.6``) based on python3.6 with::
|
||||
|
||||
conda create -n abipy3.6 python=3.6
|
||||
|
||||
and activate it with::
|
||||
|
||||
source activate abipy3.6
|
||||
|
||||
Add ``conda-forge``, ``matsci`` and ``abinit`` to your channels with::
|
||||
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels matsci
|
||||
conda config --add channels abinit
|
||||
|
||||
Finally, install AbiPy from the abinit-channel_ with::
|
||||
|
||||
conda install abipy -c abinit
|
||||
|
||||
One of the big advantages of conda over pip is that conda can also install
|
||||
libraries and executables written in Fortran.
|
||||
For example, one can easily install abinit inside the conda environment with::
|
||||
|
||||
conda install abinit -c abinit
|
||||
abinit --version
|
||||
|
||||
Additional information on the steps required to install AbiPy with anaconda are available
|
||||
in the `anaconda howto <http://pythonhosted.org/abipy/installation.html>`_.
|
||||
|
||||
We are also working with the spack_ community
|
||||
to provide packages for AbiPy and Abinit in order to facilitate the installation on large supercomputing centers.
|
||||
|
||||
---------------------
|
||||
Optional dependencies
|
||||
---------------------
|
||||
|
||||
Optional libraries that are required if you need certain features:
|
||||
|
||||
``ipython``
|
||||
|
||||
Required to interact with the AbiPy/Pymatgen objects in the ipython_ shell
|
||||
(strongly recommended, already provided by conda_).
|
||||
|
||||
``jupyter`` and ``nbformat``
|
||||
|
||||
Required to generate jupyter_ notebooks.
|
||||
Install these two packages with ``conda install jupyter nbformat`` or use ``pip``.
|
||||
Recommended but you will also need a web browser to open the notebook.
|
||||
|
||||
.. ``wxPython`` and ``wxmplot`` for the GUI
|
||||
.. Use ``conda install wxpython``
|
||||
.. The directory ``abipy.gui.demos`` contains demos that can be used to test the installation.
|
||||
.. of the GUI (run the script ``runall.py`` to have an overview of the different graphical interfaces).
|
||||
|
||||
Developmental version
|
||||
---------------------
|
||||
|
||||
Getting the developmental version of AbiPy is easy.
|
||||
You can clone it from the `github repository <https://github.com/abinit/abipy>`_ using this command::
|
||||
You can clone the `github repository <https://github.com/abinit/abipy>`_ with::
|
||||
|
||||
git clone https://github.com/abinit/abipy
|
||||
|
||||
After cloning the repository, type::
|
||||
For pip, use::
|
||||
|
||||
pip install -r requirements.txt
|
||||
pip install -r requirements-optional.txt
|
||||
|
||||
If you are using conda_, create a new environment (``abipy3.6``) based on python3.6 with::
|
||||
|
||||
conda create -n abipy3.6 python=3.6
|
||||
source activate abipy3.6
|
||||
|
||||
Add ``conda-forge``, ``matsci`` and ``abinit`` to your channels with::
|
||||
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels matsci
|
||||
conda config --add channels abinit
|
||||
|
||||
and install the AbiPy dependencies with::
|
||||
|
||||
conda install --file ./requirements.txt
|
||||
conda install --file ./requirements-optional.txt
|
||||
|
||||
Once the requirements have been installer (either with pip or conda), execute::
|
||||
|
||||
python setup.py install
|
||||
|
||||
|
@ -122,14 +150,14 @@ To run the suite of unit tests, make sure you have pytest_ installed and then ty
|
|||
pytest
|
||||
|
||||
in the AbiPy root directory.
|
||||
Unit tests require two additional packages that can be installed with::
|
||||
Unit tests require ``scripttest`` that can be installed with::
|
||||
|
||||
pip install nose-exclude scripttest
|
||||
pip install scripttest
|
||||
|
||||
Note that several unit tests check the integration between AbiPy and Abinit.
|
||||
In order to run the tests, you need a working set of Abinit executables and a ``manager.yml`` configuration file.
|
||||
A pre-compiled sequential version of Abinit for Linux and OSx can be installed directly from the
|
||||
`abinit channel <https://anaconda.org/abinit>`_ with::
|
||||
abinit-channel_ with::
|
||||
|
||||
conda install abinit -c abinit
|
||||
|
||||
|
@ -165,6 +193,8 @@ Below is a brief description of the different directories found there:
|
|||
The directory ``abipy/examples/flows`` contains python scripts that can be used
|
||||
to automate typical ab-initio calculations.
|
||||
|
||||
Users are strongly encouraged to explore the detailed `API docs <http://pythonhosted.org/abipy/api/index.html>`_.
|
||||
|
||||
Command line tools
|
||||
------------------
|
||||
|
||||
|
@ -181,11 +211,6 @@ The following scripts can be invoked directly from the terminal:
|
|||
|
||||
For further information, please consult the `official documentation <http://pythonhosted.org/abipy/scripts.html>`_.
|
||||
|
||||
Advanced Usage
|
||||
--------------
|
||||
|
||||
Users are strongly encouraged to explore the detailed `API docs <http://pythonhosted.org/abipy/api/index.html>`_.
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
|
@ -193,6 +218,7 @@ AbiPy is released under the GNU GPL license. For more details see the LICENSE fi
|
|||
|
||||
.. _Python: http://www.python.org/
|
||||
.. _Abinit: https://www.abinit.org
|
||||
.. _abinit-channel: https://anaconda.org/abinit
|
||||
.. _pymatgen: http://www.pymatgen.org
|
||||
.. _`abipy docpage` : http://pythonhosted.org/abipy
|
||||
.. _matplotlib: http://matplotlib.org
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
"""
|
||||
Script process the GW output generated by GWsetup using VASP or ABINIT.
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
__author__ = "Michiel van Setten"
|
||||
__copyright__ = " "
|
||||
__version__ = "0.9"
|
||||
__maintainer__ = "Michiel van Setten"
|
||||
__email__ = "mjvansetten@gmail.com"
|
||||
__date__ = "May 2014"
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from abipy.gw.datastructures import get_spec
|
||||
|
||||
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.isfile('plots'):
|
||||
os.remove('plots')
|
||||
if os.path.isfile('plot-fits'):
|
||||
os.remove('plot-fits')
|
||||
spec = get_spec('GW')
|
||||
spec.read_from_file('spec.in')
|
||||
print('Found setup for ', spec.get_code())
|
||||
spec.loop_structures('o')
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
"""
|
||||
Script to print GW results for VASP and ABINIT.
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
__author__ = "Michiel van Setten"
|
||||
__copyright__ = " "
|
||||
__version__ = "0.9"
|
||||
__maintainer__ = "Michiel van Setten"
|
||||
__email__ = "mjvansetten@gmail.com"
|
||||
__date__ = "May 2014"
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from abipy.gw.datastructures import get_spec
|
||||
|
||||
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if __name__ == "__main__":
|
||||
counter = 0
|
||||
spec_in = get_spec('GW')
|
||||
spec_in.read_from_file('spec.in')
|
||||
spec_in.loop_structures('w')
|
|
@ -1,48 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
# coding: utf-8
|
||||
"""
|
||||
Script to write GW Input for VASP and ABINIT / set up work flows.
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
import sys
|
||||
import os.path
|
||||
from abipy.gw.datastructures import get_spec
|
||||
|
||||
__author__ = "Michiel van Setten"
|
||||
__copyright__ = " "
|
||||
__version__ = "0.9"
|
||||
__maintainer__ = "Michiel van Setten"
|
||||
__email__ = "mjvansetten@gmail.com"
|
||||
__date__ = "May 2014"
|
||||
|
||||
|
||||
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def main(update=True):
|
||||
"""
|
||||
main gw setup
|
||||
"""
|
||||
spec_in = get_spec('GW')
|
||||
|
||||
try:
|
||||
spec_in.read_from_file('spec.in')
|
||||
except (IOError, OSError):
|
||||
try:
|
||||
spec_in.read_from_file('$HOME/.abinit/abipy/spec.in')
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
pass
|
||||
|
||||
if update:
|
||||
# in testing mode there should not be interactive updating
|
||||
spec_in.update_interactive()
|
||||
|
||||
spec_in.test()
|
||||
spec_in.write_to_file('spec.in')
|
||||
spec_in.loop_structures('i')
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Script to store GW results for VASP and ABINIT in a database.
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
__author__ = "Michiel van Setten"
|
||||
__copyright__ = " "
|
||||
__version__ = "0.9"
|
||||
__maintainer__ = "Michiel van Setten"
|
||||
__email__ = "mjvansetten@gmail.com"
|
||||
__date__ = "May 2014"
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
||||
from abipy.gw.datastructures import get_spec
|
||||
|
||||
MODULE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
if __name__ == "__main__":
|
||||
counter = 0
|
||||
spec_in = get_spec('GW')
|
||||
spec_in.read_from_file('spec.in')
|
||||
spec_in.loop_structures('s')
|
|
@ -1,101 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""Script to inspect the status of Abinit calculations at run-time."""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
|
||||
from monty.functools import prof_main
|
||||
from pymatgen.io.abinit.events import EventsParser
|
||||
from pymatgen.io.abinit.abiinspect import plottable_from_outfile
|
||||
from abipy import abilab
|
||||
|
||||
|
||||
@prof_main
|
||||
def main():
|
||||
|
||||
def str_examples():
|
||||
examples = """\
|
||||
Usage example:
|
||||
abiinsp.py OUTFILE status ==> Report the list of Warning, Commments, Errors
|
||||
abiinsp.py OUTFILE plot ==> Plot results of the GS Scf cycle, Phonon Scf cycle...
|
||||
abiinsp.py OUTFILE timer ==> Visualize timing data with matplotlib.
|
||||
"""
|
||||
return examples
|
||||
|
||||
|
||||
def show_examples_and_exit(err_msg=None, error_code=1):
|
||||
"""Display the usage of the script."""
|
||||
sys.stderr.write(str_examples())
|
||||
if err_msg: sys.stderr.write("Fatal Error\n" + err_msg + "\n")
|
||||
sys.exit(error_code)
|
||||
|
||||
parser = argparse.ArgumentParser(epilog=str_examples(), formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
|
||||
parser.add_argument('-V', '--version', action='version', version="%(prog)s version " + abilab.__version__)
|
||||
parser.add_argument('--loglevel', default="ERROR", type=str,
|
||||
help="set the loglevel. Possible values: CRITICAL, ERROR (default), WARNING, INFO, DEBUG")
|
||||
parser.add_argument('filepath', nargs="?", help="File to inspect (output file or log file)")
|
||||
|
||||
# Create the parsers for the sub-commands
|
||||
subparsers = parser.add_subparsers(dest='command', help='sub-command help', description="Valid subcommands")
|
||||
|
||||
# Subparser for status command.
|
||||
p_status = subparsers.add_parser('status', help="Check the status of the run (errors, warning, completion)")
|
||||
#p_status.add_argument('format', nargs="?", default="cif", type=str, help="Format of the output file (ciff, POSCAR, json).")
|
||||
|
||||
# Subparser for plot command.
|
||||
p_plot = subparsers.add_parser('plot', help="Plot data")
|
||||
#p_plot.add_argument('visualizer', nargs="?", default="xcrysden", type=str, help="Visualizer.")
|
||||
|
||||
p_timer = subparsers.add_parser('timer', help="Show timing data.")
|
||||
|
||||
p_pseudo = subparsers.add_parser('pseudo', help="Show info on pseudopotential file.")
|
||||
|
||||
# Parse command line.
|
||||
try:
|
||||
options = parser.parse_args()
|
||||
except Exception:
|
||||
show_examples_and_exit(error_code=1)
|
||||
|
||||
# loglevel is bound to the string value obtained from the command line argument.
|
||||
# Convert to upper case to allow the user to specify --loglevel=DEBUG or --loglevel=debug
|
||||
import logging
|
||||
numeric_level = getattr(logging, options.loglevel.upper(), None)
|
||||
if not isinstance(numeric_level, int):
|
||||
raise ValueError('Invalid log level: %s' % options.loglevel)
|
||||
logging.basicConfig(level=numeric_level)
|
||||
|
||||
if options.command == "status":
|
||||
# Parse the Abinit Events in filepath.
|
||||
parser = EventsParser()
|
||||
report = parser.parse(options.filepath)
|
||||
print(report)
|
||||
|
||||
elif options.command == "plot":
|
||||
# TODO: At present only GS runs are supported by plottable_from_outfile
|
||||
obj = plottable_from_outfile(options.filepath)
|
||||
|
||||
if obj is not None:
|
||||
obj.plot()
|
||||
else:
|
||||
raise ValueError("Don't know how to extract plottable data from %s" % options.filepath)
|
||||
|
||||
elif options.command == "timer":
|
||||
parser = abilab.AbinitTimerParser()
|
||||
parser.parse(options.filepath)
|
||||
|
||||
elif options.command == "pseudo":
|
||||
from pymatgen.io.abinit.pseudos import PseudoParser
|
||||
pseudo = PseudoParser().parse(options.filepath)
|
||||
print(pseudo)
|
||||
|
||||
else:
|
||||
raise ValueError("Unsupported command %s" % options.command)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,282 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
abi script to generate and post process flows for phonons.
|
||||
|
||||
needs a cif file in the working dir,
|
||||
needs the ABINIT_PS and ABINIT_PS_EXT environmental variables set to obtain pseudo's.
|
||||
Pseudo's wil be read as:
|
||||
|
||||
$ABINIT_PS/element$ABINIT_PS_EXT
|
||||
|
||||
optionally a qpoint file, if this is not present a 444 mesh will be used.
|
||||
TODO automatic QPOINT setup
|
||||
|
||||
if no flow is present a new flow will be generated for the cif file
|
||||
if a finished flow is found the DDB files will be fully merged and various anaddb tasks are executed.
|
||||
the anaddb task will appear in a new work in the flow.
|
||||
|
||||
TODO include the same interface as in abiGWsetup to enable precision setting, multiple input sources, ...
|
||||
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
__author__ = "Michiel van Setten, Matteo Giantomassi"
|
||||
__copyright__ = " "
|
||||
__version__ = "0.9"
|
||||
__maintainer__ = "Michiel van Setten"
|
||||
__email__ = "mjvansetten@gmail.com"
|
||||
__date__ = "Dec. 2014"
|
||||
|
||||
import ast
|
||||
import os
|
||||
import sys
|
||||
import numpy as np
|
||||
import abipy.abilab as abilab
|
||||
|
||||
from pymatgen.io.abinit.pseudos import PseudoTable
|
||||
|
||||
|
||||
def unique_rows(a):
|
||||
a = np.ascontiguousarray(a)
|
||||
unique_a = np.unique(a.view([('', a.dtype)]*a.shape[1]))
|
||||
return unique_a.view(a.dtype).reshape((unique_a.shape[0], a.shape[1]))
|
||||
|
||||
|
||||
def to_vec(var_dict, var):
|
||||
"""
|
||||
turn the entry var in the dictionary var_dict into an vector length 3
|
||||
"""
|
||||
tmp = var_dict[var]
|
||||
tmp = 3*[tmp] if not isinstance(tmp, (list, tuple)) else tmp
|
||||
var_dict[var] = tmp
|
||||
|
||||
|
||||
def to_vecs(var_dict):
|
||||
"""
|
||||
turn the items in list into vectors if they are present
|
||||
"""
|
||||
vec_list = ['ngkpt', 'acell']
|
||||
for var in vec_list:
|
||||
if var in var_dict.keys():
|
||||
to_vec(var_dict, var)
|
||||
|
||||
|
||||
def scf_ph_inputs(structure, options):
|
||||
"""
|
||||
This function constructs the input files for the phonon calculation:
|
||||
GS input + the input files for the phonon calculation.
|
||||
"""
|
||||
|
||||
abi_pseudo = os.environ['ABINIT_PS_EXT']
|
||||
abi_pseudo_dir = os.environ['ABINIT_PS']
|
||||
pseudos = []
|
||||
for element in structure.composition.element_composition:
|
||||
pseudo = os.path.join(abi_pseudo_dir, str(element) + abi_pseudo)
|
||||
pseudos.append(pseudo)
|
||||
pseudos = PseudoTable(pseudos)
|
||||
|
||||
#print('bounds:\n', structure.calc_kptbounds)
|
||||
#print('ngkpt:\n', structure.calc_ngkpt(4))
|
||||
print('ks:\n', structure.calc_ksampling(4)) # try to get the qpoints from this ...
|
||||
|
||||
qptbounds = structure.calc_kptbounds()
|
||||
qptbounds = np.reshape(qptbounds, (-1, 3))
|
||||
|
||||
# List of q-points for the phonon calculation.
|
||||
qpoints = [
|
||||
0.00000000E+00, 0.00000000E+00, 0.00000000E+00,
|
||||
2.50000000E-01, 0.00000000E+00, 0.00000000E+00,
|
||||
2.50000000E-01, 0.00000000E+00, 2.50000000E+00,
|
||||
5.00000000E-01, 0.00000000E+00, 0.00000000E+00,
|
||||
2.50000000E-01, 2.50000000E-01, 0.00000000E+00,
|
||||
5.00000000E-01, 2.50000000E-01, 0.00000000E+00,
|
||||
-2.50000000E-01, 2.50000000E-01, 0.00000000E+00,
|
||||
5.00000000E-01, 5.00000000E-01, 0.00000000E+00,
|
||||
0.00000000E+00, 0.00000000E+00, 2.50000000E-01,
|
||||
-2.50000000E-01, 5.00000000E-01, 2.50000000E-01,
|
||||
]
|
||||
qpoints2 = [
|
||||
0.00000000E+00, 0.00000000E+00, 0.00000000E+00,
|
||||
5.00000000E-01, 0.00000000E+00, 0.00000000E+00,
|
||||
0.00000000E-01, 5.00000000E-01, 0.00000000E+00,
|
||||
0.00000000E+00, 0.00000000E+00, 5.00000000E-01,
|
||||
5.00000000E-01, 5.00000000E-01, 0.00000000E+00,
|
||||
0.00000000E+00, 5.00000000E-01, 5.00000000E-01,
|
||||
5.00000000E-01, 0.00000000E+00, 5.00000000E-01,
|
||||
5.00000000E-01, 5.00000000E-01, 5.00000000E-01,
|
||||
]
|
||||
|
||||
qpoints = np.reshape(qpoints, (-1, 3))
|
||||
qpoints = unique_rows(np.concatenate((qpoints, qptbounds), axis=0))
|
||||
|
||||
if os.path.isfile('qpoints'):
|
||||
f = open('qpoints', 'r')
|
||||
qpoints = np.reshape(ast.literal_eval(f.read()), (-1, 3))
|
||||
f.close()
|
||||
|
||||
# Global variables used both for the GS and the DFPT run.
|
||||
global_vars = dict(
|
||||
istwfk='*1',
|
||||
ecut=16.0,
|
||||
ngkpt=[8, 8, 8],
|
||||
shiftk=[0, 0, 0],
|
||||
paral_kgb=0,
|
||||
nstep=200)
|
||||
|
||||
global_vars.update(options)
|
||||
|
||||
to_vecs(global_vars)
|
||||
|
||||
inp = abilab.AbiInput(pseudos=pseudos, ndtset=1+len(qpoints))
|
||||
|
||||
inp.set_structure(structure)
|
||||
inp.set_variables(**global_vars)
|
||||
|
||||
inp[1].set_variables(tolwfr=1.0e-18, prtden=1, paral_kgb=1)
|
||||
|
||||
for i, qpt in enumerate(qpoints):
|
||||
# Response-function calculation for phonons.
|
||||
inp[i+2].set_variables(
|
||||
tolvrs=1.0e-10,
|
||||
kptopt=3,
|
||||
iscf=5,
|
||||
rfphon=1, # Will consider phonon-type perturbation
|
||||
nqpt=1, # One wavevector is to be considered
|
||||
qpt=qpt, # This wavevector is q=0 (Gamma)
|
||||
)
|
||||
|
||||
#rfatpol 1 1 # Only the first atom is displaced
|
||||
#rfdir 1 0 0 # Along the first reduced coordinate axis
|
||||
#kptopt 2 # Automatic generation of k points, taking
|
||||
|
||||
# Split input into gs_inp and ph_inputs
|
||||
return inp.split_datasets()
|
||||
|
||||
|
||||
def run_annaddb(flow, structure):
|
||||
|
||||
#structure = flow[0][0].
|
||||
manager = abilab.TaskManager.from_user_config()
|
||||
|
||||
# We should have a DDB files with IFC(q) in work.outdir
|
||||
ddb_files = []
|
||||
for work in flow[1:]:
|
||||
ddbs = work.outdir.list_filepaths(wildcard="*DDB")
|
||||
assert len(ddbs) == 1
|
||||
ddb_files.append(ddbs[0])
|
||||
|
||||
# TODO: Check automatic restart
|
||||
assert all(work.finalized for work in flow)
|
||||
assert flow.all_ok
|
||||
|
||||
# Merge the DDB files
|
||||
out_ddb = flow.outdir.path_in("flow_DDB")
|
||||
ddb_path = abilab.Mrgddb(manager=manager).merge(flow.outdir.path, ddb_files, out_ddb=out_ddb,
|
||||
description="DDB generated by %s" % __file__)
|
||||
|
||||
assert ddb_path == out_ddb
|
||||
|
||||
# Build new work with Anaddb tasks.
|
||||
# Construct a manager with mpi_ncpus==1 since anaddb do not support mpi_ncpus > 1 (except in elphon)
|
||||
shell_manager = manager.to_shell_manager()
|
||||
awork = abilab.Work(manager=shell_manager)
|
||||
|
||||
# modes
|
||||
anaddb_input = abilab.AnaddbInput.modes(structure)
|
||||
atask = abilab.AnaddbTask(anaddb_input, ddb_node=ddb_path, manager=shell_manager)
|
||||
awork.register(atask)
|
||||
|
||||
# Thermodynamics
|
||||
anaddb_input = abilab.AnaddbInput.thermo(structure, ngqpt=(40, 40, 40), nqsmall=20)
|
||||
atask = abilab.AnaddbTask(anaddb_input, ddb_node=ddb_path, manager=shell_manager)
|
||||
awork.register(atask)
|
||||
|
||||
# Phonons bands and DOS with gaussian method
|
||||
anaddb_input = abilab.AnaddbInput.phbands_and_dos(
|
||||
structure, ngqpt=(4, 4, 4), nqsmall=10, ndivsm=5, dos_method="gaussian: 0.001 eV")
|
||||
atask = abilab.AnaddbTask(anaddb_input, ddb_node=ddb_path, manager=shell_manager)
|
||||
awork.register(atask)
|
||||
|
||||
# Phonons bands and DOS with tetrahedron method
|
||||
anaddb_input = abilab.AnaddbInput.phbands_and_dos(
|
||||
structure, ngqpt=(4, 4, 4), nqsmall=10, ndivsm=5, dos_method="tetra")
|
||||
atask = abilab.AnaddbTask(anaddb_input, ddb_node=ddb_path, manager=shell_manager)
|
||||
awork.register(atask)
|
||||
|
||||
flow.register_work(awork)
|
||||
flow.allocate()
|
||||
flow.build()
|
||||
|
||||
for i, atask in enumerate(awork):
|
||||
print("about to run anaddb task: %d" % i)
|
||||
atask.start_and_wait()
|
||||
#assert atask.status == atask.S_DONE
|
||||
atask.check_status()
|
||||
#assert atask.status == atask.S_OK
|
||||
|
||||
# TODO: output files are not produced in outdir
|
||||
#assert len(atask.outdir.list_filepaths(wildcard="*PHBST.nc")) == 1
|
||||
#assert len(atask.outdir.list_filepaths(wildcard="*PHDOS.nc")) == 1
|
||||
|
||||
|
||||
def build_flow(structure, workdir, options):
|
||||
"""
|
||||
Create a :class:`Flow` for phonon calculations:
|
||||
|
||||
1) One work for the GS run.
|
||||
|
||||
2) nqpt workflows for phonon calculations. Each workflow contains
|
||||
nirred tasks where nirred is the number of irreducible phonon perturbations
|
||||
for that particular q-poin t.
|
||||
"""
|
||||
|
||||
# Instantiate the TaskManager.
|
||||
manager = abilab.TaskManager.from_user_config()
|
||||
|
||||
all_inps = scf_ph_inputs(structure, options)
|
||||
scf_input, ph_inputs = all_inps[0], all_inps[1:]
|
||||
if len(ph_inputs) == 1:
|
||||
return abilab.phonon_flow(workdir, manager, scf_input, ph_inputs, with_nscf=False, with_ddk=True, with_dde=True)
|
||||
else:
|
||||
return abilab.phonon_flow(workdir, manager, scf_input, ph_inputs, with_nscf=True, with_ddk=False, with_dde=False)
|
||||
|
||||
|
||||
class NotReady(Exception):
|
||||
"""
|
||||
previous flow is not complete
|
||||
"""
|
||||
|
||||
|
||||
#@abilab.flow_main
|
||||
def main():
|
||||
|
||||
cifs = [f for f in os.listdir('.') if f.endswith('cif')]
|
||||
convtests = {'ecut': [16, 20, 24, 37], 'ngkpt': [8], 'acell': [1.0]}
|
||||
|
||||
for cif in cifs:
|
||||
structure = abilab.Structure.from_file(cif)
|
||||
print(type(structure))
|
||||
structure = structure.get_sorted_structure_z()
|
||||
print(structure)
|
||||
structure.item = cif
|
||||
for convtest in convtests:
|
||||
for value in convtests[convtest]:
|
||||
|
||||
workdir = '%s_%s_%s' % (structure.item, str(convtest), str(value))
|
||||
|
||||
try:
|
||||
flow = abilab.Flow.pickle_load(workdir)
|
||||
if not flow.all_ok:
|
||||
raise NotReady
|
||||
run_annaddb(flow=flow, structure=structure)
|
||||
except NotReady:
|
||||
pass
|
||||
except (ValueError, IOError):
|
||||
options = {convtest: value}
|
||||
flow = build_flow(structure=structure, workdir=workdir, options=options)
|
||||
flow.build_and_pickle_dump()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,83 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Script to plot pseudopotential data and/or compare multiple pseudopotentials.
|
||||
It invokes Abinit to produce the PSPS.nc files with form-factors, model core charges
|
||||
and other quantities used by Abinit to apply the non-local part of the KS Hamiltonian.
|
||||
"""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from abipy.electrons.psps import PspsFile, compare_pseudos
|
||||
from abipy import abilab
|
||||
|
||||
|
||||
def main():
|
||||
def str_examples():
|
||||
return """\
|
||||
Usage example:
|
||||
abipsps.py pseudo => Visualize data relative to a single pseudo.
|
||||
abipsps.py pseudo1 pseudo2 => Compare pseudo1 with pseudo2 (accept an arbitrary number of pseudos).
|
||||
"""
|
||||
|
||||
def show_examples_and_exit(err_msg=None, error_code=1):
|
||||
"""Display the usage of the script."""
|
||||
sys.stderr.write(str_examples())
|
||||
if err_msg: sys.stderr.write("Fatal Error\n" + err_msg + "\n")
|
||||
sys.exit(error_code)
|
||||
|
||||
# Build the main parser.
|
||||
parser = argparse.ArgumentParser(epilog=str_examples(), formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
|
||||
parser.add_argument('-V', '--version', action='version', version="%(prog)s version " + abilab.__version__)
|
||||
parser.add_argument('-v', '--verbose', default=0, action='count', # -vv --> verbose=2
|
||||
help='verbose, can be supplied multiple times to increase verbosity')
|
||||
parser.add_argument('--loglevel', default="ERROR", type=str,
|
||||
help="set the loglevel. Possible values: CRITICAL, ERROR (default), WARNING, INFO, DEBUG")
|
||||
|
||||
parser.add_argument("-e", '--ecut', type=float, default=10, help="Cutoff energy in Hartree (default: 10).")
|
||||
parser.add_argument('--seaborn', action="store_true", help="Use seaborn settings")
|
||||
|
||||
parser.add_argument('pseudos', nargs="+", help="Pseudo or list of pseudopotential files")
|
||||
|
||||
# Parse command line.
|
||||
try:
|
||||
options = parser.parse_args()
|
||||
except Exception as exc:
|
||||
show_examples_and_exit(error_code=1)
|
||||
|
||||
# loglevel is bound to the string value obtained from the command line argument.
|
||||
# Convert to upper case to allow the user to specify --loglevel=DEBUG or --loglevel=debug
|
||||
import logging
|
||||
numeric_level = getattr(logging, options.loglevel.upper(), None)
|
||||
if not isinstance(numeric_level, int):
|
||||
raise ValueError('Invalid log level: %s' % options.loglevel)
|
||||
logging.basicConfig(level=numeric_level)
|
||||
|
||||
if options.seaborn:
|
||||
import seaborn as sns
|
||||
#sns.set(style='ticks', palette='Set2')
|
||||
#sns.set(style="dark", palette="Set2")
|
||||
#And to remove "chartjunk", do:
|
||||
#sns.despine()
|
||||
#plt.tight_layout()
|
||||
#sns.despine(offset=10, trim=True)
|
||||
|
||||
pseudos = options.pseudos
|
||||
|
||||
if len(pseudos) > 1:
|
||||
compare_pseudos(pseudos, options.ecut)
|
||||
|
||||
else:
|
||||
pseudo = abilab.Pseudo.from_file(pseudos[0])
|
||||
with pseudo.open_pspsfile(ecut=options.ecut) as psps:
|
||||
print("Printing data from:", psps.filepath)
|
||||
psps.plot()
|
||||
#psps.plot_ffspl()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,265 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
Fabric file providing useful tools for the synchronization of the code on the CECI clusters.
|
||||
"""
|
||||
from __future__ import print_function, division, unicode_literals, absolute_import
|
||||
|
||||
import os
|
||||
import cStringIO as StringIO
|
||||
|
||||
from fabric.api import local, settings, abort, run, cd, env, prefix, put
|
||||
from contextlib import contextmanager as _contextmanager
|
||||
|
||||
env.user = "gmatteo"
|
||||
|
||||
USER_HOME = "~" + env.user
|
||||
|
||||
# The directory of the virtual environment.
|
||||
VENV = "~/VENV-2.7"
|
||||
|
||||
#env.password = ""
|
||||
|
||||
# We store our git branches in this directory
|
||||
GIT_REPOSDIR = USER_HOME + "/git_repos"
|
||||
|
||||
git_urls = {
|
||||
"abipy": "https://github.com/gmatteo/abipy.git",
|
||||
"pymatgen": "https://github.com/gmatteo/pymatgen.git",
|
||||
#"matplotlib": "https://github.com/matplotlib/matplotlib.git",
|
||||
#"abipy": "git@github.com:gmatteo/abipy.git",
|
||||
#"pymatgen": "git@github.com:gmatteo/pymatgen.git",
|
||||
#"matplotlib": "git@github.com:matplotlib/matplotlib.git",
|
||||
#git://git.gnome.org/pygtk
|
||||
}
|
||||
|
||||
git_repospaths = [os.path.join(GIT_REPOSDIR, dirpath) for dirpath in git_urls]
|
||||
|
||||
# We store our bzr branches in this directory
|
||||
bzr_reposdir = USER_HOME + "/bzr_repos"
|
||||
|
||||
bzr_branchurl = "bzr+ssh://forge.abinit.org/abinit/gmatteo/7.11.5-public"
|
||||
|
||||
to_location = os.path.join(*bzr_branchurl.split("/")[-2:]).replace("/", "_")
|
||||
|
||||
repo_path = os.path.join(bzr_reposdir, to_location)
|
||||
build_path = os.path.join(repo_path, "build")
|
||||
|
||||
|
||||
@_contextmanager
|
||||
def _virtualenv(venv_dir):
|
||||
with prefix("source %s" % os.path.join(venv_dir, "bin", "activate")):
|
||||
yield
|
||||
|
||||
|
||||
def _exists(path):
|
||||
"""True if path exists on the remote host."""
|
||||
return run('test -e %s' % path, warn_only=True, quiet=True).succeeded
|
||||
|
||||
|
||||
def _cpu_count():
|
||||
"""Returns the number of CPUs in the remote host."""
|
||||
with _virtualenv(VENV):
|
||||
cmd = run("python -c 'import multiprocessing, sys; sys.exit(multiprocessing.cpu_count())'")
|
||||
return cmd.return_code
|
||||
|
||||
|
||||
def all_hosts():
|
||||
"""
|
||||
Used to run the command on all the CECI clusters.
|
||||
example: fab all_hosts pip_install abipy
|
||||
"""
|
||||
env.hosts = [
|
||||
#"green.cism.ucl.ac.be",
|
||||
#"manneback.cism.ucl.ac.be",
|
||||
"hmem.cism.ucl.ac.be",
|
||||
"lemaitre2.cism.ucl.ac.be",
|
||||
"vega.ulb.ac.be",
|
||||
"dragon1.umons.ac.be",
|
||||
"hercules.ptci.unamur.be",
|
||||
"nic4.segi.ulg.ac.be",
|
||||
]
|
||||
|
||||
|
||||
def git_pull():
|
||||
"""
|
||||
Synchronize the git branches with the master branches located on github.
|
||||
"""
|
||||
# Create ~/git_repos and clone the repositories if this is the first time.
|
||||
if not _exists(GIT_REPOSDIR):
|
||||
run("mkdir %s" % GIT_REPOSDIR)
|
||||
|
||||
with cd(GIT_REPOSDIR):
|
||||
for name, url in git_urls.items():
|
||||
if not _exists(name):
|
||||
run("git clone %s" % url)
|
||||
|
||||
# Pull from github.
|
||||
for apath in git_repospaths:
|
||||
with cd(apath):
|
||||
run("git pull")
|
||||
|
||||
|
||||
def git_install():
|
||||
"""Install the code of the git branches."""
|
||||
git_pull()
|
||||
for apath in git_repospaths:
|
||||
with cd(apath), _virtualenv(VENV):
|
||||
run("python setup.py clean")
|
||||
#run("rm -rf build")
|
||||
#run("rm -rf sdist")
|
||||
#run("python setup.py install")
|
||||
run("python setup.py develop")
|
||||
|
||||
|
||||
def git_checkout():
|
||||
"""Perform git_checkout."""
|
||||
for apath in git_repospaths:
|
||||
with cd(apath), _virtualenv(VENV):
|
||||
run("git checkout .")
|
||||
|
||||
|
||||
def pytest(opts=""):
|
||||
"""
|
||||
Run the test suite with py.test. Usage: pytests:"-v"
|
||||
"""
|
||||
for apath in git_repospaths:
|
||||
if "pymatgen" in apath: continue
|
||||
with cd(apath), _virtualenv(VENV):
|
||||
run("py.test %s" % opts)
|
||||
|
||||
|
||||
def pip_install(*options):
|
||||
"""
|
||||
Execute `pip install options` on the remote hosts.
|
||||
Examples:
|
||||
|
||||
pip_install foo bar
|
||||
|
||||
.. note:
|
||||
use the virtual environment VENV
|
||||
"""
|
||||
with _virtualenv(VENV):
|
||||
run("pip install %s" % " ".join(o for o in options))
|
||||
|
||||
|
||||
def py_version():
|
||||
"""
|
||||
Show the default python version and the python modules
|
||||
available on the remote machines.
|
||||
"""
|
||||
out = run("python --version", quiet=True)
|
||||
py_version = out.split()[1]
|
||||
|
||||
out = StringIO.StringIO()
|
||||
run("module available", stdout=out)
|
||||
|
||||
py_modules = []
|
||||
for o in out.getvalue().splitlines():
|
||||
py_modules.extend([s for s in o.split() if "python" in s])
|
||||
|
||||
print("default python:", py_version, "python modules:", py_modules)
|
||||
|
||||
|
||||
def bzr_pull():
|
||||
"""
|
||||
Upload the bzr repository on the remote clusters.
|
||||
"""
|
||||
# Create ~/bzr_repos and clone the repositories if this is the first time.
|
||||
print("repo_path", repo_path, "to_location", to_location)
|
||||
|
||||
with _virtualenv(VENV):
|
||||
if not _exists(bzr_reposdir):
|
||||
run("mkdir %s" % bzr_reposdir)
|
||||
|
||||
if not _exists(repo_path):
|
||||
with cd(bzr_reposdir):
|
||||
run("bzr branch %s %s" % (bzr_branchurl, to_location))
|
||||
|
||||
# Pull the branch
|
||||
with cd(repo_path):
|
||||
run("bzr pull")
|
||||
run("bzr status")
|
||||
|
||||
|
||||
def upload_file(local_path, remote_path, mode=None):
|
||||
"""
|
||||
Copy local_path to host:remote_path.
|
||||
If mode is not None `chmod mode remote_path` is executed.
|
||||
"""
|
||||
put(local_path, remote_path)
|
||||
|
||||
if mode is not None:
|
||||
run("chmod %s %s" % (mode, remote_path))
|
||||
|
||||
|
||||
def wget(urls):
|
||||
"""
|
||||
Download files on the remove host from URLS to ~/Downloads
|
||||
|
||||
fab wget:"foo.tar.gz bar.tar.gz"
|
||||
"""
|
||||
downloads_dir = "Downloads"
|
||||
|
||||
with cd (USER_HOME):
|
||||
if not _exists(downloads_dir):
|
||||
run("mkdir %s" % downloads_dir)
|
||||
|
||||
with cd(downloads_dir):
|
||||
for u in urls.split():
|
||||
run("wget %s " % u)
|
||||
|
||||
|
||||
def upload_key(key):
|
||||
"""
|
||||
key: path of the SSH key to upload on the cluster.
|
||||
"""
|
||||
if not _exists("~/.ssh/"): run("mkdir ~/.ssh")
|
||||
filename = os.path.basename(key)
|
||||
remotepath = "~/.ssh/" + filename
|
||||
put(key, remotepath)
|
||||
run("chmod go-rwx %s" % remotepath)
|
||||
|
||||
|
||||
#def use_ssh_agent():
|
||||
# run("eval $(ssh-agent)")
|
||||
# run("ssh-add ~/.ssh/id_rsa.ceci")
|
||||
|
||||
|
||||
def abinit_version():
|
||||
"""Show the version of Abinit available on the remote host."""
|
||||
if run("abinit --version", warn_only=True, quiet=True).return_code:
|
||||
run("mpirun abinit --version") # Try to prepend mpirun
|
||||
|
||||
|
||||
def abinit_build(self):
|
||||
"""Show the Abinit build parameters."""
|
||||
if run("abinit --build", warn_only=True, quiet=True).return_code:
|
||||
run("mpirun abinit --build") # Try to prepend mpirun
|
||||
|
||||
|
||||
def abinit_makemake():
|
||||
"""Run abinit makemake to generate configure script."""
|
||||
with cd(repo_path):
|
||||
run("./config/scripts/makemake")
|
||||
|
||||
|
||||
def abinit_build():
|
||||
with cd(build_path):
|
||||
conf_file = os.path.join(bzr_reposdir, "build.ac")
|
||||
run("../configure --with-config-file=%s" % conf_file)
|
||||
run("make clean")
|
||||
run("make -j8")
|
||||
|
||||
|
||||
def abinit_makeall(self):
|
||||
"""Runs abinit makemake and build."""
|
||||
abinit_makemake()
|
||||
abinit_build()
|
||||
|
||||
|
||||
def abinit_runtests(opts=""):
|
||||
"""
|
||||
Run the abinit automatic tests. Usage: abinit_runtests:"-j8 -k GW"
|
||||
"""
|
||||
with cd(build_path):
|
||||
run("../tests/runtests.py %s" % opts)
|
|
@ -1,116 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""Extract the names of the entities defined in a fortran datatype."""
|
||||
from __future__ import print_function, division, unicode_literals, absolute_import
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
|
||||
def remove_text_in_parenthesis(s):
|
||||
return re.sub(r'\([^)]*\)', '', s)
|
||||
|
||||
|
||||
class FortypeParserError(Exception):
|
||||
"""Exceptions raised by FortypeParser."""
|
||||
|
||||
|
||||
class FortypeParser(object):
|
||||
"""
|
||||
Extracts the name of the variables defined in a Fortran datatype
|
||||
Assumes plain F90 format without CPP macros.
|
||||
"""
|
||||
Error = FortypeParserError
|
||||
|
||||
# Name of the type ("type xxxx", "type :: xxxx" or "type, yyy :: xxxx"
|
||||
re_name_type = re.compile('^[ \t]*type[ ]*(|.*::)[ ]*(?P<name>\w+)', re.IGNORECASE)
|
||||
|
||||
# Detect "end type"
|
||||
re_end_type = re.compile('^[ \t]*end[ ]+type[ ]*(?P<name>\w+)', re.IGNORECASE)
|
||||
|
||||
def __init__(self, filepath, ftype_name):
|
||||
"""
|
||||
Args:
|
||||
filepath:
|
||||
Fortran file with the declaraion of the datatype
|
||||
ftype_name:
|
||||
Name of the datatype
|
||||
"""
|
||||
# Open the file and find the section with the type declaration.
|
||||
indec, self.declaration = 0, []
|
||||
with open(filepath) as fh:
|
||||
for line in fh:
|
||||
line = line.lower().strip()
|
||||
if not line or line.startswith("!"):
|
||||
continue
|
||||
|
||||
m = self.re_name_type.match(line)
|
||||
if m and m.groups()[1] == ftype_name:
|
||||
#print(m, m.groups())
|
||||
indec = 1
|
||||
|
||||
if indec:
|
||||
self.declaration.append(line)
|
||||
m = self.re_end_type.match(line)
|
||||
if m:
|
||||
#print(m.groups())
|
||||
if m.groups()[0] != ftype_name:
|
||||
raise self.Error("Cannot find end to type declaration!")
|
||||
break
|
||||
|
||||
if not self.declaration:
|
||||
raise self.Error("Cannot find declaration of Fortran type: %s" % ftype_name)
|
||||
|
||||
# Here we assume abinit coding rules e.g. real :: var
|
||||
# and we use "::" to find the section with the variables.
|
||||
self.varnames, badlines = [], []
|
||||
for dec in self.declaration[1:-1]:
|
||||
s = dec.find("::")
|
||||
if s == -1:
|
||||
badlines.append(dec)
|
||||
else:
|
||||
# Strip comments.
|
||||
dec = dec[s+2:]
|
||||
e = dec.find("!")
|
||||
if e != -1:
|
||||
dec = dec[:e]
|
||||
|
||||
# Dec is the string containing our variables.
|
||||
# Remove text inside (..) to avoid problems with arrays and split using ,
|
||||
# print("dec: ", dec)
|
||||
tokens = remove_text_in_parenthesis(dec)
|
||||
tokens = [s.strip() for s in tokens.split(",")]
|
||||
|
||||
self.varnames.extend(tokens)
|
||||
|
||||
if badlines:
|
||||
print(badlines)
|
||||
err_msg = "You are not following abinit coding rules"
|
||||
raise ValueError(err_msg)
|
||||
|
||||
def __str__(self):
|
||||
return "\n".join(self.varnames)
|
||||
|
||||
def json_dump(self, stream=sys.stdout):
|
||||
import json
|
||||
json.dump(self.varnames, stream, indent=4)
|
||||
|
||||
|
||||
def main():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
parser.add_argument('filepath', help="Fortran file with the declaration of the datatype")
|
||||
parser.add_argument('datatype', help="Name of the datatype to be analyzed")
|
||||
|
||||
options = parser.parse_args()
|
||||
|
||||
p = FortypeParser(options.filepath, options.datatype)
|
||||
#import pprint
|
||||
#pprint.pprint(p.varnames)
|
||||
p.json_dump()
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -1,67 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
"""This script wraps the Fortran executable mrgddb."""
|
||||
from __future__ import unicode_literals, division, print_function, absolute_import
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from abipy.abilab import Mrgddb, TaskManager
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
def str_examples():
|
||||
examples = (
|
||||
"Example usage:\n\n"
|
||||
"mrgddb -o output_DDB file1_DDB file2_DDB\n"
|
||||
"mrgddb -o output_DDB -d 'String with description' file1_DDB file2_DDB\n"
|
||||
"mrgddb -o output_DDB *_DDB\n"
|
||||
)
|
||||
return examples
|
||||
|
||||
def show_examples_and_exit(err_msg=None, error_code=0):
|
||||
""""Display the usage of the script."""
|
||||
sys.stderr.write(str_examples())
|
||||
if err_msg:
|
||||
sys.stderr.write("Fatal Error\n" + err_msg + "\n")
|
||||
sys.exit(error_code)
|
||||
|
||||
#print(sys.argv)
|
||||
parser = argparse.ArgumentParser(epilog=str_examples(),
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,)
|
||||
|
||||
parser.add_argument('-v', '--verbose', default=0, action='count', # -vv --> verbose=2
|
||||
help='verbose, can be supplied multiple times to increase verbosity.')
|
||||
|
||||
parser.add_argument('-e', '--executable', metavar='STRING', type=str, default="mrgddb", help="Path to the mrgddb executable.")
|
||||
|
||||
parser.add_argument('-d', '--description', metavar='STRING', type=str, default="No description available",
|
||||
help="Description added to the merged DDB file.")
|
||||
|
||||
parser.add_argument('-o', '--out_ddb', metavar='STRING', type=str, default="", help="Name of the output DDB file")
|
||||
|
||||
parser.add_argument('ddb_files', nargs="+", help="List of DDB files to merge.")
|
||||
|
||||
# Parse the command line.
|
||||
try:
|
||||
options = parser.parse_args()
|
||||
except Exception:
|
||||
show_examples_and_exit(error_code=1)
|
||||
|
||||
if not options.out_ddb:
|
||||
raise ValueError("out_ddb must be specified")
|
||||
|
||||
manager = TaskManager.from_user_config()
|
||||
mrgddb = Mrgddb(manager=manager, executable=options.executable, verbose=options.verbose)
|
||||
|
||||
try:
|
||||
workdir = "."
|
||||
mrgddb.merge(workdir, options.ddb_files, options.out_ddb, options.description)
|
||||
except Exception:
|
||||
print("got ddb_files: ", options.ddb_files)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
|
@ -11,10 +11,8 @@ if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
|||
else
|
||||
if [[ "${PYTHON_VERSION}" == "2.7" ]]; then
|
||||
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
#wget https://repo.continuum.io/miniconda/Miniconda2-4.3.14-Linux-x86_64.sh -O miniconda.sh;
|
||||
else
|
||||
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
|
||||
#wget https://repo.continuum.io/miniconda/Miniconda3-4.3.14-Linux-x86_64.sh -O miniconda.sh;
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,23 +1,25 @@
|
|||
#!/bin/bash
|
||||
set -e # exit on first error
|
||||
|
||||
echo Installing AbiPy dependencies with conda.
|
||||
echo Adding conda-forge, matsci and abinit to channels
|
||||
echo Working in CONDA_PREFIX: ${CONDA_PREFIX}
|
||||
echo "Installing AbiPy dependencies with conda."
|
||||
echo "Adding conda-forge, matsci and abinit to channels"
|
||||
echo "Working in CONDA_PREFIX: ${CONDA_PREFIX} ..."
|
||||
conda config --add channels conda-forge
|
||||
conda config --add channels matsci
|
||||
conda config --add channels abinit
|
||||
|
||||
echo "Installing requirements listed requirements.txt and requirements-optional.txt ..."
|
||||
# https://github.com/ContinuumIO/anaconda-issues/issues/542
|
||||
conda install -y -c anaconda setuptools
|
||||
conda install -y --file ./requirements.txt
|
||||
conda install -y --file ./requirements-optional.txt
|
||||
# Install bader (http://theory.cm.utexas.edu/henkelman/code/bader/) from matsci
|
||||
|
||||
echo "Installing bader executable (http://theory.cm.utexas.edu/henkelman/code/bader/) from matsci ..."
|
||||
conda install -y -c matsci bader
|
||||
|
||||
# Install abinit from abinit conda channel.
|
||||
echo "Installing abinit from abinit channel ..."
|
||||
conda install -y -c gmatteo abinit=${ABINIT_VERSION}
|
||||
abinit --version
|
||||
abinit --build
|
||||
|
||||
echo Installation complete. Use: conda install abinit to install Fortran executable
|
||||
echo "Installation completed"
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# http://www.willmcginnis.com/2016/02/29/automating-documentation-workflow-with-sphinx-and-github-pages/
|
||||
|
||||
HTML_PATH=./docs/_build/html
|
||||
|
||||
# build the docs
|
||||
cd docs && make clean && make html && cd ..
|
||||
|
||||
# commit and push
|
||||
git add -A && git commit -m "building and pushing docs" && git push origin master
|
||||
|
||||
# switch branches and pull the data we want
|
||||
git checkout gh-pages
|
||||
rm -rf .
|
||||
touch .nojekyll
|
||||
#git checkout master docs/build/html
|
||||
#mv ./docs/build/html/* ./
|
||||
git checkout master ${SITE_PATH}
|
||||
mv ${SITE_PATH}/html/* ./
|
||||
rm -rf ./docs
|
||||
git add -A && git commit -m "publishing updated docs..." && git push origin gh-pages
|
||||
|
||||
# switch back
|
||||
git checkout master
|
|
@ -13,14 +13,15 @@ benefit from the different tools and python objects available in the pymatgen ec
|
|||
AbiPy can be used in conjunction with matplotlib_, pandas_, seaborn_,
|
||||
ipython_ and jupyter_ thus providing a powerful and user-friendly environment for data analysis and visualization.
|
||||
Check out the list of plotting scripts available in our :ref:`plot-gallery`.
|
||||
To learn more about the integration between jupyter and AbiPy, visit our collection of `notebooks
|
||||
<http://nbviewer.ipython.org/github/abinit/abipy/blob/master/abipy/examples/notebooks/index.ipynb>`_
|
||||
and the
|
||||
`AbiPy lessons <http://nbviewer.ipython.org/github/abinit/abipy/blob/master/abipy/examples/notebooks/lessons/index.ipynb>`_.
|
||||
To learn more about the integration between jupyter_ and AbiPy, visit `our collection of notebooks
|
||||
<https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb>`_
|
||||
or click the **Launch Binder** badge to start a Docker image with Abinit, AbiPy and all the other python dependencies
|
||||
required to run the code inside the jupyter notebooks.
|
||||
The notebook will be opened in your browser after building.
|
||||
|
||||
AbiPy supports both Python 2.7 as well as Python >= 3.4.
|
||||
Note however that Python 2.7 is more intensively tested than py3k, especially at the level of workflows.
|
||||
We hence still recommend py2.7 if you plan to run automatic calculations with AbiPy.
|
||||
.. AbiPy supports both Python 2.7 as well as Python >= 3.4.
|
||||
.. Note however that Python 2.7 is more intensively tested than py3k, especially at the level of workflows.
|
||||
.. We hence still recommend py2.7 if you plan to run automatic calculations with AbiPy.
|
||||
|
||||
Note also that the majority of the post-processing tools available in AbiPy require Abinit output files in
|
||||
netcdf_ format so we strongly suggest to compile Abinit with netcdf support
|
||||
|
|
|
@ -21,11 +21,11 @@ and then follow the instructions in the :ref:`netcdf4_installation` section.
|
|||
|
||||
The installation process is greatly simplified if you install the required
|
||||
packages through the Anaconda_ distribution.
|
||||
We routinely use conda_ to test new developments with multiple versions of Python and multiple virtual environments.
|
||||
The anaconda distribution already provides the most critical dependencies (numpy_, scipy_, matplotlib_, ...)
|
||||
in the form of pre-compiled packages and netcdf4-python_ can be easily installed with::
|
||||
We routinely use conda_ to test new developments with multiple Python versions and multiple virtual environments.
|
||||
The anaconda distribution already provides the most critical dependencies (numpy_, scipy_, matplotlib_, netcdf4-python_)
|
||||
in the form of pre-compiled packages that can be easily installed with e.g.::
|
||||
|
||||
conda install netcdf4
|
||||
conda install numpy scipy netcdf4
|
||||
|
||||
Additional information on the steps required to install AbiPy with anaconda
|
||||
are available in the :ref:`anaconda_howto` howto as well as in the
|
||||
|
@ -52,7 +52,7 @@ ipython_
|
|||
jupyter_ and nbformat_
|
||||
|
||||
Required to generate jupyter notebooks.
|
||||
Install these two packages with ``conda install jupyter nbformat`` or use ``pip_``.
|
||||
Install these two packages with ``conda install jupyter nbformat`` or use pip_.
|
||||
To use ``jupyter`` you will also need a web browser to open the notebook.
|
||||
(recommended)
|
||||
|
||||
|
@ -63,7 +63,7 @@ Anaconda Howto
|
|||
--------------
|
||||
|
||||
Download the anaconda installer from the `official web-site <https://www.continuum.io/downloads>`_.
|
||||
Choose the version that matches your OS and select python2.7.
|
||||
Choose the version that matches your OS and select python3.6.
|
||||
You may want to use the ``wget`` utility to download the anaconda script directly from the terminal
|
||||
(useful if you are installing anaconda on a cluster).
|
||||
|
||||
|
@ -77,7 +77,7 @@ Once the installation is completed, execute::
|
|||
to activate the ``root`` environment.
|
||||
The output of ``which python`` should show that you are using the python interpreter provided by anaconda.
|
||||
|
||||
Use the ``conda`` command-line interface to install the packages not included in the official distribution.
|
||||
Use the conda_ command-line interface to install the packages not included in the official distribution.
|
||||
For example, you can install ``pyyaml`` and ``netcdf4`` with::
|
||||
|
||||
conda install pyyaml netcdf4
|
||||
|
@ -123,7 +123,7 @@ Developmental version
|
|||
Getting the developmental version of AbiPy is easy.
|
||||
You can clone it from our `github repository <https://github.com/abinit/abipy>`_ using::
|
||||
|
||||
git clone https://github.com/abinit/abipy
|
||||
git clone https://github.com/abinit/abipy
|
||||
|
||||
After cloning the repository, type::
|
||||
|
||||
|
|
Loading…
Reference in New Issue