diff --git a/previews/PR77/.documenter-siteinfo.json b/previews/PR77/.documenter-siteinfo.json index cc9146d..da1f3f8 100644 --- a/previews/PR77/.documenter-siteinfo.json +++ b/previews/PR77/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-05T22:30:46","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-05T23:26:17","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/previews/PR77/api/index.html b/previews/PR77/api/index.html index b19698c..60dff8a 100644 --- a/previews/PR77/api/index.html +++ b/previews/PR77/api/index.html @@ -1,60 +1,60 @@ -API · PotentialLearning.jl

API Reference

This page provides a list of all documented types and functions and in PotentialLearning.jl.

PotentialLearning.ActiveSubspaceType
ActiveSubspace{T<:Real} <: DimensionReducer
+API · PotentialLearning.jl

API Reference

This page provides a list of all documented types and functions and in PotentialLearning.jl.

PotentialLearning.ActiveSubspaceType
ActiveSubspace{T<:Real} <: DimensionReducer
     Q :: Function 
     ∇Q :: Function (gradient of Q)
-    tol :: T

Use the theory of active subspaces, with a given quantity of interest (expressed as the function Q) which takes a Configuration as an input and outputs a real scalar. ∇Q should input a Configuration and output an appropriate gradient. If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.AtomicDataType
AtomicData <: Data

Abstract type declaring the type of information that is unique to a particular atom (instead of a whole configuration).

source
PotentialLearning.ConfigurationMethod
Configuration(data::Union{AtomsBase.FlexibleSystem, ConfigurationData} )

A Configuration is a data struct that contains information unique to a particular configuration of atoms (Energy, LocalDescriptors, ForceDescriptors, and a FlexibleSystem) in a dictionary. Example: '''julia e = Energy(-0.57, u"eV") ld = LocalDescriptors(...) c = Configuration(e, ld) '''

Configurations can be added together, which merges the data dictionaries '''julia c1 = Configuration(e) # Contains energy c2 = Configuration(f) # contains forces c = c1 + c2 # c <: Configuration, contains energy and forces '''

source
PotentialLearning.CorrelationMatrixType
CorrelationMatrix 
-    α :: Vector{Float64} # weights

CorrelationMatrix produces a global descriptor that is the correlation matrix of the local descriptors. In other words, it is mean(bi'*bi for bi in B).

source
PotentialLearning.CovariateLinearProblemType

struct CovariateLinearProblem{T<:Real} <: LinearProblem{T} e::Vector f::Vector{Vector{T}} B::Vector{Vector{T}} dB::Vector{Matrix{T}} β::Vector{T} β0::Vector{T} σe::Vector{T} σf::Vector{T} Σ::Symmetric{T,Matrix{T}} end

A CovariateLinearProblem is a linear problem in which we are fitting energies and forces using both descriptors and their gradients (B and dB, respectively). When this is the case, the solution is not available analytically and must be solved using some iterative optimization proceedure. In the end, we fit the model coefficients, β, standard deviations corresponding to energies and forces, σe and σf, and the covariance Σ.

source
PotentialLearning.DBSCANSelectorType
struct DBSCANSelector <: SubsetSelector
+    tol :: T

Use the theory of active subspaces, with a given quantity of interest (expressed as the function Q) which takes a Configuration as an input and outputs a real scalar. ∇Q should input a Configuration and output an appropriate gradient. If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.AtomicDataType
AtomicData <: Data

Abstract type declaring the type of information that is unique to a particular atom (instead of a whole configuration).

source
PotentialLearning.ConfigurationMethod
Configuration(data::Union{AtomsBase.FlexibleSystem, ConfigurationData} )

A Configuration is a data struct that contains information unique to a particular configuration of atoms (Energy, LocalDescriptors, ForceDescriptors, and a FlexibleSystem) in a dictionary. Example: '''julia e = Energy(-0.57, u"eV") ld = LocalDescriptors(...) c = Configuration(e, ld) '''

Configurations can be added together, which merges the data dictionaries '''julia c1 = Configuration(e) # Contains energy c2 = Configuration(f) # contains forces c = c1 + c2 # c <: Configuration, contains energy and forces '''

source
PotentialLearning.CorrelationMatrixType
CorrelationMatrix 
+    α :: Vector{Float64} # weights

CorrelationMatrix produces a global descriptor that is the correlation matrix of the local descriptors. In other words, it is mean(bi'*bi for bi in B).

source
PotentialLearning.CovariateLinearProblemType

struct CovariateLinearProblem{T<:Real} <: LinearProblem{T} e::Vector f::Vector{Vector{T}} B::Vector{Vector{T}} dB::Vector{Matrix{T}} β::Vector{T} β0::Vector{T} σe::Vector{T} σf::Vector{T} Σ::Symmetric{T,Matrix{T}} end

A CovariateLinearProblem is a linear problem in which we are fitting energies and forces using both descriptors and their gradients (B and dB, respectively). When this is the case, the solution is not available analytically and must be solved using some iterative optimization proceedure. In the end, we fit the model coefficients, β, standard deviations corresponding to energies and forces, σe and σf, and the covariance Σ.

source
PotentialLearning.DBSCANSelectorType
struct DBSCANSelector <: SubsetSelector
     clusters
     eps
     minpts
     sample_size
-end

Definition of the type DBSCANSelector, a subselector based on the clustering method DBSCAN.

source
PotentialLearning.DBSCANSelectorMethod
function DBSCANSelector(
     ds::DataSet,
     eps,
     minpts,
     sample_size
-)

Constructor of DBSCANSelector based on the atomic configurations in ds, the DBSCAN params eps and minpts, and the sample size sample_size.

source
PotentialLearning.DataSetType
DataSet

Struct that holds vector of configuration. Most operations in PotentialLearning are built around the DataSet structure.

source
PotentialLearning.DistanceType
Distance
+)

Constructor of DBSCANSelector based on the atomic configurations in ds, the DBSCAN params eps and minpts, and the sample size sample_size.

source
PotentialLearning.DataSetType
DataSet

Struct that holds vector of configuration. Most operations in PotentialLearning are built around the DataSet structure.

source
PotentialLearning.DistanceType
Distance
 
-A struct of abstract type Distance produces the distance between two `global` descriptors, or features. Not all distances might be compatible with all types of features.
source
PotentialLearning.DivergenceType
Divergence
+A struct of abstract type Distance produces the distance between two `global` descriptors, or features. Not all distances might be compatible with all types of features.
source
PotentialLearning.DivergenceType
Divergence
 
-A struct of abstract type Divergence produces a measure of discrepancy between two probability distributions. Discepancies may take as argument analytical distributions or sets of samples representing empirical distributions.
source
PotentialLearning.DotProductType
DotProduct <: Kernel 
+A struct of abstract type Divergence produces a measure of discrepancy between two probability distributions. Discepancies may take as argument analytical distributions or sets of samples representing empirical distributions.
source
PotentialLearning.DotProductType
DotProduct <: Kernel 
     α :: Power of DotProduct kernel 
 
 
 Computes the dot product kernel between two features, i.e.,
 
-cos(θ) = ( A ⋅ B / (||A||^2||B||^2) )^α
source
PotentialLearning.EnergyType
Energy <: ConfigurationData
     d :: Real
-    u :: Unitful.FreeUnits

Convenience struct that holds energy information (and corresponding units). Default unit is eV

source
PotentialLearning.EuclideanType
Euclidean <: Distance 
+    u :: Unitful.FreeUnits

Convenience struct that holds energy information (and corresponding units). Default unit is eV

source
PotentialLearning.EuclideanType
Euclidean <: Distance 
     Cinv :: Covariance Matrix 
 
-Computes the squared euclidean distance with weight matrix Cinv, the inverse of some covariance matrix.
source
PotentialLearning.FeatureType
Feature

A struct of abstract type Feature represents a function that takes in a set of local descriptors corresponding to some atomic environment and produce a global descriptor.

source
PotentialLearning.ForceType
Force <: AtomicData 
+Computes the squared euclidean distance with weight matrix Cinv, the inverse of some covariance matrix.
source
PotentialLearning.FeatureType
Feature

A struct of abstract type Feature represents a function that takes in a set of local descriptors corresponding to some atomic environment and produce a global descriptor.

source
PotentialLearning.ForceType
Force <: AtomicData 
     f :: Vector{<:Real}
-    u :: Unitful.FreeUnits

Contains the force with (x,y,z)-components in f with units u. Default unit is "eV/Å".

source
PotentialLearning.ForcesType
Forces <: ConfigurationData
-    f :: Vector{force}

Forces is a struct that contains all force information in a configuration.

source
PotentialLearning.ForstnerType
Forstner <: Distance 
+    u :: Unitful.FreeUnits

Contains the force with (x,y,z)-components in f with units u. Default unit is "eV/Å".

source
PotentialLearning.ForcesType
Forces <: ConfigurationData
+    f :: Vector{force}

Forces is a struct that contains all force information in a configuration.

source
PotentialLearning.ForstnerType
Forstner <: Distance 
     α :: Regularization parameter
 
-Computes the squared Forstner distance between two positive semi-definite matrices.
source
PotentialLearning.InverseMultiquadricType
InverseMultiquadric <: Kernel 
     d :: Distance function 
     c2 :: Squared constant parameter
     ℓ :: Length-scale parameter
 
 Computes the inverse multiquadric (IMQ) kernel, i.e.,
 
- k(A, B) = (c^2 + d(A,B)/β^2)^{-1/2}
source
PotentialLearning.KernelType
Kernel
 
-A struct of abstract type Kernel is function that takes in two features and produces a semi-definite scalar representing the similarity between the two features.
source
PotentialLearning.KernelSteinDiscrepancyType
KernelSteinDiscrepancy <: Divergence
+A struct of abstract type Kernel is function that takes in two features and produces a semi-definite scalar representing the similarity between the two features.
source
PotentialLearning.KernelSteinDiscrepancyType
KernelSteinDiscrepancy <: Divergence
     score :: Function
     knl :: Kernel
 
-Computes the kernel Stein discrepancy between distributions p (from which samples are provided) and q (for which the score is provided) based on the RKHS defined by kernel k.
source
PotentialLearning.LAMMPSType
struct LAMMPS <: IO
+Computes the kernel Stein discrepancy between distributions p (from which samples are provided) and q (for which the score is provided) based on the RKHS defined by kernel k.
source
PotentialLearning.LearningProblemType

struct LearningProblem{T<:Real} <: AbstractLearningProblem ds::DataSet logprob::Function ∇logprob::Function params::Vector{T} end

Generic LearningProblem that allows the user to pass a logprob(y::params, ds::DataSet) function and its gradient. The gradient should return a vector of logprob with respect to it's params. If the user does not have a gradient function available, then Flux can provide one for it (provided that logprob is of the form above).

source
PotentialLearning.LinearProblemMethod

function LinearProblem( ds::DataSet; T = Float64 )

Construct a LinearProblem by detecting if there are energy descriptors and/or force descriptors and construct the appropriate LinearProblem (either Univariate, if only a single type of descriptor, or Covariate, if there are both types).

source
PotentialLearning.PCAType
PCA <: DimensionReducer
-    tol :: Float64

Use SVD to compute the PCA of the design matrix of descriptors. (using Force descriptors TBA)

If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.PCAStateType
PCAState <: DimensionReducer
-    tol :: Float64

Use SVD to compute the PCA of the design matrix of descriptors.

If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.LearningProblemType

struct LearningProblem{T<:Real} <: AbstractLearningProblem ds::DataSet logprob::Function ∇logprob::Function params::Vector{T} end

Generic LearningProblem that allows the user to pass a logprob(y::params, ds::DataSet) function and its gradient. The gradient should return a vector of logprob with respect to it's params. If the user does not have a gradient function available, then Flux can provide one for it (provided that logprob is of the form above).

source
PotentialLearning.LinearProblemMethod

function LinearProblem( ds::DataSet; T = Float64 )

Construct a LinearProblem by detecting if there are energy descriptors and/or force descriptors and construct the appropriate LinearProblem (either Univariate, if only a single type of descriptor, or Covariate, if there are both types).

source
PotentialLearning.PCAType
PCA <: DimensionReducer
+    tol :: Float64

Use SVD to compute the PCA of the design matrix of descriptors. (using Force descriptors TBA)

If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.PCAStateType
PCAState <: DimensionReducer
+    tol :: Float64

Use SVD to compute the PCA of the design matrix of descriptors.

If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.

source
PotentialLearning.RBFType
RBF <: Kernel 
     d :: Distance function 
     α :: Regularization parameter 
     ℓ :: Length-scale parameter
@@ -63,64 +63,64 @@
 
 Computes the squared exponential kernel, i.e.,
 
- k(A, B) = β xp( -rac{1}{2} d(A,B)/ℓ^2 ) + α δ(A, B)
source
PotentialLearning.RandomSelectorType
struct Random
     num_configs :: Int 
     batch_size  :: Int 
-end

A convenience function that allows the user to randomly select indices uniformly over [1, num_configs].

source
PotentialLearning.UnivariateLinearProblemType

struct UnivariateLinearProblem{T<:Real} <: LinearProblem{T} ivdata::Vector dvdata::Vector β::Vector{T} β0::Vector{T} σ::Vector{T} Σ::Symmetric{T,Matrix{T}} end

A UnivariateLinearProblem is a linear problem in which there is only 1 type of independent variable / dependent variable. Typically, that means we are either only fitting energies or only fitting forces. When this is the case, the solution is available analytically and the standard deviation, σ, and covariance, Σ, of the coefficients, β, are computable.

source
PotentialLearning.YAMLType
YAML <: IO
+end

A convenience function that allows the user to randomly select indices uniformly over [1, num_configs].

source
PotentialLearning.UnivariateLinearProblemType

struct UnivariateLinearProblem{T<:Real} <: LinearProblem{T} ivdata::Vector dvdata::Vector β::Vector{T} β0::Vector{T} σ::Vector{T} Σ::Symmetric{T,Matrix{T}} end

A UnivariateLinearProblem is a linear problem in which there is only 1 type of independent variable / dependent variable. Typically, that means we are either only fitting energies or only fitting forces. When this is the case, the solution is available analytically and the standard deviation, σ, and covariance, Σ, of the coefficients, β, are computable.

source
PotentialLearning.kDPPType
struct kDPP
     K :: EllEnsemble
-end

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a similarity kernel, for which the user must provide a LinearProblem and two functions to compute descriptor (1) diversity and (2) quality.

source
PotentialLearning.kDPPMethod
kDPP(ds::Dataset, f::Feature, k::Kernel)

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a dataset, a method to compute features, and a kernel. Optional arguments include batch size and type of descriptor (default LocalDescriptors).

source
PotentialLearning.kDPPMethod
kDPP(features::Union{Vector{Vector{T}}, Vector{Symmetric{T, Matrix{T}}}}, k::Kernel)

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantaljl. All that is required to construct a kDPP are features (either a vector of vector features or a vector of symmetric matrix features) and a kernel. Optional argument is batch_size (default length(features)).

source
InteratomicPotentials.compute_local_descriptorsMethod

function computelocaldescriptors( ds::DataSet, basis::BasisSystem; pbar = true )

ds: dataset. basis: basis system (e.g. ACE) pbar: progress bar

Compute local descriptors of a basis system and dataset using threads.

source
PotentialLearning.KernelMatrixMethod
KernelMatrix(ds1::DataSet, ds2::DataSet, F::Feature, k::Kernel)
+end

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a similarity kernel, for which the user must provide a LinearProblem and two functions to compute descriptor (1) diversity and (2) quality.

source
PotentialLearning.kDPPMethod
kDPP(ds::Dataset, f::Feature, k::Kernel)

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a dataset, a method to compute features, and a kernel. Optional arguments include batch size and type of descriptor (default LocalDescriptors).

source
PotentialLearning.kDPPMethod
kDPP(features::Union{Vector{Vector{T}}, Vector{Symmetric{T, Matrix{T}}}}, k::Kernel)

A convenience function that allows the user access to a k-Determinantal Point Process through Determinantaljl. All that is required to construct a kDPP are features (either a vector of vector features or a vector of symmetric matrix features) and a kernel. Optional argument is batch_size (default length(features)).

source
InteratomicPotentials.compute_local_descriptorsMethod

function computelocaldescriptors( ds::DataSet, basis::BasisSystem; pbar = true )

ds: dataset. basis: basis system (e.g. ACE) pbar: progress bar

Compute local descriptors of a basis system and dataset using threads.

source
PotentialLearning.KernelMatrixMethod
KernelMatrix(ds1::DataSet, ds2::DataSet, F::Feature, k::Kernel)
 
-Compute nonsymmetric kernel matrix K using features of the datasets ds1 and ds2 calculated using the Feature method F.
source
PotentialLearning.KernelMatrixMethod
KernelMatrix(ds::DataSet, F::Feature, k::Kernel)

Compute symmetric kernel matrix K using features of the dataset ds calculated using the Feature method F.

source
PotentialLearning.calc_centroidMethod
function calc_centroid(
+Compute nonsymmetric kernel matrix K using features of the datasets ds1 and ds2 calculated using the Feature method F.
source
PotentialLearning.KernelMatrixMethod
KernelMatrix(ds::DataSet, F::Feature, k::Kernel)

Compute symmetric kernel matrix K using features of the dataset ds calculated using the Feature method F.

source
PotentialLearning.calc_metricsMethod
calc_metrics(x_pred, x)

x_pred: vector of predicted values of a variable. E.g. energy. x: vector of true values of a variable. E.g. energy.

Returns MAE, RMSE, and RSQ.

source
PotentialLearning.compute_featuresMethod
compute_feature(ds::DataSet, f::Feature; dt = LocalDescriptors)

Computes features of the dataset ds using the feature method F on descriptors dt (default option are the LocalDescriptors, if available).

source
PotentialLearning.calc_metricsMethod
calc_metrics(x_pred, x)

x_pred: vector of predicted values of a variable. E.g. energy. x: vector of true values of a variable. E.g. energy.

Returns MAE, RMSE, and RSQ.

source
PotentialLearning.compute_featuresMethod
compute_feature(ds::DataSet, f::Feature; dt = LocalDescriptors)

Computes features of the dataset ds using the feature method F on descriptors dt (default option are the LocalDescriptors, if available).

source
PotentialLearning.fitFunction
fit(ds::DataSet, dr::DimensionReducer)

Fits a linear dimension reduction routine using information from DataSet. See individual types of DimensionReducers for specific details.

source
PotentialLearning.fitMethod
fit(ds::DataSet, as::ActiveSubspace)

Fits a linear dimension reduction routine using the eigendirections of the uncentered covariance of the function ∇Q(c::Configuration) over the configurations in ds. Primarily used to reduce the dimension of the descriptors.

source
PotentialLearning.fitMethod
fit(ds::DataSet, pca::PCA)

Fits a linear dimension reduction routine using PCA on the global descriptors in the dataset ds.

source
PotentialLearning.fit_transformMethod
fit_transform(ds::DataSet, dr::DimensionReducer)

Fits a linear dimension reduction routine using information from DataSet and performs dimension reduction on descriptors and force_descriptors (whichever are available). See individual types of DimensionReducers for specific details.

source
PotentialLearning.forceMethod

function force( c::Configuration, nnbp::NNBasisPotential )

c: atomic configuration. nnbp: neural network basis potential.

source
PotentialLearning.fitFunction
fit(ds::DataSet, dr::DimensionReducer)

Fits a linear dimension reduction routine using information from DataSet. See individual types of DimensionReducers for specific details.

source
PotentialLearning.fitMethod
fit(ds::DataSet, as::ActiveSubspace)

Fits a linear dimension reduction routine using the eigendirections of the uncentered covariance of the function ∇Q(c::Configuration) over the configurations in ds. Primarily used to reduce the dimension of the descriptors.

source
PotentialLearning.fitMethod
fit(ds::DataSet, pca::PCA)

Fits a linear dimension reduction routine using PCA on the global descriptors in the dataset ds.

source
PotentialLearning.fit_transformMethod
fit_transform(ds::DataSet, dr::DimensionReducer)

Fits a linear dimension reduction routine using information from DataSet and performs dimension reduction on descriptors and force_descriptors (whichever are available). See individual types of DimensionReducers for specific details.

source
PotentialLearning.forceMethod

function force( c::Configuration, nnbp::NNBasisPotential )

c: atomic configuration. nnbp: neural network basis potential.

source
PotentialLearning.get_batchesMethod
get_batches(n_batches, B_train, B_train_ext, e_train, dB_train, f_train,
-            B_test, B_test_ext, e_test, dB_test, f_test)

n_batches: no. of batches per dataset. B_train: descriptors of the energies used in training. B_train_ext: extendended descriptors of the energies used in training. Requiered to compute forces. e_train: energies used in training. dB_train: derivatives of the energy descritors used in training. f_train: forces used in training. B_test: descriptors of the energies used in test. B_test_ext: extendended descriptors of the energies used in test. Requiered to compute forces. e_test: energies used in test. dB_test: derivatives of the energy descritors used in test. f_test: forces used in test.

Returns the data loaders for training and test of energies and forces.

source
PotentialLearning.get_batchesMethod
get_batches(n_batches, B_train, B_train_ext, e_train, dB_train, f_train,
+            B_test, B_test_ext, e_test, dB_test, f_test)

n_batches: no. of batches per dataset. B_train: descriptors of the energies used in training. B_train_ext: extendended descriptors of the energies used in training. Requiered to compute forces. e_train: energies used in training. dB_train: derivatives of the energy descritors used in training. f_train: forces used in training. B_test: descriptors of the energies used in test. B_test_ext: extendended descriptors of the energies used in test. Requiered to compute forces. e_test: energies used in test. dB_test: derivatives of the energy descritors used in test. f_test: forces used in test.

Returns the data loaders for training and test of energies and forces.

source
PotentialLearning.get_clustersMethod
function get_clusters(
     ds,
     eps,
     minpts
-)

Computes clusters from the configurations in ds using DBSCAN with parameters eps and minpts.

source
PotentialLearning.get_dpp_modeMethod
get_dpp_mode(dpp::kDPP, batch_size::Int) <: Vector{Int64}

Access an approximate mode of the k-DPP as calculated by a greedy subset algorithm. See Determinantal.jl for details.

source
PotentialLearning.get_inclusion_probMethod
get_inclusion_prob(dpp::kDPP) <: Vector{Float64}

Access an approximation to the inclusion probabilities as calculated by Determinantal.jl (see package for details).

source
PotentialLearning.get_inputMethod
get_input(args)

args: vector of arguments (strings)

Returns an OrderedDict with the arguments. See https://github.com/cesmix-mit/AtomisticComposableWorkflows documentation for information about how to define the input arguments.

source
PotentialLearning.get_metricsMethod
get_metrics( e_train_pred, e_train, f_train_pred, f_train,
+)

Computes clusters from the configurations in ds using DBSCAN with parameters eps and minpts.

source
PotentialLearning.get_dpp_modeMethod
get_dpp_mode(dpp::kDPP, batch_size::Int) <: Vector{Int64}

Access an approximate mode of the k-DPP as calculated by a greedy subset algorithm. See Determinantal.jl for details.

source
PotentialLearning.get_inclusion_probMethod
get_inclusion_prob(dpp::kDPP) <: Vector{Float64}

Access an approximation to the inclusion probabilities as calculated by Determinantal.jl (see package for details).

source
PotentialLearning.get_inputMethod
get_input(args)

args: vector of arguments (strings)

Returns an OrderedDict with the arguments. See https://github.com/cesmix-mit/AtomisticComposableWorkflows documentation for information about how to define the input arguments.

source
PotentialLearning.get_metricsMethod
get_metrics( e_train_pred, e_train, f_train_pred, f_train,
              e_test_pred, e_test, f_test_pred, f_test,
-             B_time, dB_time, time_fitting)

e_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. f_train_pred: vector of predicted training force values. f_train: vector of true training force values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values. f_test_pred: vector of predicted test force values. f_test: vector of true test force values. B_time: elapsed time consumed by descriptors calculation. dB_time: elapsed time consumed by descriptor derivatives calculation. time_fitting: elapsed time consumed by fitting process.

Computes MAE, RMSE, and RSQ for training and testing energies and forces. Also add elapsed times about descriptors and fitting calculations. Returns an OrderedDict with the information above.

source
PotentialLearning.get_metricsMethod
get_metrics( e_train_pred, e_train, e_test_pred, e_test)

e_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values.

Computes MAE, RMSE, and RSQ for training and testing energies. Returns an OrderedDict with the information above.

source
PotentialLearning.get_metricsMethod
get_metrics(
+             B_time, dB_time, time_fitting)

e_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. f_train_pred: vector of predicted training force values. f_train: vector of true training force values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values. f_test_pred: vector of predicted test force values. f_test: vector of true test force values. B_time: elapsed time consumed by descriptors calculation. dB_time: elapsed time consumed by descriptor derivatives calculation. time_fitting: elapsed time consumed by fitting process.

Computes MAE, RMSE, and RSQ for training and testing energies and forces. Also add elapsed times about descriptors and fitting calculations. Returns an OrderedDict with the information above.

source
PotentialLearning.get_metricsMethod
get_metrics( e_train_pred, e_train, e_test_pred, e_test)

e_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values.

Computes MAE, RMSE, and RSQ for training and testing energies. Returns an OrderedDict with the information above.

source
PotentialLearning.get_metricsMethod
get_metrics(
     x_pred,
     x;
     metrics = [mae, rmse, rsq],
     label = "x"
-)

x_pred: vector of predicted forces, x: vector of true forces. metrics: vector of metrics. label: label used as prefix in dictionary keys.

Returns and OrderedDict with different metrics.

source
PotentialLearning.get_random_subsetFunction
function get_random_subset(
+)

x_pred: vector of predicted forces, x: vector of true forces. metrics: vector of metrics. label: label used as prefix in dictionary keys.

Returns and OrderedDict with different metrics.

source
PotentialLearning.get_random_subsetFunction
get_random_subset(r::Random, batch_size :: Int) <: Vector{Int64}

Access a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.

source
PotentialLearning.get_random_subsetFunction
function get_random_subset(
     s::DBSCANSelector,
     batch_size = s.sample_size
-)

Returns a random subset of indexes composed of samples of size batch_size ÷ length(s.clusters) from each cluster in s.

source
PotentialLearning.get_random_subsetFunction
get_random_subset(r::Random, batch_size :: Int) <: Vector{Int64}

Access a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.

source
PotentialLearning.get_random_subsetMethod
get_random_subset(dpp::kDPP, batch_size :: Int) <: Vector{Int64}

Access a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.

source
PotentialLearning.get_systemMethod
get_system(c::Configuration) <: AtomsBase.AbstractSystem

Retrieves the AtomsBase system (if available) in the Configuration c.

source
PotentialLearning.hyperlearn!Method

function hyperlearn!( model::DataType, pars::OrderedDict, conftrain::DataSet; nsamples = 5, sampler = RandomSampler(), loss = loss, ws = [1.0, 1.0], int = true )

Hyper-parameter optimization of linear interatomic potentials.

source
PotentialLearning.hyperlossMethod

function hyperloss( metrics::OrderedDict: we = 1.0, wf = 1.0, wt = 1.0E-3, emaemax = 0.05, fmae_max = 0.05 )

metrics: OrderedDict object with metrics of the fitting process. - Mean absolute error of energies: emae. - Mean absolute error of forces: fmae. - Time per force per atom: timeus. `we: energy weight.wf: force weight.wt: time weight.emaemax: maximum mean absolute error for energies.fmaemax`: maximum mean absolute error for forces.

Loss function for hyper-parameter optimization: minimizes fitting error and time.

source
PotentialLearning.kabschMethod
function kabsch(
+)

Returns a random subset of indexes composed of samples of size batch_size ÷ length(s.clusters) from each cluster in s.

source
PotentialLearning.get_random_subsetMethod
get_random_subset(dpp::kDPP, batch_size :: Int) <: Vector{Int64}

Access a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.

source
PotentialLearning.get_systemMethod
get_system(c::Configuration) <: AtomsBase.AbstractSystem

Retrieves the AtomsBase system (if available) in the Configuration c.

source
PotentialLearning.hyperlearn!Method

function hyperlearn!( model::DataType, pars::OrderedDict, conftrain::DataSet; nsamples = 5, sampler = RandomSampler(), loss = loss, ws = [1.0, 1.0], int = true )

Hyper-parameter optimization of linear interatomic potentials.

source
PotentialLearning.hyperlossMethod

function hyperloss( metrics::OrderedDict: we = 1.0, wf = 1.0, wt = 1.0E-3, emaemax = 0.05, fmae_max = 0.05 )

metrics: OrderedDict object with metrics of the fitting process. - Mean absolute error of energies: emae. - Mean absolute error of forces: fmae. - Time per force per atom: timeus. `we: energy weight.wf: force weight.wt: time weight.emaemax: maximum mean absolute error for energies.fmaemax`: maximum mean absolute error for forces.

Loss function for hyper-parameter optimization: minimizes fitting error and time.

source
PotentialLearning.kabschMethod
function kabsch(
     reference::Array{Float64,2},
     coords::Array{Float64,2}
-)

Input: two sets of points: reference, coords as Nx3 Matrices (so) Returns optimally rotated matrix

source
PotentialLearning.learn!Method

function learn!( iap::InteratomicPotentials.LinearBasisPotential, ds::DataSet, args... )

Learning dispatch function, common to ordinary and weghted least squares implementations.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, α::Real )

Fit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)

