Skip to content

Commit 21ac83f

Browse files
authored
Merge pull request #142 from 1041176461/develop
add some example for plotting PDOS and PBAND
2 parents aff6b0d + cfaa2db commit 21ac83f

File tree

14 files changed

+64705
-118
lines changed

14 files changed

+64705
-118
lines changed

tools/plot-tools/README.md

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [NumPy](https://numpy.org/)
1212
- [Matplotlib](https://matplotlib.org/)
1313
- [lxml](https://lxml.de/)
14+
- [setuptools](https://setuptools.pypa.io/en/latest/index.html)
1415

1516
## Installation
1617
Use the following command to install this tool:
@@ -20,31 +21,31 @@ python setup.py install
2021

2122
## Usage
2223
There are two ways to use this tool:
23-
1. Specify parameters in `band.py` or `dos.py` directly, and then `python band.py` or `python dos.py`. And you can also import module in your own script e.g. `from abacus_plot.band import Band`
24-
2. Command-line tools are also supported in this tool. In this way, you need prepare an input file and execute some commands as follows
24+
1. Specify parameters in `band.py` or `dos.py` directly, and then `python band.py` or `python dos.py`. And you can also import module in your own script e.g. `from abacus_plot.band import Band`. (Recommend)
25+
2. Command-line tools are also supported in this tool. In this way, you need prepare an input file and execute some commands (see below). You can use `abacus-plot -h` to check command-line information
2526

2627
### Band Structure
27-
First, prepare a json file e.g. band-input.json:
28+
First, prepare a file named 'config.json' in json format:
2829
```json
2930
{
3031
"bandfile" : "BANDS_1.dat",
31-
"efermi" : 10.39537843955395,
32+
"efermi" : 6.585653952007503,
3233
"energy_range" : [-1.5, 6],
3334
"kptfile" : "KPT"
3435
}
3536
```
36-
| Property | Type | Note |
37-
| :------------: | :----------------------: | :------------------------------------------------------------: |
38-
| *bandfile* | `str` or `List[str]` | Bands data file output from ABACUS |
39-
| *efermi* | `float` or `List[float]` | Fermi level in eV |
40-
| *energy_range* | `list` | Range of energy in eV |
41-
| *shift* | `bool` | If set `'true'`, it will evaluate band gap. Default: `'false'` |
42-
| *index* | `List[int]` or `Dict[int, List[int]]` or `Dict[int, Dict[int, List[int]]]]` | Extract PDOS of each atom e.g. [0, 1], {0:[0, 1], 1:[0]}, [0:{0:[0]}, 1:{1:[0, 1]}] |
43-
| *atom_index* | `List[int]` or `Dict[int, List[int]]` or `Dict[int, Dict[int, List[int]]]]` | Extract PDOS of each atom with same atom_index e.g. [0, 1], {0:[0, 1], 1:[0]}, [0:{0:[0]}, 1:{1:[0, 1]}] |
44-
| *species* | `List[str]` or `Dict[str, List[int]]` or `Dict[str, Dict[int, List[int]]]]` | Extract PDOS of each atom with same species e.g. ["C", "Si"], {"C":[0, 1], "Si":[0]}, ["C":{0:[0]}, "Si":{1:[0, 1]}] |
45-
| *kptfile* | `str` | K-points file in ABACUS format |
46-
| *label* | `str` or `List[str]` | Label of band structure |
47-
| *color* | `str` or `List[str]` | Color of band structure |
37+
| Property | Type | Note |
38+
| :------------: | :-------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
39+
| *bandfile* | `str` or `List[str]` | Bands data file output from ABACUS. 'BANDS_*.dat' for band structure and 'PBANDS_*' for projected band structure |
40+
| *efermi* | `float` or `List[float]` | Fermi level in eV |
41+
| *energy_range* | `list` | Range of energy in eV |
42+
| *shift* | `bool` | If set `'true'`, it will evaluate band gap (only for semiconductors and insulators). Default: `'false'` |
43+
| *index* | `List[int]` or `Dict[str, List[int]]` or `Dict[str, Dict[int, List[int]]]]` | Extract PBANDS of each atom from 'PBANDS_*' file e.g. [index_0, index_1...] or {index_0:[l_0, l_1, ...], ...}, [index_0:{l_0:[m_0, m_1, ...], ...}, ...] |
44+
| *atom_index* | `List[int]` or `Dict[str, List[int]]` or `Dict[str, Dict[int, List[int]]]]` | Extract PBANDS of each atom with same atom_index from 'PBANDS_*' file e.g. [atom_index_0, atom_index_1...] or {atom_index_0:[l_0, l_1, ...], ...}, [atom_index_0:{l_0:[m_0, m_1, ...], ...}, ...] |
45+
| *species* | `List[str]` or `Dict[str, List[int]]` or `Dict[str, Dict[int, List[int]]]]` | Extract PBANDS of each atom with same species from 'PBANDS_*' file e.g. [elem_0, elem_1...] or {elem_0:[l_0, l_1, ...], ...}, [elem_0:{l_0:[m_0, m_1, ...], ...}, ...] |
46+
| *kptfile* | `str` | K-points file with `Line` mode in ABACUS format |
47+
| *label* | `str` or `List[str]` | Label of band structure |
48+
| *color* | `str` or `List[str]` | Color of band structure |
4849

4950
If you want to plot band structure of `nspin=2` or compare two band structure on same k-path, you can set *bandfile*, *efermi*, *label*, *color* in `list` type.
5051

@@ -63,15 +64,25 @@ Line
6364
```
6465
Then, use the following command to plot band structure:
6566
```shell
66-
abacus-plot -b -f band-input.json
67+
abacus-plot -b
68+
```
69+
70+
Then, the following command will plot projected band structure and figures output to directory `PBAND*_FIG` ($*=1$ for $nspin=1$, $*=2$ for $nspin=2$):
71+
```shell
72+
abacus-plot -d -p
73+
```
74+
75+
Then, the following command will output parsed partial DOS to directory `PBAND*_FILE` ($*=1$ for $nspin=1$, $*=2$ for $nspin=2$):
76+
```shell
77+
abacus-plot -d -o
6778
```
6879

6980
### DOS
70-
First, prepare a json file e.g. dos-input.json:
81+
First, prepare a file named 'config.json' in json format:
7182
```json
7283
{
7384
"pdosfile": "PDOS",
74-
"efermi": 10.39537843955395,
85+
"efermi": 6.585653952007503,
7586
"energy_range": [
7687
-5,
7788
7
@@ -82,10 +93,10 @@ First, prepare a json file e.g. dos-input.json:
8293
],
8394
"species": {
8495
"C": {
85-
0: [
96+
"0": [
8697
0
8798
],
88-
1: [
99+
"1": [
89100
0,
90101
1
91102
]
@@ -99,30 +110,30 @@ First, prepare a json file e.g. dos-input.json:
99110
}
100111
```
101112
If you only want to plot total DOS, you can modify `pdosfile` to `tdosfile` and do not set `species` and `pdosfig`.
102-
| Property | Type | Note |
103-
| :------------: | :-------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: |
104-
| *tdosfile* | `str` | Total DOS data file output from ABACUS |
105-
| *pdosfile* | `str` | Partial DOS data file output from ABACUS in xml format |
106-
| *efermi* | `float` | Fermi level in eV |
107-
| *energy_range* | `list` | Range of energy in eV |
108-
| *shift* | `bool` | If set `'true'`, it will evaluate band gap. Default: `'false'` |
109-
| *index* | `List[int]` or `Dict[int, List[int]]` or `Dict[int, Dict[int, List[int]]]]` | Extract PDOS of each atom e.g. [0, 1], {0:[0, 1], 1:[0]}, [0:{0:[0]}, 1:{1:[0, 1]}] |
110-
| *atom_index* | `List[int]` or `Dict[int, List[int]]` or `Dict[int, Dict[int, List[int]]]]` | Extract PDOS of each atom with same atom_index e.g. [0, 1], {0:[0, 1], 1:[0]}, [0:{0:[0]}, 1:{1:[0, 1]}] |
111-
| *species* | `List[str]` or `Dict[str, List[int]]` or `Dict[str, Dict[int, List[int]]]]` | Extract PDOS of each atom with same species e.g. ["C", "Si"], {"C":[0, 1], "Si":[0]}, ["C":{0:[0]}, "Si":{1:[0, 1]}] |
112-
| *tdosfig* | `str` | Output picture of total DOS |
113-
| *pdosfig* | `str` | Output picture of partial DOS |
113+
| Property | Type | Note |
114+
| :------------: | :-------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
115+
| *tdosfile* | `str` | Total DOS data file output from ABACUS |
116+
| *pdosfile* | `str` | Partial DOS data file output from ABACUS in xml format |
117+
| *efermi* | `float` | Fermi level in eV |
118+
| *energy_range* | `list` | Range of energy in eV |
119+
| *shift* | `bool` | If set `'true'`, it will evaluate band gap. Default: `'false'` |
120+
| *index* | `List[int]` or `Dict[str, List[int]]` or `Dict[str, Dict[str, List[int]]]]` | Extract PDOS of each atom e.g. [index_0, index_1...] or {index_0:[l_0, l_1, ...], ...}, [index_0:{l_0:[m_0, m_1, ...], ...}, ...] |
121+
| *atom_index* | `List[int]` or `Dict[str, List[int]]` or `Dict[str, Dict[str, List[int]]]]` | Extract PDOS of each atom with same atom_index e.g. [atom_index_0, atom_index_1...] or {atom_index_0:[l_0, l_1, ...], ...}, [atom_index_0:{l_0:[m_0, m_1, ...], ...}, ...] |
122+
| *species* | `List[str]` or `Dict[str, List[int]]` or `Dict[str, Dict[str, List[int]]]]` | Extract PDOS of each atom with same species e.g. [elem_0, elem_1...] or {elem_0:[l_0, l_1, ...], ...}, [elem_0:{l_0:[m_0, m_1, ...], ...}, ...] |
123+
| *tdosfig* | `str` | Output picture of total DOS |
124+
| *pdosfig* | `str` | Output picture of partial DOS |
114125

115126
Then, the following command will plot total DOS:
116127
```shell
117-
abacus-plot -t tdos-input.json
128+
abacus-plot -d
118129
```
119130

120131
Then, the following command will plot partial DOS:
121132
```shell
122-
abacus-plot -p pdos-input.json
133+
abacus-plot -d -p
123134
```
124135

125136
Then, the following command will output parsed partial DOS to directory `PDOS_FILE`:
126137
```shell
127-
abacus-plot -o pdos-input.json
138+
abacus-plot -d -o
128139
```

0 commit comments

Comments
 (0)