diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index e2eca53..cef4c51 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-09T18:38:10","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-12T23:11:36","documenter_version":"1.5.0"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 1fcb7fa..733a943 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -2,59 +2,59 @@ 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/dev/generated/ACE-aHfO2/fit-ace-ahfo2/21eec00f.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/21eec00f.png deleted file mode 100644 index bfbdec1..0000000 Binary files a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/21eec00f.png and /dev/null differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/2d379fdf.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/2d379fdf.png new file mode 100644 index 0000000..fb733cc Binary files /dev/null and b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/2d379fdf.png differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/35bbb441.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/35bbb441.png new file mode 100644 index 0000000..01ca1b1 Binary files /dev/null and b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/35bbb441.png differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/714cc9de.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/714cc9de.png deleted file mode 100644 index db34d59..0000000 Binary files a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/714cc9de.png and /dev/null differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ab5762e7.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ab5762e7.png new file mode 100644 index 0000000..b7f49c4 Binary files /dev/null and b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ab5762e7.png differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ca738572.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ca738572.png deleted file mode 100644 index 354afaa..0000000 Binary files a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/ca738572.png and /dev/null differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/d041fab7.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/d041fab7.png deleted file mode 100644 index ae50d84..0000000 Binary files a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/d041fab7.png and /dev/null differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/e6194570.png b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/e6194570.png new file mode 100644 index 0000000..b38e547 Binary files /dev/null and b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/e6194570.png differ diff --git a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/index.html b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/index.html index 3fbe6c2..0d92c07 100644 --- a/dev/generated/ACE-aHfO2/fit-ace-ahfo2/index.html +++ b/dev/generated/ACE-aHfO2/fit-ace-ahfo2/index.html @@ -4,19 +4,19 @@ 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}})

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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

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

