pyxtal.optimize.base module
A base class for global optimization including:
WFS: Width First Sampling
DFS: Depth First Sampling
QRS: Quasi Random Sampling
- class pyxtal.optimize.base.GlobalOptimize(smiles: str, workdir: str, sg: int | list[int], tag: str, info: dict[any, any] | None = None, ff_opt: bool = False, ff_style: str = 'openff', ff_parameters: str = 'parameters.xml', reference_file: str = 'references.xml', ref_criteria: dict[any, any] | None = None, N_cpu: int = 1, cif: str | None = None, block: list[any] | None = None, num_block: list[any] | None = None, composition: list[any] | None = None, lattice: Lattice | None = None, torsions: list[any] | None = None, molecules: list[pyxtal_molecule] | None = None, sites: list[any] | None = None, use_hall: bool = False, skip_ani: bool = True, factor: float = 1.1, eng_cutoff: float = 5.0, E_max: float = 10000000000.0, random_state=None, max_time: float | None = None, matcher: StructureMatcher | None = None, early_quit: bool = True, check_stable: bool = False, use_mpi: bool = False, pre_opt: bool = False)[source]
Bases:
object
Base-class for all global optimization methods
- Parameters:
smiles (str) – smiles string
workdir (str) – path of working directory
sg (int or list) – space group number or list of spg numbers
tag (string) – job prefix
ff_opt (bool) – activate on the fly FF mode
ff_style (str) – automated force style (gaff or openff)
ff_parameters (str or list) – ff parameter xml file or list
reference_file (str) – path of reference xml data for FF training
N_cpu (int) – number of cpus for parallel calculation (default: 1)
cif (str) – cif file name to store all structure information
block – block mode
num_block – list of blocks
compositions – list of composition, (default is [1]*Num_mol)
lattice (bool) – whether or not supply the lattice
torsions – list of torsion angle
molecules (list) – list of pyxtal_molecule objects
sites (list) – list of wp sites, e.g., [[‘4a’]]
use_hall (bool) – whether or not use hall number (default: False)
skip_ani (bool) – whether or not use ani or not (default: True)
eng_cutoff (float) – the cutoff energy for FF training
E_max (float) – maximum energy defined as an invalid structure
matcher – structurematcher from pymatgen
early_quit – whether quit the program early when the target is found
pre_opt – whether pre_optimize the structure or not
- check_ref(reps=None, reference=None, filename='pyxtal.cif')[source]
Check if ground state structure is found.
- Parameters:
reps – list of representations
refernce – [pmg, eng]
filename – filename
- count_pxrd_match(xtals, matches)[source]
Wrap up the matched PXRD results
- Parameters:
xtals – list of (xtal, tag) tuples
matches (list) – list of XRD matches
- export_references(xtals, engs, N_min=50, dE=2.5, FMSE=2.5)[source]
Add trainning data for FF optimization
- Parameters:
xtals – a list of pyxtals
engs – a list of energies
N_min (int) – minimum number of configs to add
dE (float) – the cutoff energy value
FMSE (float) – the cutoff Force MSE value
- gen_summary(t0, gen_results, xtals)[source]
Write the generic summary for each generation.
- Parameters:
t0 (float) – time stamp
gen_results – list of results (id, xtal, match)
xtals – list of (xtal, tag) tuples
- local_optimization(xtals, qrs=False, pool=None)[source]
Perform MPI optimization for each structure in each generation.
- Parameters:
xtals – list of (xtal, tag) tuples
qrs (bool) – Force mutation or not (related to QRS)
- local_optimization_mpi(xtals, qrs, pool)[source]
Perform MPI optimization for each structure in each generation.
- Parameters:
xtals – list of (xtal, tag) tuples
qrs (bool) – Force mutation or not (related to QRS)
- local_optimization_mproc(xtals, ncpu, ids=None, qrs=False, pool=None)[source]
Perform optimization for each structure in multiprocess mode.
- Parameters:
xtals – list of (xtal, tag) tuples
ncpu (int) – number of parallel python processes
ids (list) – list of ids of the associated xtals
qrs (bool) – Force mutation or not (related to QRS)
- local_optimization_serial(xtals, qrs=False)[source]
Perform optimization for each structure in each generation.
- Parameters:
xtals – list of (xtal, tag) tuples
qrs (bool) – Force mutation or not (related to QRS)
- plot_results(save=True, figsize=(8.0, 5.0), figname=None, ylim=None)[source]
Plot the results
- Parameters:
save (bool) – whether or not save the data
figsize – e.g. (8.5, 5.0)
figname (str)
ylim – e.g. (0, 1.0)
- print_matches(header=None)[source]
Formatted output for the matched structures with xtal rep and eng rank
- pyxtal.optimize.base.run_optimizer_with_timeout(args, logger)[source]
Run the optimizer with a timeout. This function will be executed by each process.
- pyxtal.optimize.base.setup_worker_logger(log_file)[source]
Set up the logger for each worker process.