uf3.representation.bspline.BSplineBasis

class BSplineBasis(chemical_system, r_min_map=None, r_max_map=None, resolution_map=None, knot_strategy='linear', offset_1b=True, trailing_trim=3, mask_trim=True, knots_map=None)[source]

Bases: object

Handler class for BSpline basis sets defined using knot sequences and/or pair distance constraints. Functions include generating regularizer matrices and masking basis functions with symmetry.

Parameters
  • chemical_system (uf3.data.composition.ChemicalSystem) –

  • r_min_map (dict) – map of minimum pair distance per interaction. If unspecified, defaults to 1.0 for all interactions. e.g. {(A-A): 2.0, (A-B): 3.0, (B-B): 4.0}

  • r_max_map (dict) – map of maximum pair distance per interaction. If unspecified, defaults to 6.0 angstroms for all interactions, which probably encompasses 2nd-nearest neighbors,

  • resolution_map (dict) – map of resolution (number of knot intervals) per interaction. If unspecified, defaults to 20 for all two- body interactions and 5 for three-body interactions.

  • knot_strategy (str) – “linear” for uniform spacing or “lammps” for knot spacing by r^2.

  • trailing_trim (int) – number of basis functions at trailing edge to suppress. Useful for ensuring smooth cutoffs.

  • knots_map (dict) – pre-generated map of knots. Overrides other settings.

Methods

compress_3B

decompress_3B

from_config

Instantiate from configuration dictionary

generate_frozen_indices

get_cutoff

get_feature_partition_sizes

Get partition sizes: one-body, two-body, and three-body terms.

get_interaction_partitions

get_regularization_matrix

param ridge_map

n-body term ridge regularizer strengths.

set_flatten_template_3B

Compute masks for flattening and unflattening 3B grid. The 3B BSpline

update_basis_functions

update_knots

update_knots_from_dict

Attributes

degree

element_list

interactions

interactions_map

n_feats

static from_config(config)[source]

Instantiate from configuration dictionary

get_feature_partition_sizes() List[source]

Get partition sizes: one-body, two-body, and three-body terms.

get_regularization_matrix(ridge_map={}, curvature_map={}, **kwargs)[source]
Parameters
  • ridge_map (dict) – n-body term ridge regularizer strengths. default: {1: 1e-4, 2: 1e-6, 3: 1e-5}

  • curvature_map (dict) – n-body term curvature regularizer strengths. default: {1: 0.0, 2: 1e-5, 3: 1e-5}

TODO: refactor to break up into smaller, reusable functions

Returns

regularization matrix made up of

individual matrices per n-body interaction.

Return type

combined_matrix (np.ndarray)

set_flatten_template_3B()[source]
Compute masks for flattening and unflattening 3B grid. The 3B BSpline

set has three planes of symmetry corresponding to permutation of i, j, and k indices. Training is therefore performed with only the subset of basis functions corresponding to i < j < k. Basis functions on planes of symmetry have reduced weight.

Returns

vector of subset indices to use. unflatten_mask (np.ndarray): L x L x L boolean array for

regenerating full basis function set.

Return type

flat_weights (np.ndarray)