pyace package
Subpackages
Submodules
pyace.asecalc module
- class pyace.asecalc.PyACECalculator(basis_set, **kwargs)[source]
Bases:
ase.calculators.calculator.CalculatorPyACE ASE calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- __init__(basis_set, **kwargs)[source]
PyACE ASE calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- Parameters
(default (recursive) – False)
(default – False)
- calculate(atoms=None, properties=['energy', 'forces', 'stress', 'energies'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.
- implemented_properties: List[str] = ['energy', 'forces', 'stress', 'energies', 'free_energy']
Properties calculator can handle (energy, forces, …)
- class pyace.asecalc.PyACEEnsembleCalculator(basis_set, **kwargs)[source]
Bases:
ase.calculators.calculator.CalculatorPyACE ASE ensemble calculator :param basis_set - list of specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- __init__(basis_set, **kwargs)[source]
PyACE ASE ensemble calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- calculate(atoms=None, properties=('energy', 'forces', 'stress', 'energies', 'energy_std', 'forces_std', 'stress_std', 'energies_std'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.
- implemented_properties: List[str] = ['energy', 'forces', 'stress', 'energies', 'free_energy', 'energy_std', 'forces_std', 'stress_std', 'energies_std', 'free_energy_std']
Properties calculator can handle (energy, forces, …)
pyace.atomicenvironment module
- pyace.atomicenvironment.aseatoms_to_atomicenvironment(atoms, cutoff=9, elements_mapper_dict=None)[source]
Function to read from a ASE atoms objects
- Parameters
atoms (ASE Atoms object) – name of the ASE atoms object
cutoff (float) – cutoff value for calculating neighbors
- pyace.atomicenvironment.aseatoms_to_atomicenvironment_old(atoms, cutoff=9, skin=0, elements_mapper_dict=None)[source]
Function to read from a ASE atoms objects
- Parameters
atoms (ASE Atoms object) – name of the ASE atoms object
cutoff (float) – cutoff value for calculating neighbors
- pyace.atomicenvironment.calculate_minimal_nn_distance(df: pandas.core.frame.DataFrame, target_column_name='min_distance')[source]
- pyace.atomicenvironment.create_cube(dr, cube_side_length)[source]
Create a simple cube without pbc. Test function
pyace.basisextension module
- pyace.basisextension.construct_bbasisconfiguration(potential_config: Dict, initial_basisconfig: Optional[pyace.basis.BBasisConfiguration] = None) pyace.basis.BBasisConfiguration[source]
- pyace.basisextension.extend_basis(initial_basis: pyace.basis.BBasisConfiguration, final_basis: pyace.basis.BBasisConfiguration, ladder_type: str, func_step: Optional[int] = None, return_is_extended=False) pyace.basis.BBasisConfiguration[source]
- pyace.basisextension.get_actual_ladder_step(ladder_step_param: Union[int, float, List], current_number_of_funcs: int, final_number_of_funcs: int) int[source]
- pyace.basisextension.sort_funcspecs_list(lst: List[pyace.basis.BBasisFunctionSpecification], ladder_type: str) List[pyace.basis.BBasisFunctionSpecification][source]
pyace.const module
pyace.fitadapter module
- class pyace.fitadapter.BackendConfig(backend_config_dict: Dict)[source]
Bases:
object- property evaluator_name
- class pyace.fitadapter.FitBackendAdapter(backend_config: Union[Dict, pyace.fitadapter.BackendConfig], loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, fit_config: Optional[Dict] = None, callback: Optional[Callable] = None, fit_metrics_callback: Optional[Callable] = None, test_metrics_callback: Optional[Callable] = None)[source]
Bases:
object- __init__(backend_config: Union[Dict, pyace.fitadapter.BackendConfig], loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, fit_config: Optional[Dict] = None, callback: Optional[Callable] = None, fit_metrics_callback: Optional[Callable] = None, test_metrics_callback: Optional[Callable] = None)[source]
- compute_metrics(energy_col='energy_corrected', nat_column='NUMBER_OF_ATOMS', force_col='forces')[source]
- property evaluator_name
- fit(bbasisconfig: pyace.basis.BBasisConfiguration, dataframe: pandas.core.frame.DataFrame, loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, fit_config: Optional[Dict] = None, callback: Optional[Callable] = None, test_dataframe: Optional[pandas.core.frame.DataFrame] = None) pyace.basis.BBasisConfiguration[source]
- property last_fit_metric_data
- property last_loss
- property last_test_metric_data
- run_pyace_fit(bbasisconfig: pyace.basis.BBasisConfiguration, dataframe: pandas.core.frame.DataFrame, loss_spec: pyace.lossfuncspec.LossFunctionSpecification, fit_config: Dict, trainable_parameters_dict: Dict, test_dataframe: Optional[pandas.core.frame.DataFrame] = None) pyace.basis.BBasisConfiguration[source]
- run_tensorpot_fit(bbasisconfig: pyace.basis.BBasisConfiguration, dataframe: pandas.core.frame.DataFrame, loss_spec: pyace.lossfuncspec.LossFunctionSpecification, fit_config: Dict, trainable_parameters_dict: Dict, test_dataframe: Optional[pandas.core.frame.DataFrame] = None) pyace.basis.BBasisConfiguration[source]
- setup_pyace(bbasisconfig: pyace.basis.BBasisConfiguration, dataframe: pandas.core.frame.DataFrame, loss_spec: pyace.lossfuncspec.LossFunctionSpecification, trainable_parameters_dict: Dict) pyace.basis.BBasisConfiguration[source]
- setup_tensorpot(bbasisconfig: pyace.basis.BBasisConfiguration, dataframe: pandas.core.frame.DataFrame, loss_spec: pyace.lossfuncspec.LossFunctionSpecification, trainable_parameters_dict: Dict) pyace.basis.BBasisConfiguration[source]
pyace.fitcallbacks module
pyace.generalfit module
- class pyace.generalfit.GeneralACEFit(potential_config: Union[Dict, str, pyace.basis.BBasisConfiguration, pyace.basis.ACEBBasisSet], fit_config: Dict, data_config: Union[Dict, pandas.core.frame.DataFrame], backend_config: Dict, cutoff=None, seed=None, callbacks=None)[source]
Bases:
objectMain fitting wrapper class
- Parameters
potential_config – specification of the potential - configuration dictionary - YAML with BBasisConfiguration potential configuration - BBasisConfiguration - ACEBBasisSet
fit_config – specification of fitting (loss function, number of iterations, weighting policy, …)
data_config – training data specification
backend_config – specification of potential evaluation and fitting backend (pyace / tensorpot) - dict [‘evaluator’]
- __init__(potential_config: Union[Dict, str, pyace.basis.BBasisConfiguration, pyace.basis.ACEBBasisSet], fit_config: Dict, data_config: Union[Dict, pandas.core.frame.DataFrame], backend_config: Dict, cutoff=None, seed=None, callbacks=None)[source]
- static apply_gaussian_noise(current_bbasisconfig, trainable_parameters_dict, noise_abs_sigma, noise_rel_sigma)[source]
- callback_hook(basis_config: pyace.basis.BBasisConfiguration, current_fit_cycle: int, current_ladder_step: int)[source]
- cycle_fitting(bbasisconfig: pyace.basis.BBasisConfiguration) pyace.basis.BBasisConfiguration[source]
- pyace.generalfit.active_import(name)[source]
This function will import the :param name: :type name: :return: :rtype:
- pyace.generalfit.apply_noise(all_coeffs: Union[numpy.array, List], sigma: float, relative: bool = True) numpy.array[source]
- pyace.generalfit.safely_update_bbasisconfiguration_coefficients(coeffs: numpy.array, config: Optional[pyace.basis.BBasisConfiguration] = None) None[source]
- pyace.generalfit.save_interim_potential(basis_config: pyace.basis.BBasisConfiguration, coeffs=None, potential_filename='interim_potential.yaml', verbose=True)[source]
- pyace.generalfit.save_interim_potential_callback(basis_config: pyace.basis.BBasisConfiguration, current_fit_iteration: int, current_fit_cycle: int, current_ladder_step: int)[source]
- pyace.generalfit.set_general_metadata(bbasisconfig: pyace.basis.BBasisConfiguration, **kwargs) None[source]
pyace.helpers module
pyace.lossfuncspec module
pyace.metrics_aggregator module
- class pyace.metrics_aggregator.FitMetrics(w_e, w_f, e_scale, f_scale, ncoefs, regs=None)[source]
Bases:
object
- class pyace.metrics_aggregator.MetricsAggregator(extended_display_step=20, running_metrics_filename='metrics.txt', ladder_metrics_filename='ladder_metrics.txt', cycle_metrics_filename='cycle_metrics.txt', test_running_metrics_filename='test_metrics.txt', test_ladder_metrics_filename='test_ladder_metrics.txt', test_cycle_metrics_filename='test_cycle_metrics.txt')[source]
Bases:
object- __init__(extended_display_step=20, running_metrics_filename='metrics.txt', ladder_metrics_filename='ladder_metrics.txt', cycle_metrics_filename='cycle_metrics.txt', test_running_metrics_filename='test_metrics.txt', test_ladder_metrics_filename='test_ladder_metrics.txt', test_cycle_metrics_filename='test_cycle_metrics.txt')[source]
- columns = [('ladder_step', 11), ('cycle_step', 11), ('iter_num', 8), 'loss', 'e_loss_contrib', 'f_loss_contrib', 'reg_loss', 'rmse_epa', 'rmse_f_comp', 'low_rmse_epa', 'low_rmse_f_comp', 'mae_f_comp', 'low_mae_f_comp', ('nfuncs', 6), ('ncoefs', 6), 'l1_reg_contrib', 'l2_reg_contrib', 'smooth_orth', 'smooth_w1', 'smooth_w2', 'smooth_w3']
pyace.multispecies_basisextension module
- class pyace.multispecies_basisextension.BlockBasisFunctionsList(block: pyace.basis.BBasisFunctionsSpecificationBlock)[source]
Bases:
object- __init__(block: pyace.basis.BBasisFunctionsSpecificationBlock)[source]
- find_existing(func: pyace.basis.BBasisFunctionSpecification) bool[source]
- pyace.multispecies_basisextension.compute_bbasisset_train_mask(bbasisconf: Union[pyace.basis.BBasisConfiguration, pyace.basis.ACEBBasisSet], extended_trainable_parameters_dict: dict)[source]
- pyace.multispecies_basisextension.create_multispecies_basis_config(potential_config: Dict, unif_mus_ns_to_lsLScomb_dict: Optional[Dict] = None, func_coefs_initializer='zero', initial_basisconfig: Optional[pyace.basis.BBasisConfiguration] = None) pyace.basis.BBasisConfiguration[source]
Creates a BBasisConfiguration using potential_config dict
Possible keywords: ALL, UNARY, BINARY, TERNARY, QUATERNARY, QUINARY
Example:
- potential_config = {
‘deltaSplineBins’: 0.001, ‘elements’: [‘Al’, ‘H’],
- ‘embeddings’: {‘ALL’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1], ‘ndensity’: 1, ‘npot’: ‘FinnisSinclair’, ‘rho_core_cut’: 200000},
- ‘Al’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1, 1, 0.5], ‘ndensity’: 2, ‘npot’: ‘FinnisSinclairShiftedScaled’, ‘rho_core_cut’: 200000}
},
- ‘bonds’: {‘ALL’: {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebPow’, ‘radparameters’: [2.0], ‘rcut’: 3.9},
- (‘Al’, ‘H’): {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebExpCos’, ‘radparameters’: [2.0], ‘rcut’: 3.5},
},
- ‘functions’: {
- ‘UNARY’: {
‘nradmax_by_orders’: [5, 2, 2], ‘lmax_by_orders’: [0, 1, 1]
},
- ‘BINARY’: {
‘nradmax_by_orders’: [5, 1, 1], ‘lmax_by_orders’: [0, 1, 1],
},
}
}
- Parameters
potential_config – potential configuration dictionary, see above
unif_mus_ns_to_lsLScomb_dict – “whitelist” (dictionary) of the { unify_mus_ns_comb(mus_comb, ns_comb): list of (ls,LS) }
func_coefs_initializer – “zero” or “random”
initial_basisconfig –
- Returns
BBasisConfiguration
- pyace.multispecies_basisextension.create_multispecies_basisblocks_list(potential_config: Dict, element_ndensity_dict: Optional[Dict] = None, func_coefs_initializer='zero', unif_mus_ns_to_lsLScomb_dict=None, verbose=False) List[pyace.basis.BBasisFunctionsSpecificationBlock][source]
- pyace.multispecies_basisextension.create_species_block(elements_vec: List, block_spec_dict: Dict, ndensity: int, func_coefs_initializer='zero', unif_mus_ns_to_lsLScomb_dict=None) pyace.basis.BBasisFunctionsSpecificationBlock[source]
- pyace.multispecies_basisextension.create_species_block_without_funcs(elements_vec: List[str], block_spec: Dict) pyace.basis.BBasisFunctionsSpecificationBlock[source]
Create a BBasisFunctionsSpecificationBlock :param elements_vec: block’s elements, i.e. (ele1, ele2, …) :param block_spec: block specification dictionary :param crad_initializer: “delta” or “random” :return: BBasisFunctionsSpecificationBlock
- pyace.multispecies_basisextension.expand_trainable_parameters(elements: list, trainable_parameters: Optional[Union[str, list, dict]] = None) dict[source]
- pyace.multispecies_basisextension.extend_basis_block(init_block: pyace.basis.BBasisFunctionsSpecificationBlock, final_block: pyace.basis.BBasisFunctionsSpecificationBlock, num_funcs=None, ladder_type='body_order') Tuple[pyace.basis.BBasisFunctionsSpecificationBlock, bool][source]
- pyace.multispecies_basisextension.extend_multispecies_basis(initial_basis: pyace.basis.BBasisConfiguration, final_basis: pyace.basis.BBasisConfiguration, ladder_type='body_order', num_funcs=None, return_is_extended=False) Tuple[pyace.basis.BBasisConfiguration, bool][source]
- pyace.multispecies_basisextension.generate_all_species_keys(elements)[source]
Generate all ordered in [1:…] slice permutations of elements, that would be the species blocks names
- Parameters
elements – list of elements (str)
- Returns
list of all generated block names
- pyace.multispecies_basisextension.generate_blocks_specifications_dict(potential_config: Dict) Dict[source]
Creates a blocks_specifications_dict using potential_config dict
Possible keywords: ALL, UNARY, BINARY, TERNARY, QUATERNARY, QUINARY
Example:
- potential_config = {
‘deltaSplineBins’: 0.001, ‘elements’: [‘Al’, ‘H’],
- ‘embeddings’: {‘ALL’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1], ‘ndensity’: 1, ‘npot’: ‘FinnisSinclair’, ‘rho_core_cut’: 200000},
- ‘Al’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1, 1, 0.5], ‘ndensity’: 2, ‘npot’: ‘FinnisSinclairShiftedScaled’, ‘rho_core_cut’: 200000}
},
- ‘bonds’: {‘ALL’: {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebPow’, ‘radparameters’: [2.0], ‘rcut’: 3.9},
- (‘Al’, ‘H’): {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebExpCos’, ‘radparameters’: [2.0], ‘rcut’: 3.5},
},
- ‘functions’: {
- ‘UNARY’: {
‘nradmax_by_orders’: [5, 2, 2], ‘lmax_by_orders’: [0, 1, 1]
},
- ‘BINARY’: {
‘nradmax_by_orders’: [5, 1, 1], ‘lmax_by_orders’: [0, 1, 1],
},
}
}
- Parameters
potential_config – potential configuration dictionary, see above
- Returns
blocks_specifications_dict
- pyace.multispecies_basisextension.generate_species_keys(elements, r)[source]
Generate all ordered permutations of the elements if size r
- Parameters
elements – list of elements
r – permutations size
- Returns
list of speices blocks names (permutation) of size r
- pyace.multispecies_basisextension.is_mult_basisfunc_equivalent(func1: pyace.basis.BBasisFunctionSpecification, func2: pyace.basis.BBasisFunctionSpecification) bool[source]
- pyace.multispecies_basisextension.species_key_to_bonds(key)[source]
Unify the tuple key to a list of bond pairs:
A -> [A,A] A:B -> [A,B] [B,A], A:BC -> [A,B] [B,A], [A,C], [C,A] A:BCD -> [A,B] [B,A], [A,C], [C,A], [A,D], [D,A]
- Parameters
key – tuple of elements
- Returns
list of bond pairs
- pyace.multispecies_basisextension.unify_absolute_by_ordering(mus_comb, ns_comb)[source]
Unify mus_comb and ns_comb by combining pairwise and sort
- pyace.multispecies_basisextension.unify_absolute_mus_ns_comb(mus_comb, ns_comb)[source]
Unify mus_comb, ns_comb by combining, sorting
- pyace.multispecies_basisextension.unify_by_ordering(mus_comb, ns_comb)[source]
Unify mus_comb and ns_comb to minimized-indices sequence, combine pairwise and sort
- pyace.multispecies_basisextension.unify_mus_ns_comb(mus_comb, ns_comb)[source]
Unify mus_comb, ns_comb by unifying to min-inds, combining, sorting and unifying the pair one more time to minimized-indices sequence
- pyace.multispecies_basisextension.unify_to_minimized_indices(seq, shift=0)[source]
Unify to minimized ordered sequence of indices
- pyace.multispecies_basisextension.validate_bonds_nradmax_lmax_nradbase(ext_basis: pyace.basis.BBasisConfiguration)[source]
Check the nradbase, lmax and nradmax over all bonds in all species blocks
pyace.paralleldataexecutor module
- class pyace.paralleldataexecutor.ParallelDataExecutor(distributed_data: pandas.core.frame.DataFrame, parallel_mode: str = 'serial', index_col: Optional[str] = None, batch_size: Optional[int] = None, n_workers: Optional[int] = None)[source]
Bases:
object- MODE_MPI = 'mpi'
- MODE_PROCESS = 'process'
- MODE_SERIAL = 'serial'
- class pyace.paralleldataexecutor.SerialExecutor(initializer=None, initargs=None)[source]
Bases:
concurrent.futures._base.Executor- shutdown(wait=True)[source]
Clean-up the resources associated with the Executor.
It is safe to call this method several times. Otherwise, no other methods can be called after this one.
- Parameters
wait – If True then shutdown will not return until all running futures have finished executing and the resources used by the executor have been reclaimed.
pyace.preparedata module
- class pyace.preparedata.DataFrameWithMetadata(data=None, index: Axes | None = None, columns: Axes | None = None, dtype: Dtype | None = None, copy: bool | None = None)[source]
Bases:
pandas.core.frame.DataFrame- property metadata_dict
- class pyace.preparedata.EnergyBasedWeightingPolicy(nfit=20000, cutoff=None, DElow=1.0, DEup=10.0, DE=1.0, DF=1.0, wlow=None, DFup=None, reftype='all', seed=None, energy='convex_hull')[source]
- class pyace.preparedata.ExternalWeightingPolicy(filename: str)[source]
- class pyace.preparedata.StructuresDatasetSpecification(config: Optional[Dict] = None, cutoff: float = 10, filename: Optional[str] = None, datapath: str = '', db_conn_string: Optional[str] = None, force_query: bool = False, ignore_weights: bool = False, query_limit: Optional[int] = None, seed: Optional[int] = None, cache_ref_df: bool = True, progress_bar: bool = False, df: Optional[pandas.core.frame.DataFrame] = None, force_rebuild: bool = False, **kwargs)[source]
Bases:
objectObject to query or load from cache the fitting dataset
- param config
dictionary with “element” - the element for which the data will be collected “calculator” - calculator and “seed” - random seed
- param cutoff
- param filename
- param datapath
- param db_conn_string
- param force_query
- param query_limit
- param seed
- param cache_ref_df
- FHI_AIMS_PBE_TIGHT = 'FHI-aims/PBE/tight'
- __init__(config: Optional[Dict] = None, cutoff: float = 10, filename: Optional[str] = None, datapath: str = '', db_conn_string: Optional[str] = None, force_query: bool = False, ignore_weights: bool = False, query_limit: Optional[int] = None, seed: Optional[int] = None, cache_ref_df: bool = True, progress_bar: bool = False, df: Optional[pandas.core.frame.DataFrame] = None, force_rebuild: bool = False, **kwargs)[source]
- Parameters
config –
cutoff –
filename –
datapath –
db_conn_string –
force_query –
query_limit –
seed –
cache_ref_df –
- get_actual_filename()[source]
Get actual filename to load dataframe: 1. If filename is provided
try to find file locally
else try to find in datapath. If no datapath - switch back to local
- If filename is not provided
generate standard filename based on element and calculator name (prepend with datapath, if provided)
- Returns
filename of dataframe
- pyace.preparedata.generate_atomic_env_column(df, cutoff=9, elements_mapper_dict=None, ase_atoms_column='ase_atoms')[source]
- pyace.preparedata.get_dataset_specification(evaluator_name, data_config: Dict, cutoff=10, elements=None) pyace.preparedata.StructuresDatasetSpecification[source]
- pyace.preparedata.get_fitting_dataset(evaluator_name, data_config: Dict, weighting_policy_spec: Optional[Dict] = None, cutoff=10, elements=None, force_query=False, force_weighting=None) pandas.core.frame.DataFrame[source]
- pyace.preparedata.get_reference_dataset(evaluator_name, data_config: Dict, cutoff=10, elements=None, force_query=False, cache_ref_df=True)[source]
- pyace.preparedata.get_weighting_policy(weighting_policy_spec: Dict) pyace.preparedata.StructuresDatasetWeightingPolicy[source]
- pyace.preparedata.load_dataframe(filename: str, compression: str = 'infer') pandas.core.frame.DataFrame[source]
- pyace.preparedata.normalize_energy_forces_weights(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]
- pyace.preparedata.query_data(config: Dict, seed=None, query_limit=None, db_conn_string=None)[source]
pyace.pyacefit module
- class pyace.pyacefit.PyACEFit(basis: Optional[pyace.basis.BBasisConfiguration] = None, structures_dataframe: Optional[pandas.core.frame.DataFrame] = None, loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, seed=None, executors_kw_args=None, display_step=10, trainable_parameters=None)[source]
Bases:
objectCreate a class for fitting ACE potential
:param basis (BBasisConfiguration, ACEBBasisSet) basis set specification :param loss_spec (LossFunctionSpecification)
- __init__(basis: Optional[pyace.basis.BBasisConfiguration] = None, structures_dataframe: Optional[pandas.core.frame.DataFrame] = None, loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, seed=None, executors_kw_args=None, display_step=10, trainable_parameters=None)[source]
- fit(structures_dataframe, method='Nelder-Mead', options=None, callback=None, verbose=True, fit_metric_callback=None)[source]
- property metrics
- predict_energy_forces(params=None, structures_dataframe=None, keep_parallel_dataexecutor=False)[source]
- predict_projections(params=None, structures_dataframe=None, keep_parallel_dataexecutor=False)[source]
- property structures_dataframe
pyace.pyneighbor module
pyace.radial module
- class pyace.radial.RadialFunctionSmoothness(radialFunctionsValues: pyace.radial.RadialFunctionsValues)[source]
Bases:
object- __init__(radialFunctionsValues: pyace.radial.RadialFunctionsValues)[source]
- property smooth_quad
- class pyace.radial.RadialFunctionsValues(basis_set: Union[pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet], npoints=None)[source]
Bases:
object- __init__(basis_set: Union[pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet], npoints=None)[source]
- class pyace.radial.RadialFunctionsVisualization(radialFunctionsValues: Union[pyace.radial.RadialFunctionsValues, pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet, pyace.basis.BBasisConfiguration], k=None, nl=None, xmin=- 0.5, xmax=None, ymin=None, ymax=None)[source]
Bases:
object- __init__(radialFunctionsValues: Union[pyace.radial.RadialFunctionsValues, pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet, pyace.basis.BBasisConfiguration], k=None, nl=None, xmin=- 0.5, xmax=None, ymin=None, ymax=None)[source]
pyace.read_base_conf module
pyace.validate module
Module contents
- class pyace.ACEAtomicEnvironment
Bases:
pybind11_builtins.pybind11_objectAtomic environment class
- n_atoms_real
- n_atoms_extended
- x
- species_type
- neighbour_list
- __init__()
- get_minimal_nn_distance()
- load_full()
- property n_atoms_extended
- property n_atoms_real
- property neighbour_list
- property origins
- save_full()
- property species_type
- property x
- class pyace.ACEBBasisFunction
Bases:
pyace.basis.ACEAbstractBasisFunction- property LS
- __init__()
- property coeffs
- property gen_cgs
- property is_half_ms_basis
- property is_proxy
- property ls
- property ms_combs
- property mu0
- property mus
- property ndensity
- property ns
- property num_ms_combs
- print()
- property rank
- property rankL
- property sort_order
- class pyace.ACEBBasisSet
Bases:
pyace.basis.ACEAbstractBasisSet- __init__()
- property auxdata
- property basis
- property basis_coeffs
- property basis_coeffs_mask
- property basis_rank1
- property crad_coeffs
- property crad_coeffs_mask
- initialize_basis()
- load()
- property metadata
- save()
- to_ACECTildeBasisSet()
- to_BBasisConfiguration()
- class pyace.ACEBEvaluator
Bases:
pyace.evaluator.ACEEvaluator- __init__()
- set_basis()
Set a basis to the evaluator
- Parameters
basis (ACECTildeBasisSet object) –
- Returns
- Return type
None
- class pyace.ACECTildeBasisFunction
Bases:
pyace.basis.ACEAbstractBasisFunction- __init__()
- property ctildes
- property is_half_ms_basis
- property is_proxy
- property ls
- property ms_combs
- property mu0
- property mus
- property ndensity
- property ns
- property num_ms_combs
- print()
- property rank
- class pyace.ACECTildeBasisSet
Bases:
pyace.basis.ACEAbstractBasisSetACECTildeBasisSet class which reads in the potential file.
- nelements
- ndensitymax
- nradbase
- lmax
- nradmax
- cutoffmax
Notes
This class contains multi-level inheritance, the base classes are not exposed. Values of parameters read in from the potential file are read-only.
- __init__()
- property basis
- property basis_rank1
- load()
- load_yaml()
- property nelements
- save()
- save_yaml()
- class pyace.ACECTildeEvaluator
Bases:
pyace.evaluator.ACEEvaluator- __init__()
- property element_type_mapping
- set_basis()
Set a basis to the evaluator
- Parameters
basis (ACECTildeBasisSet object) –
- Returns
- Return type
None
- class pyace.ACECalculator
Bases:
pybind11_builtins.pybind11_object- __init__()
- property basis_projections
- property basis_projections_rank1
- compute()
- property energies
- property energy
- property forces
- set_evaluator()
- property virial
- class pyace.ACECouplingTree
Bases:
pybind11_builtins.pybind11_objectWrapper class for M-coupling tree construction
- __init__(self: pyace.coupling.ACECouplingTree, rank: int = 2) None
- property tree_indices_array
- class pyace.ACERadialFunctions
Bases:
pyace.basis.AbstractRadialBasis- __init__()
- calcCheb()
- property cheb
- property cheb2
- property crad
- property d2fr_vec
- property d2gr_vec
- property dcheb
- property dfr_vec
- property dgr_vec
- evaluate_range()
- property fr_vec
- property gr_vec
- property lamb
- property lambhc
- property prehc
- radbase()
- radcore()
- radfunc()
- class pyace.BBasisConfiguration
Bases:
pybind11_builtins.pybind11_object- __init__()
- property auxdata
- copy()
- property deltaSplineBins
- property funcspecs_blocks
- get_all_coeffs()
- get_func_coeffs()
- get_radial_coeffs()
- property is_sort_functions
- load()
- property metadata
- save()
- set_all_coeffs()
- set_func_coeffs()
- set_radial_coeffs()
- property total_number_of_functions
- validate()
- class pyace.BBasisFunctionSpecification
Bases:
pybind11_builtins.pybind11_objectB-basis function specification class. Example:
BBasisFunctionSpecification(elements=[“Al”,”Al”], ns=[1], ls=[0], coeffs=[1., 2.]) BBasisFunctionSpecification(elements=[“Al”,”Al”,”Al”], ns=[1,1,1,1], ls=[1,1,1,1], LS=[0], coeffs=[1., 2.])
- property LS
- __init__()
- property coeffs
- copy()
- property elements
- property ls
- property ns
- class pyace.BBasisFunctionsSpecificationBlock
Bases:
pybind11_builtins.pybind11_object- property NameOfCutoffFunctionij
- __init__()
- property block_name
- copy()
- property core_rep_parameters
- property dcutij
- property delta_in
- property drho_cut
- property elements_vec
- property fs_parameters
- property funcspecs
- get_all_coeffs()
- get_func_coeffs()
- get_radial_coeffs()
- property inner_cutoff_type
- property lmaxi
- property mu0
- property ndensityi
- property npoti
- property nradbaseij
- property nradmaxi
- property number_of_species
- property r_in
- property radbase
- property radcoefficients
- property radparameters
- property rankmax
- property rcutij
- property rho_cut
- set_all_coeffs()
- set_func_coeffs()
- set_radial_coeffs()
- class pyace.EnergyBasedWeightingPolicy(nfit=20000, cutoff=None, DElow=1.0, DEup=10.0, DE=1.0, DF=1.0, wlow=None, DFup=None, reftype='all', seed=None, energy='convex_hull')[source]
- pyace.Fexp()
- class pyace.PyACECalculator(basis_set, **kwargs)[source]
Bases:
ase.calculators.calculator.CalculatorPyACE ASE calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- __init__(basis_set, **kwargs)[source]
PyACE ASE calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- Parameters
(default (recursive) – False)
(default – False)
- calculate(atoms=None, properties=['energy', 'forces', 'stress', 'energies'], system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.
- implemented_properties: List[str] = ['energy', 'forces', 'stress', 'energies', 'free_energy']
Properties calculator can handle (energy, forces, …)
- class pyace.PyACEEnsembleCalculator(basis_set, **kwargs)[source]
Bases:
ase.calculators.calculator.CalculatorPyACE ASE ensemble calculator :param basis_set - list of specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- __init__(basis_set, **kwargs)[source]
PyACE ASE ensemble calculator :param basis_set - specification of ACE potential, could be in following forms:
“.ace” potential filename “.yaml” potential filename ACEBBasisSet object ACECTildeBasisSet object BBasisConfiguration object
- calculate(atoms=None, properties=('energy', 'forces', 'stress', 'energies', 'energy_std', 'forces_std', 'stress_std', 'energies_std'), system_changes=['positions', 'numbers', 'cell', 'pbc', 'initial_charges', 'initial_magmoms'])[source]
Do the calculation.
- properties: list of str
List of what needs to be calculated. Can be any combination of ‘energy’, ‘forces’, ‘stress’, ‘dipole’, ‘charges’, ‘magmom’ and ‘magmoms’.
- system_changes: list of str
List of what has changed since last calculation. Can be any combination of these six: ‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’ and ‘initial_magmoms’.
Subclasses need to implement this, but can ignore properties and system_changes if they want. Calculated properties should be inserted into results dictionary like shown in this dummy example:
self.results = {'energy': 0.0, 'forces': np.zeros((len(atoms), 3)), 'stress': np.zeros(6), 'dipole': np.zeros(3), 'charges': np.zeros(len(atoms)), 'magmom': 0.0, 'magmoms': np.zeros(len(atoms))}
The subclass implementation should first call this implementation to set the atoms attribute and create any missing directories.
- implemented_properties: List[str] = ['energy', 'forces', 'stress', 'energies', 'free_energy', 'energy_std', 'forces_std', 'stress_std', 'energies_std', 'free_energy_std']
Properties calculator can handle (energy, forces, …)
- class pyace.PyACEFit(basis: Optional[pyace.basis.BBasisConfiguration] = None, structures_dataframe: Optional[pandas.core.frame.DataFrame] = None, loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, seed=None, executors_kw_args=None, display_step=10, trainable_parameters=None)[source]
Bases:
objectCreate a class for fitting ACE potential
:param basis (BBasisConfiguration, ACEBBasisSet) basis set specification :param loss_spec (LossFunctionSpecification)
- __init__(basis: Optional[pyace.basis.BBasisConfiguration] = None, structures_dataframe: Optional[pandas.core.frame.DataFrame] = None, loss_spec: Optional[pyace.lossfuncspec.LossFunctionSpecification] = None, seed=None, executors_kw_args=None, display_step=10, trainable_parameters=None)[source]
- fit(structures_dataframe, method='Nelder-Mead', options=None, callback=None, verbose=True, fit_metric_callback=None)[source]
- property metrics
- predict_energy_forces(params=None, structures_dataframe=None, keep_parallel_dataexecutor=False)[source]
- predict_projections(params=None, structures_dataframe=None, keep_parallel_dataexecutor=False)[source]
- property structures_dataframe
- class pyace.RadialFunctionSmoothness(radialFunctionsValues: pyace.radial.RadialFunctionsValues)[source]
Bases:
object- __init__(radialFunctionsValues: pyace.radial.RadialFunctionsValues)[source]
- property smooth_quad
- class pyace.RadialFunctionsValues(basis_set: Union[pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet], npoints=None)[source]
Bases:
object- __init__(basis_set: Union[pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet], npoints=None)[source]
- class pyace.RadialFunctionsVisualization(radialFunctionsValues: Union[pyace.radial.RadialFunctionsValues, pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet, pyace.basis.BBasisConfiguration], k=None, nl=None, xmin=- 0.5, xmax=None, ymin=None, ymax=None)[source]
Bases:
object- __init__(radialFunctionsValues: Union[pyace.radial.RadialFunctionsValues, pyace.basis.ACEBBasisSet, pyace.basis.ACECTildeBasisSet, pyace.basis.BBasisConfiguration], k=None, nl=None, xmin=- 0.5, xmax=None, ymin=None, ymax=None)[source]
- class pyace.StructuresDatasetSpecification(config: Optional[Dict] = None, cutoff: float = 10, filename: Optional[str] = None, datapath: str = '', db_conn_string: Optional[str] = None, force_query: bool = False, ignore_weights: bool = False, query_limit: Optional[int] = None, seed: Optional[int] = None, cache_ref_df: bool = True, progress_bar: bool = False, df: Optional[pandas.core.frame.DataFrame] = None, force_rebuild: bool = False, **kwargs)[source]
Bases:
objectObject to query or load from cache the fitting dataset
- param config
dictionary with “element” - the element for which the data will be collected “calculator” - calculator and “seed” - random seed
- param cutoff
- param filename
- param datapath
- param db_conn_string
- param force_query
- param query_limit
- param seed
- param cache_ref_df
- FHI_AIMS_PBE_TIGHT = 'FHI-aims/PBE/tight'
- __init__(config: Optional[Dict] = None, cutoff: float = 10, filename: Optional[str] = None, datapath: str = '', db_conn_string: Optional[str] = None, force_query: bool = False, ignore_weights: bool = False, query_limit: Optional[int] = None, seed: Optional[int] = None, cache_ref_df: bool = True, progress_bar: bool = False, df: Optional[pandas.core.frame.DataFrame] = None, force_rebuild: bool = False, **kwargs)[source]
- Parameters
config –
cutoff –
filename –
datapath –
db_conn_string –
force_query –
query_limit –
seed –
cache_ref_df –
- get_actual_filename()[source]
Get actual filename to load dataframe: 1. If filename is provided
try to find file locally
else try to find in datapath. If no datapath - switch back to local
- If filename is not provided
generate standard filename based on element and calculator name (prepend with datapath, if provided)
- Returns
filename of dataframe
- pyace.aseatoms_to_atomicenvironment(atoms, cutoff=9, elements_mapper_dict=None)[source]
Function to read from a ASE atoms objects
- Parameters
atoms (ASE Atoms object) – name of the ASE atoms object
cutoff (float) – cutoff value for calculating neighbors
- pyace.create_linear_chain(natoms, axis=2)[source]
Create a linear chain along partcular axis
- Parameters
natoms (int) – number of atoms
axis (int, optional) – default 2. Axis along which linear chain is created
- pyace.create_multispecies_basis_config(potential_config: Dict, unif_mus_ns_to_lsLScomb_dict: Optional[Dict] = None, func_coefs_initializer='zero', initial_basisconfig: Optional[pyace.basis.BBasisConfiguration] = None) pyace.basis.BBasisConfiguration[source]
Creates a BBasisConfiguration using potential_config dict
Possible keywords: ALL, UNARY, BINARY, TERNARY, QUATERNARY, QUINARY
Example:
- potential_config = {
‘deltaSplineBins’: 0.001, ‘elements’: [‘Al’, ‘H’],
- ‘embeddings’: {‘ALL’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1], ‘ndensity’: 1, ‘npot’: ‘FinnisSinclair’, ‘rho_core_cut’: 200000},
- ‘Al’: {‘drho_core_cut’: 250,
‘fs_parameters’: [1, 1, 1, 0.5], ‘ndensity’: 2, ‘npot’: ‘FinnisSinclairShiftedScaled’, ‘rho_core_cut’: 200000}
},
- ‘bonds’: {‘ALL’: {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebPow’, ‘radparameters’: [2.0], ‘rcut’: 3.9},
- (‘Al’, ‘H’): {‘NameOfCutoffFunction’: ‘cos’,
‘core-repulsion’: [10000.0, 5.0], ‘dcut’: 0.01, ‘radbase’: ‘ChebExpCos’, ‘radparameters’: [2.0], ‘rcut’: 3.5},
},
- ‘functions’: {
- ‘UNARY’: {
‘nradmax_by_orders’: [5, 2, 2], ‘lmax_by_orders’: [0, 1, 1]
},
- ‘BINARY’: {
‘nradmax_by_orders’: [5, 1, 1], ‘lmax_by_orders’: [0, 1, 1],
},
}
}
- Parameters
potential_config – potential configuration dictionary, see above
unif_mus_ns_to_lsLScomb_dict – “whitelist” (dictionary) of the { unify_mus_ns_comb(mus_comb, ns_comb): list of (ls,LS) }
func_coefs_initializer – “zero” or “random”
initial_basisconfig –
- Returns
BBasisConfiguration
- pyace.expand_ls_LS(arg0: int, arg1: List[int], arg2: List[int]) tuple
- pyace.generate_ms_cg_list(ls: List[int], LS: List[int] = [], half_basis: bool = True) List[pyace.coupling.MsCgPair]
Generate list of ms with corresponding generalized Clebsch-Gordan coefficients
- Parameters
ls (List[int]) – list of ls
LS (List[Int] (default = [])) – list of LS (or lint)
half_basis (boolean (default =True)) – whether generate only non-negative combinations of ms-vector, i.e. those that has first positive non-zero value
- Returns
- Return type
List[ms_cg_pair]
- pyace.get_ace_evaluator_version()
- pyace.is_valid_ls_LS(arg0: List[int], arg1: List[int]) bool
is_valid_ls_LS(ls:List[int], LS:List[int]): boolean
- pyace.validate_ls_LS(arg0: List[int], arg1: List[int]) bool
validate_ls_LS(ls:List[int], LS:List[int])