wfl.fit.gap package#
Submodules#
wfl.fit.gap.glue_2b module#
- wfl.fit.gap.glue_2b.construct_glue_2b(inputs, energy_info_key, cutoff=None, do_e0=True, filename=None)#
Construct a glue potential from dimer data, return the isolated atom energies as well
- Parameters
inputs (ConfigSet) –
energy_info_key (dict_key) – info key for energy, will not use the calculator’s energy directly
cutoff (float / dict, default None) – cutoff to set for all pairs, can be a float for uniform cutoff, or a dict with keys for pairs in ‘Z1_Z2’ format where Z1,Z2 is sorted. Dict with key missing for pair having data defaults to maximum separation possible with the given data
do_e0 (bool, default True) – calculate e0 values, only implemented to be done from homonuclear pairs
filename (path_like, default None) – if given then xml file is saved to this path
- Returns
xml_str (str) – xml param str generated
e0_by_symbol (dict, None) – dict if do_e0, otherwise None
wfl.fit.gap.multistage module#
- wfl.fit.gap.multistage.GAP_xml_modify_label(GAPfile, new_label=None)#
fix internal GAP name and return updated label
- Parameters
GAPfile (str) – gap xml file
new_label (str / None, default None) – new label, if None then old label is returned
- Returns
label – new label or old if not changed
- Return type
str
- wfl.fit.gap.multistage.fit(fitting_configs, GAP_name, params, ref_property_prefix='REF_', seeds=None, skip_if_present=False, run_dir='.', num_committee=0, committee_extra_seeds=None, committee_name_postfix='.committee_', verbose=False, remote_info=None, remote_label=None, wait_for_results=True)#
Fit a GAP iteratively, setting delta from error relative to previous stage
- Parameters
fitting_configs (ConfigSet) – input fitting configurations
GAP_name (str) – name of GAP label, also used as part of xml file
params (dict) – parameters controlling each stage of fit, typically read in from YAML file
ref_property_prefix (str, default 'REF_') – string prefix added to atoms.info/arrays keys (energy, forces, virial, stress, hessian)
seeds (list(int)) – random seeds for each stage of fitting
verbose (bool, default False) – verbose output
skip_if_present (bool, default False) – skip if final GAP file exists in expected place
run_dir (str, default '.') – directory to run fitting in
num_committee (int, default 0) – number of models to create as a committee of GAP models refits the last stage a total of this many times
committee_extra_seeds (list(int) / None) – random seeds to use for committee of models after 0th
committee_name_postfix (str, default ".committee_") – str to add to name of committee models in the format: “{GAP_name}{committee_name_postfix}{num}.xml”
remote_info (dict or wfl.autoparallelize.utils.RemoteInfo, or '_IGNORE' or None) – If present and not None and not ‘_IGNORE’, RemoteInfo or dict with kwargs for RemoteInfo constructor which triggers running job in separately queued job on remote machine. If None, will try to use env var WFL_EXPYRE_INFO used (see below). ‘_IGNORE’ is for internal use, to ensure that remotely running job does not itself attempt to spawn another remotely running job.
remote_label (str, default None) – label to match in WFL_EXPYRE_INFO
wait_for_results (bool, default True) – wait for results of remotely executed job, otherwise return after starting job
Variables (Environment) –
--------------------- –
WFL_EXPYRE_INFO (JSON dict or name of file containing JSON with kwargs for RemoteInfo) – contructor to be used to run fitting in separate queued job
WFL_GAP_FIT_OMP_NUM_THREADS (number of threads to set for OpenMP of gap_fit) –
- Returns
string name of final GAP xml file, and name of corresponding GAP (xml label)
- Return type
final_GAP_file, final_GAP_name
- wfl.fit.gap.multistage.max_cutoff(params)#
- wfl.fit.gap.multistage.prep_params(Zs, length_scales, GAP_template, spacing=1.5, no_extra_inner=False, no_extra_outer=False, sharpness=1.0)#
prepare parameters for multistage fitting based on YAML template file
- Parameters
Zs (list(int)) – atomic numbers
length_scales (dict(Z: dict('bond_len': bond_len))) – dict with bond lengths for each atomic number Z
GAP_template (dict or str) – dict with settings template (to get descriptors auto-filled from universal SOAP length scales) or filename with input template YAML
wfl.fit.gap.relocate module#
- wfl.fit.gap.relocate.gap_relocate(old_file, new_file, extra_filename_glob=None, delete_old=False)#
- relocate a GAP from one file to another, changing tags and attributes as needed to
be consistent with new name, and renaming additional files (referred to in the xml or just with same leading part of name
- Parameters
old_file (str) – original GAP xml filename
new_file (str) – new GAP xml filename
extra_filename_glob (str, default '*') – glob to add to end of old_file to generate list of files that need to be renamed
delete_old (bool, default False) – delete the old_file and all the other related files
wfl.fit.gap.simple module#
- wfl.fit.gap.simple.dict_to_gap_fit_string(param_dict)#
converts dictionary with gap_fit parameters to string for calling gap_fit.
booleans -> “T”/”F”
lists -> { v1 v2 v3 … }
- {‘key1’:[v1, v2, v3], ‘key2’:[v1, v2, v3]}
-> ‘{key1:v1:v2:v3:key2:v1:v2:v3}’
strings with spaces get enclosed in quotes
otherwise {key:val} -> key=val
asserts that mandatory parameters are given
descriptors are passed in pram_dict[‘_gap’], which is a list of dictionaries, one dictionary per descriptor
- wfl.fit.gap.simple.run_gap_fit(fitting_configs, fitting_dict, stdout_file, gap_fit_command=None, verbose=True, do_fit=True, remote_info=None, remote_label=None, skip_if_present=False, **kwargs)#
Runs gap_fit
- Parameters
fitting_configs (ConfigSet) – set of configurations to fit
fitting_dict (dict) – dict of keys to turn into command line for gap_fit
stdout_file (str / Path) – filename to pass standard output to
gap_fit_command (str, default "gap_fit") – executable for gap_fit. Alternatively set by WFL_GAP_FIT_COMMAND environment variable, which overrides this gap_fit_command argument.
verbose (bool, default True) –
do_fit (bool, default True) – carry out the fit, otherwise only print fitting command
remote_info (dict or wfl.autoparallelize.utils.RemoteInfo, or '_IGNORE' or None) – If present and not None and not ‘_IGNORE’, RemoteInfo or dict with kwargs for RemoteInfo constructor which triggers running job in separately queued job on remote machine. If None, will try to use env var WFL_EXPYRE_INFO used (see below). ‘_IGNORE’ is for internal use, to ensure that remotely running job does not itself attempt to spawn another remotely running job.
remote_label (str, default None) – remote label to patch in WFL_EXPYRE_INFO
skip_if_present (bool, default False) – skip fitting if output is already present
kwargs – any key:val pair will be added to the fitting str
Variables (Environment) –
--------------------- –
WFL_EXPYRE_INFO (JSON dict or name of file containing JSON with kwargs for RemoteInfo) – contructor to be used to run fitting in separate queued job
WFL_GAP_FIT_OMP_NUM_THREADS (number of threads to set for OpenMP of gap_fit) –
WFL_GAP_FIT_COMMAND (executable for gap_fit. Overrides the gap_fit_command argument.) –