println("Learning energies and forces...")
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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
([600.3983425339813, 329.49215057283527, 130.74099045465934, 26.268292741423185, 25527.41449734473, -13301.45017392622, 1120.7253600560857, -1447.9995933627113, 14515.35142440713, 7804.459985115604  …  164.3515708272935, 72.17177727679888, -8187.96609986972, -1793.1300246860817, 169.81968680031184, 896849.2302425556, 461006.7650720512, 21614.374004015463, -1050.8894625174562, 21147.05105260103], [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
([935.1922100782394, 516.2353143692017, 194.432645753026, 36.293012926355004, 132.80457928217947, 40.446567623643205, -17.027840073686093, -3.5536588956674677, 9724.627040863037, 5452.09805393219  …  136.49581743776798, 69.32848966121674, -1598.7716445922852, -542.0906848907471, 182.590646982193, -1613.399266242981, 3014.188949584961, 3762.494960784912, -1017.2705097198486, -1011.9801664352417], [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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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.00169863
-  "e_train_rmse"     => 0.00216933
-  "e_train_rsq"      => 0.634997
-  "f_train_mae"      => 0.171197
-  "f_train_rmse"     => 0.219348
-  "f_train_rsq"      => 0.851275
-  "f_train_mean_cos" => 0.893329

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.00220954
+  "e_train_rmse"     => 0.00246949
+  "e_train_rsq"      => 0.461244
+  "f_train_mae"      => 0.171937
+  "f_train_rmse"     => 0.219498
+  "f_train_rsq"      => 0.851422
+  "f_train_mean_cos" => 0.895849

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.00090899
-  "e_test_rmse"     => 0.00112668
-  "e_test_rsq"      => 0.879291
-  "f_test_mae"      => 0.174108
-  "f_test_rmse"     => 0.219266
-  "f_test_rsq"      => 0.845349
-  "f_test_mean_cos" => 0.887112

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.000848423
+  "e_test_rmse"     => 0.00102783
+  "e_test_rsq"      => 0.911892
+  "f_test_mae"      => 0.174895
+  "f_test_rmse"     => 0.221039
+  "f_test_rsq"      => 0.844741
+  "f_test_mean_cos" => 0.88737

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/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/0c88da81.svg b/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/0c88da81.svg deleted file mode 100644 index a9625c8..0000000 --- a/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/0c88da81.svg +++ /dev/null @@ -1,2161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/c7105f49.svg b/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/c7105f49.svg new file mode 100644 index 0000000..39016b3 --- /dev/null +++ b/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/c7105f49.svg @@ -0,0 +1,2155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html b/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html index 97d9da6..5756e1e 100644 --- a/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html +++ b/dev/generated/DPP-ACE-Na/fit-dpp-ace-na/index.html @@ -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}([6.90774149787383e-310, 6.90764357451183e-310, 6.9077414978102e-310, 1.9364916731037085, 6.9076435745561e-310, 6.9076435745577e-310, 1.9720265943665387, 2.091650066335189, 6.9077414978102e-310, 6.90764357456717e-310  …  9.0e-323, 6.0e-323, 1.9948914348241344, 2.0155644370746373, 2.0816659994661326, 2.207940216581962, 2.4308621740219887, 2.850438562747845, 1.73e-322, 1.3e-322], [6.90773387591046e-310, 6.9077304506909e-310, 6.9076291760318e-310, -0.5773502691896257, 6.9077308820497e-310, 6.9076898756849e-310, -0.5163977794943222, -0.4472135954999579, 6.9076186879462e-310, 6.907732894104e-310  …  1.24e-322, 1.2e-322, -0.5017452060042545, -0.4947274449181537, -0.47304991679126607, -0.4345240946267408, -0.3739787960033829, -0.2773500981126146, 3.5e-323, 3.0e-323])), 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{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,1], znlm[11|3,1,-1]), ACE1.RPI.PSH1pBasisFcn) => 47, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|4,0,0],), ACE1.RPI.PSH1pBasisFcn) => 4, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,2,-2], znlm[11|1,2,2], znlm[11|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 214, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,2,0], znlm[11|5,0,0]), ACE1.RPI.PSH1pBasisFcn) => 66, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,0], znlm[11|1,1,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 194, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,0], znlm[11|4,1,0]), ACE1.RPI.PSH1pBasisFcn) => 41, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,-1], znlm[11|1,2,1], znlm[11|2,1,0]), ACE1.RPI.PSH1pBasisFcn) => 185, 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|5,0,0],), ACE1.RPI.PSH1pBasisFcn) => 5, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,0,0], znlm[11|2,2,0]), ACE1.RPI.PSH1pBasisFcn) => 121…), Dict{Any, Int64}(znlm[11|2,5,-5] => 90, znlm[11|2,4,4] => 89, znlm[11|1,4,-3] => 18, znlm[11|3,5,2] => 146, znlm[11|1,5,-3] => 28, znlm[11|3,4,2] => 136, znlm[11|5,1,1] => 178, znlm[11|3,2,1] => 121, znlm[11|5,1,0] => 177, znlm[11|4,2,1] => 157…), 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.92489138309536e-310, 6.92489252586525e-310, 6.9248925258526e-310, 1.9364916731037085, 6.9248562192299e-310, 6.92485621793824e-310, 1.9720265943665387, 2.091650066335189, 6.92485621845207e-310, 6.924856216675e-310  …  6.9248562106885e-310, 6.92485621076757e-310, 1.9948914348241344, 2.0155644370746373, 2.0816659994661326, 2.207940216581962, 2.4308621740219887, 2.850438562747845, 6.92479626383574e-310, 6.9247966534583e-310], [6.924853429491e-310, 6.9249015846798e-310, 6.9249015845735e-310, -0.5773502691896257, 6.9248534295005e-310, 6.92490158473673e-310, -0.5163977794943222, -0.4472135954999579, 6.92489396313937e-310, 6.92489396313937e-310  …  6.92489100866396e-310, 6.9248557701764e-310, -0.5017452060042545, -0.4947274449181537, -0.47304991679126607, -0.4345240946267408, -0.3739787960033829, -0.2773500981126146, 6.92489396313937e-310, 6.92489396313937e-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,1,0], znlm[11|1,2,0], znlm[11|2,1,0]), ACE1.RPI.PSH1pBasisFcn) => 199, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,0,0], znlm[11|6,0,0]), ACE1.RPI.PSH1pBasisFcn) => 93, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|2,1,-1], znlm[11|3,1,1]), ACE1.RPI.PSH1pBasisFcn) => 96, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,-1], znlm[11|1,1,0], znlm[11|1,2,1]), ACE1.RPI.PSH1pBasisFcn) => 177, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 16, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,0], znlm[11|2,1,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 204, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,0,0], znlm[11|1,2,0], znlm[11|1,2,0]), ACE1.RPI.PSH1pBasisFcn) => 150, 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|2,0,0], znlm[11|3,0,0], znlm[11|3,0,0]), ACE1.RPI.PSH1pBasisFcn) => 225, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<11>, (znlm[11|1,1,1], znlm[11|3,3,-1]), ACE1.RPI.PSH1pBasisFcn) => 48…), Dict{Any, Int64}(znlm[11|3,5,4] => 148, znlm[11|1,3,-2] => 11, znlm[11|5,3,1] => 188, znlm[11|2,5,-1] => 94, znlm[11|2,6,-3] => 104, znlm[11|1,1,-1] => 2, znlm[11|1,5,0] => 31, znlm[11|5,2,1] => 182, znlm[11|3,5,3] => 147, znlm[11|2,2,2] => 73…), 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, Energy, Forces, LocalDescriptors, 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}}}}
-	 Configuration{S, Energy, Forces, LocalDescriptors, 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}}}}
+	 Configuration{S, Energy, Forces, 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}
+	 Configuration{S, Energy, Forces, 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}
 	 ⋮
