• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.github/H13-Mar-2021-5144

abipy/H03-May-2022-466,705418,556

binder/H13-Mar-2021-127122

dash_app/H03-May-2022-572425

dev_scripts/H03-May-2022-418271

docs/H03-May-2022-6,3684,476

.coveragercH A D13-Mar-2021796 3629

.gitignoreH A D13-Mar-2021867 8367

.nojekillH A D13-Mar-20210

.pycheckrcH A D13-Mar-20215 KiB235158

.travis.ymlH A D13-Mar-20213.3 KiB10991

CHANGELOG.rstH A D13-Mar-20213.4 KiB6453

INSTALLH A D13-Mar-2021811 3823

LICENSEH A D13-Mar-2021541 129

MANIFEST.inH A D13-Mar-2021156 76

README.rstH A D13-Mar-202121.3 KiB577381

TODO.rstH A D13-Mar-2021322 117

setup.cfgH A D13-Mar-20211.6 KiB4130

setup.pyH A D03-May-20226 KiB217136

tasks.pyH A D03-May-20225.9 KiB19361

README.rst

1.. :Repository: https://github.com/abinit/abipy
2.. :Author: Matteo Giantomassi (http://github.com/abinit)
3
4.. list-table::
5    :stub-columns: 1
6    :widths: 10 90
7
8    * - Package
9      - |pypi-version| |download-with-anaconda| |supported-versions|
10    * - Continuous Integration
11      - |travis-status| |coverage-status|
12    * - Documentation
13      - |docs-github| |launch-nbviewer| |launch-binder|
14
15About
16=====
17
18AbiPy is a Python_ library to analyze the results produced by Abinit_,
19an open-source program for the ab-initio calculations of the physical properties of materials
20within Density Functional Theory and Many-Body perturbation theory.
21It also provides tools to generate input files and workflows to automate
22ab-initio calculations and typical convergence studies.
23AbiPy is interfaced with pymatgen_ and this allows users to
24benefit from the different tools and python objects available in the pymatgen ecosystem.
25
26The official documentation is hosted on `github pages <http://abinit.github.io/abipy>`_.
27
28AbiPy can be used in conjunction with matplotlib_, pandas_, scipy_, seaborn_, ipython_ and jupyter_ notebooks
29thus providing a powerful and user-friendly environment for data analysis and visualization.
30Check out our `gallery of plotting scripts <http://abinit.github.io/abipy/gallery/index.html>`_
31and the `gallery of AbiPy workflows <http://abinit.github.io/abipy/flow_gallery/index.html>`_.
32
33To learn more about the integration between jupyter_ and AbiPy, visit `our collection of notebooks
34<https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb>`_
35or click the **Launch Binder** badge to start a Docker image with Abinit, AbiPy and all the other python dependencies
36required to run the code inside the jupyter notebooks.
37The notebook will be opened in your browser after building.
38
39AbiPy is free to use. However, we also welcome your help to improve this library by making your own contributions.
40Please report any bugs and issues at AbiPy's `Github page <https://github.com/abinit/abipy>`_.
41
42.. important::
43
44    Note that the majority of the post-processing tools available in AbiPy require output files in
45    netcdf_ format so we **strongly** suggest to compile Abinit with netcdf support
46    (use ``--with-trio-flavor="netcdf"`` at configure time to activate the internal netcdf library,
47    to link Abinit against an external netcdf library please consult the configuration examples provided by abiconfig_).
48
49
50Links to talks
51==============
52
53This section collects links to some of the talks given by the AbiPy developers.
54
55
56* `Automating ABINIT calculations with AbiPy. Boston MA, 3 March 2019 <https://gmatteo.github.io/abipy_slides_aps_boston_2019/>`_ (Introduction to AbiPy for newcomers).
57
58* `New features of AbiPy v0.7. Louvain-la-Neuve, Belgium, 20 May 2019 <https://gmatteo.github.io/abipy_intro_abidev2019/>`_ (How to use the AbiPy command line interface in the terminal)
59
60* `Automatize a DFT code: high-throughput workflows for Abinit
61  <https://object.cscs.ch/v1/AUTH_b1d80408b3d340db9f03d373bbde5c1e/learn-public/materials/2019_05_aiida_tutorial/day4_abipy_Petretto.pdf>`_
62
63
64Getting AbiPy
65=============
66
67Stable version
68--------------
69
70The version at the Python Package Index (PyPI) is always the latest stable release
71that can be installed with::
72
73    pip install abipy
74
75Note that you may need to install pymatgen and other critical dependencies manually.
76In this case, please consult the detailed installation instructions provided by the
77`pymatgen howto <http://pymatgen.org/index.html#standard-install>`_ to install pymatgen
78and then follow the instructions in `our howto <http://abinit.github.io/abipy/installation>`_.
79
80The installation process is greatly simplified if you install the required
81python packages through `Anaconda <https://continuum.io/downloads>`_ (or conda).
82See `Installing conda`_ to install conda itself.
83We routinely use conda_ to test new developments with multiple Python versions and multiple virtual environments.
84The anaconda distribution already provides the most critical dependencies (matplotlib_, scipy_, numpy_, netcdf4-python_)
85in the form of pre-compiled packages that can be easily installed with e.g.::
86
87    conda install numpy scipy netcdf4
88
89Create a new conda_ environment (let's call it ``abienv``) based on python3.6 with::
90
91    conda create --name abienv python=3.6
92
93and activate it with::
94
95    conda activate abienv
96
97You should see the name of the conda environment in the shell prompt.
98
99Now add ``conda-forge``, and ``abinit`` to your conda channels with::
100
101    conda config --add channels conda-forge
102    conda config --add channels abinit
103
104These are the channels from which we will download pymatgen, abipy and abinit.
105
106Finally, install AbiPy from the abinit-channel_ with::
107
108    conda install abipy -c abinit
109
110Additional information on the steps required to install AbiPy with anaconda are available
111in the `anaconda howto <http://abinit.github.io/abipy/installation#anaconda-howto>`_.
112
113We are also collaborating with the spack_ community
114to provide packages for AbiPy and Abinit in order to facilitate the installation on large supercomputing centers.
115
116Developmental version
117---------------------
118
119Getting the developmental version of AbiPy is easy.
120Clone the `github repository <https://github.com/abinit/abipy>`_ with::
121
122    git clone https://github.com/abinit/abipy
123
124For pip, use::
125
126    pip install -r requirements.txt
127    pip install -r requirements-optional.txt
128
129If you are using conda_ (see `Installing conda`_ to install conda itself),  create a new environment (``abienv``)
130based on python3.6 with::
131
132    conda create -n abienv python=3.6
133    source activate abienv
134
135Add ``conda-forge``, and ``abinit`` to your channels with::
136
137    conda config --add channels conda-forge
138    conda config --add channels abinit
139
140and install the AbiPy dependencies with::
141
142    conda install --file ./requirements.txt
143    conda install --file ./requirements-optional.txt
144
145The second command is needed for Jupyter only.
146Once the requirements have been installed (either with pip or conda), execute::
147
148    python setup.py install
149
150or alternately::
151
152    python setup.py develop
153
154to install the package in developmental mode.
155This is the recommended approach, especially if you are planning to implement new features.
156
157Note, however, that the developmental version of AbiPy is kept in sync with the
158developmental version of pymatgen thus ```python setup.py develop``` may
159try to download new versions from the PyPi portal and then fail with e.g. the error message::
160
161    ...
162    processing dependencies for abipy==0.6.0.dev0
163    error: scipy 1.0.0 is installed but scipy>=1.0.1 is required by {'pymatgen'}
164
165due to inconsistent dependencies.
166To solve the problem, use conda to update scipy to a version >= 1.0.1 with::
167
168    conda install "scipy>=1.0.1"
169
170then issue again python setup.py develop. If this fails, supposing you were upgrading abipy inside an already existing conda environment, try to restart by creating from scratch a fresh conda environment, see above.
171
172Use::
173
174    conda info pymatgen
175
176to display information about the installed version of pymatgen.
177
178Also note that the BLAS/Lapack libraries provided by conda have multithreading support activated by default.
179Each process will try to use all of the cores on your machine, which quickly overloads things
180if there are multiple processes running.
181(Also, this is a shared machine, so it is just rude behavior in general).
182To disable multithreading, add these lines to your ~/.bash_profile::
183
184    export OPENBLAS_NUM_THREADS=1
185    export OMP_NUM_THREADS=1
186
187and then activate these settings with::
188
189    source ~/.bash_profile
190
191The Github version include test files for complete unit testing.
192To run the suite of unit tests, make sure you have pytest_ installed and then type::
193
194    pytest
195
196in the AbiPy root directory. A quicker check might be obtained with::
197
198    pytest abipy/core/tests -v
199
200Unit tests require ``scripttest`` that can be installed with::
201
202    pip install scripttest
203
204Two tests rely on the availability of a
205`pymatgen PMG_MAPI_KEY <http://pymatgen.org/usage.html#setting-the-pmg-mapi-key-in-the-config-file>` in ~/.pmgrc.yaml.
206
207Note that several unit tests check the integration between AbiPy and Abinit.
208In order to run the tests, you will need a working set of Abinit executables and  a ``manager.yml`` configuration file.
209
210Contributing to AbiPy is relatively easy.
211Just send us a `pull request <https://help.github.com/articles/using-pull-requests/>`_.
212When you send your request, make ``develop`` the destination branch on the repository
213AbiPy uses the `Git Flow <http://nvie.com/posts/a-successful-git-branching-model/>`_ branching model.
214The ``develop`` branch contains the latest contributions, and ``master`` is always tagged and points
215to the latest stable release.
216
217
218Installing Abinit
219=================
220
221One of the big advantages of conda over pip is that conda can also install
222libraries and executables written in Fortran.
223A pre-compiled sequential version of Abinit for Linux and OSx can be installed directly from the
224abinit-channel_ with::
225
226    conda install abinit -c abinit
227
228Otherwise, follow the usual abinit installation instructions, and make sure abinit can be run with the command::
229
230    abinit --version
231
232
233Configuration files for Abipy
234=============================
235
236In order to run the Abipy tests, you will need a ``manager.yml`` configuration file.
237For a detailed description of the syntax used in this configuration file
238please consult the `TaskManager documentation <http://abinit.github.io/abipy/workflows/taskmanager.html>`_.
239
240At this stage, for the purpose of checking the installation, you might
241take the ``shell_nompi_manager.yml`` file from the ``abipy/data/managers`` directory
242of this repository, and copy it with new name ``manager.yml`` to your `$HOME/.abinit/abipy` directory.
243Open this file and make sure that the ``pre_run`` section contains the shell commands
244needed to setup the environment before launching Abinit (e.g. Abinit is in $PATH), unless it is available from the environment (e.g. conda).
245
246To complete the configuration files for Abipy, you might also copy the ``simple_scheduler.yml`` file from the same directory,
247and copy it with name ``scheduler.yml``. Modifications are needed if you are developer.
248
249Checking the installation
250=========================
251
252Now open the python interpreter and import the following three modules
253to check that the python installation is OK::
254
255    import spglib
256    import pymatgen
257    from abipy import abilab
258
259then quit the interpreter.
260
261For general information about how to troubleshoot problems that may occur at this level,
262see the :ref:`troubleshooting` section.
263
264.. _anaconda_howto:
265
266The Abinit executables are placed inside the anaconda directory associated to the ``abienv`` environment::
267
268    which abinit
269    /Users/gmatteo/anaconda3/envs/abienv/bin/abinit
270
271To perform a basic validation of the build, execute::
272
273    abinit -b
274
275Abinit should echo miscellaneous information, starting with::
276
277    DATA TYPE INFORMATION:
278    REAL:      Data type name: REAL(DP)
279               Kind value:      8
280               Precision:      15
281
282and ending with::
283
284    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
285    Default optimizations:
286      --- None ---
287
288
289    ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
290
291If successful, one can start to use the AbiPy scripts from the command line to analyze the output results.
292Execute::
293
294    abicheck.py
295
296You should see (with minor changes)::
297
298    $ abicheck.py
299    AbiPy Manager:
300    [Qadapter 0]
301    ShellAdapter:localhost
302    Hardware:
303       num_nodes: 2, sockets_per_node: 1, cores_per_socket: 2, mem_per_node 4096,
304    Qadapter selected: 0
305
306    Abinitbuild:
307    Abinit Build Information:
308        Abinit version: 8.8.2
309        MPI: True, MPI-IO: True, OpenMP: False
310        Netcdf: True
311
312    Abipy Scheduler:
313    PyFlowScheduler, Pid: 19379
314    Scheduler options: {'weeks': 0, 'days': 0, 'hours': 0, 'minutes': 0, 'seconds': 5}
315
316    Installed packages:
317    Package         Version
318    --------------  ---------
319    system          Darwin
320    python_version  3.6.5
321    numpy           1.14.3
322    scipy           1.1.0
323    netCDF4         1.4.0
324    apscheduler     2.1.0
325    pydispatch      2.0.5
326    yaml            3.12
327    pymatgen        2018.6.11
328
329
330    Abipy requirements are properly configured
331
332If the script fails with the error message::
333
334    Abinit executable does not support netcdf
335    Abipy requires Abinit version >= 8.0.8 but got 0.0.0
336
337it means that your environment is not property configured or that there's a problem
338with the binary executable.
339In this case, look at the files produced in the temporary directory of the flow.
340The script reports the name of the directory, something like::
341
342    CRITICAL:pymatgen.io.abinit.tasks:Error while executing /var/folders/89/47k8wfdj11x035svqf8qnl4m0000gn/T/tmp28xi4dy1/job.sh
343
344Check the `job.sh` script for possible typos, then search for possible error messages in `run.err`.
345
346The last test consists in executing a small calculation with AbiPy and Abinit.
347Inside the shell, execute::
348
349    abicheck.py --with-flow
350
351to run a GS + NSCF band structure calculation for Si.
352If the software stack is properly configured, the output should end with::
353
354    Work #0: <BandStructureWork, node_id=313436, workdir=../../../../var/folders/89/47k8wfdj11x035svqf8qnl4m0000gn/T/tmpygixwf9a/w0>, Finalized=True
355      Finalized works are not shown. Use verbose > 0 to force output.
356
357    all_ok reached
358
359    Submitted on: Sat Jul 28 09:14:28 2018
360    Completed on: Sat Jul 28 09:14:38 2018
361    Elapsed time: 0:00:10.030767
362    Flow completed successfully
363
364    Calling flow.finalize()...
365
366    Work #0: <BandStructureWork, node_id=313436, workdir=../../../../var/folders/89/47k8wfdj11x035svqf8qnl4m0000gn/T/tmpygixwf9a/w0>, Finalized=True
367      Finalized works are not shown. Use verbose > 0 to force output.
368
369    all_ok reached
370
371
372    Test flow completed successfully
373
374Great, if you've reached this part it means that you've installed AbiPy and Abinit on your machine!
375We can finally start to run the scripts in this repo or use one of the AbiPy script to analyze  the results.
376
377
378Using AbiPy
379===========
380
381Basic usage
382-----------
383
384There are a variety of ways to use AbiPy, and most of them are illustrated in the ``abipy/examples`` directory.
385Below is a brief description of the different directories found there:
386
387  * `examples/plot <http://abinit.github.io/abipy/gallery/index.html>`_
388
389    Scripts showing how to read data from netcdf files and produce plots with matplotlib_
390
391  * `examples/flows <http://abinit.github.io/abipy/flow_gallery/index.html>`_.
392
393    Scripts showing how to generate an AbiPy flow, run the calculation and use ipython to analyze the data.
394
395Additional jupyter notebooks with the Abinit tutorials written with AbiPy are available in the
396`abitutorial repository <https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb>`_.
397
398Users are strongly encouraged to explore the detailed `API docs <http://abinit.github.io/abipy/api/index.html>`_.
399
400Command line tools
401------------------
402
403The following scripts can be invoked directly from the terminal:
404
405* ``abiopen.py``    Open file inside ipython.
406* ``abistruct.py``  Swiss knife to operate on structures.
407* ``abiview.py``    Visualize results from file.
408* ``abicomp.py``    Compare results extracted from multiple files.
409* ``abicheck.py``   Validate integration between AbiPy and Abinit
410* ``abirun.py``     Execute AbiPy flow from terminal.
411* ``abidoc.py``     Document Abinit input variables and Abipy configuration files.
412* ``abinp.py``      Build input files (simplified interface for the AbiPy factory functions).
413
414Use ``SCRIPT --help`` to get the list of supported commands and
415``SCRIPT COMMAND --help`` to get the documentation for ``COMMAND``.
416
417For further information, please consult the `scripts docs <http://abinit.github.io/abipy/scripts/index.html>`_ section.
418
419
420Installing conda
421================
422
423A brief install guide, in case you have not yet used conda ... For a more extensive description, see our
424`Anaconda Howto <http://abinit.github.io/abipy/installation#anaconda-howto>`_.
425
426Download the `miniconda installer <https://conda.io/miniconda.html>`_.
427Select python3.6 and the version corresponding to your operating system.
428
429As an example, if you are a Linux user, download and install `miniconda` on your local machine with::
430
431    wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
432    bash Miniconda3-latest-Linux-x86_64.sh
433
434while for MacOSx use::
435
436    curl -o https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
437    bash Miniconda3-latest-MacOSX-x86_64.sh
438
439Answer ``yes`` to the question::
440
441    Do you wish the installer to prepend the Miniconda3 install location
442    to PATH in your /home/gmatteo/.bashrc ? [yes|no]
443    [no] >>> yes
444
445Source your ``.bashrc`` file to activate the changes done by ``miniconda`` to your ``$PATH``::
446
447    source ~/.bashrc
448
449.. _troubleshooting:
450
451Troubleshooting
452===============
453
454GLIBC error
455-----------
456
457The python interpreter may raise the following exception when importing one of the pymatgen modules::
458
459    from pymatgen.util.coord import pbc_shortest_vectors
460    File "/python3.6/site-packages/pymatgen/util/coord.py", line 11, in <module>
461    from . import coord_cython as cuc
462    ImportError: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /python3.6/site-packages/pymatgen/util/coord_cython.cpython-36m-x86_64-linux-gnu.so)`
463
464This means that the pre-compiled version of pymatgen is not compatible with the GLIBC version available on your machine.
465To solve the problem, we suggest to build and install pymatgen from source using the local version of GLIBC and the gcc compiler.
466In the example below, we use a conda environment to install most of the dependencies with the exception of pymatgen and abipy.
467
468Let's start by creating a conda environment with::
469
470    conda create -n glibc_env python=3.6
471    source activate glibc_env
472    conda config --add channels conda-forge
473
474Use pip to install spglib::
475
476    pip install spglib
477
478and try to ``import spglib`` inside the python terminal.
479
480Download the pymatgen repository from github with::
481
482    git clone https://github.com/materialsproject/pymatgen.git
483    cd pymatgen
484
485If git is not installed, use ``conda install git``
486
487Now use conda to install the pymatgen requirements listed in ``requirements.txt``
488but before that make sure that ``gcc`` is in ``$PATH``.
489If you are working on a cluster, you may want to issue::
490
491    module purge
492
493to avoid compiling C code with the intel compiler (it's possible to use ``icc`` but ``gcc`` is less problematic).
494
495Remove the line::
496
497    enum34==1.1.6; python_version < '3.4'
498
499from ``requirements.txt`` as this syntax is not supported by conda then issue::
500
501    conda install -y --file requirements.txt
502
503At this point, we can build pymatgen and the C extensions::
504
505        python setup.py install
506
507then ``cd`` to another directory (important) and test the build inside the python terminal with::
508
509    import spglib
510    import pymatgen
511
512Finally, we can install Abipy from source with::
513
514	git clone https://github.com/abinit/abipy.git
515	cd abipy && conda install -y --file ./requirements.txt
516
517
518License
519=======
520
521AbiPy is released under the GNU GPL license. For more details see the LICENSE file.
522
523.. _Python: http://www.python.org/
524.. _Abinit: https://www.abinit.org
525.. _abinit-channel: https://anaconda.org/abinit
526.. _pymatgen: http://pymatgen.org
527.. _matplotlib: http://matplotlib.org
528.. _pandas: http://pandas.pydata.org
529.. _scipy: https://www.scipy.org/
530.. _seaborn: https://seaborn.pydata.org/
531.. _ipython: https://ipython.org/index.html
532.. _jupyter: http://jupyter.org/
533.. _netcdf: https://www.unidata.ucar.edu/software/netcdf/docs/faq.html#whatisit
534.. _abiconfig: https://github.com/abinit/abiconfig
535.. _conda: https://conda.io/docs/
536.. _netcdf4-python: http://unidata.github.io/netcdf4-python/
537.. _spack: https://github.com/LLNL/spack
538.. _pytest: https://docs.pytest.org/en/latest/contents.html
539.. _numpy: http://www.numpy.org/
540
541
542.. |pypi-version| image:: https://badge.fury.io/py/abipy.svg
543    :alt: PyPi version
544    :target: https://badge.fury.io/py/abipy
545
546.. |travis-status| image:: https://travis-ci.org/abinit/abipy.svg?branch=develop
547    :alt: Travis status
548    :target: https://travis-ci.org/abinit/abipy
549
550.. |coverage-status| image:: https://coveralls.io/repos/github/abinit/abipy/badge.svg?branch=develop
551    :alt: Coverage status
552    :target: https://coveralls.io/github/abinit/abipy?branch=develop
553
554.. |download-with-anaconda| image:: https://anaconda.org/abinit/abipy/badges/installer/conda.svg
555    :alt: Download with Anaconda
556    :target: https://conda.anaconda.org/abinit
557
558.. |launch-binder| image:: https://mybinder.org/badge.svg
559    :alt: Launch binder
560    :target: https://mybinder.org/v2/gh/abinit/abipy/develop
561
562.. |launch-nbviewer| image:: https://img.shields.io/badge/render-nbviewer-orange.svg
563    :alt: Launch nbviewer
564    :target: https://nbviewer.jupyter.org/github/abinit/abitutorials/blob/master/abitutorials/index.ipynb
565
566.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/abipy.svg?style=flat
567    :alt: Supported versions
568    :target: https://pypi.python.org/pypi/abipy
569
570.. |requires| image:: https://requires.io/github/abinit/abipy/requirements.svg?branch=develop
571     :target: https://requires.io/github/abinit/abipy/requirements/?branch=develop
572     :alt: Requirements Status
573
574.. |docs-github| image:: https://img.shields.io/badge/docs-ff69b4.svg
575     :alt: AbiPy Documentation
576     :target: http://abinit.github.io/abipy
577