|
2 | 2 |
|
3 | 3 | ## Introduction |
4 | 4 |
|
5 | | -[ASE](https://wiki.fysik.dtu.dk/ase/) (Atomic Simulation Environment) provides a set of Python tools for setting, running, and analysing atomic simulations. We have developed an ABACUS calculator ([ase-abacus](https://gitlab.com/1041176461/ase-abacus )) to be used together with the ASE tools, which exists as an external project with respect to ASE and is maintained by ABACUS developers. |
| 5 | +[ASE](https://wiki.fysik.dtu.dk/ase/) (Atomic Simulation Environment) performs as a powerful Pythonic platform for atomistic simulations, in which there are plenty of functionalties supported, such as various geometry optimization algorithms for finding both the minimum energy point and the transition states, including BFGS, BFGSLineSearch, FIRE, NEB, AUTO-NEB, etc, and various molecular dynamics techniques, including thermostats (Langevin, CSVR, Nose-Hoover Chain, etc) and metadynamics (via the interface with Plumed). |
| 6 | + |
| 7 | +Due to the growing number of softwares and machine-learning forcefields, we turn to maintain the interface with ASE by our own, while a legacy version of ASE interface can still be found at [our GitLab repository of ase-abacus](https://gitlab.com/1041176461/ase-abacus ). |
6 | 8 |
|
7 | 9 | ## Installation |
8 | 10 |
|
9 | | -```bash |
10 | | -git clone https://gitlab.com/1041176461/ase-abacus.git |
11 | | -cd ase-abacus |
12 | | -pip install . |
13 | | -``` |
| 11 | +We strongly recommend you create a virtual environment for the installation of Python packages of abacus, such as `conda` or `venv`, to avoid conflicts with other packages, for example, with the `conda`: |
14 | 12 |
|
15 | | -Another direct way: |
16 | 13 | ```bash |
17 | | -pip install git+https://gitlab.com/1041176461/ase-abacus.git |
| 14 | +conda create -n abacus python=3.10 |
| 15 | +conda activate abacus |
18 | 16 | ``` |
19 | 17 |
|
20 | | -## Environment variables |
21 | | - |
22 | | -[ABACUS](http://abacus.ustc.edu.cn) supports two types of basis sets: PW, LCAO. The path of pseudopotential and numerical orbital files can be set throught the environment variables `ABACUS_PP_PATH` and `ABACUS_ORBITAL_PATH`, respectively, e.g.: |
| 18 | +Then, install the ASE interface by: |
23 | 19 |
|
24 | 20 | ```bash |
25 | | - PP=${HOME}/pseudopotentials |
26 | | - ORB=${HOME}/orbitals |
27 | | - export ABACUS_PP_PATH=${PP} |
28 | | - export ABACUS_ORBITAL_PATH=${ORB} |
| 21 | +cd interfaces/ASE_interface |
| 22 | +pip install . |
29 | 23 | ``` |
30 | | - |
31 | | -For PW calculations, only `ABACUS_PP_PATH` is needed. For LCAO calculations, both `ABACUS_PP_PATH` and `ABACUS_ORBITAL_PATH` should be set. |
32 | | - |
33 | | -Also, one can manally set the paths of PP and ORB when using ABACUS calculator in ASE. |
34 | 24 |
|
35 | 25 | ## ABACUS Calculator |
36 | 26 |
|
37 | | -The default initialization command for the ABACUS calculator is |
| 27 | +Present calculator implementation requires a "profile" to act as an interface between the Python runtime and the file system. |
| 28 | +Instantiate an `AbacusProfile` object with proper settings: |
38 | 29 |
|
39 | 30 | ```python |
40 | | -from ase.calculators.abacus import Abacus |
| 31 | +from abacuslite import AbacusProfile |
| 32 | +aprof = AbacusProfile( |
| 33 | + command='mpirun -np 4 abacus', |
| 34 | + omp_num_threads=1, |
| 35 | + pseudo_dir='/path/to/folder/of/pseudopotentials', |
| 36 | + orbital_dir='/path/to/folder/of/orbitals', # OPTIONAL! |
| 37 | +) |
41 | 38 | ``` |
| 39 | +, by such lines, you build the interface between the computational environment and the Python runtime. |
| 40 | +This interface can be reused in multiple calculations. |
42 | 41 |
|
43 | | -In order to run a calculation, you have to ensure that at least the following parameters are specified, either in the initialization or as environment variables: |
44 | | - |
45 | | -|keyword |description |
46 | | -|:---------------|:---------------------------------------------------------- |
47 | | -|`pp` |dict of pseudopotentials for involved elememts, <br> such as `pp={'Al':'Al_ONCV_PBE-1.0.upf',...}`. |
48 | | -|`pseudo_dir` |directory where the pseudopotential are located, <br> Can also be specified with the `ABACUS_PP_PATH` <br> environment variable. Default: `pseudo_dir=./`. |
49 | | -|`basis` |dict of orbital files for involved elememts, such as <br> `basis={'Al':'Al_gga_10au_100Ry_4s4p1d.orb'}`.<br> It must be set if you want to do LCAO <br> calculations. But for pw calculations, it can be omitted. |
50 | | -|`basis_dir` |directory where the orbital files are located, <br> Can also be specified with the `ABACUS_ORBITAL_PATH`<br> environment variable. Default: `basis_dir=./`. |
51 | | -|`xc` |which exchange-correlation functional is used.<br> An alternative way to set this parameter is via <br> seting `dft_functional` which is an ABACUS <br> parameter used to specify exchange-correlation <br> functional |
52 | | -|`kpts` |a tuple (or list) of 3 integers `kpts=(int, int, int)`, <br>it is interpreted as the dimensions of a Monkhorst-Pack <br> grid, when `kmode` is `Gamma` or `MP`. It is <br> interpreted as k-points, when `kmode` is `Direct`,<br> `Cartesian` or `Line`, and `knumber` should also<br> be set in these modes to denote the number of k-points.<br> Some other parameters for k-grid settings:<br> including `koffset` and `kspacing`. |
53 | | - |
54 | | -For more information on pseudopotentials and numerical orbitals, please visit [ABACUS]. The elaboration of input parameters can be found [here](../input_files/input-main.md). |
| 42 | +Then, you can instantiate the `Abacus` calculator with the profile by: |
55 | 43 |
|
| 44 | +```python |
| 45 | +from abacuslite import Abacus |
| 46 | +abacus = Abacus( |
| 47 | + profile=aprof, |
| 48 | + directory='/path/to/work/directory', |
| 49 | + pseudopotentials={ |
| 50 | + 'Si': 'Si_ONCV_PBE-1.0.upf', |
| 51 | + }, |
| 52 | + basissets={ |
| 53 | + 'Si': 'Si_gga_8au_100Ry_2s2p1d.orb', |
| 54 | + }, |
| 55 | + inp={ |
| 56 | + 'calculation': 'scf', |
| 57 | + 'nspin': 1, |
| 58 | + 'basis_type': 'lcao', |
| 59 | + 'ks_solver': 'genelpa', |
| 60 | + 'ecutwfc': 100, |
| 61 | + 'symmetry': 1, |
| 62 | + 'kspacing': 0.1 |
| 63 | + } |
| 64 | +) |
| 65 | +``` |
| 66 | +, where except the `directory`, you can focus on the setting of ABACUS itself. In `inp`, you can set everything as you do in INPUT file of ABACUS. The kpoint sampling can also be set by the `kpts` parameter, like: |
56 | 67 |
|
57 | | -The input parameters can be set like:: |
58 | 68 | ```python |
59 | | - # for ABACUS calculator |
60 | | - calc = Abacus(profile=profile, |
61 | | - ecutwfc=100, |
62 | | - scf_nmax=100, |
63 | | - smearing_method='gaussian', |
64 | | - smearing_sigma=0.01, |
65 | | - basis_type='pw', |
66 | | - ks_solver='dav', |
67 | | - calculation='scf', |
68 | | - pp=pp, |
69 | | - basis=basis, |
70 | | - kpts=kpts) |
| 69 | +abacus = Abacus( |
| 70 | + # all other parameters |
| 71 | + kpts={ |
| 72 | + 'mode': 'mp-sampling', |
| 73 | + 'gamma-centered': True, |
| 74 | + 'nk': (4, 4, 4), |
| 75 | + 'kshift': (0, 0, 0), |
| 76 | + } |
| 77 | +) |
71 | 78 | ``` |
72 | 79 |
|
73 | | -The command to run jobs can be set by specifying `AbacusProfile`:: |
| 80 | +If with the `tempfile` module, you can create an abacus instance whose directory will be automatically removed when leaves from the context: |
74 | 81 |
|
75 | 82 | ```python |
76 | | - from ase.calculators.abacus import AbacusProfile |
77 | | - # for OpenMP setting inside python env |
78 | | - import os |
79 | | - os.environ("OMP_NUM_THREADS") = 1 |
80 | | - # for MPI setting used in abacus |
81 | | - mpi_num = 4 |
82 | | - # for ABACUS Profile |
83 | | - abacus = '/usr/local/bin/abacus' # specify abacus exec |
84 | | - profile = AbacusProfile(command=f'mpirun -n {mpi_num} {abacus}') # directly the command for running ABACUS |
| 83 | +import tempfile |
| 84 | +with tempfile.TemporaryDirectory() as tmpdir: |
| 85 | + abacus = Abacus( |
| 86 | + profile=aprof, |
| 87 | + directory=tmpdir, |
| 88 | + pseudopotentials={ |
| 89 | + 'Si': 'Si_ONCV_PBE-1.0.upf', |
| 90 | + }, |
| 91 | + basissets={ |
| 92 | + 'Si': 'Si_gga_8au_100Ry_2s2p1d.orb', |
| 93 | + }, |
| 94 | + inp={ |
| 95 | + # the rest of input parameters |
| 96 | + } |
| 97 | + ) |
85 | 98 | ``` |
86 | 99 |
|
87 | | -in which `abacus` sets the absolute path of the `abacus` executable. |
88 | | - |
89 | | -## MD Analysis |
90 | | -After molecular dynamics calculations, the log file `running_md.log` can be read. If the 'STRU_MD_*' files are not continuous (e.g. 'STRU_MD_0', 'STRU_MD_5', 'STRU_MD_10'...), the index parameter of read should be as a slice object. For example, when using the command `read('running_md.log', index=slice(0, 15, 5), format='abacus-out')` to parse 'running_md.log', 'STRU_MD_0', 'STRU_MD_5' and 'STRU_MD_10' will be read. |
| 100 | +## Perform Calculations |
91 | 101 |
|
92 | | -The `MD_dump` file is also supported to be read-in by `read('MD_dump', format='abacus-md')` |
| 102 | +In the new implementation, we limit the range of functionalties supported to mainly include the necessary ones, such as the SCF calculation, the energy and force/stress evaluation. The other features, such as starting the molecule dynamics directly in ABACUS from Python, is not supported anymore. Instead, it is encouraged to use the ASE tools to perform the molecule dynamics. |
93 | 103 |
|
| 104 | +Please read the examples in `interfaces/ASE_interface/examples/` for more details. |
94 | 105 |
|
95 | 106 | ## SPAP Analysis |
96 | 107 |
|
|
0 commit comments