-	 Configuration{S, Energy, Forces, LocalDescriptors, 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}}}}

d. Subsampling via DPP.

Create DPP subselector.

dpp = kDPP(ds_train, GlobalMean(), DotProduct(); batch_size = 200)
kDPP(L-Ensemble.
+	 Configuration{S, Energy, Forces, 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}

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}:
-    4
-   11
-   13
-   17
-   27
-   28
-   30
-   34
-   37
-   39
+    2
+   12
+   16
+   20
+   23
+   32
+   33
+   36
+   38
+   60
     ⋮
-  990
-  991
+  986
+  987
+  988
   992
   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.07888006115209834, 0.36077336879580457, -0.8380691283879287, 1.22870510525064, -1.0685311800893658, 0.14639187521365216, 0.8122141081469181, 0.47643282150846744, -0.003047646785949043, 0.009780569942642536, -0.02199020178882094, 0.028180404568999506, -0.0074642101305606445, -0.06346702462497156, 0.1948107762294029, -0.008246241092693118, 0.030615390924985775, -0.08844230241722784, 0.18454721323814738, -0.3068913058430667, 0.0030677002511021456, -0.010882008586171388, 0.029360620654221847, -0.003497278843608509, -0.06028149879580269, 0.08744514319366203, -0.08133119578670289, -0.09062018085310797, 0.5503696247323546, -0.22749099563080222, 0.4651680563572995, -0.9719824105932275, 0.07719584569094451, -0.19491962471866486, -0.038538716102124226, 0.7953499683932286, -1.9050612004438108, 1.2155100106258558, -0.0002428241806602116, 0.0007061013836396901, -0.001917698632638798, 0.0036579423455580518, -0.0053237234862715255, 0.005947133272459659, -0.00014710146687460512, 0.0005445200262069738, -0.0015662715409543448, 0.003248519225329094, 6.310476923268582e-5, -0.00022466083886318877, -0.0035311341960739817, 0.006703625081436293, -0.012545980414600422, 0.01764924640797716, -0.004034142327447032, 0.00821356251405625, -0.024970843748807425, 0.03197667512933933, 2.970809325752305e-5, 0.0008009100422533, -0.00015018339793780588, -0.002438123051651475, 0.005471798281369011, -0.00010813790848708538, -0.002965345741263281, 0.008532251863184293, 0.009029682060483601, -0.0003390895818922435, 0.030327600669096455, -0.04635514758986403, 0.0847008996006835, 0.021973869444300576, 0.11982476227309746], [0.2345374431019263]}

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.11970133962840634, 0.5426910091410093, -1.240854330232196, 1.761249275529451, -1.3919237202878776, -0.1310731730821999, 1.5390413737626432, 0.9247628212503969, -0.005291152067977034, 0.017280597241077444, -0.04031674451940148, 0.057165465622478706, -0.03563217599554491, -0.06061241011379659, 0.2474181799695785, -0.011167533928931217, 0.0410710444385014, -0.11701570901296776, 0.23939707720225556, -0.38695013116887367, 0.004676898073955105, -0.01643361870461657, 0.04366880852575861, -0.006401961671567147, -0.10934706390133897, 0.16877392822176773, -0.19851670351447126, -0.009883811262156428, 0.6455632141110499, -0.3022638368084074, 0.6094318449480909, -1.248180173886567, 0.11533874115866638, -0.44203694810687466, 0.15827453577142592, 0.8343199629189613, -2.460291895098294, 1.1947113201037638, -0.00039898243472899497, 0.0011627221096134899, -0.003169496387322557, 0.006084238847560375, -0.008959246668463372, 0.010258300025402178, -0.0002102042536854254, 0.0007721267595877657, -0.0021958993086276246, 0.004480760194976341, 9.847716218364805e-5, -0.0003486347419108804, -0.005830637436140762, 0.011121184508131599, -0.02098635725373832, 0.02999557519645002, -0.005675673297846684, 0.011423174033112105, -0.04169894395386109, 0.05404438499328279, 4.8413295167058085e-5, 0.001140183533352046, -0.00024528261817194363, -0.003453362964781048, 0.007700622819754255, -0.000175722476859215, -0.004188681990395349, 0.011914620456247249, 0.012688698042029323, -0.0005268324869530105, 0.05025200473679803, -0.07727546553580922, 0.14275646381037888, 0.030793549836170442, 0.20148805435168526], [0.23905484046014985]}

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, Energy, Forces, LocalDescriptors, 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}}}}
-	 Configuration{S, Energy, Forces, LocalDescriptors, 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}}}}
+	 Configuration{S, Energy, Forces, 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}
+	 Configuration{S, Energy, Forces, 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}
 	 ⋮
