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

Created a new unified flow module for RSS. #203

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
357 changes: 357 additions & 0 deletions autoplex/auto/rss/flow.py

Large diffs are not rendered by default.

678 changes: 678 additions & 0 deletions autoplex/auto/rss/jobs.py

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions autoplex/auto/rss/rss_default_configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# General Parameters
tag: 'Si'
train_from_scratch: true
resume_from_previous_state:
test_error:
pre_database_dir:
mlip_path:
isolated_atom_energies:

# Buildcell Parameters
generated_struct_numbers:
- 8000
- 2000
buildcell_options:
- NFORM: '{2,4,6,8}'
SYMMOPS: '1-4'
MINSEP: '1.5 Ti-Ti=2.5-2.8 Ti-O=1.3-1.6 O-O=1.9-2.2'
- NFORM: '{3,5,7}'
SYMMOPS: '1-4'
MINSEP: '1.5 Ti-Ti=2.5-2.8 Ti-O=1.3-1.6 O-O=1.9-2.2'
fragment_file: null
fragment_numbers: null
num_processes_buildcell: 128

# Sampling Parameters
num_of_initial_selected_structs:
- 80
- 20
num_of_rss_selected_structs: 100
initial_selection_enabled: true
rss_selection_method: 'bcur2i'
bcur_params:
soap_paras:
l_max: 12
n_max: 12
atom_sigma: 0.0875
cutoff: 10.5
cutoff_transition_width: 1.0
zeta: 4.0
average: true
species: true
frac_of_bcur: 0.8
bolt_max_num: 3000
random_seed: null

# DFT Labelling Parameters
include_isolated_atom: true
isolatedatom_box:
- 20.0
- 20.0
- 20.0
e0_spin: false
include_dimer: true
dimer_box:
- 20.0
- 20.0
- 20.0
dimer_range:
- 1.0
- 5.0
dimer_num: 41
custom_incar:
ISMEAR: 0
SIGMA: 0.05
PREC: 'Accurate'
ADDGRID: '.TRUE.'
EDIFF: 1e-7
NELM: 250
LWAVE: '.FALSE.'
LCHARG: '.FALSE.'
ALGO: 'Normal'
AMIX: null
LREAL: '.FALSE.'
ISYM: 0
ENCUT: 520.0
KSPACING: 0.20
GGA: 'PS'
KPAR: 8
NCORE: 16
LSCALAPACK: '.FALSE.'
LPLANE: '.FALSE.'
custom_potcar:
Ti: 'Ti'
vasp_ref_file: 'vasp_ref.extxyz'

# Data Preprocessing Parameters
config_types:
- 'initial'
- 'traj_early'
- 'traj'
rss_group:
- 'traj'
test_ratio: 0.1
regularization: false
scheme: 'linear-hull'
reg_minmax:
- [0.1, 1]
- [0.001, 0.1]
- [0.0316, 0.316]
- [0.0632, 0.632]
distillation: false
force_max: null
force_label: null
pre_database_dir: null

# MLIP Parameters
mlip_type: 'GAP'
ref_energy_name: 'REF_energy'
ref_force_name: 'REF_forces'
ref_virial_name: 'REF_virial'
auto_delta: true
num_processes_fit: 32
device_for_fitting: 'cpu'
fit_kwargs:
twob:
cutoff: 5.0
n_sparse: 15
theta_uniform: 1.0
threeb:
cutoff: 3.0
soap:
l_max: 10
n_max: 10
atom_sigma: 0.5
n_sparse: 2500
cutoff: 5.0
general:
three_body: false

# RSS Exploration Parameters
scalar_pressure_method: 'uniform'
scalar_exp_pressure: 100
scalar_pressure_exponential_width: 0.2
scalar_pressure_low: 0
scalar_pressure_high: 50
max_steps: 300
force_tol: 0.01
stress_tol: 0.01
stop_criterion: 0.01
max_iteration_number: 25
num_groups: 6
initial_kt: 0.3
current_iter_index: 1
hookean_repul: true
hookean_paras:
'(8, 8)': [1000, 1.3]
'(8, 22)': [1000, 0.9]
'(22, 22)': [1000, 1.7]
keep_symmetry: false
write_traj: true
num_processes_rss: 128
device_for_rss: 'cpu'
97 changes: 62 additions & 35 deletions autoplex/data/common/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from dataclasses import dataclass
from dataclasses import dataclass, field
from typing import TYPE_CHECKING