through an optimization procedure.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, ss::SubsetSelector, α::Real; num_steps=100, opt=Flux.Optimise.Adam() )

Fit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)

through an iterative batch gradient descent optimization proceedure where the batches are provided by the subset selector.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, ws::Vector, int::Bool )

Fit energies and forces using weighted least squares.

source
PotentialLearning.learn!Method

function learn!( lp::LearningProblem, ss::SubsetSelector; num_steps = 100::Int, opt = Flux.Optimisers.Adam() )

Attempts to fit the parameters lp.params in the learning problem lp using batch gradient descent with the optimizer opt and num_steps number of iterations. Batching is provided by the passed ss::SubsetSelector.

source
PotentialLearning.learn!Method

function learn!( lp::LearningProblem; num_steps=100::Int, opt=Flux.Optimisers.Adam() )

Attempts to fit the parameters lp.params in the learning problem lp using gradient descent with the optimizer opt and num_steps number of iterations.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, α::Real )

Fit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via SVD on the design matrix, A'*A (formed iteratively), where eigenvalues less than α are cut-off.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, ss::SubsetSelector, α::Real; num_steps = 100, opt = Flux.Optimise.Adam() )

Fit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via batched gradient descent with batches provided by the subset selector and the gradients are calculated using Flux.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, ws::Vector, int::Bool )

Fit energies using weighted least squares.

source
PotentialLearning.learn!Method

function learn!( iap::InteratomicPotentials.LinearBasisPotential, ds::DataSet, args... )

Learning dispatch function, common to ordinary and weghted least squares implementations.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, α::Real )

Fit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)

through an optimization procedure.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, ss::SubsetSelector, α::Real; num_steps=100, opt=Flux.Optimise.Adam() )

Fit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)

through an iterative batch gradient descent optimization proceedure where the batches are provided by the subset selector.

source
PotentialLearning.learn!Method

function learn!( lp::CovariateLinearProblem, ws::Vector, int::Bool )

Fit energies and forces using weighted least squares.

source
PotentialLearning.learn!Method

function learn!( lp::LearningProblem, ss::SubsetSelector; num_steps = 100::Int, opt = Flux.Optimisers.Adam() )

Attempts to fit the parameters lp.params in the learning problem lp using batch gradient descent with the optimizer opt and num_steps number of iterations. Batching is provided by the passed ss::SubsetSelector.

source
PotentialLearning.learn!Method

function learn!( lp::LearningProblem; num_steps=100::Int, opt=Flux.Optimisers.Adam() )

Attempts to fit the parameters lp.params in the learning problem lp using gradient descent with the optimizer opt and num_steps number of iterations.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, α::Real )

Fit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via SVD on the design matrix, A'*A (formed iteratively), where eigenvalues less than α are cut-off.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, ss::SubsetSelector, α::Real; num_steps = 100, opt = Flux.Optimise.Adam() )

Fit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via batched gradient descent with batches provided by the subset selector and the gradients are calculated using Flux.

source
PotentialLearning.learn!Method

function learn!( lp::UnivariateLinearProblem, ws::Vector, int::Bool )

Fit energies using weighted least squares.

source
PotentialLearning.load_dataMethod
load_data(file::string, yaml::YAML)
 
 Load configurations from a yaml file into a Vector of Flexible Systems, with Energies and Force.
 Returns 
     ds - DataSet
-    t = Vector{Dict} (any miscellaneous info from yaml file)
source
PotentialLearning.load_datasetsMethod
load_datasets(input)

input: OrderedDict with input arguments. See get_defaults_args().

Returns training and test systems, energies, forces, and stresses.

source
PotentialLearning.maeMethod
mae(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns mean absolute error.

source
PotentialLearning.load_datasetsMethod
load_datasets(input)

input: OrderedDict with input arguments. See get_defaults_args().

Returns training and test systems, energies, forces, and stresses.

source
PotentialLearning.maeMethod
mae(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns mean absolute error.

source
PotentialLearning.periodic_rmsdMethod
function periodic_rmsd(
     p1::Array{Float64,2},
     p2::Array{Float64,2},
     box_lengths::Array{Float64,1}
-)

Calculates the RMSD between atom positions of two configurations taking into account the periodic boundaries.

source
PotentialLearning.rmsdMethod
function rmsd(
+)

Calculates the RMSD between atom positions of two configurations taking into account the periodic boundaries.

source
PotentialLearning.rmsdMethod
function rmsd(
     A::Array{Float64,2},
     B::Array{Float64,2}
-)

Calculate root mean square deviation of two matrices A, B. See http://en.wikipedia.org/wiki/Root-mean-squaredeviationofatomicpositions

source
PotentialLearning.rmseMethod
rmse(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns mean root mean square error.

source
PotentialLearning.rsqMethod
rsq(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns R-squared.

source
PotentialLearning.sampleMethod
function sample(
+)

Calculate root mean square deviation of two matrices A, B. See http://en.wikipedia.org/wiki/Root-mean-squaredeviationofatomicpositions

source
PotentialLearning.rmseMethod
rmse(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns mean root mean square error.

source
PotentialLearning.rsqMethod
rsq(x_pred, x)

x_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.

Returns R-squared.

source
PotentialLearning.translate_pointsMethod
function translate_points(
     P::Array{Float64,2},
     Q::Array{Float64,2}
-)

Translate P, Q so centroids are equal to the origin of the coordinate system Translation der Massenzentren, so dass beide Zentren im Ursprung des Koordinatensystems liegen

source
+)

Translate P, Q so centroids are equal to the origin of the coordinate system Translation der Massenzentren, so dass beide Zentren im Ursprung des Koordinatensystems liegen

source
diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/10c758fe.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/10c758fe.png new file mode 100644 index 0000000..5fa273d Binary files /dev/null and b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/10c758fe.png differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/51bac40e.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/51bac40e.png deleted file mode 100644 index 218051a..0000000 Binary files a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/51bac40e.png and /dev/null differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5ac5ae8a.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5ac5ae8a.png deleted file mode 100644 index 3b0577d..0000000 Binary files a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5ac5ae8a.png and /dev/null differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5b9c498e.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5b9c498e.png new file mode 100644 index 0000000..dc22f68 Binary files /dev/null and b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/5b9c498e.png differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/90f5790f.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/90f5790f.png new file mode 100644 index 0000000..58b1fa6 Binary files /dev/null and b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/90f5790f.png differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/babe8006.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/babe8006.png deleted file mode 100644 index 8a26cc1..0000000 Binary files a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/babe8006.png and /dev/null differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/c5f772a0.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/c5f772a0.png deleted file mode 100644 index c5295f6..0000000 Binary files a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/c5f772a0.png and /dev/null differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/f43c3391.png b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/f43c3391.png new file mode 100644 index 0000000..c4c9133 Binary files /dev/null and b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/f43c3391.png differ diff --git a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/index.html b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/index.html index 236540d..3d9d3c9 100644 --- a/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/index.html +++ b/previews/PR77/generated/ACE-aHfO2/fit-ace-ahfo2/index.html @@ -1,22 +1,22 @@ -Example 1 - Fit a-HfO2 dataset with ACE · PotentialLearning.jl

Fit a-HfO2 dataset with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
+Fit a-HfO2 dataset with ACE · PotentialLearning.jl

Fit a-HfO2 dataset with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
 using Unitful, UnitfulAtomic
 using LinearAlgebra, Random, DisplayAs

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/ACE-aHfO2")
 ds_path =  "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz"
 res_path = "$path/results/";

Load utility functions.

include("$path/../utils/utils.jl")

Create experiment folder.

run(`mkdir -p $res_path`);

b. Load atomistic dataset and split it into training and test.

Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)

ds = load_data(ds_path, uparse("eV"), uparse("Å"))[1:1000] # Only the first 1K samples are used in this example.
DataSet{num_configs = 1000} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Split atomistic dataset into training and test

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Split atomistic dataset into training and test

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
 conf_train, conf_test = split(ds, n_train, n_test)
(DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}, DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces})

c. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis

basis = ACE(species           = [:Hf, :O],
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces})

c. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis

basis = ACE(species           = [:Hf, :O],
             body_order        = 3,
             polynomial_degree = 4,
             rcutoff           = 5.0,
@@ -49,26 +49,26 @@
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}

Update training dataset by adding energy and force descriptors.

ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

d. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

d. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
 lb = LBasisPotential(basis)
 ws, int = [1.0, 1.0], false
 learn!(lb, ds_train, ws, int)
 @save_var res_path lb.β
 @save_var res_path lb.β0
-lb.β, lb.β0
([750.7604792899732, 397.47733105288256, 149.18529411843883, 28.653282959022295, -21238.350055683866, -2579.137760410357, -508.9554296191392, 1320.6086482291319, 13657.318939094936, 7403.961689636436  …  155.12002983335015, 80.14733655498108, -9798.66312747347, -2005.2527332350646, 57.55448164693387, 856182.9329391937, 439418.7987879781, 22502.685723447757, -1093.5402371457112, 19382.012759246365], [0.0])

e. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
+lb.β, lb.β0
([485.4140568925364, 299.23758369245235, 129.41292617568394, 27.028409424833, 38370.699092846706, -20579.417723771232, -7032.747110799581, 2153.679826392357, 13113.784258423939, 7191.530407873396  …  164.36384224975546, 88.4077959932703, -13179.867650139502, -2700.3851305844614, 89.72637363324985, 1.150931382020889e6, 590164.0487980547, 29805.27181545622, -1061.1936960725604, 26153.106761401737], [0.0])

e. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
 e_descr_test = compute_local_descriptors(conf_test, basis;
                                          pbar = false)
 println("Computing force descriptors of test dataset...")
 f_descr_test = compute_force_descriptors(conf_test, basis;
                                          pbar = false);
Computing energy descriptors of test dataset...
 Computing force descriptors of test dataset...

Update test dataset by adding energy and force descriptors.

ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
 n_atoms_test = length.(get_system.(ds_test))
 
 e_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,
@@ -96,13 +96,13 @@
 train_metrics = merge(e_train_metrics, f_train_metrics)
 @save_dict res_path train_metrics
 train_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_train_mae"      => 0.00170343
-  "e_train_rmse"     => 0.00198712
-  "e_train_rsq"      => 0.546344
-  "f_train_mae"      => 0.172296
-  "f_train_rmse"     => 0.220539
-  "f_train_rsq"      => 0.848306
-  "f_train_mean_cos" => 0.885247

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.00193572
+  "e_train_rmse"     => 0.0023447
+  "e_train_rsq"      => 0.495002
+  "f_train_mae"      => 0.171544
+  "f_train_rmse"     => 0.218963
+  "f_train_rsq"      => 0.851455
+  "f_train_mean_cos" => 0.890263

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
                              metrics = [mae, rmse, rsq],
                              label = "e_test")
 f_test_metrics = get_metrics(f_test, f_test_pred,
@@ -111,28 +111,28 @@
 test_metrics = merge(e_test_metrics, f_test_metrics)
 @save_dict res_path test_metrics
 test_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_test_mae"      => 0.000728772
-  "e_test_rmse"     => 0.00086062
-  "e_test_rsq"      => 0.940672
-  "f_test_mae"      => 0.173454
-  "f_test_rmse"     => 0.218661
-  "f_test_rsq"      => 0.845074
-  "f_test_mean_cos" => 0.885544

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.000660039
+  "e_test_rmse"     => 0.000816911
+  "e_test_rsq"      => 0.935053
+  "f_test_mae"      => 0.17451
+  "f_test_rmse"     => 0.219334
+  "f_test_rsq"      => 0.853064
+  "f_test_mean_cos" => 0.895142

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
                      e_test, e_test_pred)
 @save_fig res_path e_plot
-DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
+DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
                      f_test, f_test_pred)
 @save_fig res_path f_plot
-DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
+DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
 f_train_plot = plot_forces(f_train, f_train_pred)
 f_train_cos  = plot_cos(f_train, f_train_pred)
 @save_fig res_path e_train_plot
 @save_fig res_path f_train_plot
 @save_fig res_path f_train_cos
-DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
+DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
 f_test_plot = plot_forces(f_test, f_test_pred)
 f_test_cos  = plot_cos(f_test, f_test_pred)
 @save_fig res_path e_test_plot
 @save_fig res_path f_test_plot
 @save_fig res_path f_test_cos
-DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

+DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/5fe84350.svg b/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/2a132da0.svg similarity index 53% rename from previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/5fe84350.svg rename to previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/2a132da0.svg index bc4951a..42eaee0 100644 --- a/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/5fe84350.svg +++ b/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/2a132da0.svg @@ -1,2161 +1,2161 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html b/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html index 4eccea9..4ff4a85 100644 --- a/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html +++ b/previews/PR77/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html @@ -1,5 +1,5 @@ -Example 2 - Subsample Na dataset with DPP and fit with ACE · PotentialLearning.jl

Subsample Na dataset with DPP and fit energies with ACE

a. Load packages and define paths.

Load packages.

using Unitful, UnitfulAtomic
+Subsample Na dataset with DPP and fit with ACE · PotentialLearning.jl

Subsample Na dataset with DPP and fit energies with ACE

a. Load packages and define paths.

Load packages.

using Unitful, UnitfulAtomic
 using AtomsBase, InteratomicPotentials, PotentialLearning
 using LinearAlgebra, Plots

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-Na")
 ds_path = "$path/../data/Na/liquify_sodium.yaml";

b. Load atomistic dataset and split it into training and test.

Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.).

confs, thermo = load_data(ds_path, YAML(:Na, u"eV", u"Å"))
@@ -21,7 +21,7 @@
           wL = 1.0,                # Defaults, See ACE.jl documentation
           csp = 1.0,               # Defaults, See ACE.jl documentation
           r0 = 1.0,                # minimum distance between atoms
-          rcutoff = 5.0)           # cutoff radius
InteratomicPotentials.ACE([:Na], 4, 8, 5.0, 1.0, 1.0, 1.0, ACE1.RPI.RPIBasis{Float64, ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.PIBasis{ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}(ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}(ACE1.OrthPolys.OrthPolyBasis{Float64}(2, 0.1111111111111111, 0, 1.4692378328741966, [1.2122846178990336, 5.227280512910888, 3.8961916731449633, 3.4886755208481057, 3.3018911797277886, 3.1988782330379095, 3.1354893667826973, 3.093509091814522], [0.0, -6.496897603120461, -3.9605854355556267, -3.2304583771700464, -2.908013820175524, -2.734530541817598, -2.629640563396752, -2.5610802914456907], [0.0, 0.0, -0.7453572968815758, -0.8954065440091857, -0.9464598126125192, -0.9688018347417594, -0.9801840327648189, -0.9866112526443516], [0.11179017447199265, 0.11314830119375573, 0.11450642791551882, 0.1158645546372819, 0.11722268135904498, 0.11858080808080808, 0.11993893480257116, 0.12129706152433424, 0.12265518824609734, 0.12401331496786042  …  1.4563356290174474, 1.4576937557392105, 1.4590518824609735, 1.4604100091827366, 1.4617681359044996, 1.4631262626262627, 1.464484389348026, 1.465842516069789, 1.467200642791552, 1.468558769513315], [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001  …  0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001]), ACE1.Transforms.PolyTransform{Int64, Float64}(2, 1.0, 1.0), 0.65, 5.0, ACE1.OrthPolys.OneEnvelope()), ACE1.SphericalHarmonics.SHBasis{Float64}(7, ACE1.SphericalHarmonics.ALPCoefficients{Float64}([1.0e-323, 1.5e-323, 3.0e-323, 1.9364916731037085, 6.4e-323, 7.4e-323, 1.9720265943665387, 2.091650066335189, 1.3e-322, 1.5e-322  …  3.7e-322, 4.2e-322, 1.9948914348241344, 2.0155644370746373, 2.0816659994661326, 2.207940216581962, 2.4308621740219887, 2.850438562747845, 5.9e-322, 5.93e-322], [6.92749272245496e-310, 6.9274927224668e-310, 6.9274927224787e-310, -0.5773502691896257, 6.92749272249053e-310, 6.9274927225261e-310, -0.5163977794943222, -0.4472135954999579, 6.9274927225617e-310, 6.92749272257354e-310  …  6.9274927514183e-310, 6.927492751442e-310, -0.5017452060042545, -0.4947274449181537, -0.47304991679126607, -0.4345240946267408, -0.3739787960033829, -0.2773500981126146, 6.9274927228581e-310, 6.92749272278697e-310])), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<11>]), ACE1.RPI.PSH1pBasisFcn[znlm[0|1,0,0], znlm[0|1,1,-1], znlm[0|1,1,0], znlm[0|1,1,1], znlm[0|1,2,-2], znlm[0|1,2,-1], znlm[0|1,2,0], znlm[0|1,2,1], znlm[0|1,2,2], znlm[0|1,3,-3]  …  znlm[0|6,2,-2], znlm[0|6,2,-1], znlm[0|6,2,0], znlm[0|6,2,1], znlm[0|6,2,2], znlm[0|7,0,0], znlm[0|7,1,-1], znlm[0|7,1,0], znlm[0|7,1,1], znlm[0|8,0,0]], UnitRange{Int64}[1:204;;]), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<11>]), (ACE1.InnerPIBasis([1, 1, 1, 1, 1, 1, 1, 1, 2, 2  …  3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [1 0 0; 65 0 0; … ; 65 67 67; 65 114 114], Dict{ACE1.PIBasisFcn, Int64}(ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,2,-1], znlm[11|1,2,1]), ACE1.RPI.PSH1pBasisFcn) => 148, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,2,0], znlm[11|1,2,0], znlm[11|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 216, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,0,0]), ACE1.RPI.PSH1pBasisFcn) => 9, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,-1], znlm[11|1,5,1]), ACE1.RPI.PSH1pBasisFcn) => 27, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|2,1,0], znlm[11|2,1,0]), ACE1.RPI.PSH1pBasisFcn) => 169, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,1,0], znlm[11|2,1,0]), ACE1.RPI.PSH1pBasisFcn) => 98, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,2,0], znlm[11|2,2,0]), ACE1.RPI.PSH1pBasisFcn) => 152, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|3,0,0],), ACE1.RPI.PSH1pBasisFcn) => 3, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|6,0,0]), ACE1.RPI.PSH1pBasisFcn) => 93, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|2,0,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 221…), Dict{Any, Int64}(znlm[11|2,4,0] => 85, znlm[11|1,7,0] => 57, znlm[11|1,2,-1] => 6, znlm[11|1,4,-2] => 19, znlm[11|1,5,4] => 35, znlm[11|4,4,-2] => 168, znlm[11|2,4,-2] => 83, znlm[11|1,4,-3] => 18, znlm[11|3,3,-2] => 124, znlm[11|4,3,2] => 164…), 1:225, <11>, ACE1.DAG.CorrEvalGraph{Int64, Int64}([(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0)  …  (232, 65), (233, 65), (233, 114), (239, 65), (239, 71), (239, 114), (239, 150), (65, 241), (65, 243), (240, 114)], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0  …  216, 217, 218, 219, 220, 221, 222, 223, 224, 225], 204, 255)),), ACE1.DAGEvaluator()), (sparse([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  67, 68, 68, 68, 69, 70, 71, 72, 72, 73], [1, 2, 3, 4, 5, 6, 7, 8, 9, 13  …  213, 214, 215, 216, 219, 221, 222, 223, 224, 225], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.4142135623730951, 1.0  …  -0.5773502691896257, -1.264911064067351, 1.2649110640673515, -0.6324555320336758, 2.449489742783178, 1.4142135623730951, 1.4142135623730951, -1.6329931618554525, 0.816496580927726, 1.4142135623730951], 73, 225),), (1:73,)))

Update training dataset by adding energy (local) descriptors.

println("Computing local descriptors of training dataset")
+          rcutoff = 5.0)           # cutoff radius
InteratomicPotentials.ACE([:Na], 4, 8, 5.0, 1.0, 1.0, 1.0, ACE1.RPI.RPIBasis{Float64, ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.PIBasis{ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}(ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}(ACE1.OrthPolys.OrthPolyBasis{Float64}(2, 0.1111111111111111, 0, 1.4692378328741966, [1.2122846178990336, 5.227280512910888, 3.8961916731449633, 3.4886755208481057, 3.3018911797277886, 3.1988782330379095, 3.1354893667826973, 3.093509091814522], [0.0, -6.496897603120461, -3.9605854355556267, -3.2304583771700464, -2.908013820175524, -2.734530541817598, -2.629640563396752, -2.5610802914456907], [0.0, 0.0, -0.7453572968815758, -0.8954065440091857, -0.9464598126125192, -0.9688018347417594, -0.9801840327648189, -0.9866112526443516], [0.11179017447199265, 0.11314830119375573, 0.11450642791551882, 0.1158645546372819, 0.11722268135904498, 0.11858080808080808, 0.11993893480257116, 0.12129706152433424, 0.12265518824609734, 0.12401331496786042  …  1.4563356290174474, 1.4576937557392105, 1.4590518824609735, 1.4604100091827366, 1.4617681359044996, 1.4631262626262627, 1.464484389348026, 1.465842516069789, 1.467200642791552, 1.468558769513315], [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001  …  0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001]), ACE1.Transforms.PolyTransform{Int64, Float64}(2, 1.0, 1.0), 0.65, 5.0, ACE1.OrthPolys.OneEnvelope()), ACE1.SphericalHarmonics.SHBasis{Float64}(7, ACE1.SphericalHarmonics.ALPCoefficients{Float64}([6.9445429902859e-310, 6.9446736252561e-310, 6.9445429902867e-310, 1.9364916731037085, 6.94466711835935e-310, 6.94467362525687e-310, 1.9720265943665387, 2.091650066335189, 6.94466711835935e-310, 6.94467362525687e-310  …  6.94466711835935e-310, 6.94467362525687e-310, 1.9948914348241344, 2.0155644370746373, 2.0816659994661326, 2.207940216581962, 2.4308621740219887, 2.850438562747845, 6.94466711835935e-310, 6.94467362525687e-310], [6.9445429902859e-310, 6.9446736252561e-310, 6.9445429902867e-310, -0.5773502691896257, 6.94466711835935e-310, 6.94467362525687e-310, -0.5163977794943222, -0.4472135954999579, 6.94466711835935e-310, 6.94467362525687e-310  …  6.94467790183297e-310, 6.9446736252561e-310, -0.5017452060042545, -0.4947274449181537, -0.47304991679126607, -0.4345240946267408, -0.3739787960033829, -0.2773500981126146, 6.94466711835935e-310, 6.94467362525687e-310])), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<11>]), ACE1.RPI.PSH1pBasisFcn[znlm[0|1,0,0], znlm[0|1,1,-1], znlm[0|1,1,0], znlm[0|1,1,1], znlm[0|1,2,-2], znlm[0|1,2,-1], znlm[0|1,2,0], znlm[0|1,2,1], znlm[0|1,2,2], znlm[0|1,3,-3]  …  znlm[0|6,2,-2], znlm[0|6,2,-1], znlm[0|6,2,0], znlm[0|6,2,1], znlm[0|6,2,2], znlm[0|7,0,0], znlm[0|7,1,-1], znlm[0|7,1,0], znlm[0|7,1,1], znlm[0|8,0,0]], UnitRange{Int64}[1:204;;]), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<11>]), (ACE1.InnerPIBasis([1, 1, 1, 1, 1, 1, 1, 1, 2, 2  …  3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [1 0 0; 65 0 0; … ; 65 67 67; 65 114 114], Dict{ACE1.PIBasisFcn, Int64}(ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,0,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 123, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|2,0,0], znlm[11|4,0,0]), ACE1.RPI.PSH1pBasisFcn) => 222, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,0], znlm[11|3,3,0]), ACE1.RPI.PSH1pBasisFcn) => 40, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|2,4,0]), ACE1.RPI.PSH1pBasisFcn) => 87, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,0,0], znlm[11|1,4,0]), ACE1.RPI.PSH1pBasisFcn) => 119, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|2,1,0], znlm[11|3,1,0]), ACE1.RPI.PSH1pBasisFcn) => 170, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|5,2,0]), ACE1.RPI.PSH1pBasisFcn) => 22, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,1,1], znlm[11|2,3,-1]), ACE1.RPI.PSH1pBasisFcn) => 143, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,2,2], znlm[11|2,2,-2]), ACE1.RPI.PSH1pBasisFcn) => 156, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|2,0,0], znlm[11|2,2,0]), ACE1.RPI.PSH1pBasisFcn) => 220…), Dict{Any, Int64}(znlm[11|3,4,-3] => 131, znlm[11|5,1,1] => 178, znlm[11|5,2,2] => 183, znlm[11|1,6,6] => 49, znlm[11|6,1,-1] => 192, znlm[11|4,3,-2] => 160, znlm[11|1,3,-3] => 10, znlm[11|3,5,2] => 146, znlm[11|1,4,-2] => 19, znlm[11|2,5,5] => 100…), 1:225, <11>, ACE1.DAG.CorrEvalGraph{Int64, Int64}([(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0)  …  (232, 65), (233, 65), (233, 114), (239, 65), (239, 71), (239, 114), (239, 150), (65, 241), (65, 243), (240, 114)], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0  …  216, 217, 218, 219, 220, 221, 222, 223, 224, 225], 204, 255)),), ACE1.DAGEvaluator()), (sparse([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  67, 68, 68, 68, 69, 70, 71, 72, 72, 73], [1, 2, 3, 4, 5, 6, 7, 8, 9, 13  …  213, 214, 215, 216, 219, 221, 222, 223, 224, 225], [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.4142135623730951, 1.0  …  -0.5773502691896257, -1.264911064067351, 1.2649110640673515, -0.6324555320336758, 2.449489742783178, 1.4142135623730951, 1.4142135623730951, -1.6329931618554525, 0.816496580927726, 1.4142135623730951], 73, 225),), (1:73,)))

Update training dataset by adding energy (local) descriptors.

println("Computing local descriptors of training dataset")
 e_descr_train = compute_local_descriptors(conf_train, ace) # JLD.load("data/sodium_empirical_full.jld", "descriptors")