-	 Configuration{S, Energy, Forces, LocalDescriptors, 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}}}}

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, Energy, Forces, 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}

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.0535971729706755, -1.0566912644031965, -1.0555414702373018, -1.0511057505176993, -1.0532247272923647, -1.0609764625639524, -1.0526005767363644, -1.044931756744939, -1.0620834877774814, -1.0572916686183842  …  -1.0160605522217305, -1.0189607765527313, -1.0164928928761658, -1.009201300938574, -1.0183478651416147, -1.0077120309038357, -1.0135727801387984, -1.0149462099471074, -1.0156685810983912, -1.0103809662153114])

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.004536859272269855, RMSE: 0.005971113823543045, RSQ: 0.8373474707357711

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.0523376750908946, -1.0554940015790193, -1.0552643961725106, -1.0509424522947162, -1.0538382003528535, -1.0622124933800192, -1.0528373723133002, -1.0441959385808703, -1.0620038464058825, -1.0581218927962361  …  -1.0132495028821173, -1.0156099233649296, -1.013802445333616, -1.0068283796992392, -1.0152499381425086, -1.0047239248309714, -1.0103992754196913, -1.0123376447327261, -1.012427312787095, -1.0082926554698954])

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.004529085380182573, RMSE: 0.00597195746393586, RSQ: 0.8369459877881329

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/dev/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html b/dev/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html index 193d97c..3fa9539 100644 --- a/dev/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html +++ b/dev/generated/DPP-ACE-Si/fit-dpp-ace-si/index.html @@ -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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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}([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{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|2,0,0],), ACE1.RPI.PSH1pBasisFcn) => 2, 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{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,0,0], znlm[14|1,2,0]), ACE1.RPI.PSH1pBasisFcn) => 21, 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,1,-1], znlm[14|1,1,1]), ACE1.RPI.PSH1pBasisFcn) => 12, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,1,-1], znlm[14|1,1,1]), ACE1.RPI.PSH1pBasisFcn) => 24, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,0,0], znlm[14|1,0,0]), ACE1.RPI.PSH1pBasisFcn) => 20, ACE1.PIBasisFcn{1, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|3,0,0],), ACE1.RPI.PSH1pBasisFcn) => 3, 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,2,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 17…), Dict{Any, Int64}(znlm[14|1,3,1] => 14, znlm[14|1,4,2] => 23, znlm[14|2,3,-1] => 37, znlm[14|1,2,-2] => 5, znlm[14|2,3,-3] => 35, znlm[14|2,3,0] => 38, znlm[14|1,2,2] => 9, znlm[14|1,2,-1] => 6, znlm[14|1,4,1] => 22, znlm[14|2,2,2] => 34…), 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], [5.02e-321, 4.99e-321, 4.97e-321, -0.5773502691896257, 4.965e-321, 5.025e-321, -0.5163977794943222, -0.4472135954999579, 5.01e-321, 4.975e-321, -0.50709255283711, -0.47809144373375745, -0.3779644730092272, 5.015e-321, 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|2,0,0],), ACE1.RPI.PSH1pBasisFcn) => 2, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|2,0,0]), ACE1.RPI.PSH1pBasisFcn) => 8, ACE1.PIBasisFcn{3, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,0,0], znlm[14|1,0,0], znlm[14|1,2,0]), ACE1.RPI.PSH1pBasisFcn) => 21, 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,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|2,2,0]), ACE1.RPI.PSH1pBasisFcn) => 9, ACE1.PIBasisFcn{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,1,1], znlm[14|2,1,-1]), ACE1.RPI.PSH1pBasisFcn) => 16, 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{2, ACE1.RPI.PSH1pBasisFcn}(<14>, (znlm[14|1,1,-1], znlm[14|1,1,1]), ACE1.RPI.PSH1pBasisFcn) => 12…), Dict{Any, Int64}(znlm[14|2,3,-1] => 37, znlm[14|1,3,2] => 15, znlm[14|2,3,0] => 38, znlm[14|3,2,-2] => 46, znlm[14|1,4,1] => 22, znlm[14|1,1,-1] => 2, znlm[14|3,2,-1] => 47, znlm[14|1,4,-3] => 18, znlm[14|2,3,1] => 39, znlm[14|1,2,1] => 8…), 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.9234010617388634e10, 1.8072444369643528e10, 1.9108547901653976e10, 1.8758137188786034e10, 1.8674663096201523e10]
+condnum: [2.0032816713705605e10, 1.9551924694690586e10, 1.992093234058963e10, 1.9967690632806892e10, 1.932353698595302e10]
 =============== Starting batch size 40 ===============
 batch 1
 batch 2
 batch 3
 batch 4
 batch 5
-condnum: [1.9292230925396603e10, 1.968842004170845e10, 2.0590815670136208e10, 1.876321244507782e10, 1.836942593257039e10]

This page was generated using Literate.jl.

+condnum: [1.813026899682877e10, 1.779947949196178e10, 1.596057436685529e10, 1.7030292504222696e10, 1.767252997034955e10]

