Skip to content

Commit

Permalink
doing grammer check for the updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
floatingCatty committed Jul 23, 2024
1 parent c002499 commit fb11eae
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 30 deletions.
18 changes: 9 additions & 9 deletions docs/advanced/e3tb/advanced_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ In `common_options`, the user should define the some global param like:
"seed": 42
}
```
- `basis` sould align with the basis used to perform LCAO DFT calculations. The `"2s2p1d"` here indicates 2x`s` orbital, 2x`p`orbital and one `d` orbital. The
- `seed` controls the global random seed of all related package. `dtype` can be chosen between `float32` and `float64`, but the former are accurate enough in most cases. If you have multiple card, the
- `basis` should align with the basis used to perform LCAO DFT calculations. The `"2s2p1d"` here indicates 2x`s` orbital, 2x`p`orbital and one `d` orbital. The
- `seed` controls the global random seed of all related packages. `dtype` can be chosen between `float32` and `float64`, but the former is accurate enough in most cases. If you have multiple cards, the
- `device` can be setted as `cuda:0`, `cuda:1` and so on, where the number is the device id.
- `overlap` controls the fitting of overlap matrix. The user should provide overlap in the dataset when configuring the data_options if `overlap` is setted as True.
- `overlap` controls the fitting of the overlap matrix. The user should provide overlap in the dataset when configuring the data_options if `overlap` is setted as True.

In `train_options`, a common parameter looks like this:
```JSON
Expand Down Expand Up @@ -43,15 +43,15 @@ In `train_options`, a common parameter looks like this:
```
For `lr_scheduler`, please ensure the `patience` x `num_samples` / `batch_size` ranged between 2000 to 6000.

When the dataset contraining multiple elements, and you are fitting the Hamiltonian, it is suggested to open a tag in loss_options for better performance. Since most DFT software would allow for a uniform shift when computing the electrostatic potentials, therefore, bringing extra degree of freedom. The `onsite_shift` tag allow such freedom and make the model generalizable to all sort of elements combinations:
When the dataset contains multiple elements, and you are fitting the Hamiltonian, it is suggested to open a tag in loss_options for better performance. Most DFT software would allow for a uniform shift when computing the electrostatic potentials, therefore, bringing an extra degree of freedom. The `onsite_shift` tag allows such freedom and makes the model generalizable to all sorts of element combinations:
```JSON
"loss_options":{
"train": {"method": "hamil_abs", "onsite_shift": true},
"validation": {"method": "hamil_abs", "onsite_shift" : true}
}
```

In `model_options`, we support two type of e3 group equivariant embedding methods: Strictly Localized Equivariant Message-passing or `slem`, and Localized Equivariant Message-passing or `lem`. Former one ensure strict localization by truncate the propagation of distant eighbours' information, therefore are suitable for bulk systems where the electron localization is enhanced by scattering effect. `lem` method, on the other hand, contrained such localization design inherently by incooperating a learnable decaying functions describing the dependency across distance.
In `model_options`, we support two types of e3 group equivariant embedding methods: Strictly Localized Equivariant Message-passing or `slem`, and Localized Equivariant Message-passing or `lem`. The former ensures strict localization by truncating the propagation of distant neighbours' information and, therefore is suitable for bulk systems where the electron localization is enhanced by the scattering effect. `Lem` method, on the other hand, contained such localization design inherently by incorporating learnable decaying functions describing the dependency across distance.

The model options for slem and lem are the same, here is an short example:
```JSON
Expand All @@ -73,9 +73,9 @@ The model options for slem and lem are the same, here is an short example:
```
Here, `method` indicates the e3 descripor employed.

`r_max` can be a float or int number, or a dict with atom species specific float/int number, which indicates their cutoff envolope function, used to decaying the distant atom's effect smoothly. We highly suggest the user go to the DFT calculation files, and check the orbital's radial cutoff information to figure out how large this value should be.
`r_max` can be a float or int number, or a dict with atom species-specific float/int number, which indicates their cutoff envelope function, used to decay the distant atom's effect smoothly. We highly suggest the user go to the DFT calculation files and check the orbital's radial cutoff information to figure out how large this value should be.

`irreps_hidden`: Very important! This parameter decide mostly the representation capacity of the model, along with the model size and consumption of GPU memory. This parameter indicates the irreps of hidden equiraviant space, the definition here follows the for example, `64x0e` states `64` ireducible representation with `l=0` and `even` parity. For each basis setting, we provide a tool to generate least essential `irreps_hidden`, we also highly suggest the user to add at least 3 times of the number of essential irreps to enhance to representation capacity.
`irreps_hidden`: Very important! This parameter decides mostly the representation capacity of the model, along with the model size and consumption of GPU memory. This parameter indicates the irreps of hidden equivariant space, the definition here follows that for example, `64x0e` states `64` irreducible representation with `l=0` and `even` parity. For each basis set, we provide a tool to generate the least essential `irreps_hidden`, we also highly suggest the user add at least 3 times the number of essential irreps to enhance representation capacity.

```IPYTHON
In [5]: from dptb.data import OrbitalMapper
Expand All @@ -88,9 +88,9 @@ Out[7]: 7x0e+6x1o+6x2e+2x3o+1x4e