1000-element Vector{LocalDescriptors}:
  LocalDescriptors{n = 108, d = 73}
  LocalDescriptors{n = 108, d = 73}
@@ -43,43 +43,43 @@
  LocalDescriptors{n = 108, d = 73}
  LocalDescriptors{n = 108, d = 73}
  LocalDescriptors{n = 108, d = 73}

Update training dataset by adding energy and force descriptors.

ds_train = DataSet(conf_train .+ e_descr_train)
DataSet{num_configs = 1000} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}

d. Subsampling via DPP.

Create DPP subselector.

dpp = kDPP(ds_train, GlobalMean(), DotProduct(); batch_size = 200)
kDPP(L-Ensemble.
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}

d. Subsampling via DPP.

Create DPP subselector.

dpp = kDPP(ds_train, GlobalMean(), DotProduct(); batch_size = 200)
kDPP(L-Ensemble.
 Number of items in ground set : 1000. Max. rank : 1000. Rescaling constant α=4.306186451810486e14
 , 200)

Subsample trainig dataset.

dpp_inds = get_random_subset(dpp)
200-element Vector{Int64}:
-    5
-    6
-    8
-   10
-   20
-   25
-   27
-   42
-   55
-   57
+    3
+    7
+   15
+   22
+   24
+   29
+   40
+   41
+   47
+   49
     ⋮
-  992
+  984
+  985
+  986
+  987
+  989
   993
-  994
-  995
-  996
   997
-  998
   999
  1000

e. Learn ACE coefficients based on ACE descriptors and DFT data.

lb = LBasisPotential(ace)
 α = 1e-8
-Σ = learn!(lb, ds_train[dpp_inds], α)
UnivariateLinearProblem{T, [-0.06302415406755202, 0.2904769189869256, -0.6837253220933803, 1.0278181238209925, -0.9531336906440231, 0.26380653528545395, 0.52989588990323, 0.2936031041852232, -0.001984215039722903, 0.006225943346692908, -0.01332077949360766, 0.014591213434746564, 0.005141773531024185, -0.06212096596228145, 0.16203209691925835, -0.007054972346388855, 0.026238897748143586, -0.0759643044257956, 0.1588846358237035, -0.264781822805503, 0.002229146402125237, -0.007921123678880093, 0.021413793909439427, -0.0018520918291662913, -0.03700964263921591, 0.04889208190051164, -0.026218075679743436, -0.12587858540682362, 0.4928198198546383, -0.19526399505261338, 0.3999896808000756, -0.8373343762023637, 0.056270115469832405, -0.07755790010395458, -0.1315056918629125, 0.7709367449145024, -1.6402028179184072, 1.2247239160599612, -0.00014864509778915458, 0.00042646151771780216, -0.0011329803040563968, 0.0020828870996705273, -0.0028347160958088757, 0.002732522255600056, -0.00012381100185671762, 0.0004595786150235204, -0.001326752869231007, 0.0027639083350083915, 4.420460688690439e-5, -0.0001578041342219158, -0.0020975668979525963, 0.0038728674471832925, -0.006905700577911844, 0.008836252072129902, -0.003413392325005704, 0.006972358267800072, -0.013875005916743177, 0.016521675840870387, 2.4693530845922018e-5, 0.0006756176852988349, -0.0001254499718511201, -0.002062686196971697, 0.004645315549994367, -9.042739466420119e-5, -0.002508216514021999, 0.007242455684474347, 0.007659158726458948, -0.00023818050324063422, 0.017643931201527963, -0.026017736409441383, 0.04451682164203774, 0.018631777907310187, 0.06382390262963611], [0.17397542704081634]}

f. Post-process output: calculate metrics, create plots, and save results.

Update test dataset by adding energy descriptors.

println("Computing local descriptors of test dataset")
+Σ = learn!(lb, ds_train[dpp_inds], α)
UnivariateLinearProblem{T, [-0.05584430295331799, 0.2583302452328837, -0.6121027046634424, 0.9323904672483536, -0.8947474782129348, 0.31508390580324885, 0.39393209648284255, 0.210647141705806, -0.0015881776377766332, 0.0048965197460990595, -0.010048852860265356, 0.009338982225983727, 0.010486697998835837, -0.06351066947495276, 0.15474051108856912, -0.005823789598613516, 0.02167646990438854, -0.06283597162200039, 0.13170516505894625, -0.22027700935282724, 0.001828684409339254, -0.006488550044990049, 0.01750527993248241, -0.00217042372718923, -0.028270480543088894, 0.03427625289513969, -0.0047096712329448565, -0.14221613023769208, 0.4807773524753145, -0.16144945784076015, 0.3311887758216585, -0.6949086266860149, 0.04603955622431499, -0.032525592703251505, -0.16902651367544763, 0.7705259379269371, -1.3602507126519185, 1.238204212277779, -0.00012664573321920225, 0.0003637545344002957, -0.0009681639567258316, 0.001785347843876739, -0.00244336435367698, 0.002385173080396985, -9.967064821456151e-5, 0.0003700838128288808, -0.0010690390882234224, 0.002229641128844273, 3.581865794608646e-5, -0.0001275366427897634, -0.0017913827440989571, 0.0033144785752572403, -0.005931643793826602, 0.0076451191651436545, -0.0027497703665610995, 0.005620930183601658, -0.011905890365229155, 0.01424791547217552, 1.9890141749946688e-5, 0.0005440858309573304, -0.0001006892275220092, -0.0016619742975177987, 0.0037455080832238252, -7.274345096996288e-5, -0.0020205324672550873, 0.00583786051444779, 0.006173185215757382, -0.00019308671805916278, 0.015089964611451734, -0.022306589833004153, 0.03834131748906344, 0.015015067073722577, 0.054900616644246725], [0.18250968090807276]}

f. Post-process output: calculate metrics, create plots, and save results.

Update test dataset by adding energy descriptors.

println("Computing local descriptors of test dataset")
 e_descr_test = compute_local_descriptors(conf_test, ace)
 ds_test = DataSet(conf_test .+ e_descr_test)
DataSet{num_configs = 1092} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, Energy, Forces}

Get true and predicted energy values (assuming that all configurations have the same no. of atoms).

n = size(get_system(ds_train[1]))[1]
+	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom{3, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}, Unitful.Quantity{Float64, 𝐋 𝐓^-1, Unitful.FreeUnits{(a₀, s^-1), 𝐋 𝐓^-1, nothing}}, Unitful.Quantity{Float64, 𝐌, Unitful.FreeUnits{(u,), 𝐌, nothing}}}, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, LocalDescriptors, Forces}

Get true and predicted energy values (assuming that all configurations have the same no. of atoms).

n = size(get_system(ds_train[1]))[1]
 e_train, e_train_pred = get_all_energies(ds_train)/n, get_all_energies(ds_train, lb)/n
-e_test, e_test_pred   = get_all_energies(ds_test)/n, get_all_energies(ds_test, lb)/n
([-1.050120757771066, -1.0562140682089582, -1.056995661892708, -1.052943346117414, -1.0507336521441548, -1.0492654039689084, -1.0551928840372566, -1.0478345821564456, -1.0509946266385062, -1.0612155101072316  …  -1.0308587567190317, -1.037507962529589, -1.0364581866168459, -1.0470370158056794, -1.0408819752481295, -1.0360241207765786, -1.0350755250212837, -1.041561846516676, -1.0337330922011918, -1.0331453994779503], [-1.0542322231206587, -1.0574836003469679, -1.0563209350066198, -1.052041129160132, -1.0539754836078907, -1.0613631328961206, -1.0535576440689403, -1.0462109986553916, -1.0628131241304333, -1.0579152540497307  …  -1.0175652918734288, -1.0207108156856974, -1.0175901187904106, -1.0103855739849523, -1.0200141762750223, -1.0093819182411, -1.015077323727857, -1.0164985303725573, -1.0174493005354788, -1.011539568444534])

Compute and print metrics.

e_mae, e_rmse, e_rsq = calc_metrics(e_train, e_train_pred)
-println("MAE: $e_mae, RMSE: $e_rmse, RSQ: $e_rsq")
MAE: 0.004585619110031217, RMSE: 0.006025001431235763, RSQ: 0.8239726702382972

Plot energy error.

e_err_train, e_err_test = (e_train_pred - e_train), (e_test_pred - e_test)
+e_test, e_test_pred   = get_all_energies(ds_test)/n, get_all_energies(ds_test, lb)/n
([-1.050120757771066, -1.0562140682089582, -1.056995661892708, -1.052943346117414, -1.0507336521441548, -1.0492654039689084, -1.0551928840372566, -1.0478345821564456, -1.0509946266385062, -1.0612155101072316  …  -1.0308587567190317, -1.037507962529589, -1.0364581866168459, -1.0470370158056794, -1.0408819752481295, -1.0360241207765786, -1.0350755250212837, -1.041561846516676, -1.0337330922011918, -1.0331453994779503], [-1.0543553318518308, -1.057405667176994, -1.0555924768967786, -1.0510686787606165, -1.0526771662184895, -1.0599634884335367, -1.0523857942374941, -1.0455118124817997, -1.0619968508557123, -1.0566247941140172  …  -1.018424719822022, -1.02142604334396, -1.0186889006083277, -1.011284576580646, -1.020633809107385, -1.0101958463486804, -1.016059566662243, -1.0169574454951429, -1.0182262356148575, -1.0120580388654425])

Compute and print metrics.

e_mae, e_rmse, e_rsq = calc_metrics(e_train, e_train_pred)
+println("MAE: $e_mae, RMSE: $e_rmse, RSQ: $e_rsq")
MAE: 0.0045653069489317724, RMSE: 0.006003764393360106, RSQ: 0.8370826918830262

Plot energy error.

e_err_train, e_err_test = (e_train_pred - e_train), (e_test_pred - e_test)
 dpp_inds2 = get_random_subset(dpp; batch_size = 20)
 p = scatter( e_train, e_err_train, label = "Training", color = :blue,
          markersize = 1.5, markerstrokewidth=0)
@@ -89,4 +89,4 @@
          color = :darkred, label = "DPP Samples",
          markersize = 2.5, markerstrokewidth=0)
 scatter!(xlabel = "Energy (eV/atom)", ylabel = "Error (eV/atom)",
-         dpi = 1000, fontsize = 16)
Example block output

This page was generated using Literate.jl.

+ dpi = 1000, fontsize = 16)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html b/previews/PR77/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html index 36a0579..91dd303 100644 --- a/previews/PR77/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html +++ b/previews/PR77/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html @@ -1,5 +1,5 @@ -Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate · PotentialLearning.jl

Subsample Si dataset and fit with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using LinearAlgebra, Random, InvertedIndices
+Subsample Si dataset with DPP, fit with ACE, and cross validate · PotentialLearning.jl

Subsample Si dataset and fit with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using LinearAlgebra, Random, InvertedIndices
 using Statistics, StatsBase, Distributions, Determinantal
 using Unitful, UnitfulAtomic
 using AtomsBase, InteratomicPotentials, PotentialLearning
@@ -9,10 +9,10 @@
 nfile = length(file_arr)
 confs_arr = [load_data(inpath*file, ExtXYZ(u"eV", u"Å")) for file in file_arr]
 confs = concat_dataset(confs_arr)
DataSet{num_configs = 201} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Id of configurations per file.

n = 0
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Id of configurations per file.

n = 0
 confs_id = Vector{Vector{Int64}}(undef, nfile)
 for k = 1:nfile
     global n
@@ -26,7 +26,7 @@
           wL = 1.0,                     # Defaults, See ACE.jl documentation
           csp = 1.0,                    # Defaults, See ACE.jl documentation
           r0 = 1.0,                     # minimum distance between atoms
-          rcutoff = 10.0)
InteratomicPotentials.ACE([:Si], 4, 5, 10.0, 1.0, 1.0, 1.0, ACE1.RPI.RPIBasis{Float64, ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.PIBasis{ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}(ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}(ACE1.OrthPolys.OrthPolyBasis{Float64}(2, 0.03305785123966942, 0, 1.4692378328741966, [1.084095259082914, 4.943189180687471, 3.684442125691434, 3.29907359036723, 3.1224405721338866], [0.0, -6.079499869826186, -3.6494749893429064, -2.9518880477215665, -2.6443581983662967], [0.0, 0.0, -0.7453572968815606, -0.8954065440092013, -0.9464598126125047], [0.03377594123048669, 0.035212121212121215, 0.03664830119375574, 0.03808448117539027, 0.039520661157024795, 0.04095684113865933, 0.042393021120293854, 0.04382920110192838, 0.04526538108356291, 0.04670156106519743  …  1.4555941230486686, 1.4570303030303031, 1.4584664830119376, 1.4599026629935723, 1.4613388429752068, 1.4627750229568413, 1.4642112029384757, 1.4656473829201104, 1.467083562901745, 1.4685197428833794], [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001  …  0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001]), ACE1.Transforms.PolyTransform{Int64, Float64}(2, 1.0, 1.0), 0.65, 10.0, ACE1.OrthPolys.OneEnvelope()), ACE1.SphericalHarmonics.SHBasis{Float64}(4, ACE1.SphericalHarmonics.ALPCoefficients{Float64}([2.0e-323, 5.4e-323, 1.1e-322, 1.9364916731037085, 2.1e-322, 2.17e-322, 1.9720265943665387, 2.091650066335189, 3.95e-322, 4.05e-322, 1.984313483298443, 2.04939015319192, 2.29128784747792, 4.6e-322, 0.0], [2.96e-322, 1.0e-322, 2.17e-322, -0.5773502691896257, 2.03e-322, 4.15e-322, -0.5163977794943222, -0.4472135954999579, 2.87e-322, 3.06e-322, -0.50709255283711, -0.47809144373375745, -0.3779644730092272, 4.4e-322, 0.0])), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<14>]), ACE1.RPI.PSH1pBasisFcn[znlm[0|1,0,0], znlm[0|1,1,-1], znlm[0|1,1,0], znlm[0|1,1,1], znlm[0|1,2,-2], znlm[0|1,2,-1], znlm[0|1,2,0], znlm[0|1,2,1], znlm[0|1,2,2], znlm[0|1,3,-3]  …  znlm[0|3,2,-2], znlm[0|3,2,-1], znlm[0|3,2,0], znlm[0|3,2,1], znlm[0|3,2,2], znlm[0|4,0,0], znlm[0|4,1,-1], znlm[0|4,1,0], znlm[0|4,1,1], znlm[0|5,0,0]], UnitRange{Int64}[1:55;;]), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<14>]), (ACE1.InnerPIBasis([1, 1, 1, 1, 1, 2, 2, 2, 2, 2  …  2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [1 0 0; 26 0 0; … ; 1 3 3; 1 26 26], Dict{ACE1.PIBasisFcn, Int64}(ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 22, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,1,0], znlm[14|1,1,0]), ACE1.RPI.PSH1pBasisFcn) => 25, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|2,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 18, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,1,-1], znlm[14|1,1,1]), ACE1.RPI.PSH1pBasisFcn) => 12, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,1,1], znlm[14|2,1,-1]), ACE1.RPI.PSH1pBasisFcn) => 16, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|4,0,0]), ACE1.RPI.PSH1pBasisFcn) => 11, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|2,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 26, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|3,0,0],), ACE1.RPI.PSH1pBasisFcn) => 3, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,0,0]), ACE1.RPI.PSH1pBasisFcn) => 6, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|5,0,0],), ACE1.RPI.PSH1pBasisFcn) => 5…), Dict{Any, Int64}(znlm[14|2,1,1] => 29, znlm[14|2,3,0] => 38, znlm[14|1,3,2] => 15, znlm[14|4,1,0] => 53, znlm[14|2,3,1] => 39, znlm[14|1,4,3] => 24, znlm[14|3,2,-1] => 47, znlm[14|2,0,0] => 26, znlm[14|3,1,0] => 44, znlm[14|1,4,-1] => 20…), 1:26, <14>, ACE1.DAG.CorrEvalGraph{Int64, Int64}([(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0)  …  (7, 26), (26, 26), (26, 42), (56, 1), (56, 7), (56, 26), (56, 42), (1, 58), (1, 59), (57, 26)], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0  …  17, 18, 19, 20, 21, 22, 23, 24, 25, 26], 55, 59)),), ACE1.DAGEvaluator()), (sparse([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  11, 11, 12, 13, 14, 15, 16, 17, 17, 18], [1, 2, 3, 4, 5, 6, 8, 10, 11, 12  …  15, 16, 18, 19, 20, 22, 23, 24, 25, 26], [1.0, 1.0, 1.0, 1.0, 1.0, 1.4142135623730951, 1.0, 1.0, 1.0, -1.6329931618554518  …  0.5773502691896257, -0.5773502691896257, 1.4142135623730951, 1.0, 2.449489742783178, 1.4142135623730951, 1.4142135623730951, -1.6329931618554525, 0.816496580927726, 1.4142135623730951], 18, 26),), (1:18,)))

Compute ACE descriptors for energies and forces.

println("Computing local descriptors")
+          rcutoff = 10.0)
InteratomicPotentials.ACE([:Si], 4, 5, 10.0, 1.0, 1.0, 1.0, ACE1.RPI.RPIBasis{Float64, ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.PIBasis{ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}, 1, ACE1.DAGEvaluator}(ACE1.RPI.BasicPSH1pBasis{Float64, 1, ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}}(ACE1.OrthPolys.TransformedPolys{Float64, ACE1.Transforms.PolyTransform{Int64, Float64}, ACE1.OrthPolys.OrthPolyBasis{Float64}, ACE1.OrthPolys.OneEnvelope}(ACE1.OrthPolys.OrthPolyBasis{Float64}(2, 0.03305785123966942, 0, 1.4692378328741966, [1.084095259082914, 4.943189180687471, 3.684442125691434, 3.29907359036723, 3.1224405721338866], [0.0, -6.079499869826186, -3.6494749893429064, -2.9518880477215665, -2.6443581983662967], [0.0, 0.0, -0.7453572968815606, -0.8954065440092013, -0.9464598126125047], [0.03377594123048669, 0.035212121212121215, 0.03664830119375574, 0.03808448117539027, 0.039520661157024795, 0.04095684113865933, 0.042393021120293854, 0.04382920110192838, 0.04526538108356291, 0.04670156106519743  …  1.4555941230486686, 1.4570303030303031, 1.4584664830119376, 1.4599026629935723, 1.4613388429752068, 1.4627750229568413, 1.4642112029384757, 1.4656473829201104, 1.467083562901745, 1.4685197428833794], [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001  …  0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001]), ACE1.Transforms.PolyTransform{Int64, Float64}(2, 1.0, 1.0), 0.65, 10.0, ACE1.OrthPolys.OneEnvelope()), ACE1.SphericalHarmonics.SHBasis{Float64}(4, ACE1.SphericalHarmonics.ALPCoefficients{Float64}([0.0, 0.0, 0.0, 1.9364916731037085, 0.0, 0.0, 1.9720265943665387, 2.091650066335189, 0.0, 0.0, 1.984313483298443, 2.04939015319192, 2.29128784747792, 0.0, 0.0], [0.0, 0.0, 0.0, -0.5773502691896257, 0.0, 0.0, -0.5163977794943222, -0.4472135954999579, 0.0, 0.0, -0.50709255283711, -0.47809144373375745, -0.3779644730092272, 0.0, 0.0])), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<14>]), ACE1.RPI.PSH1pBasisFcn[znlm[0|1,0,0], znlm[0|1,1,-1], znlm[0|1,1,0], znlm[0|1,1,1], znlm[0|1,2,-2], znlm[0|1,2,-1], znlm[0|1,2,0], znlm[0|1,2,1], znlm[0|1,2,2], znlm[0|1,3,-3]  …  znlm[0|3,2,-2], znlm[0|3,2,-1], znlm[0|3,2,0], znlm[0|3,2,1], znlm[0|3,2,2], znlm[0|4,0,0], znlm[0|4,1,-1], znlm[0|4,1,0], znlm[0|4,1,1], znlm[0|5,0,0]], UnitRange{Int64}[1:55;;]), JuLIP.Potentials.SZList{1}(JuLIP.Chemistry.AtomicNumber[<14>]), (ACE1.InnerPIBasis([1, 1, 1, 1, 1, 2, 2, 2, 2, 2  …  2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [1 0 0; 26 0 0; … ; 1 3 3; 1 26 26], Dict{ACE1.PIBasisFcn, Int64}(ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,1,0], znlm[14|1,1,0]), ACE1.RPI.PSH1pBasisFcn) => 14, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|5,0,0],), ACE1.RPI.PSH1pBasisFcn) => 5, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|4,0,0]), ACE1.RPI.PSH1pBasisFcn) => 11, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 10, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,1,0], znlm[14|1,1,0]), ACE1.RPI.PSH1pBasisFcn) => 25, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 8, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|2,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 18, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|2,0,0], znlm[14|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 19, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|2,0,0],), ACE1.RPI.PSH1pBasisFcn) => 2, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|4,0,0],), ACE1.RPI.PSH1pBasisFcn) => 4…), Dict{Any, Int64}(znlm[14|2,1,-1] => 27, znlm[14|5,0,0] => 55, znlm[14|1,4,0] => 21, znlm[14|3,2,-2] => 46, znlm[14|4,1,1] => 54, znlm[14|1,4,1] => 22, znlm[14|3,2,-1] => 47, znlm[14|2,2,2] => 34, znlm[14|2,1,1] => 29, znlm[14|1,3,0] => 13…), 1:26, <14>, ACE1.DAG.CorrEvalGraph{Int64, Int64}([(1, 0), (2, 0), (3, 0), (4, 0), (5, 0), (6, 0), (7, 0), (8, 0), (9, 0), (10, 0)  …  (7, 26), (26, 26), (26, 42), (56, 1), (56, 7), (56, 26), (56, 42), (1, 58), (1, 59), (57, 26)], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0  …  17, 18, 19, 20, 21, 22, 23, 24, 25, 26], 55, 59)),), ACE1.DAGEvaluator()), (sparse([1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  11, 11, 12, 13, 14, 15, 16, 17, 17, 18], [1, 2, 3, 4, 5, 6, 8, 10, 11, 12  …  15, 16, 18, 19, 20, 22, 23, 24, 25, 26], [1.0, 1.0, 1.0, 1.0, 1.0, 1.4142135623730951, 1.0, 1.0, 1.0, -1.6329931618554518  …  0.5773502691896257, -0.5773502691896257, 1.4142135623730951, 1.0, 2.449489742783178, 1.4142135623730951, 1.4142135623730951, -1.6329931618554525, 0.816496580927726, 1.4142135623730951], 18, 26),), (1:18,)))

Compute ACE descriptors for energies and forces.

println("Computing local descriptors")
 e_descr = compute_local_descriptors(confs, ace; pbar=false)
 f_descr = compute_force_descriptors(confs, ace; pbar=false)
 JLD.save(outpath*"$(elname)_energy_descriptors.jld", "e_descr", e_descr)
@@ -49,11 +49,11 @@
 batch 3
 batch 4
 batch 5
-condnum: [1.9143669717097122e10, 1.921972578853058e10, 1.970879631501145e10, 1.8811960747837635e10, 1.9832237056266357e10]
+condnum: [1.882396618991678e10, 1.8410532027790737e10, 1.7869084435236763e10, 1.8082353781389385e10, 1.8388320034980217e10]
 =============== Starting batch size 40 ===============
 batch 1
 batch 2
 batch 3
 batch 4
 batch 5
-condnum: [1.88206641536156e10, 2.1498394016084793e10, 1.8337341268744442e10, 1.6974912288170311e10, 1.958303567909836e10]

This page was generated using Literate.jl.

+condnum: [1.8817216950037365e10, 2.034821312424394e10, 1.9638873607135727e10, 1.966103153867008e10, 1.7702296060159927e10]

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/38421b16.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/38421b16.png new file mode 100644 index 0000000..ac4ea80 Binary files /dev/null and b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/38421b16.png differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/6a296da4.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/6a296da4.png deleted file mode 100644 index 8e383f3..0000000 Binary files a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/6a296da4.png and /dev/null differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/70670810.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/70670810.png new file mode 100644 index 0000000..7423910 Binary files /dev/null and b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/70670810.png differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/98f0d90b.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/98f0d90b.png new file mode 100644 index 0000000..80a8c02 Binary files /dev/null and b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/98f0d90b.png differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/b716a998.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/b716a998.png deleted file mode 100644 index 867d9c4..0000000 Binary files a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/b716a998.png and /dev/null differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/c120c1aa.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/c120c1aa.png new file mode 100644 index 0000000..43531c1 Binary files /dev/null and b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/c120c1aa.png differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/ec759e76.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/ec759e76.png deleted file mode 100644 index 9906418..0000000 Binary files a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/ec759e76.png and /dev/null differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/f239e351.png b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/f239e351.png deleted file mode 100644 index 9329516..0000000 Binary files a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/f239e351.png and /dev/null differ diff --git a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html index b9cab38..9cf894c 100644 --- a/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html +++ b/previews/PR77/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html @@ -1,22 +1,22 @@ -Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE · PotentialLearning.jl

Subsample a-HfO2 dataset and fit with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
+Subsample a-HfO2 dataset with DPP and fit with ACE · PotentialLearning.jl

Subsample a-HfO2 dataset and fit with ACE

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
 using Unitful, UnitfulAtomic
 using LinearAlgebra, Random, DisplayAs

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/DPP-ACE-aHfO2-1")
 ds_path =  "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz"
 res_path = "$path/results/";

Load utility functions.

include("$path/../utils/utils.jl")

Create experiment folder.

run(`mkdir -p $res_path`);

b. Load atomistic dataset and split it into training and test.

Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)

ds = load_data(ds_path, uparse("eV"), uparse("Å"))
DataSet{num_configs = 6000} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Split atomistic dataset into training and test

n_train, n_test = 100, 50 # Few samples per dataset are used in this example.
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Split atomistic dataset into training and test

n_train, n_test = 100, 50 # Few samples per dataset are used in this example.
 conf_train, conf_test = split(ds[1:1000], n_train, n_test)
(DataSet{num_configs = 100} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}, DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces})

c. Subsampling

Compute ACE descriptors for energies as subsampling input.

basis = ACE(species           = [:Hf, :O],
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces})

c. Subsampling

Compute ACE descriptors for energies as subsampling input.