This page was generated using Literate.jl.

diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/000306ae.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/000306ae.png new file mode 100644 index 0000000..1374540 Binary files /dev/null and b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/000306ae.png differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/00b965e0.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/00b965e0.png deleted file mode 100644 index b026fa8..0000000 Binary files a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/00b965e0.png and /dev/null differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/1496d24a.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/1496d24a.png new file mode 100644 index 0000000..b3022b5 Binary files /dev/null and b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/1496d24a.png differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/2276dafb.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/2276dafb.png deleted file mode 100644 index 9a6c193..0000000 Binary files a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/2276dafb.png and /dev/null differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/7004e0af.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/7004e0af.png new file mode 100644 index 0000000..58f4357 Binary files /dev/null and b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/7004e0af.png differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/a7ed4df7.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/a7ed4df7.png deleted file mode 100644 index 3bac4d6..0000000 Binary files a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/a7ed4df7.png and /dev/null differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/d7afb65d.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/d7afb65d.png new file mode 100644 index 0000000..228ad0b Binary files /dev/null and b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/d7afb65d.png differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/fc4d886b.png b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/fc4d886b.png deleted file mode 100644 index 058a45a..0000000 Binary files a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/fc4d886b.png and /dev/null differ diff --git a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html index d34dde6..16d500f 100644 --- a/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html +++ b/dev/generated/DPP-ACE-aHfO2-1/fit-dpp-ace-ahfo2/index.html @@ -4,19 +4,19 @@ 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}})

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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors}

Create DPP subselector

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

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.761571547310763e15
+Number of items in ground set : 100. Max. rank : 100. Rescaling constant α=1.4557527673591915e15
 , 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

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