`n_layers`: indicates the number of layers of the networks.

`env_embed_multiplicity`: dicide the irreps number when initilizating the edge and node features.
`env_embed_multiplicity`: decide the irreps number when initializing the edge and node features.

`avg_num_neighbors`: the averaged number of neighbors in the system given the cutoff radius setted as `r_max`. It is recommended to do a statistics of the system you are modeling, but just pick up a number ranged from 50 to 100 is also okay.
`avg_num_neighbors`: the averaged number of neighbours in the system given the cutoff radius set as `r_max`. It is recommended to do statistics of the system you are modelling, but just picking up a number ranging from 50 to 100 is also okay.

`latent_dim`: The scalar channel's dimension of the system. 32/64/128 is good enough.

Expand Down
10 changes: 5 additions & 5 deletions docs/advanced/e3tb/data_preparation.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Data Preparation
We sugget the user to use a data parsing tool [dftio](https://github.com/floatingCatty/dftio) to directly converting the output data from DFT calculation into readable datasets. Our implementation support the parsed dataset format of `dftio`. User can just clone the `dftio` respository and run `pip install .` in its root directory. Then one can use the following parsing command for the parallel data processing directly from DFT output:
We suggest the user use a data parsing tool [dftio](https://github.com/floatingCatty/dftio) to directly convert the output data from DFT calculation into readable datasets. Our implementation supports the parsed dataset format of `dftio`. Users can just clone the `dftio` repository and run `pip install .` in its root directory. Then one can use the following parsing command for the parallel data processing directly from the DFT output:
```bash
usage: dftio parse [-h] [-ll {DEBUG,3,INFO,2,WARNING,1,ERROR,0}] [-lp LOG_PATH] [-m MODE] [-n NUM_WORKERS] [-r ROOT] [-p PREFIX] [-o OUTROOT] [-f FORMAT] [-ham] [-ovp] [-dm] [-eig]

Expand All @@ -26,7 +26,7 @@ optional arguments:
-eig, --eigenvalue Whether to parse the kpoints and eigenvalues (default: False)
```
After parsing, the user need to write a info.json file into the dataset. For default dataset type, the `info.json` looks like:
After parsing, the user need to write a info.json file and put it in the dataset. For default dataset type, the `info.json` looks like:
```JSON
{
Expand All @@ -39,15 +39,15 @@ After parsing, the user need to write a info.json file into the dataset. For def
}

```
Here `pos_type` can be `cart`, `dirc` or `ase`. For `dftio` output dataset, we use `cart` by default. The `r_max`, in principle, should align with the orbital cutoff in DFT calculation. For single element, the `r_max` should be a float number, indicating the largest bond distance included. When the system have multiple atoms, the `r_max` can also be a dict of atomic species specific number like `{A: 7.0, B: 8.0}`. Then the largest bond `A-A` would be 7 and `A-B` be (7+8)/2=7.5, and `B-B` would be 8. `pbc` can be a bool variable, indicating the open or close of the periodic boundary conditions of the model. It can also be a list of three bool elements like `[true, true, false]`, by what means we can set the periodicity of each direction independently.
Here `pos_type` can be `cart`, `dirc` or `ase`. For `dftio` output dataset, we use `cart` by default. The `r_max`, in principle, should align with the orbital cutoff in the DFT calculation. For a single element, the `r_max` should be a float number, indicating the largest bond distance included. When the system has multiple atoms, the `r_max` can also be a dict of atomic species-specific number like `{A: 7.0, B: 8.0}`. Then the largest bond `A-A` would be 7 and `A-B` be (7+8)/2=7.5, and `B-B` would be 8. `pbc` can be a bool variable, indicating the open or close of the periodic boundary conditions of the model. It can also be a list of three bool elements like `[true, true, false]`, which means we can set the periodicity of each direction independently.
For LMDB type Dataset, the info.json is much simplier, which looks like:
For LMDB type Dataset, the info.json is much simpler, which looks like this:
```JSON
{
"r_max": 7.0
}
```
Where other information have been stored in the dataset. LMDB dataset is design for handeling very large data that cannot be fit into the memory directly.
Where other information has been stored in the dataset. LMDB dataset is designed for handeling very large data that cannot be fit into the memory directly.
Then you can set the `data_options` in the input parameters to point directly to the prepared dataset, like:
```JSON
Expand Down
12 changes: 5 additions & 7 deletions docs/advanced/e3tb/loss_analysis.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Loss Analysis
## function
The **DeePTB** contrains a module to help the user better understand the details of the error of **E3TB** module.
The **DeePTB** contains a module to help the user better understand the details of the error of the **E3TB** module.
We decompose the error of **E3TB** model into several parts:
- onsite blocks: for diagonal blocks of the predicted quantum tensors
the onsite blocks are further arranged according to the atom species.
- hopping blocks: for off-diagonal blocks
the hopping blocks error are then further arranged according to the atom-pair types.
- onsite blocks: for diagonal blocks of the predicted quantum tensors the onsite blocks are further arranged according to the atom species.
- hopping blocks: for off-diagonal blocks, the hopping block errors are then further arranged according to the atom-pair types.

## usage
For using this function, we need a dataset and the model. Just build them up in advance.
Expand Down Expand Up @@ -44,7 +42,7 @@ for data in tqdm(loader, desc="doing error analysis"):
data = model(ref_data)
ana(data, ref_data, running_avg=True)
```
The analysis results are stored in `ana.stats`, which is a dictionary of statistics. The user can checkout the value directly, or displaying the results by:
The analysis results are stored in `ana.stats`, which is a dictionary of statistics. The user can check the value directly, or display the results by:

```Python
ana.report()
Expand Down Expand Up @@ -73,7 +71,7 @@ RMSE: 0.0003886453341692686
![MAE hopping](../../img/MAE_hopping.png)
![RMSE hopping](../../img/RMSE_hopping.png)

If the user want to see the loss in a decomposed irreps format, one can set the `decompose` of `HamilLossAnalysis` class to `True`, and rerun the analysis. We can display the decomposed irreps results using the following code:
If the user wants to see the loss in a decomposed irreps format, one can set the `decompose` of the `HamilLossAnalysis` class to `True`, and rerun the analysis.  We can display the decomposed irreps results using the following code:
```Python
import matplotlib.pyplot as plt
import torch
Expand Down
18 changes: 9 additions & 9 deletions docs/quick_start/hands_on/e3tb_hands_on.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Bulk Silicon model

DeePTB support training a E3-equalvariant model to predict DFT Hamiltonian, density and overlap matrix under LCAO basis. Here, cubic phase bulk silicon has been chosen as a quick start example.
DeePTB supports training an E3-equalvariant model to predict DFT Hamiltonian, density and overlap matrix under LCAO basis. Here, cubic-phase bulk silicon has been chosen as a quick start example.

Silicon is a chemical element; it has symbol Si and atomic number 14. It is a hard, brittle crystalline solid with a blue-grey metallic luster, and is a tetravalent metalloid and semiconductor. The prepared files are located in:
Silicon is a chemical element; it has the symbol Si and atomic number 14. It is a hard, brittle crystalline solid with a blue-grey metallic lustre, and is a tetravalent metalloid and semiconductor. The prepared files are located in:

```
deeptb/examples/e3/
Expand All @@ -19,7 +19,7 @@ deeptb/examples/e3/
| `-- info.json
`-- input.json
```
We prepared one frame of silicon cubic bulk structure as an example. The data was computed using DFT software ABACUS, with a LCAO basis set contraining 1 `s` and 1 `p` orbital. The cutoff radius for the orbital is 7au, which means the largest bond would be less than 14 au. Therefore, the r_max should be setted as 7.4. So we have a info.json file like:
We prepared one frame of silicon cubic bulk structure as an example. The data was computed using DFT software ABACUS, with an LCAO basis set containing 1 `s` and 1 `p` orbital. The cutoff radius for the orbital is 7au, which means the largest bond would be less than 14 au. Therefore, the r_max should be set as 7.4. So we have an info.json file like:

```json
{
Expand Down Expand Up @@ -63,16 +63,16 @@ Here comes the `model_options`:
}
}
```
The `model_options` contrains `embedding` and `prediction` parts, denoting construction of representation for equivariant features, and arrange and rescale the features into quantum operators sub-blocks such as Hamiltonian, density and overlap matrix.
The `model_options` contains `embedding` and `prediction` parts, denoting the construction of representation for equivariant features, and arranging and rescaling the features into quantum operators sub-blocks such as Hamiltonian, density and overlap matrix.

In `embedding`, the `method` support `slem` and `lem` for now, where `slem` have a strictly localized dependency, which have better transferbility and data-efficiency, while `lem` have a adjustable semi-local dependency, which have better representation capacity, but would requires a little more data. `r_max` should align with the one defined in `info.json`.
In `embedding`, the `method` supports `slem` and `lem` for now, where `slem` has a strictly localized dependency, which has better transferability and data efficiency, while `lem` has an adjustable semi-local dependency, which has better representation capacity, but would require a little more data. `r_max` should align with the one defined in `info.json`.

For `irreps_hidden`, this parameter defines the size of the hidden equivariant irreducible representation, which is highly related to the power of the model. There are certains rules to define this param. First, we should check the largest angular momentum defined in the DFT LCAO basis, the irreps's highest angular momentum should always be its double. For example, for `1s1p` basis, the irreps should contrains features with angular momentum from 0 to 2, which is 2 times 1, the angular momentum of `p` orbital. If basis contains `d` orbital, then the irreps should contrain angular momentum upto 4. `f` and `g` or even higher orbitals are also supported.
For `irreps_hidden`, this parameter defines the size of the hidden equivariant irreducible representation, which is highly related to the power of the model. There are certain rules to define this param. First, we should check the largest angular momentum defined in the DFT LCAO basis, the irreps's highest angular momentum should always be double. For example, for `1s1p` basis, the irreps should contain features with angular momentum from 0 to 2, which is 2 times 1, the angular momentum of `p` orbital. If the basis contains `d` orbital, then the irreps should contain angular momentum up to 4. `f` and `g` or even higher orbitals are also supported.

In `prediction`, we should use `e3tb` method to let the model know the output features are arranged as **E3TB** format. The neurons are defined for a simple MLP to predict the slater-koster like parameters for predicting the overlap matrix, for which [64,64] is usually fine.
In `prediction`, we should use the `e3tb` method to let the model know the output features are arranged in **E3TB** format. The neurons are defined for a simple MLP to predict the slater-koster-like parameters for predicting the overlap matrix, for which [64,64] is usually fine.


Now everything is prepared ! we can using the follwing command and we can train the first model:
Now everything is prepared! We can using the following command and we can train the first model:

```bash
cd deeptb/examples/e3
Expand All @@ -91,4 +91,4 @@ dptb run ./run/band.json -i ./e3_silicon/checkpoint/nnenv.best.pth -o ./band_plo
```
![band_first](../../img/silicon_e3_band.png)

Now you know how to train a **E3TB** model for Hamiltonian and overlap matrix. For better usage, we encourage the user to read the full input parameters for the **E3TB** model. Also, the **DeePTB** model support several post process tools, and the user can directly extract any predicted properties just using a few line of codes. Please see the basis_api for details.
Now you know how to train a **E3TB** model for Hamiltonian and overlap matrix. For better usage, we encourage the user to read the full input parameters for the **E3TB** model. Also, the **DeePTB** model supports several post-process tools, and the user can directly extract any predicted properties just using a few lines of code. Please see the basis_api for details.

0 comments on commit fb11eae

Please sign in to comment.