basis = ACE(species           = [:Hf, :O],
             body_order        = 2,
             polynomial_degree = 3,
             rcutoff           = 5.0,
@@ -46,20 +46,20 @@
  LocalDescriptors{n = 96, d = 12}
  LocalDescriptors{n = 96, d = 12}
  LocalDescriptors{n = 96, d = 12}

Update subsampling dataset

conf_train_kDPP = DataSet(conf_train .+ e_descr)
DataSet{num_configs = 100} 
-	 Configuration{S, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Create DPP subselector

dataset_selector = kDPP(  conf_train_kDPP,
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Create DPP subselector

dataset_selector = kDPP(  conf_train_kDPP,
                           GlobalMean(),
                           DotProduct();
                           batch_size = 50)
kDPP(L-Ensemble.
-Number of items in ground set : 100. Max. rank : 100. Rescaling constant α=1.6420919854950948e15
+Number of items in ground set : 100. Max. rank : 100. Rescaling constant α=1.5874258419245758e15
 , 50)

Subsample trainig dataset

inds = get_random_subset(dataset_selector)
 conf_train = @views conf_train[inds]
DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

d. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis

basis = ACE(species           = [:Hf, :O],
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

d. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis

basis = ACE(species           = [:Hf, :O],
             body_order        = 3,
             polynomial_degree = 4,
             rcutoff           = 5.0,
@@ -92,26 +92,26 @@
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}

Update training dataset by adding energy and force descriptors.

ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

e. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

e. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
 lb = LBasisPotential(basis)
 ws, int = [1.0, 1.0], false
 learn!(lb, ds_train, ws, int)
 @save_var res_path lb.β
 @save_var res_path lb.β0
-lb.β, lb.β0
([187.09050396951815, 170.93276602062133, 97.22820515233235, 23.608779623158583, -25192.52529528499, -2622.2244744901714, 2262.497641338033, 368.87748914046904, 15029.505067204316, 8178.118982842055  …  146.95007897043052, 78.17029888933321, -10956.87328633323, -2313.285657744151, 153.8635306756711, 1.2910245566966338e6, 652899.2660245628, 37589.122627987796, -1042.1762801294146, 26487.025667878992], [0.0])

f. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
+lb.β, lb.β0
([546.1687206925008, 324.60411080572476, 136.2424006027864, 28.141075254195215, 39688.26844148054, 6691.676562480983, -2876.951207902224, 5655.762257168779, 14591.739590813328, 7985.814693092652  …  153.41846979362947, 87.18051722728764, -12646.547539756482, -2601.9618504603623, 90.56642106929267, 1.4706401619140543e6, 738439.0223599069, 45639.73019746111, -1059.0351554895276, 28369.46048180691], [0.0])

f. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
 e_descr_test = compute_local_descriptors(conf_test, basis;
                                          pbar = false)
 println("Computing force descriptors of test dataset...")
 f_descr_test = compute_force_descriptors(conf_test, basis;
                                          pbar = false);
Computing energy descriptors of test dataset...
 Computing force descriptors of test dataset...

Update test dataset by adding energy and force descriptors.

ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
 n_atoms_test = length.(get_system.(ds_test))
 
 e_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,
@@ -139,13 +139,13 @@
 train_metrics = merge(e_train_metrics, f_train_metrics)
 @save_dict res_path train_metrics
 train_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_train_mae"      => 0.00177242
-  "e_train_rmse"     => 0.00219646
-  "e_train_rsq"      => 0.610169
-  "f_train_mae"      => 0.169409
-  "f_train_rmse"     => 0.215992
-  "f_train_rsq"      => 0.855007
-  "f_train_mean_cos" => 0.890308

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.00193127
+  "e_train_rmse"     => 0.00230595
+  "e_train_rsq"      => 0.57376
+  "f_train_mae"      => 0.169466
+  "f_train_rmse"     => 0.217021
+  "f_train_rsq"      => 0.859496
+  "f_train_mean_cos" => 0.889228

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
                              metrics = [mae, rmse, rsq],
                              label = "e_test")
 f_test_metrics = get_metrics(f_test, f_test_pred,
@@ -154,28 +154,28 @@
 test_metrics = merge(e_test_metrics, f_test_metrics)
 @save_dict res_path test_metrics
 test_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_test_mae"      => 0.000929661
-  "e_test_rmse"     => 0.0011045
-  "e_test_rsq"      => 0.851666
-  "f_test_mae"      => 0.17472
-  "f_test_rmse"     => 0.219158
-  "f_test_rsq"      => 0.852106
-  "f_test_mean_cos" => 0.89213

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.000782914
+  "e_test_rmse"     => 0.000914238
+  "e_test_rsq"      => 0.925635
+  "f_test_mae"      => 0.173698
+  "f_test_rmse"     => 0.218686
+  "f_test_rsq"      => 0.848214
+  "f_test_mean_cos" => 0.890302

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
                      e_test, e_test_pred)
 @save_fig res_path e_plot
-DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
+DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
                      f_test, f_test_pred)
 @save_fig res_path f_plot
-DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
+DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
 f_train_plot = plot_forces(f_train, f_train_pred)
 f_train_cos  = plot_cos(f_train, f_train_pred)
 @save_fig res_path e_train_plot
 @save_fig res_path f_train_plot
 @save_fig res_path f_train_cos
-DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
+DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
 f_test_plot = plot_forces(f_test, f_test_pred)
 f_test_cos  = plot_cos(f_test, f_test_pred)
 @save_fig res_path e_test_plot
 @save_fig res_path f_test_plot
 @save_fig res_path f_test_cos
-DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

+DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/LJ-Ar/lennard-jones-ar/index.html b/previews/PR77/generated/LJ-Ar/lennard-jones-ar/index.html index ad2cec7..bb9dd05 100644 --- a/previews/PR77/generated/LJ-Ar/lennard-jones-ar/index.html +++ b/previews/PR77/generated/LJ-Ar/lennard-jones-ar/index.html @@ -1,5 +1,5 @@ -Example 1 - Load Ar+Lennard-Jones dataset and postprocess · PotentialLearning.jl

Load Ar dataset with energies computed by Lennard-Jones and postprocess

a. Load packages and define paths.

Load packages.

using Unitful, UnitfulAtomic
+Load Ar+Lennard-Jones dataset and postprocess · PotentialLearning.jl

Load Ar dataset with energies computed by Lennard-Jones and postprocess

a. Load packages and define paths.

Load packages.

using Unitful, UnitfulAtomic
 using AtomsBase, InteratomicPotentials, PotentialLearning
 using LinearAlgebra, Plots, DisplayAs

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/LJ-Ar")
 ds_path = "$path/../data/LJ-AR/lj-ar.yaml";

b. Load atomistic dataset.

ds, thermo = load_data(ds_path, YAML(:Ar, u"eV", u"Å"))
@@ -60,4 +60,4 @@
          xlabel = "τ | ps",
          ylabel = "Lennard Jones energy | eV",
          dpi = 300, fontsize = 12)
-DisplayAs.PNG(p)
Example block output

This page was generated using Literate.jl.

+DisplayAs.PNG(p)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/015768c7.png b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/015768c7.png new file mode 100644 index 0000000..2217636 Binary files /dev/null and b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/015768c7.png differ diff --git a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/2aef2306.png b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/2aef2306.png deleted file mode 100644 index f3b7b20..0000000 Binary files a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/2aef2306.png and /dev/null differ diff --git a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/7f53d516.png b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/7f53d516.png deleted file mode 100644 index c67bd34..0000000 Binary files a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/7f53d516.png and /dev/null differ diff --git a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/a35c9ff6.png b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/a35c9ff6.png new file mode 100644 index 0000000..b963048 Binary files /dev/null and b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/a35c9ff6.png differ diff --git a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html index a31fea5..e1ad5e1 100644 --- a/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html +++ b/previews/PR77/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html @@ -1,23 +1,23 @@ -Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error · PotentialLearning.jl

Optimize ACE hyper-parameters: minimize force time and fitting error.

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
+Optimize ACE hyper-parameters: minimize force time and fitting error · PotentialLearning.jl

Optimize ACE hyper-parameters: minimize force time and fitting error.

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
 using Unitful, UnitfulAtomic
 using LinearAlgebra, Random, DisplayAs
 using DataFrames, Hyperopt

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/Opt-ACE-aHfO2")
 ds_path =  "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz"
 res_path = "$path/results/";

Load utility functions.

include("$path/../utils/utils.jl")

Create experiment folder.

run(`mkdir -p $res_path`);

b. Load atomistic dataset and split it into training and test.

Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)

ds = load_data(ds_path, uparse("eV"), uparse("Å"))[1:1000]
DataSet{num_configs = 1000} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Split atomistic dataset into training and test

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Split atomistic dataset into training and test

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
 conf_train, conf_test = split(ds, n_train, n_test)
(DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}, DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces})

c. Hyper-parameter optimization.

Define a custom loss function. Here, we minimize fitting error and force calculation time. Possible metrics are e_mae, e_rmse, e_rsq, f_mae, f_rmse, f_rsq, and time_us.

function custom_loss(
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces})

c. Hyper-parameter optimization.

Define a custom loss function. Here, we minimize fitting error and force calculation time. Possible metrics are e_mae, e_rmse, e_rsq, f_mae, f_rmse, f_rsq, and time_us.

function custom_loss(
     metrics::OrderedDict
 )
     e_mae     = metrics[:e_mae]
@@ -38,29 +38,29 @@
                     :csp               => [0.5, 1.0, 1.5],
                     :r0                => [0.5, 1.0, 1.5]);

Use random sampling to find the optimal hyper-parameters.

iap, res = hyperlearn!(model, pars, conf_train;
                        n_samples = 10, sampler = RandomSampler(),
-                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.177 eV/atom, F_MAE:0.306 eV/Å, Time per force per atom:66.63 µs
-E_MAE:0.155 eV/atom, F_MAE:0.218 eV/Å, Time per force per atom:92.235 µs
-E_MAE:0.091 eV/atom, F_MAE:0.111 eV/Å, Time per force per atom:260.039 µs
-E_MAE:0.282 eV/atom, F_MAE:0.315 eV/Å, Time per force per atom:124.924 µs
-E_MAE:0.211 eV/atom, F_MAE:0.298 eV/Å, Time per force per atom:121.678 µs
-E_MAE:0.234 eV/atom, F_MAE:0.301 eV/Å, Time per force per atom:101.461 µs
-E_MAE:0.21 eV/atom, F_MAE:0.306 eV/Å, Time per force per atom:77.915 µs
-E_MAE:0.277 eV/atom, F_MAE:0.308 eV/Å, Time per force per atom:161.098 µs
-E_MAE:0.185 eV/atom, F_MAE:0.249 eV/Å, Time per force per atom:127.834 µs
-E_MAE:0.185 eV/atom, F_MAE:0.249 eV/Å, Time per force per atom:108.336 µs

Save and show results.

@save_var res_path iap.β
+                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.14 eV/atom, F_MAE:0.218 eV/Å, Time per force per atom:141.063 µs
+E_MAE:0.076 eV/atom, F_MAE:0.101 eV/Å, Time per force per atom:306.117 µs
+E_MAE:0.158 eV/atom, F_MAE:0.204 eV/Å, Time per force per atom:273.579 µs
+E_MAE:0.135 eV/atom, F_MAE:0.226 eV/Å, Time per force per atom:92.97 µs
+E_MAE:0.054 eV/atom, F_MAE:0.095 eV/Å, Time per force per atom:552.886 µs
+E_MAE:0.734 eV/atom, F_MAE:0.56 eV/Å, Time per force per atom:51.748 µs
+E_MAE:0.234 eV/atom, F_MAE:0.253 eV/Å, Time per force per atom:125.366 µs
+E_MAE:0.058 eV/atom, F_MAE:0.096 eV/Å, Time per force per atom:555.079 µs
+E_MAE:0.199 eV/atom, F_MAE:0.301 eV/Å, Time per force per atom:107.324 µs
+E_MAE:0.173 eV/atom, F_MAE:0.168 eV/Å, Time per force per atom:182.337 µs

Save and show results.

@save_var res_path iap.β
 @save_var res_path iap.β0
 @save_var res_path iap.basis
 @save_dataframe res_path res
-res
10×13 DataFrame
Rowe_maee_rmsee_rsqf_maef_rmsef_rsqtime_usbody_orderpolynomial_degreercutoffwLcspr0
AnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAny
10.09052470.11270.8639540.1110140.1415090.945984260.0394.03.05.01.01.01.5
20.1549820.191260.608180.2183160.2865930.77844392.23522.05.04.51.50.50.5
30.1769790.2329580.418710.3057520.4015890.56497266.63042.05.04.51.50.50.5
40.1850530.2380340.3931040.2493020.3208430.722324127.8342.05.05.51.00.50.5
50.1850530.2380340.3931040.2493020.3208430.722324108.3362.05.05.51.00.50.5
60.2096020.2756750.1859880.305730.4010690.56609777.91512.04.05.00.51.51.5
70.211180.2658940.2427240.2981280.3909010.58782121.6783.05.05.01.50.51.0
80.234080.2772330.1767580.3013170.3936110.582086101.4613.05.05.01.50.51.0
90.2768210.338858-0.2299080.3077010.4018930.564313161.0982.04.05.00.51.51.5
100.2819060.340179-0.2395170.3147480.4114170.543418124.9244.03.05.01.01.01.5

Plot error vs time.

err_time = plot_err_time(res)
+res
10×13 DataFrame
Rowe_maee_rmsee_rsqf_maef_rmsef_rsqtime_usbody_orderpolynomial_degreercutoffwLcspr0
AnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAny
10.05395520.07014780.9546660.09504520.1214210.961364552.8863.05.05.51.01.00.5
20.05756820.07505610.94810.09646910.1229230.960402555.0794.03.04.51.01.01.5
30.07580350.0935230.919420.1005630.1293330.956165306.1173.05.05.51.01.51.5
40.134820.1729470.7244370.2259590.2953610.77138192.97014.03.05.51.00.50.5
50.1403030.1761160.7142480.2176890.2824410.790944141.0633.05.05.51.01.51.5
60.1576960.1959730.6461770.2040580.2699770.808989273.5794.03.05.51.00.50.5
70.173290.2149680.5742670.1682130.2146120.879299182.3373.04.05.00.50.51.5
80.198570.2529620.4104770.3013460.3952420.590615107.3243.04.05.00.50.51.5
90.2339040.2880980.2353320.2527810.3287530.716766125.3664.03.04.51.01.01.5
100.7335660.872838-6.018750.5600840.712729-0.33123351.74763.05.05.51.01.00.5

Plot error vs time.

err_time = plot_err_time(res)
 @save_fig res_path err_time
-DisplayAs.PNG(err_time)
Example block output

Alternatively, use latin hypercube sampling to find the optimal hyper-parameters.

iap, res = hyperlearn!(model, pars, conf_train;
+DisplayAs.PNG(err_time)
Example block output

Alternatively, use latin hypercube sampling to find the optimal hyper-parameters.

iap, res = hyperlearn!(model, pars, conf_train;
                        n_samples = 3, sampler = LHSampler(),
-                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.185 eV/atom, F_MAE:0.249 eV/Å, Time per force per atom:121.556 µs
-E_MAE:0.061 eV/atom, F_MAE:0.105 eV/Å, Time per force per atom:1316.068 µs
-E_MAE:0.197 eV/atom, F_MAE:0.309 eV/Å, Time per force per atom:44.895 µs

Save and show results.

@save_var res_path iap.β
+                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.2 eV/atom, F_MAE:0.299 eV/Å, Time per force per atom:124.403 µs
+E_MAE:0.083 eV/atom, F_MAE:0.126 eV/Å, Time per force per atom:139.161 µs
+E_MAE:3.107 eV/atom, F_MAE:3.017 eV/Å, Time per force per atom:85.564 µs

Save and show results.

@save_var res_path iap.β
 @save_var res_path iap.β0
 @save_var res_path iap.basis
 @save_dataframe res_path res
-res
3×13 DataFrame
Rowe_maee_rmsee_rsqf_maef_rmsef_rsqtime_usbody_orderpolynomial_degreercutoffwLcspr0
AnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAny
10.06118430.07502510.9397090.1048360.1338080.9517031316.074.04.05.51.01.50.5
20.1850530.2380340.3931040.2493020.3208430.722324121.5564.04.05.51.01.50.5
30.196970.2635330.2561110.3087770.404340.55899144.89513.05.05.00.50.51.5

Plot error vs time.

err_time = plot_err_time(res)
+res
3×13 DataFrame
Rowe_maee_rmsee_rsqf_maef_rmsef_rsqtime_usbody_orderpolynomial_degreercutoffwLcspr0
AnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAnyAny
10.08260820.09844020.9107240.1260850.1625680.930741139.1612.05.05.51.01.01.5
20.2000410.2462230.4414650.2985670.3920260.59725124.4032.05.05.51.01.01.5
33.107193.62547-120.0933.017273.85697-37.985185.56363.04.04.51.50.50.5

Plot error vs time.

err_time = plot_err_time(res)
 @save_fig res_path err_time
-DisplayAs.PNG(err_time)
Example block output

This page was generated using Literate.jl.

+DisplayAs.PNG(err_time)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/2f3b2db6.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/2f3b2db6.png deleted file mode 100644 index 59d6486..0000000 Binary files a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/2f3b2db6.png and /dev/null differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/3bdc2c9b.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/3bdc2c9b.png new file mode 100644 index 0000000..6610138 Binary files /dev/null and b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/3bdc2c9b.png differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/60bf9c3e.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/60bf9c3e.png new file mode 100644 index 0000000..89cfee7 Binary files /dev/null and b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/60bf9c3e.png differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/bee2b42c.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/bee2b42c.png new file mode 100644 index 0000000..fd75c21 Binary files /dev/null and b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/bee2b42c.png differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d0488492.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d0488492.png new file mode 100644 index 0000000..d912669 Binary files /dev/null and b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d0488492.png differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d054cb24.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d054cb24.png deleted file mode 100644 index f269916..0000000 Binary files a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d054cb24.png and /dev/null differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d4456c7a.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d4456c7a.png deleted file mode 100644 index bb16a41..0000000 Binary files a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d4456c7a.png and /dev/null differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d72c0091.png b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d72c0091.png deleted file mode 100644 index 5c90888..0000000 Binary files a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/d72c0091.png and /dev/null differ diff --git a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html index f18a845..76f42fc 100644 --- a/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html +++ b/previews/PR77/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html @@ -1,22 +1,22 @@ -Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset · PotentialLearning.jl

Reduce ACE descriptors with PCA and fit a-HfO2 dataset

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
+Reduce ACE descriptors with PCA and fit a-HfO2 dataset · PotentialLearning.jl

Reduce ACE descriptors with PCA and fit a-HfO2 dataset

a. Load packages, define paths, and create experiment folder.

Load packages.

using AtomsBase, InteratomicPotentials, PotentialLearning
 using Unitful, UnitfulAtomic
 using LinearAlgebra, Random, DisplayAs

Define paths.

path = joinpath(dirname(pathof(PotentialLearning)), "../examples/PCA-ACE-aHfO2")
 ds_path =  "$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz"
 res_path = "$path/results/";

Load utility functions.

include("$path/../utils/utils.jl")

Create experiment folder.

run(`mkdir -p $res_path`);

b. Load atomistic dataset and split it into training and test.

Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)

ds = load_data(ds_path, uparse("eV"), uparse("Å"))[1:1000] # Only first 1K samples are used in this example.
DataSet{num_configs = 1000} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Split atomistic dataset into training and test.

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}

Split atomistic dataset into training and test.

n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.
 conf_train, conf_test = split(ds, n_train, n_test)
(DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}, DataSet{num_configs = 50} 
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces})

c. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis.

basis = ACE(species           = [:Hf, :O],
+	 Configuration{S, Energy, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces})

c. Create ACE basis, compute descriptors and add them to the dataset.

Create ACE basis.

basis = ACE(species           = [:Hf, :O],
             body_order        = 3,
             polynomial_degree = 4,
             rcutoff           = 5.0,
@@ -49,39 +49,39 @@
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}

Update training dataset by adding energy and force descriptors.

ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

d. Dimension reduction of energy and force descriptors of training dataset.

n_desc = 20
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

d. Dimension reduction of energy and force descriptors of training dataset.

n_desc = 20
 pca = PCAState(tol = n_desc)
 fit!(ds_train, pca)
 transform!(ds_train, pca)
50-element Vector{Configuration}:
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
  ⋮
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

e. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

e. Learn ACE coefficients based on ACE descriptors and DFT data.

println("Learning energies and forces...")
 lb = LBasisPotential(basis)
 ws, int = [1.0, 1.0], true
 learn!(lb, ds_train, ws, int)
 @save_var res_path lb.β
 @save_var res_path lb.β0
-lb.β, lb.β0
([-0.4554243543680833, 0.2189955754488992, -0.11209122717950516, -2.2788288649409805, -1.3546986075246612, -4.850072629707322, 2.3928507188662387, 20.60364685400231, -27.34748989941933, -29.032236878864907, 19.595006634712647, -35.95783140575452, 45.68132021186517, -65.86014832956577, 96.84717302838276, 35.86450923519259, -52.66814481020989, 170.26341954543847, 101.16419361122536, -12.321211920166547], [-952.5608474449989])

f. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
+lb.β, lb.β0
([-0.30395328015028955, 0.623870946610621, -0.3823290076328875, 1.3357937790659777, -1.4875130114742323, -0.958571042704851, 8.847153182574763, -16.333731008320555, -42.77202810493523, -0.6325736877268046, -11.875323324030976, 68.21512878801819, 5.630701589667631, -37.901991601131165, -87.39754020489572, 23.990784463219644, 75.58719091872331, 85.06748517870116, 198.30232476806452, -6.980035985065938], [-952.5538122129992])

f. Post-process output: calculate metrics, create plots, and save results.

Compute ACE descriptors for energy and forces based on the atomistic test configurations.

println("Computing energy descriptors of test dataset...")
 e_descr_test = compute_local_descriptors(conf_test, basis;
                                          pbar = false)
 println("Computing force descriptors of test dataset...")
@@ -107,30 +107,30 @@
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}
  ForceDescriptors{n = 96, d = 3}

Update test dataset by adding energy and force descriptors.

ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)
DataSet{num_configs = 50} 
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
 	 ⋮
-	 Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Dimension reduction of energy and force descriptors of test dataset.

transform!(ds_test, pca)
50-element Vector{Configuration}:
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
+	 Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

Dimension reduction of energy and force descriptors of test dataset.

transform!(ds_test, pca)
50-element Vector{Configuration}:
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
  ⋮
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}
- Configuration{S, ForceDescriptors, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}
+ Configuration{S, Energy, LocalDescriptors, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Forces, ForceDescriptors}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
 n_atoms_test = length.(get_system.(ds_test))
 
 e_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,
@@ -158,13 +158,13 @@
 train_metrics = merge(e_train_metrics, f_train_metrics)
 @save_dict res_path train_metrics
 train_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_train_mae"      => 0.00243149
-  "e_train_rmse"     => 0.00318051
-  "e_train_rsq"      => 0.267693
-  "f_train_mae"      => 0.243279
-  "f_train_rmse"     => 0.31029
-  "f_train_rsq"      => 0.642716
-  "f_train_mean_cos" => 0.798415

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.00221251
+  "e_train_rmse"     => 0.00275507
+  "e_train_rsq"      => 0.346287
+  "f_train_mae"      => 0.23775
+  "f_train_rmse"     => 0.301964
+  "f_train_rsq"      => 0.654615
+  "f_train_mean_cos" => 0.79645

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
                              metrics = [mae, rmse, rsq],
                              label = "e_test")
 f_test_metrics = get_metrics(f_test, f_test_pred,
@@ -173,28 +173,28 @@
 test_metrics = merge(e_test_metrics, f_test_metrics)
 @save_dict res_path test_metrics
 test_metrics
OrderedCollections.OrderedDict{String, Float64} with 7 entries:
-  "e_test_mae"      => 0.00215773
-  "e_test_rmse"     => 0.00250926
-  "e_test_rsq"      => 0.336914
-  "f_test_mae"      => 0.241845
-  "f_test_rmse"     => 0.306485
-  "f_test_rsq"      => 0.634883
-  "f_test_mean_cos" => 0.787618

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.00232735
+  "e_test_rmse"     => 0.00271698
+  "e_test_rsq"      => 0.371426
+  "f_test_mae"      => 0.240521
+  "f_test_rmse"     => 0.305126
+  "f_test_rsq"      => 0.638094
+  "f_test_mean_cos" => 0.790998

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
                      e_test, e_test_pred)
 @save_fig res_path e_plot
-DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
+DisplayAs.PNG(e_plot)
Example block output

Plot and save force results.

f_plot = plot_forces(f_train, f_train_pred,
                      f_test, f_test_pred)
 @save_fig res_path f_plot
-DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
+DisplayAs.PNG(f_plot)
Example block output

Plot and save training force cosine.

e_train_plot = plot_energy(e_train, e_train_pred)
 f_train_plot = plot_forces(f_train, f_train_pred)
 f_train_cos  = plot_cos(f_train, f_train_pred)
 @save_fig res_path e_train_plot
 @save_fig res_path f_train_plot
 @save_fig res_path f_train_cos
-DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
+DisplayAs.PNG(f_train_cos)
Example block output

Plot and save test force cosine.

e_test_plot = plot_energy(e_test, e_test_pred)
 f_test_plot = plot_forces(f_test, f_test_pred)
 f_test_cos  = plot_cos(f_test, f_test_pred)
 @save_fig res_path e_test_plot
 @save_fig res_path f_test_plot
 @save_fig res_path f_test_cos
-DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

+DisplayAs.PNG(f_test_cos)
Example block output

This page was generated using Literate.jl.

diff --git a/previews/PR77/how-to-run-the-examples/index.html b/previews/PR77/how-to-run-the-examples/index.html index fe8a646..b94c096 100644 --- a/previews/PR77/how-to-run-the-examples/index.html +++ b/previews/PR77/how-to-run-the-examples/index.html @@ -1,5 +1,5 @@ -How to run the examples · PotentialLearning.jl

How to run the examples

Add registries

Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:

    pkg> registry add https://github.com/JuliaRegistries/General
+How to run the examples · PotentialLearning.jl

How to run the examples

Add registries

Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:

    pkg> registry add https://github.com/JuliaRegistries/General
     pkg> registry add https://github.com/cesmix-mit/CESMIX.git 
     pkg> registry add https://github.com/JuliaMolSim/MolSim.git
-    pkg> registry add https://github.com/ACEsuit/ACEregistry

Clone repository and access an example folder

Clone PotentialLearning.jl repository in your working directory.

    $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git

Access to any folder within PotentialLearning.jl/examples. E.g.

    $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1

Run example

Open a Julia REPL, activate the examples folder project, and define the number of threads.

    $ julia --project=./ --threads=4

Type ] to enter the Pkg REPL and instantiate.

    pkg> instantiate

Finally, include the example file.

    julia> include("fit-dpp-ace-ahfo2.jl")
+ pkg> registry add https://github.com/ACEsuit/ACEregistry

Clone repository and access an example folder

Clone PotentialLearning.jl repository in your working directory.

    $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git

Access to any folder within PotentialLearning.jl/examples. E.g.

    $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1

Run example

Open a Julia REPL, activate the examples folder project, and define the number of threads.

    $ julia --project=./ --threads=4

Type ] to enter the Pkg REPL and instantiate.

    pkg> instantiate

Finally, include the example file.

    julia> include("fit-dpp-ace-ahfo2.jl")
diff --git a/previews/PR77/index.html b/previews/PR77/index.html index fd25a11..e4eb6a1 100644 --- a/previews/PR77/index.html +++ b/previews/PR77/index.html @@ -1,14 +1,14 @@ -Home · PotentialLearning.jl

PotentialLearning.jl

Optimize your atomistic data and interatomic potential models in your molecular dynamic workflows.

<ins>Reduce expensive ***Density functional theory*** calculations</ins> while maintaining training accuracy by intelligently subsampling your atomistic dataset:

  1. Subsample your atomistic configurations using a Determinantal Point Process (DPP) based algorithm that compares energy descriptors computed with the Atomic Cluster Expansion (ACE).
ds = DataSet(conf_train .+ e_descr)
+Home · PotentialLearning.jl

PotentialLearning.jl

Optimize your atomistic data and interatomic potential models in your molecular dynamic workflows.

Reduce expensive Density functional theory calculations

Reduce expensive Density functional theory calculations while maintaining training accuracy by intelligently subsampling your atomistic dataset:

1 - Subsample your atomistic configurations using a Determinantal Point Process (DPP) based algorithm that compares energy descriptors computed with the Atomic Cluster Expansion (ACE).

ds = DataSet(conf_train .+ e_descr)
 dataset_selector = kDPP(ds, GlobalMean(), DotProduct())
 inds = get_random_subset(dataset_selector)
-conf_train = @views conf_train[inds]
  1. Export the reduced dataset, use Density functional theory (DFT) on it, and fit your model.

See example.

We are working to provide different intelligent subsampling algorithms based on DPP, DBSCAN, and CUR; highly scalable parallel subsampling via hierarchical subsampling and distributed parallelism; and optimal subsampler selection.