if TYPE_CHECKING:
Expand Down Expand Up @@ -237,7 +237,7 @@ def static_run_and_convert(


@dataclass
class DFTStaticMaker(Maker):
class DFTStaticLabelling(Maker):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this maker is now renamed to DFTStaticLabelling, we would also need to rename it here on this line https://github.com/YuanbinLiu/autoplex_pub/blob/52731b1cbefd8a4546ee2b769430ff80ffb00868/autoplex/data/common/flows.py#L46

"""
Maker to set up and run VASP static calculations for input structures, including bulk, isolated atoms, and dimers.
Expand All @@ -247,66 +247,78 @@ class DFTStaticMaker(Maker):
----------
name: str
Name of the flow.
isolated_atom : bool, optional
Whether to perform calculations for isolated atoms. Default is False.
isolated_species : list[str], optional
isolated_atom: bool
If true, perform single-point calculations for isolated atoms. Default is False.
isolated_species: list[str]
List of species for which to perform isolated atom calculations. If None,
species will be automatically derived from the 'structures' list. Default is None.
e0_spin : bool, optional
Whether to include spin polarization in isolated atom and dimer calculations.
e0_spin: bool
If true, include spin polarization in isolated atom and dimer calculations.
Default is False.
dimer : bool, optional
Whether to perform calculations for dimers. Default is False.
dimer_species : list[str], optional
isolatedatom_box: list[float]
List of the lattice constants for a isolated_atom configuration.
dimer: bool
If true, perform single-point calculations for dimers. Default is False.
dimer_box: list[float]
The lattice constants of a dimer box.
dimer_species: list[str]
List of species for which to perform dimer calculations. If None, species
will be derived from the 'structures' list. Default is None.
dimer_range : list[float], optional
Range of distances for dimer calculations. Default is [0.8, 4.8].
dimer_num : int, optional
Number of different distances to consider for dimer calculations. Default is 22.
custom_set : dict, optional
dimer_range: list[float]
Range of distances for dimer calculations.
dimer_num: int
Number of different distances to consider for dimer calculations.
custom_incar: dict
Dictionary of custom VASP input parameters. If provided, will update the
default parameters. Default is None.
custom_potcar: dict
Dictionary of POTCAR settings to update. Keys are element symbols, values are the desired POTCAR labels.
Default is None.
Returns
-------
Response
A Response object containing the VASP jobs and the directories where
the calculations were set up.
dict
A dictionary containing:
- 'dirs_of_vasp': List of directories containing VASP data.
- 'config_type': List of configuration types corresponding to each directory.
"""

name: str = "DFT single-point calculations"
name: str = "do_dft_labelling"
isolated_atom: bool = False
isolated_species: list[str] | None = None
e0_spin: bool = False
isolatedatom_box: list[float] = field(default_factory=lambda: [20, 20, 20])
dimer: bool = False
dimer_box: list[float] = field(default_factory=lambda: [20, 20, 20])
dimer_species: list[str] | None = None
dimer_range: list[float] | None = None
dimer_num: int = 21
custom_set: dict | None = None
custom_incar: dict | None = None
custom_potcar: dict | None = None

@job
def make(
self,
structures: list[Structure],
config_types: list[str] | None = None,
structures: list,
config_type: str | None = None,
):
"""
Maker to set up and run VASP static calculations.
Parameters
----------
structures : list[Structure], optional
structures : list[Structure] | list[list[Structure]]
List of structures for which to run the VASP static calculations. If None,
no bulk calculations will be performed. Default is None.
config_types : list[str], optional
List of configuration types corresponding to the structures. If provided,
should have the same length as the 'structures' list. If None, defaults
config_type : str
Configuration types corresponding to the structures. If None, defaults
to 'bulk'. Default is None.
"""
job_list = []

if isinstance(structures[0], list):
structures = flatten(structures, recursive=False)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flatten is not imported


dirs: dict[str, list[str]] = {"dirs_of_vasp": [], "config_type": []}

default_custom_set = {
Expand Down Expand Up @@ -336,8 +348,8 @@ def make(
"AMIN": None,
}

if self.custom_set is not None:
default_custom_set.update(self.custom_set)
if self.custom_incar is not None:
default_custom_set.update(self.custom_incar)

custom_set = default_custom_set

Expand All @@ -358,13 +370,16 @@ def make(
run_vasp_kwargs={"handlers": custom_handlers},
)

if self.custom_potcar is not None:
st_m = update_user_potcar_settings(st_m, potcar_updates=self.custom_potcar)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this import is missing as well in this module


if structures:
for idx, struct in enumerate(structures):
static_job = st_m.make(structure=struct)
static_job.name = f"static_bulk_{idx}"
dirs["dirs_of_vasp"].append(static_job.output.dir_name)
if config_types:
dirs["config_type"].append(config_types[idx])
if config_type:
dirs["config_type"].append(config_type)
else:
dirs["config_type"].append("bulk")
job_list.append(static_job)
Expand All @@ -380,12 +395,18 @@ def make(
syms = ElementCollection(atoms).get_species()

for idx, sym in enumerate(syms):
lattice = Lattice.orthorhombic(20.0, 20.5, 21.0)
lattice = Lattice.orthorhombic(
self.isolatedatom_box[0],
self.isolatedatom_box[1],
self.isolatedatom_box[2],
)
isolated_atom_struct = Structure(lattice, [sym], [[0.0, 0.0, 0.0]])
static_job = st_m.make(structure=isolated_atom_struct)
static_job.name = f"static_isolated_{idx}"
static_job = update_user_incar_settings(
static_job, {"KSPACING": 2.0}
# static_job, {"KSPACING": 100.0, "ALGO": "All", "KPAR": 1, "NBANDS": 20}
static_job,
{"KSPACING": 100.0, "ALGO": "All", "KPAR": 1},
)

if self.e0_spin:
Expand Down Expand Up @@ -419,7 +440,11 @@ def make(
self.dimer_num - 1 + 0.000000000001
)

lattice = Lattice.orthorhombic(15.0, 15.5, 16.0)
lattice = Lattice.orthorhombic(
self.dimer_box[0],
self.dimer_box[1],
self.dimer_box[2],
)
dimer_struct = Structure(
lattice,
[pair[0], pair[1]],
Expand All @@ -430,7 +455,9 @@ def make(
static_job = st_m.make(structure=dimer_struct)
static_job.name = f"static_dimer_{dimer_i}"
static_job = update_user_incar_settings(
static_job, {"KSPACING": 2.0}
# static_job, {"KSPACING": 100.0, "ALGO": "All", "KPAR": 1, "NBANDS": 20}
static_job,
{"KSPACING": 100.0, "ALGO": "All", "KPAR": 1},
)

if self.e0_spin:
Expand Down
Loading
Loading