println("Learning energies and forces...")
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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
([415.16034100386935, 258.7246414082674, 116.2747800363158, 25.311049379994422, -25185.33872179595, -18224.852348429744, 6289.608756649479, -2344.6323073272056, 14691.409520016028, 7968.917924826727  …  138.53544101261477, 73.33954769605671, -10431.840384578376, -2141.7981525529835, 92.3439560676678, 926352.2886706392, 479096.27324863157, 21431.705145246462, -1038.1001349541698, 22587.854325594933], [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
([926.8471122980118, 495.49161446094513, 182.79809483885765, 33.80033758841455, 96.17168906703591, 22.304911399260163, -25.77749038208276, -8.049065698869526, 8189.284978866577, 4403.63533782959  …  140.72889107093215, 62.703479304909706, -441.50307846069336, -399.0467233657837, 267.7437629699707, -1422.296947479248, 2693.1725749969482, 3084.5173568725586, -1047.8668817281723, -798.5879411697388], [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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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.00178298
-  "e_train_rmse"     => 0.00215635
-  "e_train_rsq"      => 0.494199
-  "f_train_mae"      => 0.17171
-  "f_train_rmse"     => 0.219033
-  "f_train_rsq"      => 0.849877
-  "f_train_mean_cos" => 0.886446

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.00157719
+  "e_train_rmse"     => 0.00184344
+  "e_train_rsq"      => 0.630108
+  "f_train_mae"      => 0.171437
+  "f_train_rmse"     => 0.218975
+  "f_train_rsq"      => 0.851052
+  "f_train_mean_cos" => 0.886305

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.000768434
-  "e_test_rmse"     => 0.000929155
-  "e_test_rsq"      => 0.913904
-  "f_test_mae"      => 0.17411
-  "f_test_rmse"     => 0.219383
-  "f_test_rsq"      => 0.848935
-  "f_test_mean_cos" => 0.887418

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.000866311
+  "e_test_rmse"     => 0.00106424
+  "e_test_rsq"      => 0.857985
+  "f_test_mae"      => 0.174162
+  "f_test_rmse"     => 0.21996
+  "f_test_rsq"      => 0.847088
+  "f_test_mean_cos" => 0.888746

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/dev/generated/LJ-Ar/lennard-jones-ar/index.html b/dev/generated/LJ-Ar/lennard-jones-ar/index.html index 5362423..cb08895 100644 --- a/dev/generated/LJ-Ar/lennard-jones-ar/index.html +++ b/dev/generated/LJ-Ar/lennard-jones-ar/index.html @@ -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/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/8f3b6fe6.png b/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/8f3b6fe6.png deleted file mode 100644 index 7a45c78..0000000 Binary files a/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/8f3b6fe6.png and /dev/null differ diff --git a/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/9b49add3.png b/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/9b49add3.png new file mode 100644 index 0000000..312b340 Binary files /dev/null and b/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/9b49add3.png differ diff --git a/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html b/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html index 2676cc9..207a5c1 100644 --- a/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html +++ b/dev/generated/Opt-ACE-aHfO2/fit-opt-ace-ahfo2/index.html @@ -5,19 +5,19 @@ 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}})

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]
@@ -40,19 +40,19 @@
                            Continuous(), Continuous(), Continuous()])
 iap, res = hyperlearn!(model, pars, conf_train;
                        n_samples = 10, sampler = sampler,
-                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.16 eV/atom, F_MAE:0.304 eV/Å, Time per force per atom:58.495 µs
-E_MAE:0.129 eV/atom, F_MAE:0.158 eV/Å, Time per force per atom:156.79 µs
-E_MAE:0.188 eV/atom, F_MAE:0.293 eV/Å, Time per force per atom:154.063 µs
-E_MAE:0.068 eV/atom, F_MAE:0.124 eV/Å, Time per force per atom:265.944 µs
-E_MAE:0.179 eV/atom, F_MAE:0.246 eV/Å, Time per force per atom:113.711 µs
-E_MAE:0.145 eV/atom, F_MAE:0.149 eV/Å, Time per force per atom:234.765 µs
-E_MAE:2.055 eV/atom, F_MAE:2.173 eV/Å, Time per force per atom:73.832 µs
-E_MAE:0.13 eV/atom, F_MAE:0.229 eV/Å, Time per force per atom:72.853 µs
-E_MAE:0.076 eV/atom, F_MAE:0.106 eV/Å, Time per force per atom:292.833 µs
-E_MAE:0.139 eV/atom, F_MAE:0.223 eV/Å, Time per force per atom:89.146 µs

Save and show results.

@save_var res_path iap.β
+                       loss = custom_loss, ws = [1.0, 1.0], int = true);
E_MAE:0.202 eV/atom, F_MAE:0.301 eV/Å, Time per force per atom:83.753 µs
+E_MAE:0.066 eV/atom, F_MAE:0.078 eV/Å, Time per force per atom:8156.674 µs
+E_MAE:0.201 eV/atom, F_MAE:0.246 eV/Å, Time per force per atom:133.517 µs
+E_MAE:0.157 eV/atom, F_MAE:0.305 eV/Å, Time per force per atom:53.118 µs
+E_MAE:0.167 eV/atom, F_MAE:0.193 eV/Å, Time per force per atom:102.179 µs
+E_MAE:0.108 eV/atom, F_MAE:0.116 eV/Å, Time per force per atom:362.909 µs
+E_MAE:0.193 eV/atom, F_MAE:0.164 eV/Å, Time per force per atom:216.455 µs
+E_MAE:0.201 eV/atom, F_MAE:0.25 eV/Å, Time per force per atom:90.856 µs
+E_MAE:0.183 eV/atom, F_MAE:0.305 eV/Å, Time per force per atom:72.501 µs
+E_MAE:0.195 eV/atom, F_MAE:0.25 eV/Å, Time per force per atom:41.086 µ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.06842180.09396480.8459290.1240030.1650110.923822265.9443.05.05.111111.50.7222220.611111
20.07588040.08535140.8728810.1062540.1374750.947125292.8333.04.05.555560.6111111.51.16667
30.1285230.1584190.562070.1579610.200630.887385156.792.04.04.222220.8333331.166671.38889
40.1302090.1655510.521750.2290930.2986160.75052372.8533.04.04.666670.7222220.51.05556
50.1391550.1673310.5114090.2231480.2908080.76339989.14633.04.05.555560.6111111.51.16667
60.1451740.1751430.4647240.1485410.1901980.898791234.7652.05.05.777781.166671.055561.5
70.1599080.2090540.237380.3044680.3980330.55675658.4952.04.04.222220.8333331.166671.38889
80.1793330.2362170.0263260.2456310.3170470.718776113.7112.05.05.777781.166671.055561.5
90.1882880.2312070.06718940.2927440.3834150.588715154.0633.05.05.111111.50.7222220.611111
102.055442.57372-114.5882.172582.98761-23.97273.83173.04.04.666670.7222220.51.05556

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.06630950.07636020.9417630.07818780.1011010.9721618156.672.03.05.111111.277780.8333330.5
20.1076250.1276020.8373770.1155050.1482160.940168362.9093.04.06.01.166671.50.944444
30.1567160.2095050.5616150.30540.4008120.56244953.11854.05.05.333330.7222220.50.722222
40.1670270.2013710.5949930.1930270.2516390.827534102.1793.04.06.01.166671.50.944444
50.1826950.2548370.351380.3047040.3980530.56845372.50124.05.04.01.055561.166670.611111
60.1928670.2264570.4878020.1637830.2095490.880404216.4552.04.04.222220.8333330.6111111.16667
70.1949380.2397120.4260860.2502060.3261420.71029241.0864.05.04.01.055561.166670.611111
80.2006250.2505690.3729210.2501650.3252840.71181590.85562.04.04.222220.8333330.6111111.16667
90.2007930.2502470.3745330.2464620.3183890.723902133.5174.05.05.333330.7222220.50.722222
100.2016020.2672090.2868680.3008330.3934560.57836183.75312.03.05.111111.277780.8333330.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/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0317d5e1.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0317d5e1.png new file mode 100644 index 0000000..6af9916 Binary files /dev/null and b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0317d5e1.png differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0f75fe35.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0f75fe35.png new file mode 100644 index 0000000..1c5bd9d Binary files /dev/null and b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/0f75fe35.png differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/1ed5d06b.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/1ed5d06b.png deleted file mode 100644 index 9d4a489..0000000 Binary files a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/1ed5d06b.png and /dev/null differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/22f04745.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/22f04745.png deleted file mode 100644 index 3961c12..0000000 Binary files a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/22f04745.png and /dev/null differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/326006fe.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/326006fe.png deleted file mode 100644 index 7685d8c..0000000 Binary files a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/326006fe.png and /dev/null differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/b3edb109.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/b3edb109.png new file mode 100644 index 0000000..d955024 Binary files /dev/null and b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/b3edb109.png differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f8651ab3.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f8651ab3.png new file mode 100644 index 0000000..271632f Binary files /dev/null and b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f8651ab3.png differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f91cdf8b.png b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f91cdf8b.png deleted file mode 100644 index 9fcba1c..0000000 Binary files a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/f91cdf8b.png and /dev/null differ diff --git a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html index 14f35c4..42572c8 100644 --- a/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html +++ b/dev/generated/PCA-ACE-aHfO2/fit-pca-ace-ahfo2/index.html @@ -4,19 +4,19 @@ 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}

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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}, DataSet{num_configs = 50} 
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}}
 	 ⋮
