Skip to content

Commit

Permalink
Add gh action
Browse files Browse the repository at this point in the history
  • Loading branch information
gmatteo committed Jul 23, 2024
1 parent e6bd177 commit 120f60a
Show file tree
Hide file tree
Showing 25 changed files with 714 additions and 645 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Based on https://github.com/executablebooks/cookiecutter-jupyter-book/blob/main/.github/workflows/tests.yml
name: tests

on:
# Trigger the workflow on push or pull request on main branch
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# Run cron job every month, https://crontab.guru/every-month
- cron: '0 0 1 * *'
workflow_dispatch:

jobs:
# This job tests that the CC works
test-cc-and-jb-build:
# prevent this action from running on forks
#if: github.repository == 'abinit/abipy'
defaults:
run:
shell: bash -l {0} # enables conda/mamba env activation by reading bash profile

runs-on: ubuntu-latest
#env:
# PMG_MAPI_KEY: ${{ secrets.PMG_MAPI_KEY }}

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
pages: write
id-token: write

steps:
- name: Set up Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true

# Install dependencies
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install Abinit, AbiPy and dependencies
run: |
conda create -n abipy python=${{ matrix.config.python }} --yes
conda activate abipy
conda install abinit -c conda-forge --yes
mpirun -n 1 abinit --version
mpirun -n 1 abinit --build
pip install --editable .
mkdir -p $HOME/.abinit/abipy/
#cp abipy/data/managers/travis_manager.yml $HOME/.abinit/abipy/manager.yml
#cp abipy/data/managers/simple_scheduler.yml $HOME/.abinit/abipy/scheduler.yml
jupyter-book build abipy_book --builder linkcheck
# Build the example book
#- name: Build book
# run: |
# jupyter-book build my_book/my_book/

## Upload the book's HTML as an artifact
#- name: Upload artifact
# uses: actions/upload-pages-artifact@v2
# with:
# path: "my_book/my_book/_build/html"

# Deploy the book's HTML to GitHub Pages
#- name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Profile.prof
abipy/examples/flows/flow_*
abipy/examples/flows/develop/flow_*
_debug
_build
#__abinb_workdir__
#abinb_*.ipynb
$*.pickle
Expand Down
Empty file modified LICENSE
100755 → 100644
Empty file.
6 changes: 3 additions & 3 deletions abipy_book/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# Documentation Howto
# Documentation Howto

To insert a link to an Abinit variable, use:

Expand All @@ -9,10 +9,10 @@ or:

{{asr_anaddb}}

if you want to refer to the asr variable of the anaddb code
if you want to refer to the asr variable of the anaddb code
(note that in abimkdocs one uses asr@anaddb but, unfortunately this syntax is not supported my MyST).

There are several other replacements defined in _config.yml, mainly for links
There are several other replacements defined in _config.yml, mainly for links
to the abipy documentation, python libraries and other useful websites.
Also in this case, the syntax is:

Expand Down
10 changes: 5 additions & 5 deletions abipy_book/abinit_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ The `set_structure` method sets the value of the ABINIT variables:

It is always a good idea to set the structure immediately after the creation of an `AbinitInput`
because several methods use this information to facilitate the specification of other variables.
For instance, the `set_kpath` method uses the structure to generate the high-symmetry $k$-path
For instance, the `set_kpath` method uses the structure to generate the high-symmetry $k$-path
for band structure calculations.

```{warning}
Expand All @@ -186,7 +186,7 @@ for band structure calculations.
It is possible to create a structure in different ways.

The most explicit (and verbose) consists in passing a dictionary with ABINIT variables
provided one uses python lists (or lists or lists) when ABINIT expects a 1D
provided one uses python lists (or lists or lists) when ABINIT expects a 1D
(or a multidimensional array):


Expand All @@ -208,7 +208,7 @@ print(si_struct)

+++

If you already have a string with the Abinit variable, you can use the `from_abistring` class method:
If you already have a string with the Abinit variable, you can use the `from_abistring` class method:

```{code-cell}
lif_struct = abilab.Structure.from_abistring("""
Expand All @@ -228,9 +228,9 @@ print(lif_struct)
```

This approach requires less input yet we still need to specify {{ntypat}}, {{znucl}}and {[typat}}.
Fortunately, *from_abistring* supports another Abinit-specific format in which the
Fortunately, *from_abistring* supports another Abinit-specific format in which the
fractional coordinates and the element symbol are specified via the *xred_symbols* variable.
In this case {{ntypat}}, {{znucl}} and {{typat}} do not need to be specified as they are automatically
In this case {{ntypat}}, {{znucl}} and {{typat}} do not need to be specified as they are automatically
computed from *xred_symbols*:


Expand Down
20 changes: 10 additions & 10 deletions abipy_book/abiwan.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ produced by Abinit to interpolate band energies.
As usual, one can use:

abiopen.py FILE_ABIWAN.nc

with the `--expose` or the `--print` option for a command line interface
and `--notebook` to generate a jupyter notebook.

Expand All @@ -37,7 +37,7 @@ Let's start by importing the basic modules needed for this tutorial.
```{code-cell} ipython3
import os
import warnings
import warnings
warnings.filterwarnings("ignore") # Ignore warnings
from abipy import abilab
Expand All @@ -46,13 +46,13 @@ import abipy.data as abidata
# This line configures matplotlib to show figures embedded in the notebook.
# Replace `inline` with `notebook` in classic notebook
%matplotlib inline
%matplotlib inline
# Option available in jupyterlab. See https://github.com/matplotlib/jupyter-matplotlib
#%matplotlib widget
#%matplotlib widget
```

## How to analyze the WOUT file
## How to analyze the WOUT file

+++

Expand Down Expand Up @@ -105,7 +105,7 @@ To plot the matrix elements of the KS Hamiltonian in real space in the Wannier G
abiwan.hwan.plot(title="Matrix elements in real space");
```

To interpolate the KS energies along a high-symmetry k-path and construct
To interpolate the KS energies along a high-symmetry k-path and construct
a new `ElectronBands` object, use:

```{code-cell} ipython3
Expand All @@ -129,12 +129,12 @@ ebands_kpath.plot_with_edos(ebands_kmesh.get_edos(), title="Wannier-interpolated
```

We can also compare an ab-initio band structure with the Wannier-interpolated results.
This is useful to understand if our wannier functions are well localized and if the
This is useful to understand if our wannier functions are well localized and if the
k-mesh used with wannier90 is dense enough.

In this case, it is just a matter of passing the path to the netcdf file
In this case, it is just a matter of passing the path to the netcdf file
containing the ab-initio band structure to the `get_plotter_from_ebands` method of `abiwan`.
The function interpolates the band energies using the k-path found in the netcdf file
The function interpolates the band energies using the k-path found in the netcdf file
and returns a plotter object:

```{code-cell} ipython3
Expand All @@ -151,7 +151,7 @@ plotter.combiplot();
```

As we can see, the interpolated band structures is not completely on top of the ab-initio
results. To improve the agreement we should try to reduced the spread and/or increase
results. To improve the agreement we should try to reduced the spread and/or increase
the density of the k-mesh used in the wannierization procedure.

+++
Loading

0 comments on commit 120f60a

Please sign in to comment.