Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs fixes #162

Merged
merged 5 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/user/fitting/fitting.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,61 @@ complete_flow = CompleteDFTvsMLBenchmarkWorkflow(
)
```

## Example script for `autoplex` workflow using GAP to fit and benchmark a Si database

The following code snippet will demonstrate, how you can submit an `autoplex` workflow for an automated SOAP-only GAP fit
and DFT benchmark for a Si allotrope database. The GAP fit parameters are taken from [J. Chem. Phys. 153, 044104 (2020)](https://pubs.aip.org/aip/jcp/article/153/4/044104/1056348/Combining-phonon-accuracy-with-high).
In this example we will also use `hyper_para_loop=True` to loop through a set of given GAP fit convergence parameter
and hyperparameters set as provided by the lists `atomwise_regularization_list`, `soap_delta_list` and `n_sparse_list`.
In this example script, we are using `jobflow_remote` to submit the jobs to a remote cluster.

```python
from jobflow_remote import submit_flow
from autoplex.auto.phonons.flows import CompleteDFTvsMLBenchmarkWorkflow
from mp_api.client import MPRester

mpr = MPRester(api_key='YOUR_MP_API_KEY')
struc_list = []
benchmark_structure_list = []
mpids = ["mp-149"] # add all the Si structure mpids you are interested in
mpbenchmark = ["mp-149"] # add all the Si structure mpids you are interested in
for mpid in mpids:
struc = mpr.get_structure_by_material_id(mpid)
struc_list.append(struc)
for mpbm in mpbenchmark:
bm_struc = mpr.get_structure_by_material_id(mpbm)
benchmark_structure_list.append(bm_struc)

autoplex_flow = CompleteDFTvsMLBenchmarkWorkflow(
n_structures=50, symprec=0.1,
volume_scale_factor_range=[0.95, 1.05], rattle_type=0, distort_type=0,
hyper_para_loop=True, atomwise_regularization_list=[0.1, 0.01],
soap_delta_list=[0.5], n_sparse_list=[7000, 8000, 9000]).make(
structure_list=struc_list, mp_ids=mpids, benchmark_structures=benchmark_structure_list,
benchmark_mp_ids=mpbenchmark, preprocessing_data=True,
**{
"split_ratio": 0.33,
"regularization": False,
"separated": True,
"num_processes_fit": 48,
"GAP": {"soap": {"delta": 1.0, "l_max": 12, "n_max": 10,
"atom_sigma": 0.5, "zeta": 4, "cutoff": 5.0,
"cutoff_transition_width": 1.0,
"central_weight": 1.0, "n_sparse": 9000, "f0": 0.0,
"covariance_type": "dot_product",
"sparse_method": "cur_points"},
"general": {"two_body": False, "three_body": False, "soap": True,
"default_sigma": "{0.001 0.05 0.05 0.0}", "sparse_jitter": 1.0e-8, }}},
)

autoplex_flow.name = "autoplex_wf"

resources = {...}