-	 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, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}})

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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

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

n_desc = 20
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
  ⋮
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
- Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

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

println("Learning energies and forces...")
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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.297124857851939, -0.4792878452314005, -0.961501372729971, -1.376773751216957, -1.5127214033982064, 2.8513366223127643, 9.76390956440362, -25.672271502385133, -31.127502678091616, 27.980624421395486, 59.07312200851334, 1.8368260416814262, -29.678914106797645, 16.47691213666069, -22.565987577091054, -102.18701747468786, 39.876576814149956, 154.99837667738188, 98.98983119544431, -70.73743129366821], [-952.6053956517989])

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.3833010033671369, 0.5473592284801594, 0.04981049146611696, 2.3943930281899855, 2.04536364697852, -1.797073918585867, -6.662652286719205, 14.505030674925749, -43.96869757970287, -33.3235353186957, 51.3598207402797, 61.84066751488459, 19.09258641963203, 34.6059391186358, -53.39352779760397, -48.193612982015935, 8.51978713541899, 95.47413172341581, -30.849341510804358, -256.28990623568217], [-952.5055382378009])

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, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+	 Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
 	 ⋮
-	 Configuration{S, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, Energy, Forces, LocalDescriptors, ForceDescriptors}

Dimension reduction of energy and force descriptors of test dataset.

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

Dimension reduction of energy and force descriptors of test dataset.

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

Get true and predicted values for energies and forces.

n_atoms_train = length.(get_system.(ds_train))
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, ForceDescriptors}
+ Configuration{S, Energy, Forces, AtomsBase.FlexibleSystem{3, AtomsBase.Atom, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(Å,), 𝐋, nothing}}}, LocalDescriptors, 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.00205129
-  "e_train_rmse"     => 0.00263072
-  "e_train_rsq"      => 0.511762
-  "f_train_mae"      => 0.245236
-  "f_train_rmse"     => 0.312854
-  "f_train_rsq"      => 0.620129
-  "f_train_mean_cos" => 0.788535

Compute test metrics.

e_test_metrics = get_metrics(e_test, e_test_pred,
+  "e_train_mae"      => 0.0020288
+  "e_train_rmse"     => 0.00279302
+  "e_train_rsq"      => 0.547671
+  "f_train_mae"      => 0.237476
+  "f_train_rmse"     => 0.302543
+  "f_train_rsq"      => 0.664197
+  "f_train_mean_cos" => 0.801765

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.00256987
-  "e_test_rmse"     => 0.00296471
-  "e_test_rsq"      => 0.3017
-  "f_test_mae"      => 0.246699
-  "f_test_rmse"     => 0.312511
-  "f_test_rsq"      => 0.617141
-  "f_test_mean_cos" => 0.781249

Plot and save energy results.

e_plot = plot_energy(e_train, e_train_pred,
+  "e_test_mae"      => 0.00162294
+  "e_test_rmse"     => 0.00189117
+  "e_test_rsq"      => 0.585471
+  "f_test_mae"      => 0.237902
+  "f_test_rmse"     => 0.3035
+  "f_test_rsq"      => 0.648808
+  "f_test_mean_cos" => 0.797907

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/dev/index.html b/dev/index.html index cf5aac8..58177ec 100644 --- a/dev/index.html +++ b/dev/index.html @@ -11,4 +11,4 @@ end 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 interatomic potential data and model

Compress 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)

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).