<ins>Get fast and accurate interatomic potential models</ins> through parallel multi-objective hyper-parameter optimization:

  1. Define the interatomic potential model, hyper-parameter value ranges, and custom loss function. Then, optimize your model.
model = ACE
+conf_train = @views conf_train[inds]

2 - Export the reduced dataset, use Density functional theory (DFT) on it, and fit your model.

See example.

We are working to provide different intelligent subsampling algorithms based on DPP, DBSCAN, and CUR; highly scalable parallel subsampling via hierarchical subsampling and distributed parallelism; and optimal subsampler selection.

Get fast and accurate interatomic potential models

Get fast and accurate interatomic potential models through parallel multi-objective hyper-parameter optimization:

1 - Define the interatomic potential model, hyper-parameter value ranges, and custom loss function. Then, optimize your model.

model = ACE
 pars = OrderedDict( :body_order        => [2, 3, 4],
                     :polynomial_degree => [3, 4, 5], ...)
 function custom_loss(metrics::OrderedDict)
     ...
     return w_e * e_mae + w_f * f_mae + w_t * time_us
 end
-iap, res = hyperlearn!(model, pars, conf_train; loss = custom_loss);
  1. Export optimal values to your molecular dynamic workflow.

See example.

The models are compatible with the interfaces of our sister package InteratomicPotentials.jl. In particular, we are interested in maintaining compatibility with ACESuit, as well as integrating LAMMPS based potentials such as ML-POD and ML-PACE. We are also working to provide neural network potential architecture optimization.

<ins>Compress your interatomic potential data and model</ins> using dimensionality reduction of energy and force descriptors:

pca = PCAState(tol = n_desc)
+iap, res = hyperlearn!(model, pars, conf_train; loss = custom_loss);

2 - Export optimal values to your molecular dynamic workflow.

See example.

The models are compatible with the interfaces of our sister package InteratomicPotentials.jl. In particular, we are interested in maintaining compatibility with ACESuit, as well as integrating LAMMPS based potentials such as ML-POD and ML-PACE. We are also working to provide neural network potential architecture optimization.

Compress your interatomic potential data and model

Compress your interatomic potential data and model using dimensionality reduction of energy and force descriptors:

1 - Define a PCA state, fit PCA with your the energy and force descriptors of your dataset, and transform all dataset descriptors.

pca = PCAState(tol = n_desc)
 fit!(ds_train, pca)
-transform!(ds_train, pca)

See example.

We are working to provide feature selection of energy and force descriptors based on CUR.

Additionally, this package includes utilities for loading input data (such as XYZ files), computing various metrics (including MAE, MSE, RSQ, and COV), exporting results, and generating plots.

Acknowledgment: Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).

+transform!(ds_train, pca)

2 - Export PCA fitted data to be used in your workflow.

See example.

We are working to provide feature selection of energy and force descriptors based on CUR.

Additionally, this package includes utilities for loading input data (such as XYZ files), computing various metrics (including MAE, MSE, RSQ, and COV), exporting results, and generating plots.

Acknowledgment: Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).