print(submit_flow(autoplex_flow, worker="autoplex_worker", resources=resources, project="autoplex"))
```


## Running a MLIP fit only

The following script shows an example of how you can run a sole GAP fit with `autoplex` using `run_locally` from
Expand Down
6 changes: 4 additions & 2 deletions docs/user/flows/flows.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This tutorial will demonstrate how to use `autoplex` with its default setup and

The complete workflow of `autoplex` involves the data generation
(including the execution of VASP calculations),
the fitting of the machine-learned interatomic potential (MLIP) and the benchmark to the DFT results.
the fitting of the machine-learned interatomic potential (MLIP) and the benchmark to the DFT results.

### Before running the workflow

Expand Down Expand Up @@ -42,9 +42,11 @@ check_supercells(structure_list, mpids, min_length=18, max_length=25, fallback_m
`check_supercells` will list all structures that should likely be excluded.
However, please carefully check yourself as your local memory requirements might be different.
Remove all structures which you cannot treat computationally
(e.g., structures with lattice parameters larger than 25 Angstrom or more than 500 atoms).
(e.g., structures with lattice parameters larger than 25 Å or more than 500 atoms).

Using the `MPRester` is a convenient way to draw structures from the Materials Project database using their MP-ID.


### Test DFT run times and memory requirements

To get a rough estimate of DFT requirements for the supercells that you have chosen, you can use the `DFTSupercellSettingsMaker`
Expand Down
51 changes: 43 additions & 8 deletions docs/user/generation/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,60 @@ that can be used to construct customized randomized structures workflows.

## VASP settings

For the single-atom displaced as well as the randomized structures the [TightDFTStaticMaker](#autoplex.data.phonons.flows.TightDFTStaticMaker) is used to set up the
VASP calculation input and settings. PBEsol is the default GGA functional.
This part will show you how you can adjust the different Makers for the VASP calculations in the workflow.

The `TightDFTStaticMaker` settings can be overridden by
For the single-atom displaced as well as the rattled structures the `autoplex` [TightDFTStaticMaker](#autoplex.data.phonons.flows.TightDFTStaticMaker) is
used to set up the VASP calculation input and settings. PBEsol is the default GGA functional. For the VASP calculation
of the isolated atoms' energies, `autoplex` also provides its own [IsoAtomStaticMaker](#autoplex.data.phonons.flows.IsoAtomStaticMaker),
which settings you can further adjust.
For the VASP geometry relaxation and static calculations of the unit cells as prerequisite calculations for generating
the single-atom displaced as well as the rattled supercells,
we rely on the [atomate2](https://materialsproject.github.io/atomate2/user/codes/vasp.html#list-of-vasp-workflows)
Makers `StaticMaker`, `TightRelaxMaker` in combination with the `StaticSetGenerator` VASP input set generator for this example.

```python
from autoplex.auto.phonons.flows import CompleteDFTvsMLBenchmarkWorkflow
from autoplex.data.phonons.flows import TightDFTStaticMaker
from autoplex.data.phonons.flows import IsoAtomStaticMaker, TightDFTStaticMaker
from atomate2.vasp.jobs.core import StaticMaker, TightRelaxMaker
from atomate2.vasp.sets.core import StaticSetGenerator

complete_flow = CompleteDFTvsMLBenchmarkWorkflow(
displacement_maker=TightDFTStaticMaker(
input_set_generator=StaticSetGenerator(user_incar_settings={
example_input_set = StaticSetGenerator( # you can also define multiple input sets
user_kpoints_settings={"grid_density": 1},
user_incar_settings={
"ALGO": "Normal",
"IBRION": -1,
"ISPIN": 1,
"ISMEAR": 0,
..., # set all INCAR tags you need
"SIGMA": 0.05,
"GGA": "PE", # switches to PBE
...}))).make(...)
...},
)
static_isolated_atom_maker = IsoAtomStaticMaker(
name="isolated_atom_maker",
input_set_generator=example_input_set,
)
displacement_maker = TightDFTStaticMaker(
name="displacement_maker",
input_set_generator=example_input_set,
)
rattled_bulk_relax_maker = TightRelaxMaker(
name="bulk_rattled_maker",
input_set_generator=example_input_set,
)
phonon_bulk_relax_maker = TightRelaxMaker(
name="bulk_phonon_maker",
input_set_generator=example_input_set,
)
phonon_static_energy_maker = StaticMaker(
name="phonon_static_energy_maker",
input_set_generator=example_input_set,
)

complete_flow = CompleteDFTvsMLBenchmarkWorkflow(
displacement_maker=displacement_maker, # one displacement maker for rattled and single-atom displaced supercells to keep VASP settings consistent
phonon_bulk_relax_maker=phonon_bulk_relax_maker,
phonon_static_energy_maker=phonon_static_energy_maker,
rattled_bulk_relax_maker=rattled_bulk_relax_maker,
isolated_atom_maker=static_isolated_atom_maker,).make(...)
```
Loading