+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/dev/install-and-run-examples/index.html b/dev/install-and-run-examples/index.html index 25613f5..2aab929 100644 --- a/dev/install-and-run-examples/index.html +++ b/dev/install-and-run-examples/index.html @@ -3,4 +3,4 @@ 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

Then, add PotentialLearning:

    pkg> add PotentialLearning
-

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")
+

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/dev/search_index.js b/dev/search_index.js index 1e9c48c..791eb20 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"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":"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":"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 => LinRange(4, 6, 10),\n :wL => LinRange(0.5, 1.5, 10),\n :csp => LinRange(0.5, 1.5, 10),\n :r0 => LinRange(0.5, 1.5, 10));\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 latin hypercube sampling to find the optimal hyper-parameters. Alternatively, use random sampling (sampler = RandomSampler()).","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":"sampler = CLHSampler(dims=[Categorical(3), Categorical(3), Continuous(),\n Continuous(), Continuous(), Continuous()])\niap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 10, sampler = sampler,\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-interatomic-potential-data-and-model","page":"Home","title":"Compress interatomic potential data and model","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Compress 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":"#Acknowledgment","page":"Home","title":"Acknowledgment","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).","category":"page"},{"location":"install-and-run-examples/#Install-package-and-run-examples","page":"Install and run examples","title":"Install package and run examples","text":"","category":"section"},{"location":"install-and-run-examples/#Add-registries-and-package","page":"Install and run examples","title":"Add registries and package","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run 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":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Then, add PotentialLearning:","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" pkg> add PotentialLearning\n","category":"page"},{"location":"install-and-run-examples/#Clone-repository-and-access-an-example-folder","page":"Install and run examples","title":"Clone repository and access an example folder","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Clone PotentialLearning.jl repository in your working directory.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Access to any folder within PotentialLearning.jl/examples. E.g.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1","category":"page"},{"location":"install-and-run-examples/#Run-example","page":"Install and run examples","title":"Run example","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Open a Julia REPL, activate the examples folder project, and define the number of threads.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ julia --project=./ --threads=4","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Type ] to enter the Pkg REPL and instantiate.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" pkg> instantiate","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Finally, include the example file.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" julia> include(\"fit-dpp-ace-ahfo2.jl\")","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":"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 => LinRange(4, 6, 10),\n :wL => LinRange(0.5, 1.5, 10),\n :csp => LinRange(0.5, 1.5, 10),\n :r0 => LinRange(0.5, 1.5, 10));\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 latin hypercube sampling to find the optimal hyper-parameters. Alternatively, use random sampling (sampler = RandomSampler()).","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":"sampler = CLHSampler(dims=[Categorical(3), Categorical(3), Continuous(),\n Continuous(), Continuous(), Continuous()])\niap, res = hyperlearn!(model, pars, conf_train;\n n_samples = 10, sampler = sampler,\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-interatomic-potential-data-and-model","page":"Home","title":"Compress interatomic potential data and model","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Compress 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":"#Acknowledgment","page":"Home","title":"Acknowledgment","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Center for the Exascale Simulation of Materials in Extreme Environments (CESMIX). Massachusetts Institute of Technology (MIT).","category":"page"},{"location":"install-and-run-examples/#Install-package-and-run-examples","page":"Install and run examples","title":"Install package and run examples","text":"","category":"section"},{"location":"install-and-run-examples/#Add-registries-and-package","page":"Install and run examples","title":"Add registries and package","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Open a Julia REPL ($ julia), type ] to enter the Pkg REPL, and add the following registries:","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run 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":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Then, add PotentialLearning:","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" pkg> add PotentialLearning\n","category":"page"},{"location":"install-and-run-examples/#Clone-repository-and-access-an-example-folder","page":"Install and run examples","title":"Clone repository and access an example folder","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Clone PotentialLearning.jl repository in your working directory.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ git clone git@github.com:cesmix-mit/PotentialLearning.jl.git","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Access to any folder within PotentialLearning.jl/examples. E.g.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ cd PotentialLearning.jl/examples/DPP-ACE-aHfO2-1","category":"page"},{"location":"install-and-run-examples/#Run-example","page":"Install and run examples","title":"Run example","text":"","category":"section"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Open a Julia REPL, activate the examples folder project, and define the number of threads.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" $ julia --project=./ --threads=4","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Type ] to enter the Pkg REPL and instantiate.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" pkg> instantiate","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":"Finally, include the example file.","category":"page"},{"location":"install-and-run-examples/","page":"Install and run examples","title":"Install and run examples","text":" julia> include(\"fit-dpp-ace-ahfo2.jl\")","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"}] }