diff --git a/previews/PR77/objects.inv b/previews/PR77/objects.inv index a268598..4691b6e 100644 Binary files a/previews/PR77/objects.inv and b/previews/PR77/objects.inv differ diff --git a/previews/PR77/search_index.js b/previews/PR77/search_index.js index 6c373c3..b03402c 100644 --- a/previews/PR77/search_index.js +++ b/previews/PR77/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"EditURL = \"../../../../examples/ACE-aHfO2/fit-ace-ahfo2.jl\"","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#Fit-a-HfO2-dataset-with-ACE","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Load packages.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Define paths.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Load utility functions.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Create experiment folder.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000] # Only the first 1K samples are used in this example.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#c.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"c. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Create ACE basis","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#d.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"d. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], false\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#e.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"e. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false);\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Compute training metrics.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Compute test metrics.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Plot and save energy results.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Plot and save force results.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Example 1 - Fit a-HfO2 dataset with ACE","title":"Example 1 - Fit a-HfO2 dataset with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"EditURL = \"../../../../examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl\"","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#Subsample-a-HfO2-dataset-and-fit-with-ACE","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset and fit with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-aHfO2-1\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load utility functions.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create experiment folder.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"n_train, n_test = 100, 50 # Few samples per dataset are used in this example.\nconf_train, conf_test = split(ds[1:1000], n_train, n_test)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#c.-Subsampling","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"c. Subsampling","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energies as subsampling input.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 2,\n polynomial_degree = 3,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\ne_descr = compute_local_descriptors(conf_train,\n basis,\n pbar = false)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update subsampling dataset","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"conf_train_kDPP = DataSet(conf_train .+ e_descr)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create DPP subselector","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"dataset_selector = kDPP( conf_train_kDPP,\n GlobalMean(),\n DotProduct();\n batch_size = 50)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Subsample trainig dataset","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"inds = get_random_subset(dataset_selector)\nconf_train = @views conf_train[inds]","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#d.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"d. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create ACE basis","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], false\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false);\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute training metrics.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute test metrics.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save energy results.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save force results.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Example 1 - Subsample a-HfO2 dataset with DPP and fit with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"api/#API-Reference","page":"API","title":"API Reference","text":"","category":"section"},{"location":"api/","page":"API","title":"API","text":"This page provides a list of all documented types and functions and in PotentialLearning.jl.","category":"page"},{"location":"api/","page":"API","title":"API","text":"Modules = [PotentialLearning]\nOrder = [:type, :function, :constant]","category":"page"},{"location":"api/#PotentialLearning.ActiveSubspace","page":"API","title":"PotentialLearning.ActiveSubspace","text":"ActiveSubspace{T<:Real} <: DimensionReducer\n Q :: Function \n ∇Q :: Function (gradient of Q)\n tol :: T\n\nUse the theory of active subspaces, with a given quantity of interest (expressed as the function Q) which takes a Configuration as an input and outputs a real scalar. ∇Q should input a Configuration and output an appropriate gradient. If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.AtomicData","page":"API","title":"PotentialLearning.AtomicData","text":"AtomicData <: Data\n\nAbstract type declaring the type of information that is unique to a particular atom (instead of a whole configuration).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Configuration-Tuple{Vararg{Union{ConfigurationData, AtomsBase.FlexibleSystem}}}","page":"API","title":"PotentialLearning.Configuration","text":"Configuration(data::Union{AtomsBase.FlexibleSystem, ConfigurationData} )\n\nA Configuration is a data struct that contains information unique to a particular configuration of atoms (Energy, LocalDescriptors, ForceDescriptors, and a FlexibleSystem) in a dictionary. Example: '''julia e = Energy(-0.57, u\"eV\") ld = LocalDescriptors(...) c = Configuration(e, ld) '''\n\nConfigurations can be added together, which merges the data dictionaries '''julia c1 = Configuration(e) # Contains energy c2 = Configuration(f) # contains forces c = c1 + c2 # c <: Configuration, contains energy and forces '''\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.ConfigurationData","page":"API","title":"PotentialLearning.ConfigurationData","text":"ConfigurationData <: Data\n\nAbstract type declaring the type of data that is unique to a particular configuration (instead of just an atom).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.CorrelationMatrix","page":"API","title":"PotentialLearning.CorrelationMatrix","text":"CorrelationMatrix \n α :: Vector{Float64} # weights\n\nCorrelationMatrix produces a global descriptor that is the correlation matrix of the local descriptors. In other words, it is mean(bi'*bi for bi in B). \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.CovariateLinearProblem","page":"API","title":"PotentialLearning.CovariateLinearProblem","text":"struct CovariateLinearProblem{T<:Real} <: LinearProblem{T} e::Vector f::Vector{Vector{T}} B::Vector{Vector{T}} dB::Vector{Matrix{T}} β::Vector{T} β0::Vector{T} σe::Vector{T} σf::Vector{T} Σ::Symmetric{T,Matrix{T}} end\n\nA CovariateLinearProblem is a linear problem in which we are fitting energies and forces using both descriptors and their gradients (B and dB, respectively). When this is the case, the solution is not available analytically and must be solved using some iterative optimization proceedure. In the end, we fit the model coefficients, β, standard deviations corresponding to energies and forces, σe and σf, and the covariance Σ. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DBSCANSelector","page":"API","title":"PotentialLearning.DBSCANSelector","text":"struct DBSCANSelector <: SubsetSelector\n clusters\n eps\n minpts\n sample_size\nend\n\nDefinition of the type DBSCANSelector, a subselector based on the clustering method DBSCAN.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DBSCANSelector-Tuple{DataSet, Any, Any, Any}","page":"API","title":"PotentialLearning.DBSCANSelector","text":"function DBSCANSelector(\n ds::DataSet,\n eps,\n minpts,\n sample_size\n)\n\nConstructor of DBSCANSelector based on the atomic configurations in ds, the DBSCAN params eps and minpts, and the sample size sample_size.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.Data","page":"API","title":"PotentialLearning.Data","text":"Data\n\nAbstract supertype of ConfigurationData.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DataBase","page":"API","title":"PotentialLearning.DataBase","text":"DataBase\n\nAbstract type for DataSets. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DataSet","page":"API","title":"PotentialLearning.DataSet","text":"DataSet\n\nStruct that holds vector of configuration. Most operations in PotentialLearning are built around the DataSet structure.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Distance","page":"API","title":"PotentialLearning.Distance","text":"Distance\n\nA struct of abstract type Distance produces the distance between two `global` descriptors, or features. Not all distances might be compatible with all types of features.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Divergence","page":"API","title":"PotentialLearning.Divergence","text":"Divergence\n\nA struct of abstract type Divergence produces a measure of discrepancy between two probability distributions. Discepancies may take as argument analytical distributions or sets of samples representing empirical distributions.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DotProduct","page":"API","title":"PotentialLearning.DotProduct","text":"DotProduct <: Kernel \n α :: Power of DotProduct kernel \n\n\nComputes the dot product kernel between two features, i.e.,\n\ncos(θ) = ( A ⋅ B / (||A||^2||B||^2) )^α\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Energy","page":"API","title":"PotentialLearning.Energy","text":"Energy <: ConfigurationData\n d :: Real\n u :: Unitful.FreeUnits\n\nConvenience struct that holds energy information (and corresponding units). Default unit is eV\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Euclidean","page":"API","title":"PotentialLearning.Euclidean","text":"Euclidean <: Distance \n Cinv :: Covariance Matrix \n\nComputes the squared euclidean distance with weight matrix Cinv, the inverse of some covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ExtXYZ","page":"API","title":"PotentialLearning.ExtXYZ","text":"ExtXYZ <: IO\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Feature","page":"API","title":"PotentialLearning.Feature","text":"Feature\n\nA struct of abstract type Feature represents a function that takes in a set of local descriptors corresponding to some atomic environment and produce a global descriptor. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Force","page":"API","title":"PotentialLearning.Force","text":"Force <: AtomicData \n f :: Vector{<:Real}\n u :: Unitful.FreeUnits\n\nContains the force with (x,y,z)-components in f with units u. Default unit is \"eV/Å\". \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ForceDescriptor","page":"API","title":"PotentialLearning.ForceDescriptor","text":"ForceDescriptor <: AtomicData\n b :: Vector{<:Vector{<:Real}}\n\nContains the x,y,z components (out vector) of the force descriptor (inner vector).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ForceDescriptors","page":"API","title":"PotentialLearning.ForceDescriptors","text":"ForceDescriptors <: ConfigurationData\n b :: Vector{ForceDescriptor}\n\nA container holding all of the ForceDescriptors for all atoms in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Forces","page":"API","title":"PotentialLearning.Forces","text":"Forces <: ConfigurationData\n f :: Vector{force}\n\nForces is a struct that contains all force information in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Forstner","page":"API","title":"PotentialLearning.Forstner","text":"Forstner <: Distance \n α :: Regularization parameter\n\nComputes the squared Forstner distance between two positive semi-definite matrices.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.GlobalMean","page":"API","title":"PotentialLearning.GlobalMean","text":" GlobalMean{T}\n\nGlobalMean produces the mean of the local descriptors.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.GlobalSum","page":"API","title":"PotentialLearning.GlobalSum","text":" GlobalSum{T}\n\nGlobalSum produces the sum of the local descriptors.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.InverseMultiquadric","page":"API","title":"PotentialLearning.InverseMultiquadric","text":"InverseMultiquadric <: Kernel \n d :: Distance function \n c2 :: Squared constant parameter\n ℓ :: Length-scale parameter\n\nComputes the inverse multiquadric (IMQ) kernel, i.e.,\n\n k(A, B) = (c^2 + d(A,B)/β^2)^{-1/2}\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Kernel","page":"API","title":"PotentialLearning.Kernel","text":"Kernel\n\nA struct of abstract type Kernel is function that takes in two features and produces a semi-definite scalar representing the similarity between the two features.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.KernelSteinDiscrepancy","page":"API","title":"PotentialLearning.KernelSteinDiscrepancy","text":"KernelSteinDiscrepancy <: Divergence\n score :: Function\n knl :: Kernel\n\nComputes the kernel Stein discrepancy between distributions p (from which samples are provided) and q (for which the score is provided) based on the RKHS defined by kernel k.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LAMMPS","page":"API","title":"PotentialLearning.LAMMPS","text":"struct LAMMPS <: IO\n elements :: Vector{Symbol}\n boundary_conditions :: Vector\nend\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LearningProblem","page":"API","title":"PotentialLearning.LearningProblem","text":"struct LearningProblem{T<:Real} <: AbstractLearningProblem ds::DataSet logprob::Function ∇logprob::Function params::Vector{T} end\n\nGeneric LearningProblem that allows the user to pass a logprob(y::params, ds::DataSet) function and its gradient. The gradient should return a vector of logprob with respect to it's params. If the user does not have a gradient function available, then Flux can provide one for it (provided that logprob is of the form above).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LearningProblem-Union{Tuple{T}, Tuple{DataSet, Function, Vector{T}}} where T","page":"API","title":"PotentialLearning.LearningProblem","text":"function LearningProblem( ds::DataSet, logprob::Function, params::Vector{T} ) where {T}\n\nGeneric LearningProblem construnctor.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.LinearProblem","page":"API","title":"PotentialLearning.LinearProblem","text":"abstract type LinearProblem{T<:Real} <: AbstractLearningProblem end\n\nAn abstract type to specify linear potential inference problems. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LinearProblem-Tuple{DataSet}","page":"API","title":"PotentialLearning.LinearProblem","text":"function LinearProblem( ds::DataSet; T = Float64 )\n\nConstruct a LinearProblem by detecting if there are energy descriptors and/or force descriptors and construct the appropriate LinearProblem (either Univariate, if only a single type of descriptor, or Covariate, if there are both types).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.LocalDescriptor","page":"API","title":"PotentialLearning.LocalDescriptor","text":"LocalDescriptor <: AtomicData\n\nA vector corresponding to the descriptor for a particular atom's neighborhood.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LocalDescriptors","page":"API","title":"PotentialLearning.LocalDescriptors","text":"LocalDescriptors <: ConfigurationData\n\nA vector of LocalDescriptor, which now should represent all local descriptors for atoms in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.PCA","page":"API","title":"PotentialLearning.PCA","text":"PCA <: DimensionReducer\n tol :: Float64\n\nUse SVD to compute the PCA of the design matrix of descriptors. (using Force descriptors TBA)\n\nIf tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.PCAState","page":"API","title":"PotentialLearning.PCAState","text":"PCAState <: DimensionReducer\n tol :: Float64\n\nUse SVD to compute the PCA of the design matrix of descriptors.\n\nIf tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.RBF","page":"API","title":"PotentialLearning.RBF","text":"RBF <: Kernel \n d :: Distance function \n α :: Regularization parameter \n ℓ :: Length-scale parameter\n β :: Scale parameter\n\n\nComputes the squared exponential kernel, i.e.,\n\n k(A, B) = β \u001bxp( -\frac{1}{2} d(A,B)/ℓ^2 ) + α δ(A, B)\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.RandomSelector","page":"API","title":"PotentialLearning.RandomSelector","text":"struct Random\n num_configs :: Int \n batch_size :: Int \nend\n\nA convenience function that allows the user to randomly select indices uniformly over [1, num_configs]. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.UnivariateLinearProblem","page":"API","title":"PotentialLearning.UnivariateLinearProblem","text":"struct UnivariateLinearProblem{T<:Real} <: LinearProblem{T} ivdata::Vector dvdata::Vector β::Vector{T} β0::Vector{T} σ::Vector{T} Σ::Symmetric{T,Matrix{T}} end\n\nA UnivariateLinearProblem is a linear problem in which there is only 1 type of independent variable / dependent variable. Typically, that means we are either only fitting energies or only fitting forces. When this is the case, the solution is available analytically and the standard deviation, σ, and covariance, Σ, of the coefficients, β, are computable. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.YAML","page":"API","title":"PotentialLearning.YAML","text":"YAML <: IO\n energy_units :: Unitful.FreeUnits\n distance_units :: Unitful.FreeUnits\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.kDPP","page":"API","title":"PotentialLearning.kDPP","text":"struct kDPP\n K :: EllEnsemble\nend\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a similarity kernel, for which the user must provide a LinearProblem and two functions to compute descriptor (1) diversity and (2) quality. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.kDPP-Tuple{DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.kDPP","text":"kDPP(ds::Dataset, f::Feature, k::Kernel)\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a dataset, a method to compute features, and a kernel. Optional arguments include batch size and type of descriptor (default LocalDescriptors).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kDPP-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.kDPP","text":"kDPP(features::Union{Vector{Vector{T}}, Vector{Symmetric{T, Matrix{T}}}}, k::Kernel)\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantaljl. All that is required to construct a kDPP are features (either a vector of vector features or a vector of symmetric matrix features) and a kernel. Optional argument is batch_size (default length(features)).\n\n\n\n\n\n","category":"method"},{"location":"api/#InteratomicPotentials.compute_force_descriptors-Tuple{DataSet, InteratomicPotentials.BasisSystem}","page":"API","title":"InteratomicPotentials.compute_force_descriptors","text":"function computeforcedescriptors( ds::DataSet, basis::BasisSystem; pbar = true )\n\nCompute force descriptors of a basis system and dataset using threads.\n\n\n\n\n\n","category":"method"},{"location":"api/#InteratomicPotentials.compute_local_descriptors-Tuple{DataSet, InteratomicPotentials.BasisSystem}","page":"API","title":"InteratomicPotentials.compute_local_descriptors","text":"function computelocaldescriptors( ds::DataSet, basis::BasisSystem; pbar = true )\n\nds: dataset. basis: basis system (e.g. ACE) pbar: progress bar\n\nCompute local descriptors of a basis system and dataset using threads.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Tuple{DataSet, DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(ds1::DataSet, ds2::DataSet, F::Feature, k::Kernel)\n\nCompute nonsymmetric kernel matrix K using features of the datasets ds1 and ds2 calculated using the Feature method F.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Tuple{DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(ds::DataSet, F::Feature, k::Kernel)\n\nCompute symmetric kernel matrix K using features of the dataset ds calculated using the Feature method F. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(F, k::Kernel)\n\nCompute symmetric kernel matrix K where K{ij} = k(Fi, F_j). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(F1, F2, k::Kernel)\n\nCompute non-symmetric kernel matrix K where K{ij} = k(F1i, F2_j). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.calc_centroid-Tuple{Matrix{Float64}}","page":"API","title":"PotentialLearning.calc_centroid","text":"function calc_centroid(\n m::Array{Float64,2}\n)\n\nCalculate a centroid of a matrix.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.calc_metrics-Tuple{Any, Any}","page":"API","title":"PotentialLearning.calc_metrics","text":"calc_metrics(x_pred, x)\n\nx_pred: vector of predicted values of a variable. E.g. energy. x: vector of true values of a variable. E.g. energy.\n\nReturns MAE, RMSE, and RSQ.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_distance-Union{Tuple{T}, Tuple{Vector{T}, Vector{T}, Euclidean}} where T<:Real","page":"API","title":"PotentialLearning.compute_distance","text":"compute_distance(A, B, d)\n\nCompute the distance between features A and B using distance metric d. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_features-Tuple{DataSet, Feature}","page":"API","title":"PotentialLearning.compute_features","text":"compute_feature(ds::DataSet, f::Feature; dt = LocalDescriptors)\n\nComputes features of the dataset ds using the feature method F on descriptors dt (default option are the LocalDescriptors, if available).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradx_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradx_distance","text":"compute_gradx_distance(A, B, d)\n\nCompute gradient of the distance between features A and B using distance metric d, with respect to the first argument (A). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradx_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradx_kernel","text":"compute_gradx_kernel(A, B, k)\n\nCompute gradient of the kernel between features A and B using kernel k, with respect to the first argument (A). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradxy_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradxy_distance","text":"compute_gradxy_distance(A, B, d)\n\nCompute second-order cross derivative of the distance between features A and B using distance metric d. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradxy_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradxy_kernel","text":"compute_gradxy_kernel(A, B, k)\n\nCompute the second-order cross derivative of the kernel between features A and B using kernel k. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_grady_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_grady_distance","text":"compute_grady_distance(A, B, d)\n\nCompute gradient of the distance between features A and B using distance metric d, with respect to the second argument (B). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_grady_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_grady_kernel","text":"compute_grady_kernel(A, B, k)\n\nCompute gradient of the kernel between features A and B using kernel k, with respect to the second argument (B). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:Union{LinearAlgebra.Symmetric{<:Real, <:Matrix{<:Real}}, Vector{<:Real}}","page":"API","title":"PotentialLearning.compute_kernel","text":"compute_kernel(A, B, k)\n\nCompute similarity kernel between features A and B using kernel k. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.distance_matrix_kabsch-Tuple{DataSet}","page":"API","title":"PotentialLearning.distance_matrix_kabsch","text":"function distance_matrix_kabsch(\n ds::DataSet\n)\n\nCalculate a matrix of distances between atomic configurations using KABSCH method.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.distance_matrix_periodic-Tuple{DataSet}","page":"API","title":"PotentialLearning.distance_matrix_periodic","text":"function distance_matrix_periodic(\n ds::DataSet\n)\n\nCalculates a matrix of distances between atomic configurations taking into account the periodic boundaries.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, dr::DimensionReducer)\n\nFits a linear dimension reduction routine using information from DataSet. See individual types of DimensionReducers for specific details.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.fit-Tuple{DataSet, ActiveSubspace}","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, as::ActiveSubspace)\n\nFits a linear dimension reduction routine using the eigendirections of the uncentered covariance of the function ∇Q(c::Configuration) over the configurations in ds. Primarily used to reduce the dimension of the descriptors.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit-Tuple{DataSet, PCA}","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, pca::PCA)\n\nFits a linear dimension reduction routine using PCA on the global descriptors in the dataset ds. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit_transform-Tuple{DataSet, DimensionReducer}","page":"API","title":"PotentialLearning.fit_transform","text":"fit_transform(ds::DataSet, dr::DimensionReducer)\n\nFits a linear dimension reduction routine using information from DataSet and performs dimension reduction on descriptors and force_descriptors (whichever are available). See individual types of DimensionReducers for specific details.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.force-Tuple{Configuration, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.force","text":"function force( c::Configuration, bp::BasisPotential )\n\nc: atomic configuration. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.force-Tuple{Configuration, InteratomicPotentials.NNBasisPotential}","page":"API","title":"PotentialLearning.force","text":"function force( c::Configuration, nnbp::NNBasisPotential )\n\nc: atomic configuration. nnbp: neural network basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_energies-Tuple{DataSet, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.get_all_energies","text":"function get_all_energies(\n ds::DataSet,\n bp::BasisPotential\n)\n\nds: dataset. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_energies-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_all_energies","text":"function getallenergies( ds::DataSet )\n\nds: dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_forces-Tuple{DataSet, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.get_all_forces","text":"function getallforces( ds::DataSet, bp::BasisPotential )\n\nds: dataset. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_forces-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_all_forces","text":"function get_all_forces(\n ds::DataSet\n)\n\nds: dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_batches-NTuple{11, Any}","page":"API","title":"PotentialLearning.get_batches","text":"get_batches(n_batches, B_train, B_train_ext, e_train, dB_train, f_train,\n B_test, B_test_ext, e_test, dB_test, f_test)\n\nn_batches: no. of batches per dataset. B_train: descriptors of the energies used in training. B_train_ext: extendended descriptors of the energies used in training. Requiered to compute forces. e_train: energies used in training. dB_train: derivatives of the energy descritors used in training. f_train: forces used in training. B_test: descriptors of the energies used in test. B_test_ext: extendended descriptors of the energies used in test. Requiered to compute forces. e_test: energies used in test. dB_test: derivatives of the energy descritors used in test. f_test: forces used in test.\n\nReturns the data loaders for training and test of energies and forces.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_clusters-Tuple{Any, Any, Any}","page":"API","title":"PotentialLearning.get_clusters","text":"function get_clusters(\n ds,\n eps,\n minpts\n)\n\nComputes clusters from the configurations in ds using DBSCAN with parameters eps and minpts.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_dpp_mode-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_dpp_mode","text":"get_dpp_mode(dpp::kDPP, batch_size::Int) <: Vector{Int64}\n\nAccess an approximate mode of the k-DPP as calculated by a greedy subset algorithm. See Determinantal.jl for details.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_energy-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_energy","text":"get_energy(c::Configuration) <: Energy\n\nRetrieves the energy (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_force_descriptors-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_force_descriptors","text":"get_force_descriptors(c::Configuration) <: ForceDescriptors\n\nRetrieves the force descriptors (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_forces-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_forces","text":"get_forces(c::Configuration) <: Forces\n\nRetrieves the forces (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_inclusion_prob-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_inclusion_prob","text":"get_inclusion_prob(dpp::kDPP) <: Vector{Float64}\n\nAccess an approximation to the inclusion probabilities as calculated by Determinantal.jl (see package for details).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_input-Tuple{Any}","page":"API","title":"PotentialLearning.get_input","text":"get_input(args)\n\nargs: vector of arguments (strings)\n\nReturns an OrderedDict with the arguments. See https://github.com/cesmix-mit/AtomisticComposableWorkflows documentation for information about how to define the input arguments.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_local_descriptors-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_local_descriptors","text":"get_local_descriptors(c::Configuration) <: LocalDescriptors\n\nRetrieves the local descriptors (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-NTuple{11, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics( e_train_pred, e_train, f_train_pred, f_train,\n e_test_pred, e_test, f_test_pred, f_test,\n B_time, dB_time, time_fitting)\n\ne_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. f_train_pred: vector of predicted training force values. f_train: vector of true training force values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values. f_test_pred: vector of predicted test force values. f_test: vector of true test force values. B_time: elapsed time consumed by descriptors calculation. dB_time: elapsed time consumed by descriptor derivatives calculation. time_fitting: elapsed time consumed by fitting process.\n\nComputes MAE, RMSE, and RSQ for training and testing energies and forces. Also add elapsed times about descriptors and fitting calculations. Returns an OrderedDict with the information above.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-NTuple{4, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics( e_train_pred, e_train, e_test_pred, e_test)\n\ne_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values.\n\nComputes MAE, RMSE, and RSQ for training and testing energies. Returns an OrderedDict with the information above.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-Tuple{Any, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics(\n x_pred,\n x;\n metrics = [mae, rmse, rsq],\n label = \"x\"\n)\n\nx_pred: vector of predicted forces, x: vector of true forces. metrics: vector of metrics. label: label used as prefix in dictionary keys.\n\nReturns and OrderedDict with different metrics.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_positions-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_positions","text":"get_positions(c::Configuration) <: Vector{SVector}\n\nRetrieves the AtomsBase system positions (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_random_subset","page":"API","title":"PotentialLearning.get_random_subset","text":"function get_random_subset(\n s::DBSCANSelector,\n batch_size = s.sample_size\n)\n\nReturns a random subset of indexes composed of samples of size batch_size ÷ length(s.clusters) from each cluster in s.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.get_random_subset-2","page":"API","title":"PotentialLearning.get_random_subset","text":"get_random_subset(r::Random, batch_size :: Int) <: Vector{Int64}\n\nAccess a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.get_random_subset-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_random_subset","text":"get_random_subset(dpp::kDPP, batch_size :: Int) <: Vector{Int64}\n\nAccess a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_species-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_species","text":"function get_species( ds::DataSet )\n\nGet species from a dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_system-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_system","text":"get_system(c::Configuration) <: AtomsBase.AbstractSystem\n\nRetrieves the AtomsBase system (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_values-Tuple{Energy}","page":"API","title":"PotentialLearning.get_values","text":"get_values(e::Energy) <: Real\n\nGet the underlying real value (= e.d)\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_values-Tuple{StaticArraysCore.SVector}","page":"API","title":"PotentialLearning.get_values","text":"get_values(v::SVector)\n\nRemoves units from a position.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.hyperlearn!-Tuple{DataType, OrderedCollections.OrderedDict, DataSet}","page":"API","title":"PotentialLearning.hyperlearn!","text":"function hyperlearn!( model::DataType, pars::OrderedDict, conftrain::DataSet; nsamples = 5, sampler = RandomSampler(), loss = loss, ws = [1.0, 1.0], int = true )\n\nHyper-parameter optimization of linear interatomic potentials.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.hyperloss-Tuple{OrderedCollections.OrderedDict}","page":"API","title":"PotentialLearning.hyperloss","text":"function hyperloss( metrics::OrderedDict: we = 1.0, wf = 1.0, wt = 1.0E-3, emaemax = 0.05, fmae_max = 0.05 )\n\nmetrics: OrderedDict object with metrics of the fitting process. - Mean absolute error of energies: emae. - Mean absolute error of forces: fmae. - Time per force per atom: timeus. `we: energy weight.wf: force weight.wt: time weight.emaemax: maximum mean absolute error for energies.fmaemax`: maximum mean absolute error for forces.\n\nLoss function for hyper-parameter optimization: minimizes fitting error and time.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kabsch-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.kabsch","text":"function kabsch(\n reference::Array{Float64,2},\n coords::Array{Float64,2}\n)\n\nInput: two sets of points: reference, coords as Nx3 Matrices (so) Returns optimally rotated matrix \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kabsch_rmsd-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.kabsch_rmsd","text":"function kabsch_rmsd(\n P::Array{Float64,2},\n Q::Array{Float64,2}\n)\n\nDirectly return RMSD for matrices P, Q for convenience.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{InteratomicPotentials.LinearBasisPotential, DataSet, Vararg{Any}}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( iap::InteratomicPotentials.LinearBasisPotential, ds::DataSet, args... )\n\nLearning dispatch function, common to ordinary and weghted least squares implementations.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, α::Real )\n\nFit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)\n\nthrough an optimization procedure. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, SubsetSelector, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, ss::SubsetSelector, α::Real; num_steps=100, opt=Flux.Optimise.Adam() )\n\nFit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)\n\nthrough an iterative batch gradient descent optimization proceedure where the batches are provided by the subset selector. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, Vector, Bool}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, ws::Vector, int::Bool )\n\nFit energies and forces using weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LearningProblem, SubsetSelector}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LearningProblem, ss::SubsetSelector; num_steps = 100::Int, opt = Flux.Optimisers.Adam() )\n\nAttempts to fit the parameters lp.params in the learning problem lp using batch gradient descent with the optimizer opt and num_steps number of iterations. Batching is provided by the passed ss::SubsetSelector. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LearningProblem}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LearningProblem; num_steps=100::Int, opt=Flux.Optimisers.Adam() )\n\nAttempts to fit the parameters lp.params in the learning problem lp using gradient descent with the optimizer opt and num_steps number of iterations.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LinearProblem}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LinearProblem )\n\nDefault learning problem: weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, α::Real )\n\nFit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via SVD on the design matrix, A'*A (formed iteratively), where eigenvalues less than α are cut-off. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, SubsetSelector, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, ss::SubsetSelector, α::Real; num_steps = 100, opt = Flux.Optimise.Adam() )\n\nFit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via batched gradient descent with batches provided by the subset selector and the gradients are calculated using Flux. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, Vector, Bool}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, ws::Vector, int::Bool )\n\nFit energies using weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.linearize_forces-Tuple{Any}","page":"API","title":"PotentialLearning.linearize_forces","text":"linearize_forces(forces)\n\nforces: vector of forces per system\n\nReturns a vector with the components of the forces of the systems.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_data-Tuple{Any, ExtXYZ}","page":"API","title":"PotentialLearning.load_data","text":"load_data(file::string, extxyz::ExtXYZ)\nLoad configuration from an extxyz file into a DataSet\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_data-Tuple{String, YAML}","page":"API","title":"PotentialLearning.load_data","text":"load_data(file::string, yaml::YAML)\n\nLoad configurations from a yaml file into a Vector of Flexible Systems, with Energies and Force.\nReturns \n ds - DataSet\n t = Vector{Dict} (any miscellaneous info from yaml file)\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_datasets-Tuple{Any}","page":"API","title":"PotentialLearning.load_datasets","text":"load_datasets(input)\n\ninput: OrderedDict with input arguments. See get_defaults_args().\n\nReturns training and test systems, energies, forces, and stresses.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.mae-Tuple{Any, Any}","page":"API","title":"PotentialLearning.mae","text":"mae(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns mean absolute error.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.mean_cos-Tuple{Any, Any}","page":"API","title":"PotentialLearning.mean_cos","text":"mean_cos(x_pred, x)\n\nx_pred: vector of predicted forces, x: vector of true forces.\n\nReturns mean cosine.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.periodic_rmsd-Tuple{Matrix{Float64}, Matrix{Float64}, Vector{Float64}}","page":"API","title":"PotentialLearning.periodic_rmsd","text":"function periodic_rmsd(\n p1::Array{Float64,2},\n p2::Array{Float64,2},\n box_lengths::Array{Float64,1}\n)\n\nCalculates the RMSD between atom positions of two configurations taking into account the periodic boundaries.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.potential_energy-Tuple{Configuration, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.potential_energy","text":"function potential_energy( c::Configuration, bp::BasisPotential )\n\nc: atomic configuration. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.potential_energy-Tuple{Configuration, InteratomicPotentials.NNBasisPotential}","page":"API","title":"PotentialLearning.potential_energy","text":"function potential_energy( c::Configuration, nnbp::NNBasisPotential )\n\nc: atomic configuration. nnbp: neural network basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rmsd-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.rmsd","text":"function rmsd(\n A::Array{Float64,2},\n B::Array{Float64,2}\n)\n\nCalculate root mean square deviation of two matrices A, B. See http://en.wikipedia.org/wiki/Root-mean-squaredeviationofatomicpositions\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rmse-Tuple{Any, Any}","page":"API","title":"PotentialLearning.rmse","text":"rmse(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns mean root mean square error.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rsq-Tuple{Any, Any}","page":"API","title":"PotentialLearning.rsq","text":"rsq(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns R-squared.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.sample-Tuple{Any, Any}","page":"API","title":"PotentialLearning.sample","text":"function sample(\n c,\n batch_size\n)\n\nSelect from cluster c a sample of size batch_size.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.to_num-Tuple{Any}","page":"API","title":"PotentialLearning.to_num","text":"to_num(str)\n\nstr: string with a number: integer or float\n\nReturns an integer or float.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.translate_points-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.translate_points","text":"function translate_points(\n P::Array{Float64,2},\n Q::Array{Float64,2}\n)\n\nTranslate P, Q so centroids are equal to the origin of the coordinate system Translation der Massenzentren, so dass beide Zentren im Ursprung des Koordinatensystems liegen\n\n\n\n\n\n","category":"method"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"EditURL = \"../../../../examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl\"","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#Reduce-ACE-descriptors-with-PCA-and-fit-a-HfO2-dataset","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load packages.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Define paths.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/PCA-ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load utility functions.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Create experiment folder.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000] # Only first 1K samples are used in this example.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Split atomistic dataset into training and test.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#c.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"c. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Create ACE basis.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#d.-Dimension-reduction-of-energy-and-force-descriptors-of-training-dataset.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"d. Dimension reduction of energy and force descriptors of training dataset.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_desc = 20\npca = PCAState(tol = n_desc)\nfit!(ds_train, pca)\ntransform!(ds_train, pca)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], true\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Dimension reduction of energy and force descriptors of test dataset.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"transform!(ds_test, pca)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute training metrics.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute test metrics.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save energy results.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save force results.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Example 1 - Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"EditURL = \"../../../../examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl\"","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#Optimize-ACE-hyper-parameters:-minimize-force-time-and-fitting-error.","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load packages.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs\nusing DataFrames, Hyperopt","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define paths.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/Opt-ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load utility functions.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Create experiment folder.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000]","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#c.-Hyper-parameter-optimization.","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"c. Hyper-parameter optimization.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define a custom loss function. Here, we minimize fitting error and force calculation time. Possible metrics are e_mae, e_rmse, e_rsq, f_mae, f_rmse, f_rsq, and time_us.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"function custom_loss(\n metrics::OrderedDict\n)\n e_mae = metrics[:e_mae]\n f_mae = metrics[:f_mae]\n time_us = metrics[:time_us]\n e_mae_max = 0.05 # eV/atom\n f_mae_max = 0.05 # eV/Å\n w_e = e_mae/e_mae_max\n w_f = f_mae/f_mae_max\n w_t = 1.0E-3\n loss = w_e * e_mae + w_f * e_mae + w_t * time_us\n return loss\nend;\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define model and hyper-parameter value ranges to be optimized.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"model = ACE\npars = OrderedDict( :body_order => [2, 3, 4],\n :polynomial_degree => [3, 4, 5],\n :rcutoff => [4.5, 5.0, 5.5],\n :wL => [0.5, 1.0, 1.5],\n :csp => [0.5, 1.0, 1.5],\n :r0 => [0.5, 1.0, 1.5]);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Use random sampling to find the optimal hyper-parameters.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"iap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 10, sampler = RandomSampler(),\n loss = custom_loss, ws = [1.0, 1.0], int = true);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Save and show results.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"@save_var res_path iap.β\n@save_var res_path iap.β0\n@save_var res_path iap.basis\n@save_dataframe res_path res\nres","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Plot error vs time.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"err_time = plot_err_time(res)\n@save_fig res_path err_time\nDisplayAs.PNG(err_time)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Alternatively, use latin hypercube sampling to find the optimal hyper-parameters.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"iap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 3, sampler = LHSampler(),\n loss = custom_loss, ws = [1.0, 1.0], int = true);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Save and show results.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"@save_var res_path iap.β\n@save_var res_path iap.β0\n@save_var res_path iap.basis\n@save_dataframe res_path res\nres","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Plot error vs time.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"err_time = plot_err_time(res)\n@save_fig res_path err_time\nDisplayAs.PNG(err_time)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Example 1 - Optimize ACE hyper-parameters: minimize force time and fitting error","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"EditURL = \"../../../../examples/DPP-ACE-Na/fit-dpp-ace-na.jl\"","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#Subsample-Na-dataset-with-DPP-and-fit-energies-with-ACE","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit energies with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#a.-Load-packages-and-define-paths.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"a. Load packages and define paths.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"using Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing LinearAlgebra, Plots","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-Na\")\nds_path = \"$path/../data/Na/liquify_sodium.yaml\";\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.).","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"confs, thermo = load_data(ds_path, YAML(:Na, u\"eV\", u\"Å\"))\nconfs, thermo = confs[220:end], thermo[220:end]","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Split atomistic dataset into training and test.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"conf_train, conf_test = confs[1:1000], confs[1001:end]","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#c.-Create-ACE-basis,-compute-energy-descriptors-and-add-them-to-the-dataset.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"c. Create ACE basis, compute energy descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Create ACE basis.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"ace = ACE(species = [:Na], # species\n body_order = 4, # 4-body\n polynomial_degree = 8, # 8 degree polynomials\n wL = 1.0, # Defaults, See ACE.jl documentation\n csp = 1.0, # Defaults, See ACE.jl documentation\n r0 = 1.0, # minimum distance between atoms\n rcutoff = 5.0) # cutoff radius","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Update training dataset by adding energy (local) descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"println(\"Computing local descriptors of training dataset\")\ne_descr_train = compute_local_descriptors(conf_train, ace) # JLD.load(\"data/sodium_empirical_full.jld\", \"descriptors\")","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#d.-Subsampling-via-DPP.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"d. Subsampling via DPP.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Create DPP subselector.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"dpp = kDPP(ds_train, GlobalMean(), DotProduct(); batch_size = 200)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Subsample trainig dataset.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"dpp_inds = get_random_subset(dpp)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"lb = LBasisPotential(ace)\nα = 1e-8\nΣ = learn!(lb, ds_train[dpp_inds], α)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Update test dataset by adding energy descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"println(\"Computing local descriptors of test dataset\")\ne_descr_test = compute_local_descriptors(conf_test, ace)\nds_test = DataSet(conf_test .+ e_descr_test)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Get true and predicted energy values (assuming that all configurations have the same no. of atoms).","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"n = size(get_system(ds_train[1]))[1]\ne_train, e_train_pred = get_all_energies(ds_train)/n, get_all_energies(ds_train, lb)/n\ne_test, e_test_pred = get_all_energies(ds_test)/n, get_all_energies(ds_test, lb)/n","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Compute and print metrics.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"e_mae, e_rmse, e_rsq = calc_metrics(e_train, e_train_pred)\nprintln(\"MAE: $e_mae, RMSE: $e_rmse, RSQ: $e_rsq\")","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"Plot energy error.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"e_err_train, e_err_test = (e_train_pred - e_train), (e_test_pred - e_test)\ndpp_inds2 = get_random_subset(dpp; batch_size = 20)\np = scatter( e_train, e_err_train, label = \"Training\", color = :blue,\n markersize = 1.5, markerstrokewidth=0)\nscatter!(e_test, e_err_test, label = \"Test\", color = :yellow,\n markersize = 1.5, markerstrokewidth=0)\nscatter!(e_train[dpp_inds2], e_err_train[dpp_inds2],\n color = :darkred, label = \"DPP Samples\",\n markersize = 2.5, markerstrokewidth=0)\nscatter!(xlabel = \"Energy (eV/atom)\", ylabel = \"Error (eV/atom)\",\n dpi = 1000, fontsize = 16)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Example 2 - Subsample Na dataset with DPP and fit with ACE","title":"Example 2 - Subsample Na dataset with DPP and fit with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"EditURL = \"../../../../examples/LJ-Ar/lennard-jones-ar.jl\"","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#Load-Ar-dataset-with-energies-computed-by-Lennard-Jones-and-postprocess","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar dataset with energies computed by Lennard-Jones and postprocess","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/#a.-Load-packages-and-define-paths.","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"a. Load packages and define paths.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Load packages.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"using Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing LinearAlgebra, Plots, DisplayAs","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Define paths.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/LJ-Ar\")\nds_path = \"$path/../data/LJ-AR/lj-ar.yaml\";\nnothing #hide","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#b.-Load-atomistic-dataset.","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"b. Load atomistic dataset.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"ds, thermo = load_data(ds_path, YAML(:Ar, u\"eV\", u\"Å\"))\nds = @views ds[2:end] # Filter first configuration (zero energy)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#c.-Compute-distance-from-origin,-extract-LJ-energies,-and-define-time-range.","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"c. Compute distance from origin, extract LJ energies, and define time range.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Get atom positions and compute distance from origin.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"systems = get_system.(ds)\nn_atoms = length(first(systems)) # Note: in this dataset all systems contain the same no. of atoms\npositions = position.(systems)\ndists_origin = map(x->ustrip.(norm.(x)), positions)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Extract LJ energies from dataset.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"energies = get_values.(get_energy.(ds))","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Define time range.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"time_range = 0.5:0.5:5000","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#d.-Post-process-data.","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"d. Post-process data.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Plot distance from origin vs time.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"p = plot(xlabel = \"τ | ps\",\n ylabel = \"Distance from origin | Å\",\n dpi = 300, fontsize = 12)\nfor i = 1:n_atoms\n plot!(time_range, map(x->x[i], dists_origin), label=\"\")\nend\nDisplayAs.PNG(p)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"Plot LJ energies vs time.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"p = plot(time_range, energies,\n xlabel = \"τ | ps\",\n ylabel = \"Lennard Jones energy | eV\",\n dpi = 300, fontsize = 12)\nDisplayAs.PNG(p)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","title":"Example 1 - Load Ar+Lennard-Jones dataset and postprocess","text":"This page was generated using Literate.jl.","category":"page"},{"location":"#PotentialLearning.jl","page":"Home","title":"PotentialLearning.jl","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Optimize your atomistic data and interatomic potential models in your molecular dynamic workflows.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Reduce expensive ***Density functional theory*** calculations while maintaining training accuracy by intelligently subsampling your atomistic dataset:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Subsample your atomistic configurations using a Determinantal Point Process (DPP) based algorithm that compares energy descriptors computed with the Atomic Cluster Expansion (ACE).","category":"page"},{"location":"","page":"Home","title":"Home","text":"ds = DataSet(conf_train .+ e_descr)\ndataset_selector = kDPP(ds, GlobalMean(), DotProduct())\ninds = get_random_subset(dataset_selector)\nconf_train = @views conf_train[inds]","category":"page"},{"location":"","page":"Home","title":"Home","text":"Export the reduced dataset, use Density functional theory (DFT) on it, and fit your model.","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"We are working to provide different intelligent subsampling algorithms based on DPP, DBSCAN, and CUR; highly scalable parallel subsampling via hierarchical subsampling and distributed parallelism; and optimal subsampler selection.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Get fast and accurate interatomic potential models through parallel multi-objective hyper-parameter optimization:","category":"page"},{"location":"","page":"Home","title":"Home","text":"Define the interatomic potential model, hyper-parameter value ranges, and custom loss function. Then, optimize your model.","category":"page"},{"location":"","page":"Home","title":"Home","text":"model = ACE\npars = OrderedDict( :body_order => [2, 3, 4],\n :polynomial_degree => [3, 4, 5], ...)\nfunction custom_loss(metrics::OrderedDict)\n ...\n return w_e * e_mae + w_f * f_mae + w_t * time_us\nend\niap, res = hyperlearn!(model, pars, conf_train; loss = custom_loss);","category":"page"},{"location":"","page":"Home","title":"Home","text":"Export optimal values to your molecular dynamic workflow.","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"The models are compatible with the interfaces of our sister package InteratomicPotentials.jl. In particular, we are interested in maintaining compatibility with ACESuit, as well as integrating LAMMPS based potentials such as ML-POD and ML-PACE. We are also working to provide neural network potential architecture optimization.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Compress your interatomic potential data and model using dimensionality reduction of energy and force descriptors:","category":"page"},{"location":"","page":"Home","title":"Home","text":"pca = PCAState(tol = n_desc)\nfit!(ds_train, pca)\ntransform!(ds_train, pca)","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"We are working to provide feature selection of energy and force descriptors based on CUR.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Additionally, this package includes utilities for loading input data (such as XYZ files), computing various metrics (including MAE, MSE, RSQ, and COV), exporting results, and generating plots.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Acknowledgment: Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"EditURL = \"../../../../examples/DPP-ACE-Si/fit-dpp-ace-si.jl\"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#Subsample-Si-dataset-and-fit-with-ACE","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset and fit with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"using LinearAlgebra, Random, InvertedIndices\nusing Statistics, StatsBase, Distributions, Determinantal\nusing Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing CSV, JLD, DataFrames","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Define atomic type information.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"elname, elspec = \"Si\", [:Si]","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-Si\")\ninpath = \"$path/../data/Si-3Body-LAMMPS/\"\noutpath = \"$path/output/$elname/\"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load utility functions.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"include(\"$path/subsampling_utils.jl\")","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#b.-Load-atomistic-datasets.","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"b. Load atomistic datasets.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load all atomistic datasets: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"file_arr = readext(inpath, \"xyz\")\nnfile = length(file_arr)\nconfs_arr = [load_data(inpath*file, ExtXYZ(u\"eV\", u\"Å\")) for file in file_arr]\nconfs = concat_dataset(confs_arr)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Id of configurations per file.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"n = 0\nconfs_id = Vector{Vector{Int64}}(undef, nfile)\nfor k = 1:nfile\n global n\n confs_id[k] = (n+1):(n+length(confs_arr[k]))\n n += length(confs_arr[k])\nend","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#c.-Subsampling-by-DPP.","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"c. Subsampling by DPP.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Create ACE basis.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"nbody = 4\ndeg = 5\nace = ACE(species = elspec, # species\n body_order = nbody, # n-body\n polynomial_degree = deg, # degree of polynomials\n wL = 1.0, # Defaults, See ACE.jl documentation\n csp = 1.0, # Defaults, See ACE.jl documentation\n r0 = 1.0, # minimum distance between atoms\n rcutoff = 10.0)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Compute ACE descriptors for energies and forces.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"println(\"Computing local descriptors\")\ne_descr = compute_local_descriptors(confs, ace; pbar=false)\nf_descr = compute_force_descriptors(confs, ace; pbar=false)\nJLD.save(outpath*\"$(elname)_energy_descriptors.jld\", \"e_descr\", e_descr)\nJLD.save(outpath*\"$(elname)_force_descriptors.jld\", \"f_descr\", f_descr)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"ds = DataSet(confs .+ e_descr .+ f_descr)\nndata = length(ds)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#d.-Compute-cross-validation-error-from-training-dataset.","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"d. Compute cross validation error from training dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"batch_size = [80, 40]\nsel_ind = Dict{Int64, Vector}()\ncond_num = Dict{Int64, Vector}()\n\nfor bs in batch_size\n println(\"=============== Starting batch size $bs ===============\")\n sel_ind[bs], cond_num[bs] = cross_validation_training(ds; ndiv=5, dpp_batch=bs)\n println(\"condnum: $(cond_num[bs])\")\nend\n\nJLD.save(outpath*\"$(elname)_ACE-$(nbody)-$(deg)_DPP_indices_and_condnum.jld\",\n \"ind\", sel_ind,\n \"condnum\", cond_num)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Example 3 - Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"This page was generated using Literate.jl.","category":"page"},{"location":"how-to-run-the-examples/#How-to-run-the-examples","page":"How to run the examples","title":"How to run the examples","text":"","category":"section"},{"location":"how-to-run-the-examples/#Add-registries","page":"How to run the examples","title":"Add registries","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" pkg> registry add https://github.com/JuliaRegistries/General\n pkg> registry add https://github.com/cesmix-mit/CESMIX.git \n pkg> registry add https://github.com/JuliaMolSim/MolSim.git\n pkg> registry add https://github.com/ACEsuit/ACEregistry","category":"page"},{"location":"how-to-run-the-examples/#Clone-repository-and-access-an-example-folder","page":"How to run the examples","title":"Clone repository and access an example folder","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Clone PotentialLearning.jl repository in your working directory.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Access to any folder within PotentialLearning.jl/examples. E.g.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1","category":"page"},{"location":"how-to-run-the-examples/#Run-example","page":"How to run the examples","title":"Run example","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Open a Julia REPL, activate the examples folder project, and define the number of threads.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ julia --project=./ --threads=4","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Type ] to enter the Pkg REPL and instantiate.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" pkg> instantiate","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Finally, include the example file.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" julia> include(\"fit-dpp-ace-ahfo2.jl\")","category":"page"}] +[{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"EditURL = \"../../../../examples/ACE-aHfO2/fit-ace-ahfo2.jl\"","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#Fit-a-HfO2-dataset-with-ACE","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Fit a-HfO2 dataset with ACE","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Load packages.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Define paths.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Load utility functions.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Create experiment folder.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Fit a-HfO2 dataset with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000] # Only the first 1K samples are used in this example.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#c.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Fit a-HfO2 dataset with ACE","title":"c. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Create ACE basis","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#d.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Fit a-HfO2 dataset with ACE","title":"d. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], false\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/#e.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Fit a-HfO2 dataset with ACE","title":"e. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false);\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Compute training metrics.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Compute test metrics.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Plot and save energy results.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Plot and save force results.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"","category":"page"},{"location":"generated/ACE-aHfO2/fit-ace-ahfo2/","page":"Fit a-HfO2 dataset with ACE","title":"Fit a-HfO2 dataset with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"EditURL = \"../../../../examples/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2.jl\"","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#Subsample-a-HfO2-dataset-and-fit-with-ACE","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset and fit with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-aHfO2-1\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load utility functions.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create experiment folder.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"n_train, n_test = 100, 50 # Few samples per dataset are used in this example.\nconf_train, conf_test = split(ds[1:1000], n_train, n_test)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#c.-Subsampling","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"c. Subsampling","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energies as subsampling input.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 2,\n polynomial_degree = 3,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\ne_descr = compute_local_descriptors(conf_train,\n basis,\n pbar = false)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update subsampling dataset","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"conf_train_kDPP = DataSet(conf_train .+ e_descr)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create DPP subselector","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"dataset_selector = kDPP( conf_train_kDPP,\n GlobalMean(),\n DotProduct();\n batch_size = 50)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Subsample trainig dataset","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"inds = get_random_subset(dataset_selector)\nconf_train = @views conf_train[inds]","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#d.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"d. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Create ACE basis","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], false\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false);\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute training metrics.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Compute test metrics.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save energy results.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save force results.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"","category":"page"},{"location":"generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/","page":"Subsample a-HfO2 dataset with DPP and fit with ACE","title":"Subsample a-HfO2 dataset with DPP and fit with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"api/#API-Reference","page":"API","title":"API Reference","text":"","category":"section"},{"location":"api/","page":"API","title":"API","text":"This page provides a list of all documented types and functions and in PotentialLearning.jl.","category":"page"},{"location":"api/","page":"API","title":"API","text":"Modules = [PotentialLearning]\nOrder = [:type, :function, :constant]","category":"page"},{"location":"api/#PotentialLearning.ActiveSubspace","page":"API","title":"PotentialLearning.ActiveSubspace","text":"ActiveSubspace{T<:Real} <: DimensionReducer\n Q :: Function \n ∇Q :: Function (gradient of Q)\n tol :: T\n\nUse the theory of active subspaces, with a given quantity of interest (expressed as the function Q) which takes a Configuration as an input and outputs a real scalar. ∇Q should input a Configuration and output an appropriate gradient. If tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.AtomicData","page":"API","title":"PotentialLearning.AtomicData","text":"AtomicData <: Data\n\nAbstract type declaring the type of information that is unique to a particular atom (instead of a whole configuration).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Configuration-Tuple{Vararg{Union{ConfigurationData, AtomsBase.FlexibleSystem}}}","page":"API","title":"PotentialLearning.Configuration","text":"Configuration(data::Union{AtomsBase.FlexibleSystem, ConfigurationData} )\n\nA Configuration is a data struct that contains information unique to a particular configuration of atoms (Energy, LocalDescriptors, ForceDescriptors, and a FlexibleSystem) in a dictionary. Example: '''julia e = Energy(-0.57, u\"eV\") ld = LocalDescriptors(...) c = Configuration(e, ld) '''\n\nConfigurations can be added together, which merges the data dictionaries '''julia c1 = Configuration(e) # Contains energy c2 = Configuration(f) # contains forces c = c1 + c2 # c <: Configuration, contains energy and forces '''\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.ConfigurationData","page":"API","title":"PotentialLearning.ConfigurationData","text":"ConfigurationData <: Data\n\nAbstract type declaring the type of data that is unique to a particular configuration (instead of just an atom).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.CorrelationMatrix","page":"API","title":"PotentialLearning.CorrelationMatrix","text":"CorrelationMatrix \n α :: Vector{Float64} # weights\n\nCorrelationMatrix produces a global descriptor that is the correlation matrix of the local descriptors. In other words, it is mean(bi'*bi for bi in B). \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.CovariateLinearProblem","page":"API","title":"PotentialLearning.CovariateLinearProblem","text":"struct CovariateLinearProblem{T<:Real} <: LinearProblem{T} e::Vector f::Vector{Vector{T}} B::Vector{Vector{T}} dB::Vector{Matrix{T}} β::Vector{T} β0::Vector{T} σe::Vector{T} σf::Vector{T} Σ::Symmetric{T,Matrix{T}} end\n\nA CovariateLinearProblem is a linear problem in which we are fitting energies and forces using both descriptors and their gradients (B and dB, respectively). When this is the case, the solution is not available analytically and must be solved using some iterative optimization proceedure. In the end, we fit the model coefficients, β, standard deviations corresponding to energies and forces, σe and σf, and the covariance Σ. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DBSCANSelector","page":"API","title":"PotentialLearning.DBSCANSelector","text":"struct DBSCANSelector <: SubsetSelector\n clusters\n eps\n minpts\n sample_size\nend\n\nDefinition of the type DBSCANSelector, a subselector based on the clustering method DBSCAN.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DBSCANSelector-Tuple{DataSet, Any, Any, Any}","page":"API","title":"PotentialLearning.DBSCANSelector","text":"function DBSCANSelector(\n ds::DataSet,\n eps,\n minpts,\n sample_size\n)\n\nConstructor of DBSCANSelector based on the atomic configurations in ds, the DBSCAN params eps and minpts, and the sample size sample_size.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.Data","page":"API","title":"PotentialLearning.Data","text":"Data\n\nAbstract supertype of ConfigurationData.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DataBase","page":"API","title":"PotentialLearning.DataBase","text":"DataBase\n\nAbstract type for DataSets. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DataSet","page":"API","title":"PotentialLearning.DataSet","text":"DataSet\n\nStruct that holds vector of configuration. Most operations in PotentialLearning are built around the DataSet structure.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Distance","page":"API","title":"PotentialLearning.Distance","text":"Distance\n\nA struct of abstract type Distance produces the distance between two `global` descriptors, or features. Not all distances might be compatible with all types of features.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Divergence","page":"API","title":"PotentialLearning.Divergence","text":"Divergence\n\nA struct of abstract type Divergence produces a measure of discrepancy between two probability distributions. Discepancies may take as argument analytical distributions or sets of samples representing empirical distributions.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.DotProduct","page":"API","title":"PotentialLearning.DotProduct","text":"DotProduct <: Kernel \n α :: Power of DotProduct kernel \n\n\nComputes the dot product kernel between two features, i.e.,\n\ncos(θ) = ( A ⋅ B / (||A||^2||B||^2) )^α\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Energy","page":"API","title":"PotentialLearning.Energy","text":"Energy <: ConfigurationData\n d :: Real\n u :: Unitful.FreeUnits\n\nConvenience struct that holds energy information (and corresponding units). Default unit is eV\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Euclidean","page":"API","title":"PotentialLearning.Euclidean","text":"Euclidean <: Distance \n Cinv :: Covariance Matrix \n\nComputes the squared euclidean distance with weight matrix Cinv, the inverse of some covariance matrix.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ExtXYZ","page":"API","title":"PotentialLearning.ExtXYZ","text":"ExtXYZ <: IO\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Feature","page":"API","title":"PotentialLearning.Feature","text":"Feature\n\nA struct of abstract type Feature represents a function that takes in a set of local descriptors corresponding to some atomic environment and produce a global descriptor. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Force","page":"API","title":"PotentialLearning.Force","text":"Force <: AtomicData \n f :: Vector{<:Real}\n u :: Unitful.FreeUnits\n\nContains the force with (x,y,z)-components in f with units u. Default unit is \"eV/Å\". \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ForceDescriptor","page":"API","title":"PotentialLearning.ForceDescriptor","text":"ForceDescriptor <: AtomicData\n b :: Vector{<:Vector{<:Real}}\n\nContains the x,y,z components (out vector) of the force descriptor (inner vector).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.ForceDescriptors","page":"API","title":"PotentialLearning.ForceDescriptors","text":"ForceDescriptors <: ConfigurationData\n b :: Vector{ForceDescriptor}\n\nA container holding all of the ForceDescriptors for all atoms in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Forces","page":"API","title":"PotentialLearning.Forces","text":"Forces <: ConfigurationData\n f :: Vector{force}\n\nForces is a struct that contains all force information in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Forstner","page":"API","title":"PotentialLearning.Forstner","text":"Forstner <: Distance \n α :: Regularization parameter\n\nComputes the squared Forstner distance between two positive semi-definite matrices.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.GlobalMean","page":"API","title":"PotentialLearning.GlobalMean","text":" GlobalMean{T}\n\nGlobalMean produces the mean of the local descriptors.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.GlobalSum","page":"API","title":"PotentialLearning.GlobalSum","text":" GlobalSum{T}\n\nGlobalSum produces the sum of the local descriptors.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.InverseMultiquadric","page":"API","title":"PotentialLearning.InverseMultiquadric","text":"InverseMultiquadric <: Kernel \n d :: Distance function \n c2 :: Squared constant parameter\n ℓ :: Length-scale parameter\n\nComputes the inverse multiquadric (IMQ) kernel, i.e.,\n\n k(A, B) = (c^2 + d(A,B)/β^2)^{-1/2}\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.Kernel","page":"API","title":"PotentialLearning.Kernel","text":"Kernel\n\nA struct of abstract type Kernel is function that takes in two features and produces a semi-definite scalar representing the similarity between the two features.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.KernelSteinDiscrepancy","page":"API","title":"PotentialLearning.KernelSteinDiscrepancy","text":"KernelSteinDiscrepancy <: Divergence\n score :: Function\n knl :: Kernel\n\nComputes the kernel Stein discrepancy between distributions p (from which samples are provided) and q (for which the score is provided) based on the RKHS defined by kernel k.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LAMMPS","page":"API","title":"PotentialLearning.LAMMPS","text":"struct LAMMPS <: IO\n elements :: Vector{Symbol}\n boundary_conditions :: Vector\nend\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LearningProblem","page":"API","title":"PotentialLearning.LearningProblem","text":"struct LearningProblem{T<:Real} <: AbstractLearningProblem ds::DataSet logprob::Function ∇logprob::Function params::Vector{T} end\n\nGeneric LearningProblem that allows the user to pass a logprob(y::params, ds::DataSet) function and its gradient. The gradient should return a vector of logprob with respect to it's params. If the user does not have a gradient function available, then Flux can provide one for it (provided that logprob is of the form above).\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LearningProblem-Union{Tuple{T}, Tuple{DataSet, Function, Vector{T}}} where T","page":"API","title":"PotentialLearning.LearningProblem","text":"function LearningProblem( ds::DataSet, logprob::Function, params::Vector{T} ) where {T}\n\nGeneric LearningProblem construnctor.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.LinearProblem","page":"API","title":"PotentialLearning.LinearProblem","text":"abstract type LinearProblem{T<:Real} <: AbstractLearningProblem end\n\nAn abstract type to specify linear potential inference problems. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LinearProblem-Tuple{DataSet}","page":"API","title":"PotentialLearning.LinearProblem","text":"function LinearProblem( ds::DataSet; T = Float64 )\n\nConstruct a LinearProblem by detecting if there are energy descriptors and/or force descriptors and construct the appropriate LinearProblem (either Univariate, if only a single type of descriptor, or Covariate, if there are both types).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.LocalDescriptor","page":"API","title":"PotentialLearning.LocalDescriptor","text":"LocalDescriptor <: AtomicData\n\nA vector corresponding to the descriptor for a particular atom's neighborhood.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.LocalDescriptors","page":"API","title":"PotentialLearning.LocalDescriptors","text":"LocalDescriptors <: ConfigurationData\n\nA vector of LocalDescriptor, which now should represent all local descriptors for atoms in a configuration.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.PCA","page":"API","title":"PotentialLearning.PCA","text":"PCA <: DimensionReducer\n tol :: Float64\n\nUse SVD to compute the PCA of the design matrix of descriptors. (using Force descriptors TBA)\n\nIf tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.PCAState","page":"API","title":"PotentialLearning.PCAState","text":"PCAState <: DimensionReducer\n tol :: Float64\n\nUse SVD to compute the PCA of the design matrix of descriptors.\n\nIf tol is a float then the number of components to keep is determined by the smallest n such that relative percentage of variance explained by keeping the leading n principle components is greater than 1 - tol. If tol is an int, then we return the components corresponding to the tol largest eigenvalues.\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.RBF","page":"API","title":"PotentialLearning.RBF","text":"RBF <: Kernel \n d :: Distance function \n α :: Regularization parameter \n ℓ :: Length-scale parameter\n β :: Scale parameter\n\n\nComputes the squared exponential kernel, i.e.,\n\n k(A, B) = β \u001bxp( -\frac{1}{2} d(A,B)/ℓ^2 ) + α δ(A, B)\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.RandomSelector","page":"API","title":"PotentialLearning.RandomSelector","text":"struct Random\n num_configs :: Int \n batch_size :: Int \nend\n\nA convenience function that allows the user to randomly select indices uniformly over [1, num_configs]. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.UnivariateLinearProblem","page":"API","title":"PotentialLearning.UnivariateLinearProblem","text":"struct UnivariateLinearProblem{T<:Real} <: LinearProblem{T} ivdata::Vector dvdata::Vector β::Vector{T} β0::Vector{T} σ::Vector{T} Σ::Symmetric{T,Matrix{T}} end\n\nA UnivariateLinearProblem is a linear problem in which there is only 1 type of independent variable / dependent variable. Typically, that means we are either only fitting energies or only fitting forces. When this is the case, the solution is available analytically and the standard deviation, σ, and covariance, Σ, of the coefficients, β, are computable. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.YAML","page":"API","title":"PotentialLearning.YAML","text":"YAML <: IO\n energy_units :: Unitful.FreeUnits\n distance_units :: Unitful.FreeUnits\n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.kDPP","page":"API","title":"PotentialLearning.kDPP","text":"struct kDPP\n K :: EllEnsemble\nend\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a similarity kernel, for which the user must provide a LinearProblem and two functions to compute descriptor (1) diversity and (2) quality. \n\n\n\n\n\n","category":"type"},{"location":"api/#PotentialLearning.kDPP-Tuple{DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.kDPP","text":"kDPP(ds::Dataset, f::Feature, k::Kernel)\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantal.jl. All that is required to construct a kDPP is a dataset, a method to compute features, and a kernel. Optional arguments include batch size and type of descriptor (default LocalDescriptors).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kDPP-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.kDPP","text":"kDPP(features::Union{Vector{Vector{T}}, Vector{Symmetric{T, Matrix{T}}}}, k::Kernel)\n\nA convenience function that allows the user access to a k-Determinantal Point Process through Determinantaljl. All that is required to construct a kDPP are features (either a vector of vector features or a vector of symmetric matrix features) and a kernel. Optional argument is batch_size (default length(features)).\n\n\n\n\n\n","category":"method"},{"location":"api/#InteratomicPotentials.compute_force_descriptors-Tuple{DataSet, InteratomicPotentials.BasisSystem}","page":"API","title":"InteratomicPotentials.compute_force_descriptors","text":"function computeforcedescriptors( ds::DataSet, basis::BasisSystem; pbar = true )\n\nCompute force descriptors of a basis system and dataset using threads.\n\n\n\n\n\n","category":"method"},{"location":"api/#InteratomicPotentials.compute_local_descriptors-Tuple{DataSet, InteratomicPotentials.BasisSystem}","page":"API","title":"InteratomicPotentials.compute_local_descriptors","text":"function computelocaldescriptors( ds::DataSet, basis::BasisSystem; pbar = true )\n\nds: dataset. basis: basis system (e.g. ACE) pbar: progress bar\n\nCompute local descriptors of a basis system and dataset using threads.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Tuple{DataSet, DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(ds1::DataSet, ds2::DataSet, F::Feature, k::Kernel)\n\nCompute nonsymmetric kernel matrix K using features of the datasets ds1 and ds2 calculated using the Feature method F.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Tuple{DataSet, Feature, Kernel}","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(ds::DataSet, F::Feature, k::Kernel)\n\nCompute symmetric kernel matrix K using features of the dataset ds calculated using the Feature method F. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(F, k::Kernel)\n\nCompute symmetric kernel matrix K where K{ij} = k(Fi, F_j). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.KernelMatrix-Union{Tuple{T}, Tuple{Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Union{Array{Vector{T}, 1}, Array{LinearAlgebra.Symmetric{T, Matrix{T}}, 1}}, Kernel}} where T","page":"API","title":"PotentialLearning.KernelMatrix","text":"KernelMatrix(F1, F2, k::Kernel)\n\nCompute non-symmetric kernel matrix K where K{ij} = k(F1i, F2_j). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.calc_centroid-Tuple{Matrix{Float64}}","page":"API","title":"PotentialLearning.calc_centroid","text":"function calc_centroid(\n m::Array{Float64,2}\n)\n\nCalculate a centroid of a matrix.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.calc_metrics-Tuple{Any, Any}","page":"API","title":"PotentialLearning.calc_metrics","text":"calc_metrics(x_pred, x)\n\nx_pred: vector of predicted values of a variable. E.g. energy. x: vector of true values of a variable. E.g. energy.\n\nReturns MAE, RMSE, and RSQ.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_distance-Union{Tuple{T}, Tuple{Vector{T}, Vector{T}, Euclidean}} where T<:Real","page":"API","title":"PotentialLearning.compute_distance","text":"compute_distance(A, B, d)\n\nCompute the distance between features A and B using distance metric d. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_features-Tuple{DataSet, Feature}","page":"API","title":"PotentialLearning.compute_features","text":"compute_feature(ds::DataSet, f::Feature; dt = LocalDescriptors)\n\nComputes features of the dataset ds using the feature method F on descriptors dt (default option are the LocalDescriptors, if available).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradx_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradx_distance","text":"compute_gradx_distance(A, B, d)\n\nCompute gradient of the distance between features A and B using distance metric d, with respect to the first argument (A). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradx_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradx_kernel","text":"compute_gradx_kernel(A, B, k)\n\nCompute gradient of the kernel between features A and B using kernel k, with respect to the first argument (A). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradxy_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradxy_distance","text":"compute_gradxy_distance(A, B, d)\n\nCompute second-order cross derivative of the distance between features A and B using distance metric d. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_gradxy_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_gradxy_kernel","text":"compute_gradxy_kernel(A, B, k)\n\nCompute the second-order cross derivative of the kernel between features A and B using kernel k. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_grady_distance-Union{Tuple{T}, Tuple{T, T, Euclidean}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_grady_distance","text":"compute_grady_distance(A, B, d)\n\nCompute gradient of the distance between features A and B using distance metric d, with respect to the second argument (B). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_grady_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:(Vector{<:Real})","page":"API","title":"PotentialLearning.compute_grady_kernel","text":"compute_grady_kernel(A, B, k)\n\nCompute gradient of the kernel between features A and B using kernel k, with respect to the second argument (B). \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.compute_kernel-Union{Tuple{T}, Tuple{T, T, RBF}} where T<:Union{LinearAlgebra.Symmetric{<:Real, <:Matrix{<:Real}}, Vector{<:Real}}","page":"API","title":"PotentialLearning.compute_kernel","text":"compute_kernel(A, B, k)\n\nCompute similarity kernel between features A and B using kernel k. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.distance_matrix_kabsch-Tuple{DataSet}","page":"API","title":"PotentialLearning.distance_matrix_kabsch","text":"function distance_matrix_kabsch(\n ds::DataSet\n)\n\nCalculate a matrix of distances between atomic configurations using KABSCH method.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.distance_matrix_periodic-Tuple{DataSet}","page":"API","title":"PotentialLearning.distance_matrix_periodic","text":"function distance_matrix_periodic(\n ds::DataSet\n)\n\nCalculates a matrix of distances between atomic configurations taking into account the periodic boundaries.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, dr::DimensionReducer)\n\nFits a linear dimension reduction routine using information from DataSet. See individual types of DimensionReducers for specific details.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.fit-Tuple{DataSet, ActiveSubspace}","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, as::ActiveSubspace)\n\nFits a linear dimension reduction routine using the eigendirections of the uncentered covariance of the function ∇Q(c::Configuration) over the configurations in ds. Primarily used to reduce the dimension of the descriptors.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit-Tuple{DataSet, PCA}","page":"API","title":"PotentialLearning.fit","text":"fit(ds::DataSet, pca::PCA)\n\nFits a linear dimension reduction routine using PCA on the global descriptors in the dataset ds. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.fit_transform-Tuple{DataSet, DimensionReducer}","page":"API","title":"PotentialLearning.fit_transform","text":"fit_transform(ds::DataSet, dr::DimensionReducer)\n\nFits a linear dimension reduction routine using information from DataSet and performs dimension reduction on descriptors and force_descriptors (whichever are available). See individual types of DimensionReducers for specific details.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.force-Tuple{Configuration, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.force","text":"function force( c::Configuration, bp::BasisPotential )\n\nc: atomic configuration. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.force-Tuple{Configuration, InteratomicPotentials.NNBasisPotential}","page":"API","title":"PotentialLearning.force","text":"function force( c::Configuration, nnbp::NNBasisPotential )\n\nc: atomic configuration. nnbp: neural network basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_energies-Tuple{DataSet, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.get_all_energies","text":"function get_all_energies(\n ds::DataSet,\n bp::BasisPotential\n)\n\nds: dataset. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_energies-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_all_energies","text":"function getallenergies( ds::DataSet )\n\nds: dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_forces-Tuple{DataSet, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.get_all_forces","text":"function getallforces( ds::DataSet, bp::BasisPotential )\n\nds: dataset. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_all_forces-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_all_forces","text":"function get_all_forces(\n ds::DataSet\n)\n\nds: dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_batches-NTuple{11, Any}","page":"API","title":"PotentialLearning.get_batches","text":"get_batches(n_batches, B_train, B_train_ext, e_train, dB_train, f_train,\n B_test, B_test_ext, e_test, dB_test, f_test)\n\nn_batches: no. of batches per dataset. B_train: descriptors of the energies used in training. B_train_ext: extendended descriptors of the energies used in training. Requiered to compute forces. e_train: energies used in training. dB_train: derivatives of the energy descritors used in training. f_train: forces used in training. B_test: descriptors of the energies used in test. B_test_ext: extendended descriptors of the energies used in test. Requiered to compute forces. e_test: energies used in test. dB_test: derivatives of the energy descritors used in test. f_test: forces used in test.\n\nReturns the data loaders for training and test of energies and forces.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_clusters-Tuple{Any, Any, Any}","page":"API","title":"PotentialLearning.get_clusters","text":"function get_clusters(\n ds,\n eps,\n minpts\n)\n\nComputes clusters from the configurations in ds using DBSCAN with parameters eps and minpts.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_dpp_mode-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_dpp_mode","text":"get_dpp_mode(dpp::kDPP, batch_size::Int) <: Vector{Int64}\n\nAccess an approximate mode of the k-DPP as calculated by a greedy subset algorithm. See Determinantal.jl for details.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_energy-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_energy","text":"get_energy(c::Configuration) <: Energy\n\nRetrieves the energy (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_force_descriptors-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_force_descriptors","text":"get_force_descriptors(c::Configuration) <: ForceDescriptors\n\nRetrieves the force descriptors (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_forces-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_forces","text":"get_forces(c::Configuration) <: Forces\n\nRetrieves the forces (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_inclusion_prob-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_inclusion_prob","text":"get_inclusion_prob(dpp::kDPP) <: Vector{Float64}\n\nAccess an approximation to the inclusion probabilities as calculated by Determinantal.jl (see package for details).\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_input-Tuple{Any}","page":"API","title":"PotentialLearning.get_input","text":"get_input(args)\n\nargs: vector of arguments (strings)\n\nReturns an OrderedDict with the arguments. See https://github.com/cesmix-mit/AtomisticComposableWorkflows documentation for information about how to define the input arguments.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_local_descriptors-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_local_descriptors","text":"get_local_descriptors(c::Configuration) <: LocalDescriptors\n\nRetrieves the local descriptors (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-NTuple{11, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics( e_train_pred, e_train, f_train_pred, f_train,\n e_test_pred, e_test, f_test_pred, f_test,\n B_time, dB_time, time_fitting)\n\ne_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. f_train_pred: vector of predicted training force values. f_train: vector of true training force values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values. f_test_pred: vector of predicted test force values. f_test: vector of true test force values. B_time: elapsed time consumed by descriptors calculation. dB_time: elapsed time consumed by descriptor derivatives calculation. time_fitting: elapsed time consumed by fitting process.\n\nComputes MAE, RMSE, and RSQ for training and testing energies and forces. Also add elapsed times about descriptors and fitting calculations. Returns an OrderedDict with the information above.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-NTuple{4, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics( e_train_pred, e_train, e_test_pred, e_test)\n\ne_train_pred: vector of predicted training energy values. e_train: vector of true training energy values. e_test_pred: vector of predicted test energy values. e_test: vector of true test energy values.\n\nComputes MAE, RMSE, and RSQ for training and testing energies. Returns an OrderedDict with the information above.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_metrics-Tuple{Any, Any}","page":"API","title":"PotentialLearning.get_metrics","text":"get_metrics(\n x_pred,\n x;\n metrics = [mae, rmse, rsq],\n label = \"x\"\n)\n\nx_pred: vector of predicted forces, x: vector of true forces. metrics: vector of metrics. label: label used as prefix in dictionary keys.\n\nReturns and OrderedDict with different metrics.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_positions-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_positions","text":"get_positions(c::Configuration) <: Vector{SVector}\n\nRetrieves the AtomsBase system positions (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_random_subset","page":"API","title":"PotentialLearning.get_random_subset","text":"get_random_subset(r::Random, batch_size :: Int) <: Vector{Int64}\n\nAccess a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.get_random_subset-2","page":"API","title":"PotentialLearning.get_random_subset","text":"function get_random_subset(\n s::DBSCANSelector,\n batch_size = s.sample_size\n)\n\nReturns a random subset of indexes composed of samples of size batch_size ÷ length(s.clusters) from each cluster in s.\n\n\n\n\n\n","category":"function"},{"location":"api/#PotentialLearning.get_random_subset-Tuple{kDPP}","page":"API","title":"PotentialLearning.get_random_subset","text":"get_random_subset(dpp::kDPP, batch_size :: Int) <: Vector{Int64}\n\nAccess a random subset of the data as sampled from the provided k-DPP. Returns the indices of the random subset and the subset itself.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_species-Tuple{DataSet}","page":"API","title":"PotentialLearning.get_species","text":"function get_species( ds::DataSet )\n\nGet species from a dataset.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_system-Tuple{Configuration}","page":"API","title":"PotentialLearning.get_system","text":"get_system(c::Configuration) <: AtomsBase.AbstractSystem\n\nRetrieves the AtomsBase system (if available) in the Configuration c. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_values-Tuple{Energy}","page":"API","title":"PotentialLearning.get_values","text":"get_values(e::Energy) <: Real\n\nGet the underlying real value (= e.d)\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.get_values-Tuple{StaticArraysCore.SVector}","page":"API","title":"PotentialLearning.get_values","text":"get_values(v::SVector)\n\nRemoves units from a position.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.hyperlearn!-Tuple{DataType, OrderedCollections.OrderedDict, DataSet}","page":"API","title":"PotentialLearning.hyperlearn!","text":"function hyperlearn!( model::DataType, pars::OrderedDict, conftrain::DataSet; nsamples = 5, sampler = RandomSampler(), loss = loss, ws = [1.0, 1.0], int = true )\n\nHyper-parameter optimization of linear interatomic potentials.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.hyperloss-Tuple{OrderedCollections.OrderedDict}","page":"API","title":"PotentialLearning.hyperloss","text":"function hyperloss( metrics::OrderedDict: we = 1.0, wf = 1.0, wt = 1.0E-3, emaemax = 0.05, fmae_max = 0.05 )\n\nmetrics: OrderedDict object with metrics of the fitting process. - Mean absolute error of energies: emae. - Mean absolute error of forces: fmae. - Time per force per atom: timeus. `we: energy weight.wf: force weight.wt: time weight.emaemax: maximum mean absolute error for energies.fmaemax`: maximum mean absolute error for forces.\n\nLoss function for hyper-parameter optimization: minimizes fitting error and time.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kabsch-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.kabsch","text":"function kabsch(\n reference::Array{Float64,2},\n coords::Array{Float64,2}\n)\n\nInput: two sets of points: reference, coords as Nx3 Matrices (so) Returns optimally rotated matrix \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.kabsch_rmsd-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.kabsch_rmsd","text":"function kabsch_rmsd(\n P::Array{Float64,2},\n Q::Array{Float64,2}\n)\n\nDirectly return RMSD for matrices P, Q for convenience.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{InteratomicPotentials.LinearBasisPotential, DataSet, Vararg{Any}}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( iap::InteratomicPotentials.LinearBasisPotential, ds::DataSet, args... )\n\nLearning dispatch function, common to ordinary and weghted least squares implementations.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, α::Real )\n\nFit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)\n\nthrough an optimization procedure. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, SubsetSelector, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, ss::SubsetSelector, α::Real; num_steps=100, opt=Flux.Optimise.Adam() )\n\nFit a Gaussian distribution by finding the MLE of the following log probability: ℓ(β, σe, σf) = -0.5(e - A_e *β)'(e - Ae * β) / σe - 0.5*(f - Af β)'(f - A_f * β) / σf - log(σe) - log(σf)\n\nthrough an iterative batch gradient descent optimization proceedure where the batches are provided by the subset selector. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.CovariateLinearProblem, Vector, Bool}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::CovariateLinearProblem, ws::Vector, int::Bool )\n\nFit energies and forces using weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LearningProblem, SubsetSelector}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LearningProblem, ss::SubsetSelector; num_steps = 100::Int, opt = Flux.Optimisers.Adam() )\n\nAttempts to fit the parameters lp.params in the learning problem lp using batch gradient descent with the optimizer opt and num_steps number of iterations. Batching is provided by the passed ss::SubsetSelector. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LearningProblem}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LearningProblem; num_steps=100::Int, opt=Flux.Optimisers.Adam() )\n\nAttempts to fit the parameters lp.params in the learning problem lp using gradient descent with the optimizer opt and num_steps number of iterations.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.LinearProblem}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::LinearProblem )\n\nDefault learning problem: weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, α::Real )\n\nFit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via SVD on the design matrix, A'*A (formed iteratively), where eigenvalues less than α are cut-off. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, SubsetSelector, Real}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, ss::SubsetSelector, α::Real; num_steps = 100, opt = Flux.Optimise.Adam() )\n\nFit a univariate Gaussian distribution for the equation y = Aβ + ϵ, where β are model coefficients and ϵ ∼ N(0, σ). Fitting is done via batched gradient descent with batches provided by the subset selector and the gradients are calculated using Flux. \n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.learn!-Tuple{PotentialLearning.UnivariateLinearProblem, Vector, Bool}","page":"API","title":"PotentialLearning.learn!","text":"function learn!( lp::UnivariateLinearProblem, ws::Vector, int::Bool )\n\nFit energies using weighted least squares.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.linearize_forces-Tuple{Any}","page":"API","title":"PotentialLearning.linearize_forces","text":"linearize_forces(forces)\n\nforces: vector of forces per system\n\nReturns a vector with the components of the forces of the systems.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_data-Tuple{Any, ExtXYZ}","page":"API","title":"PotentialLearning.load_data","text":"load_data(file::string, extxyz::ExtXYZ)\nLoad configuration from an extxyz file into a DataSet\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_data-Tuple{String, YAML}","page":"API","title":"PotentialLearning.load_data","text":"load_data(file::string, yaml::YAML)\n\nLoad configurations from a yaml file into a Vector of Flexible Systems, with Energies and Force.\nReturns \n ds - DataSet\n t = Vector{Dict} (any miscellaneous info from yaml file)\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.load_datasets-Tuple{Any}","page":"API","title":"PotentialLearning.load_datasets","text":"load_datasets(input)\n\ninput: OrderedDict with input arguments. See get_defaults_args().\n\nReturns training and test systems, energies, forces, and stresses.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.mae-Tuple{Any, Any}","page":"API","title":"PotentialLearning.mae","text":"mae(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns mean absolute error.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.mean_cos-Tuple{Any, Any}","page":"API","title":"PotentialLearning.mean_cos","text":"mean_cos(x_pred, x)\n\nx_pred: vector of predicted forces, x: vector of true forces.\n\nReturns mean cosine.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.periodic_rmsd-Tuple{Matrix{Float64}, Matrix{Float64}, Vector{Float64}}","page":"API","title":"PotentialLearning.periodic_rmsd","text":"function periodic_rmsd(\n p1::Array{Float64,2},\n p2::Array{Float64,2},\n box_lengths::Array{Float64,1}\n)\n\nCalculates the RMSD between atom positions of two configurations taking into account the periodic boundaries.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.potential_energy-Tuple{Configuration, InteratomicPotentials.BasisPotential}","page":"API","title":"PotentialLearning.potential_energy","text":"function potential_energy( c::Configuration, bp::BasisPotential )\n\nc: atomic configuration. bp: basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.potential_energy-Tuple{Configuration, InteratomicPotentials.NNBasisPotential}","page":"API","title":"PotentialLearning.potential_energy","text":"function potential_energy( c::Configuration, nnbp::NNBasisPotential )\n\nc: atomic configuration. nnbp: neural network basis potential.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rmsd-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.rmsd","text":"function rmsd(\n A::Array{Float64,2},\n B::Array{Float64,2}\n)\n\nCalculate root mean square deviation of two matrices A, B. See http://en.wikipedia.org/wiki/Root-mean-squaredeviationofatomicpositions\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rmse-Tuple{Any, Any}","page":"API","title":"PotentialLearning.rmse","text":"rmse(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns mean root mean square error.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.rsq-Tuple{Any, Any}","page":"API","title":"PotentialLearning.rsq","text":"rsq(x_pred, x)\n\nx_pred: vector of predicted values. E.g. predicted energies. x: vector of true values. E.g. DFT energies.\n\nReturns R-squared.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.sample-Tuple{Any, Any}","page":"API","title":"PotentialLearning.sample","text":"function sample(\n c,\n batch_size\n)\n\nSelect from cluster c a sample of size batch_size.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.to_num-Tuple{Any}","page":"API","title":"PotentialLearning.to_num","text":"to_num(str)\n\nstr: string with a number: integer or float\n\nReturns an integer or float.\n\n\n\n\n\n","category":"method"},{"location":"api/#PotentialLearning.translate_points-Tuple{Matrix{Float64}, Matrix{Float64}}","page":"API","title":"PotentialLearning.translate_points","text":"function translate_points(\n P::Array{Float64,2},\n Q::Array{Float64,2}\n)\n\nTranslate P, Q so centroids are equal to the origin of the coordinate system Translation der Massenzentren, so dass beide Zentren im Ursprung des Koordinatensystems liegen\n\n\n\n\n\n","category":"method"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"EditURL = \"../../../../examples/PCA-ACE-aHfO2/fit-pca-ace-ahfo2.jl\"","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#Reduce-ACE-descriptors-with-PCA-and-fit-a-HfO2-dataset","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load packages.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Define paths.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/PCA-ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load utility functions.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Create experiment folder.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000] # Only first 1K samples are used in this example.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Split atomistic dataset into training and test.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#c.-Create-ACE-basis,-compute-descriptors-and-add-them-to-the-dataset.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"c. Create ACE basis, compute descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Create ACE basis.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"basis = ACE(species = [:Hf, :O],\n body_order = 3,\n polynomial_degree = 4,\n rcutoff = 5.0,\n wL = 1.0,\n csp = 1.0,\n r0 = 1.0)\n@save_var res_path basis;\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute ACE descriptors for energy and forces based on the atomistic training configurations.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Computing energy descriptors of training dataset...\")\ne_descr_train = compute_local_descriptors(conf_train, basis;\n pbar=false)\nprintln(\"Computing force descriptors of training dataset...\")\nf_descr_train = compute_force_descriptors(conf_train, basis;\n pbar=false)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds_train = DataSet(conf_train .+ e_descr_train .+ f_descr_train)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#d.-Dimension-reduction-of-energy-and-force-descriptors-of-training-dataset.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"d. Dimension reduction of energy and force descriptors of training dataset.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_desc = 20\npca = PCAState(tol = n_desc)\nfit!(ds_train, pca)\ntransform!(ds_train, pca)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Learning energies and forces...\")\nlb = LBasisPotential(basis)\nws, int = [1.0, 1.0], true\nlearn!(lb, ds_train, ws, int)\n@save_var res_path lb.β\n@save_var res_path lb.β0\nlb.β, lb.β0","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute ACE descriptors for energy and forces based on the atomistic test configurations.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"println(\"Computing energy descriptors of test dataset...\")\ne_descr_test = compute_local_descriptors(conf_test, basis;\n pbar = false)\nprintln(\"Computing force descriptors of test dataset...\")\nf_descr_test = compute_force_descriptors(conf_test, basis;\n pbar = false)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Update test dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"ds_test = DataSet(conf_test .+ e_descr_test .+ f_descr_test)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Dimension reduction of energy and force descriptors of test dataset.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"transform!(ds_test, pca)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Get true and predicted values for energies and forces.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"n_atoms_train = length.(get_system.(ds_train))\nn_atoms_test = length.(get_system.(ds_test))\n\ne_train, e_train_pred = get_all_energies(ds_train) ./ n_atoms_train,\n get_all_energies(ds_train, lb) ./ n_atoms_train\nf_train, f_train_pred = get_all_forces(ds_train),\n get_all_forces(ds_train, lb)\n@save_var res_path e_train\n@save_var res_path e_train_pred\n@save_var res_path f_train\n@save_var res_path f_train_pred\n\ne_test, e_test_pred = get_all_energies(ds_test) ./ n_atoms_test,\n get_all_energies(ds_test, lb) ./ n_atoms_test\nf_test, f_test_pred = get_all_forces(ds_test),\n get_all_forces(ds_test, lb)\n@save_var res_path e_test\n@save_var res_path e_test_pred\n@save_var res_path f_test\n@save_var res_path f_test_pred;\nnothing #hide","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute training metrics.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_train_metrics = get_metrics(e_train, e_train_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_train\")\nf_train_metrics = get_metrics(f_train, f_train_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_train\")\ntrain_metrics = merge(e_train_metrics, f_train_metrics)\n@save_dict res_path train_metrics\ntrain_metrics","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Compute test metrics.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_test_metrics = get_metrics(e_test, e_test_pred,\n metrics = [mae, rmse, rsq],\n label = \"e_test\")\nf_test_metrics = get_metrics(f_test, f_test_pred,\n metrics = [mae, rmse, rsq, mean_cos],\n label = \"f_test\")\ntest_metrics = merge(e_test_metrics, f_test_metrics)\n@save_dict res_path test_metrics\ntest_metrics","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save energy results.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_plot = plot_energy(e_train, e_train_pred,\n e_test, e_test_pred)\n@save_fig res_path e_plot\nDisplayAs.PNG(e_plot)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save force results.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"f_plot = plot_forces(f_train, f_train_pred,\n f_test, f_test_pred)\n@save_fig res_path f_plot\nDisplayAs.PNG(f_plot)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save training force cosine.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_train_plot = plot_energy(e_train, e_train_pred)\nf_train_plot = plot_forces(f_train, f_train_pred)\nf_train_cos = plot_cos(f_train, f_train_pred)\n@save_fig res_path e_train_plot\n@save_fig res_path f_train_plot\n@save_fig res_path f_train_cos\nDisplayAs.PNG(f_train_cos)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"Plot and save test force cosine.","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"e_test_plot = plot_energy(e_test, e_test_pred)\nf_test_plot = plot_forces(f_test, f_test_pred)\nf_test_cos = plot_cos(f_test, f_test_pred)\n@save_fig res_path e_test_plot\n@save_fig res_path f_test_plot\n@save_fig res_path f_test_cos\nDisplayAs.PNG(f_test_cos)","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"","category":"page"},{"location":"generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/","page":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","title":"Reduce ACE descriptors with PCA and fit a-HfO2 dataset","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"EditURL = \"../../../../examples/Opt-ACE-aHfO2/fit-opt-ace-ahfo2.jl\"","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#Optimize-ACE-hyper-parameters:-minimize-force-time-and-fitting-error.","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load packages.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"using AtomsBase, InteratomicPotentials, PotentialLearning\nusing Unitful, UnitfulAtomic\nusing LinearAlgebra, Random, DisplayAs\nusing DataFrames, Hyperopt","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define paths.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/Opt-ACE-aHfO2\")\nds_path = \"$path/../data/a-HfO2/a-HfO2-300K-NVT-6000.extxyz\"\nres_path = \"$path/results/\";\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load utility functions.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"include(\"$path/../utils/utils.jl\")","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Create experiment folder.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"run(`mkdir -p $res_path`);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"ds = load_data(ds_path, uparse(\"eV\"), uparse(\"Å\"))[1:1000]","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Split atomistic dataset into training and test","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"n_train, n_test = 50, 50 # Only 50 samples per dataset are used in this example.\nconf_train, conf_test = split(ds, n_train, n_test)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/#c.-Hyper-parameter-optimization.","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"c. Hyper-parameter optimization.","text":"","category":"section"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define a custom loss function. Here, we minimize fitting error and force calculation time. Possible metrics are e_mae, e_rmse, e_rsq, f_mae, f_rmse, f_rsq, and time_us.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"function custom_loss(\n metrics::OrderedDict\n)\n e_mae = metrics[:e_mae]\n f_mae = metrics[:f_mae]\n time_us = metrics[:time_us]\n e_mae_max = 0.05 # eV/atom\n f_mae_max = 0.05 # eV/Å\n w_e = e_mae/e_mae_max\n w_f = f_mae/f_mae_max\n w_t = 1.0E-3\n loss = w_e * e_mae + w_f * e_mae + w_t * time_us\n return loss\nend;\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Define model and hyper-parameter value ranges to be optimized.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"model = ACE\npars = OrderedDict( :body_order => [2, 3, 4],\n :polynomial_degree => [3, 4, 5],\n :rcutoff => [4.5, 5.0, 5.5],\n :wL => [0.5, 1.0, 1.5],\n :csp => [0.5, 1.0, 1.5],\n :r0 => [0.5, 1.0, 1.5]);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Use random sampling to find the optimal hyper-parameters.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"iap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 10, sampler = RandomSampler(),\n loss = custom_loss, ws = [1.0, 1.0], int = true);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Save and show results.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"@save_var res_path iap.β\n@save_var res_path iap.β0\n@save_var res_path iap.basis\n@save_dataframe res_path res\nres","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Plot error vs time.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"err_time = plot_err_time(res)\n@save_fig res_path err_time\nDisplayAs.PNG(err_time)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Alternatively, use latin hypercube sampling to find the optimal hyper-parameters.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"iap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 3, sampler = LHSampler(),\n loss = custom_loss, ws = [1.0, 1.0], int = true);\nnothing #hide","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Save and show results.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"@save_var res_path iap.β\n@save_var res_path iap.β0\n@save_var res_path iap.basis\n@save_dataframe res_path res\nres","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"Plot error vs time.","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"err_time = plot_err_time(res)\n@save_fig res_path err_time\nDisplayAs.PNG(err_time)","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"","category":"page"},{"location":"generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/","page":"Optimize ACE hyper-parameters: minimize force time and fitting error","title":"Optimize ACE hyper-parameters: minimize force time and fitting error","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"EditURL = \"../../../../examples/DPP-ACE-Na/fit-dpp-ace-na.jl\"","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#Subsample-Na-dataset-with-DPP-and-fit-energies-with-ACE","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit energies with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#a.-Load-packages-and-define-paths.","page":"Subsample Na dataset with DPP and fit with ACE","title":"a. Load packages and define paths.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"using Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing LinearAlgebra, Plots","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-Na\")\nds_path = \"$path/../data/Na/liquify_sodium.yaml\";\nnothing #hide","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#b.-Load-atomistic-dataset-and-split-it-into-training-and-test.","page":"Subsample Na dataset with DPP and fit with ACE","title":"b. Load atomistic dataset and split it into training and test.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Load atomistic dataset: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.).","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"confs, thermo = load_data(ds_path, YAML(:Na, u\"eV\", u\"Å\"))\nconfs, thermo = confs[220:end], thermo[220:end]","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Split atomistic dataset into training and test.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"conf_train, conf_test = confs[1:1000], confs[1001:end]","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#c.-Create-ACE-basis,-compute-energy-descriptors-and-add-them-to-the-dataset.","page":"Subsample Na dataset with DPP and fit with ACE","title":"c. Create ACE basis, compute energy descriptors and add them to the dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Create ACE basis.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"ace = ACE(species = [:Na], # species\n body_order = 4, # 4-body\n polynomial_degree = 8, # 8 degree polynomials\n wL = 1.0, # Defaults, See ACE.jl documentation\n csp = 1.0, # Defaults, See ACE.jl documentation\n r0 = 1.0, # minimum distance between atoms\n rcutoff = 5.0) # cutoff radius","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Update training dataset by adding energy (local) descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"println(\"Computing local descriptors of training dataset\")\ne_descr_train = compute_local_descriptors(conf_train, ace) # JLD.load(\"data/sodium_empirical_full.jld\", \"descriptors\")","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"ds_train = DataSet(conf_train .+ e_descr_train)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#d.-Subsampling-via-DPP.","page":"Subsample Na dataset with DPP and fit with ACE","title":"d. Subsampling via DPP.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Create DPP subselector.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"dpp = kDPP(ds_train, GlobalMean(), DotProduct(); batch_size = 200)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Subsample trainig dataset.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"dpp_inds = get_random_subset(dpp)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#e.-Learn-ACE-coefficients-based-on-ACE-descriptors-and-DFT-data.","page":"Subsample Na dataset with DPP and fit with ACE","title":"e. Learn ACE coefficients based on ACE descriptors and DFT data.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"lb = LBasisPotential(ace)\nα = 1e-8\nΣ = learn!(lb, ds_train[dpp_inds], α)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/#f.-Post-process-output:-calculate-metrics,-create-plots,-and-save-results.","page":"Subsample Na dataset with DPP and fit with ACE","title":"f. Post-process output: calculate metrics, create plots, and save results.","text":"","category":"section"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Update test dataset by adding energy descriptors.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"println(\"Computing local descriptors of test dataset\")\ne_descr_test = compute_local_descriptors(conf_test, ace)\nds_test = DataSet(conf_test .+ e_descr_test)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Get true and predicted energy values (assuming that all configurations have the same no. of atoms).","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"n = size(get_system(ds_train[1]))[1]\ne_train, e_train_pred = get_all_energies(ds_train)/n, get_all_energies(ds_train, lb)/n\ne_test, e_test_pred = get_all_energies(ds_test)/n, get_all_energies(ds_test, lb)/n","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Compute and print metrics.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"e_mae, e_rmse, e_rsq = calc_metrics(e_train, e_train_pred)\nprintln(\"MAE: $e_mae, RMSE: $e_rmse, RSQ: $e_rsq\")","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"Plot energy error.","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"e_err_train, e_err_test = (e_train_pred - e_train), (e_test_pred - e_test)\ndpp_inds2 = get_random_subset(dpp; batch_size = 20)\np = scatter( e_train, e_err_train, label = \"Training\", color = :blue,\n markersize = 1.5, markerstrokewidth=0)\nscatter!(e_test, e_err_test, label = \"Test\", color = :yellow,\n markersize = 1.5, markerstrokewidth=0)\nscatter!(e_train[dpp_inds2], e_err_train[dpp_inds2],\n color = :darkred, label = \"DPP Samples\",\n markersize = 2.5, markerstrokewidth=0)\nscatter!(xlabel = \"Energy (eV/atom)\", ylabel = \"Error (eV/atom)\",\n dpi = 1000, fontsize = 16)","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"","category":"page"},{"location":"generated/DPP-ACE-Na/fit-dpp-ace-na/","page":"Subsample Na dataset with DPP and fit with ACE","title":"Subsample Na dataset with DPP and fit with ACE","text":"This page was generated using Literate.jl.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"EditURL = \"../../../../examples/LJ-Ar/lennard-jones-ar.jl\"","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#Load-Ar-dataset-with-energies-computed-by-Lennard-Jones-and-postprocess","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar dataset with energies computed by Lennard-Jones and postprocess","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/#a.-Load-packages-and-define-paths.","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"a. Load packages and define paths.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Load packages.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"using Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing LinearAlgebra, Plots, DisplayAs","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Define paths.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/LJ-Ar\")\nds_path = \"$path/../data/LJ-AR/lj-ar.yaml\";\nnothing #hide","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#b.-Load-atomistic-dataset.","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"b. Load atomistic dataset.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"ds, thermo = load_data(ds_path, YAML(:Ar, u\"eV\", u\"Å\"))\nds = @views ds[2:end] # Filter first configuration (zero energy)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#c.-Compute-distance-from-origin,-extract-LJ-energies,-and-define-time-range.","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"c. Compute distance from origin, extract LJ energies, and define time range.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Get atom positions and compute distance from origin.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"systems = get_system.(ds)\nn_atoms = length(first(systems)) # Note: in this dataset all systems contain the same no. of atoms\npositions = position.(systems)\ndists_origin = map(x->ustrip.(norm.(x)), positions)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Extract LJ energies from dataset.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"energies = get_values.(get_energy.(ds))","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Define time range.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"time_range = 0.5:0.5:5000","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/#d.-Post-process-data.","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"d. Post-process data.","text":"","category":"section"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Plot distance from origin vs time.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"p = plot(xlabel = \"τ | ps\",\n ylabel = \"Distance from origin | Å\",\n dpi = 300, fontsize = 12)\nfor i = 1:n_atoms\n plot!(time_range, map(x->x[i], dists_origin), label=\"\")\nend\nDisplayAs.PNG(p)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"Plot LJ energies vs time.","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"p = plot(time_range, energies,\n xlabel = \"τ | ps\",\n ylabel = \"Lennard Jones energy | eV\",\n dpi = 300, fontsize = 12)\nDisplayAs.PNG(p)","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"","category":"page"},{"location":"generated/LJ-Ar/lennard-jones-ar/","page":"Load Ar+Lennard-Jones dataset and postprocess","title":"Load Ar+Lennard-Jones dataset and postprocess","text":"This page was generated using Literate.jl.","category":"page"},{"location":"#PotentialLearning.jl","page":"Home","title":"PotentialLearning.jl","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Optimize your atomistic data and interatomic potential models in your molecular dynamic workflows.","category":"page"},{"location":"#Reduce-expensive-Density-functional-theory-calculations","page":"Home","title":"Reduce expensive Density functional theory calculations","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Reduce expensive Density functional theory calculations while maintaining training accuracy by intelligently subsampling your atomistic dataset:","category":"page"},{"location":"","page":"Home","title":"Home","text":"1 - Subsample your atomistic configurations using a Determinantal Point Process (DPP) based algorithm that compares energy descriptors computed with the Atomic Cluster Expansion (ACE).","category":"page"},{"location":"","page":"Home","title":"Home","text":"ds = DataSet(conf_train .+ e_descr)\ndataset_selector = kDPP(ds, GlobalMean(), DotProduct())\ninds = get_random_subset(dataset_selector)\nconf_train = @views conf_train[inds]","category":"page"},{"location":"","page":"Home","title":"Home","text":"2 - Export the reduced dataset, use Density functional theory (DFT) on it, and fit your model.","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"We are working to provide different intelligent subsampling algorithms based on DPP, DBSCAN, and CUR; highly scalable parallel subsampling via hierarchical subsampling and distributed parallelism; and optimal subsampler selection.","category":"page"},{"location":"#Get-fast-and-accurate-interatomic-potential-models","page":"Home","title":"Get fast and accurate interatomic potential models","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Get fast and accurate interatomic potential models through parallel multi-objective hyper-parameter optimization:","category":"page"},{"location":"","page":"Home","title":"Home","text":"1 - Define the interatomic potential model, hyper-parameter value ranges, and custom loss function. Then, optimize your model.","category":"page"},{"location":"","page":"Home","title":"Home","text":"model = ACE\npars = OrderedDict( :body_order => [2, 3, 4],\n :polynomial_degree => [3, 4, 5], ...)\nfunction custom_loss(metrics::OrderedDict)\n ...\n return w_e * e_mae + w_f * f_mae + w_t * time_us\nend\niap, res = hyperlearn!(model, pars, conf_train; loss = custom_loss);","category":"page"},{"location":"","page":"Home","title":"Home","text":"2 - Export optimal values to your molecular dynamic workflow.","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"The models are compatible with the interfaces of our sister package InteratomicPotentials.jl. In particular, we are interested in maintaining compatibility with ACESuit, as well as integrating LAMMPS based potentials such as ML-POD and ML-PACE. We are also working to provide neural network potential architecture optimization.","category":"page"},{"location":"#Compress-your-interatomic-potential-data-and-model","page":"Home","title":"Compress your interatomic potential data and model","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Compress your interatomic potential data and model using dimensionality reduction of energy and force descriptors:","category":"page"},{"location":"","page":"Home","title":"Home","text":"1 - Define a PCA state, fit PCA with your the energy and force descriptors of your dataset, and transform all dataset descriptors.","category":"page"},{"location":"","page":"Home","title":"Home","text":"pca = PCAState(tol = n_desc)\nfit!(ds_train, pca)\ntransform!(ds_train, pca)","category":"page"},{"location":"","page":"Home","title":"Home","text":"2 - Export PCA fitted data to be used in your workflow.","category":"page"},{"location":"","page":"Home","title":"Home","text":"See example.","category":"page"},{"location":"","page":"Home","title":"Home","text":"We are working to provide feature selection of energy and force descriptors based on CUR.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Additionally, this package includes utilities for loading input data (such as XYZ files), computing various metrics (including MAE, MSE, RSQ, and COV), exporting results, and generating plots.","category":"page"},{"location":"","page":"Home","title":"Home","text":"Acknowledgment: Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"EditURL = \"../../../../examples/DPP-ACE-Si/fit-dpp-ace-si.jl\"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#Subsample-Si-dataset-and-fit-with-ACE","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset and fit with ACE","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#a.-Load-packages,-define-paths,-and-create-experiment-folder.","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"a. Load packages, define paths, and create experiment folder.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load packages.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"using LinearAlgebra, Random, InvertedIndices\nusing Statistics, StatsBase, Distributions, Determinantal\nusing Unitful, UnitfulAtomic\nusing AtomsBase, InteratomicPotentials, PotentialLearning\nusing CSV, JLD, DataFrames","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Define atomic type information.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"elname, elspec = \"Si\", [:Si]","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Define paths.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"path = joinpath(dirname(pathof(PotentialLearning)), \"../examples/DPP-ACE-Si\")\ninpath = \"$path/../data/Si-3Body-LAMMPS/\"\noutpath = \"$path/output/$elname/\"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load utility functions.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"include(\"$path/subsampling_utils.jl\")","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#b.-Load-atomistic-datasets.","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"b. Load atomistic datasets.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Load all atomistic datasets: atomistic configurations (atom positions, geometry, etc.) + DFT data (energies, forces, etc.)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"file_arr = readext(inpath, \"xyz\")\nnfile = length(file_arr)\nconfs_arr = [load_data(inpath*file, ExtXYZ(u\"eV\", u\"Å\")) for file in file_arr]\nconfs = concat_dataset(confs_arr)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Id of configurations per file.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"n = 0\nconfs_id = Vector{Vector{Int64}}(undef, nfile)\nfor k = 1:nfile\n global n\n confs_id[k] = (n+1):(n+length(confs_arr[k]))\n n += length(confs_arr[k])\nend","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#c.-Subsampling-by-DPP.","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"c. Subsampling by DPP.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Create ACE basis.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"nbody = 4\ndeg = 5\nace = ACE(species = elspec, # species\n body_order = nbody, # n-body\n polynomial_degree = deg, # degree of polynomials\n wL = 1.0, # Defaults, See ACE.jl documentation\n csp = 1.0, # Defaults, See ACE.jl documentation\n r0 = 1.0, # minimum distance between atoms\n rcutoff = 10.0)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Compute ACE descriptors for energies and forces.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"println(\"Computing local descriptors\")\ne_descr = compute_local_descriptors(confs, ace; pbar=false)\nf_descr = compute_force_descriptors(confs, ace; pbar=false)\nJLD.save(outpath*\"$(elname)_energy_descriptors.jld\", \"e_descr\", e_descr)\nJLD.save(outpath*\"$(elname)_force_descriptors.jld\", \"f_descr\", f_descr)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"Update training dataset by adding energy and force descriptors.","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"ds = DataSet(confs .+ e_descr .+ f_descr)\nndata = length(ds)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/#d.-Compute-cross-validation-error-from-training-dataset.","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"d. Compute cross validation error from training dataset.","text":"","category":"section"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"batch_size = [80, 40]\nsel_ind = Dict{Int64, Vector}()\ncond_num = Dict{Int64, Vector}()\n\nfor bs in batch_size\n println(\"=============== Starting batch size $bs ===============\")\n sel_ind[bs], cond_num[bs] = cross_validation_training(ds; ndiv=5, dpp_batch=bs)\n println(\"condnum: $(cond_num[bs])\")\nend\n\nJLD.save(outpath*\"$(elname)_ACE-$(nbody)-$(deg)_DPP_indices_and_condnum.jld\",\n \"ind\", sel_ind,\n \"condnum\", cond_num)","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"","category":"page"},{"location":"generated/DPP-ACE-Si/fit-dpp-ace-si/","page":"Subsample Si dataset with DPP, fit with ACE, and cross validate","title":"Subsample Si dataset with DPP, fit with ACE, and cross validate","text":"This page was generated using Literate.jl.","category":"page"},{"location":"how-to-run-the-examples/#How-to-run-the-examples","page":"How to run the examples","title":"How to run the examples","text":"","category":"section"},{"location":"how-to-run-the-examples/#Add-registries","page":"How to run the examples","title":"Add registries","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" pkg> registry add https://github.com/JuliaRegistries/General\n pkg> registry add https://github.com/cesmix-mit/CESMIX.git \n pkg> registry add https://github.com/JuliaMolSim/MolSim.git\n pkg> registry add https://github.com/ACEsuit/ACEregistry","category":"page"},{"location":"how-to-run-the-examples/#Clone-repository-and-access-an-example-folder","page":"How to run the examples","title":"Clone repository and access an example folder","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Clone PotentialLearning.jl repository in your working directory.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Access to any folder within PotentialLearning.jl/examples. E.g.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1","category":"page"},{"location":"how-to-run-the-examples/#Run-example","page":"How to run the examples","title":"Run example","text":"","category":"section"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Open a Julia REPL, activate the examples folder project, and define the number of threads.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" $ julia --project=./ --threads=4","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Type ] to enter the Pkg REPL and instantiate.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" pkg> instantiate","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":"Finally, include the example file.","category":"page"},{"location":"how-to-run-the-examples/","page":"How to run the examples","title":"How to run the examples","text":" julia> include(\"fit-dpp-ace-ahfo2.jl\")","category":"page"}] }