A friction model is a wrapper around a named tuple of matrix models, i.e.
struct FrictionModel{MODEL_IDS} <: AbstractFrictionModel
matrixmodels::NamedTuple{MODEL_IDS}
endThe symbols contained in the tuple MODEL_IDS are referred to as "IDs" of the corresponding matrix models. When evaluated at an atomic configuration, the resulting friction tensor is the sum of the friction tensors of all matrix models in the friction model, whereas diffusion coefficient matrices are evaluated seperately for each matrix model and returned in the form of a named tuple of the same signature. The following functions act on structures of type FrictionModel:
ACEfriction.FrictionModels.Gamma — Function
Gamma(fm::FrictionModel, at::AbstractSystem; filter=(_,_)->true, T=Float64)Evaluates the friction tensor according to the friction model fm at the atomic configuration at::AbstractSystem. The friction tensor is the sum of the friction tensors of all matrix models in fm.matrixmodels.
Arguments:
fm– the friction model of which the friction tensor is evaluated.at– the atomic configuration at which the basis is evaluatedfilter– (optional, default:(_,_)->true) a filter function of the generic form(i::Int,at::AbstractSystem) -> Bool. Only atomsat[i]for whichfilter(i,at)returnstrueare included in the evaluation of the friction tensor.
Output:
A friction tensor in the form of a sparse 3N x 3N matrix, where N is the number of atoms in the atomic configuration at.
Gamma(fm::FrictionModel{MODEL_IDS}, Σ_vec::NamedTuple{MODEL_IDS}) where {MODEL_IDS}Computes the friction tensor from a pre-computed collection of diffusion coefficient matrices. The friction tensor is the sum of the squares of all diffusion coefficient matrices in the collection.
Arguments:
fm– the friction model of which the friction tensor is evaluated. The friction tensor is the sum of the friction tensors of all matrix models infm.matrixmodels.Σ– a collection of diffusion coefficient matrices. The friction tensor is the sum of the squares of all matrices inΣ.
Output:
A friction tensor in the form of a sparse 3N x 3N matrix, where N is the number of atoms in the atomic configuration at. The friction tensor is the sum of the symmetric squares $\Sigma\Sigma^T$ of all diffusion coefficient matrices $\Sigma$ in Σ_vec.
ACEfriction.FrictionModels.Sigma — Function
Sigma(fm::FrictionModel{MODEL_IDS}, at::AbstractSystem; filter=(_,_)->true, T=Float64) where {MODEL_IDS}Computes the diffusion coefficient matrices for all matrix models in the friction model at a given configuration.
Arguments:
fm– the friction model of which the diffusion coefficient matrices are evaluatedat– the atomic configuration at which the diffusion coefficient matrices are evaluatedfilter– (optional, default:(_,_)->true) a filter function of the generic form(i::Int,at::AbstractSystem) -> Bool. Only atomsat[i]for whichfilter(i,at)returnstrueare included in the evaluation of the diffusion coefficient matrices.
Output:
A NamedTuple of diffusion coefficient matrices, where the keys are the IDs of the matrix models in the friction model.
ACEfriction.MatrixModels.randf — Function
randf(M::MatrixModel, Σ_vec::AbstractVector)Random force of a single matrix model from its per-replica diffusion matrices Σ_vec = Sigma(M, at) (one sparse / Diagonal matrix per replica). Each replica draws an independent random force via the coupling-scheme-specific randf(M, Σ) method (defined in the model files), and the model's force is their sum. Its covariance equals the model's friction tensor Gamma(M, Σ_vec). Usually called through randf(fm, Σ) rather than directly.
randf(fm::FrictionModel{MODEL_IDS}, Σ::NamedTuple{MODEL_IDS}) where {MODEL_IDS}Draws a ${\rm Normal}({\bm 0}, {\bm \Gamma})$-distributed Gaussian random force from a precomputed collection of diffusion coefficient matrices Σ = Sigma(fm, at). The sample covariance of the returned force equals the friction tensor ${\bm \Gamma} =$ Gamma(fm, Σ) (the fluctuation–dissipation relation); this holds for every coupling scheme, even where ${\bm \Gamma} \neq {\bm \Sigma}{\bm \Sigma}^{T}$ (e.g. the pair-wise coupling).
This is the cheap, per-step entry point for Langevin/GLE-type dynamics: assemble Σ once with Sigma, then call randf each timestep to obtain the stochastic force.
Arguments:
fm– the friction model; the total force is the sum over its matrix models.Σ– aNamedTupleof per-model diffusion coefficient matrices (each a vector of per-replica matrices), as returned bySigma(fm, at).
Output:
A Vector{SVector{3,Float64}} of length N (one 3-vector per atom), where N is the number of atoms in the configuration for which Σ was evaluated. Each matrix model draws its own independent noise (summed over replicas), and the model forces are summed.
ACEfriction.MatrixModels.basis — Function
basis(fm::FrictionModel{MODEL_IDS}, at::AbstractSystem; join_sites=false, filter=(_,_)->true, T=Float64) where {MODEL_IDS}Evaluates the ACE-basis functions of the friction model fm at the atomic configuration at::AbstractSystem.
Arguments:
fm– the friction model of which the basis is evaluatedat– the atomic configuration at which the basis is evaluatedjoin_sites– (optional, default:false) iftrue, the basis evaulations of all matrix models are concatenated into a single array. Iffalse, the basis evaluations are returned as a named tuple of the typeNamedTuple{MODEL_IDS}.filter– (optional, default:(_,_)->true) a filter function of the generic form(i::Int,at::AbstractSystem) -> Bool. The atomat[i]will be included in the basis ifffilter(i,at)returnstrue.
Setter and getter functions for model parameters
ACEfriction.MatrixModels.params — Function
params(fm::FrictionModel{MODEL_IDS}) where {MODEL_IDS}Returns the parameters of all matrix models in the FrictionModel object as a NamedTuple.
params(m::FluxFrictionModel; transformed=true)Return the parameters of the model m.
ACEfriction.MatrixModels.nparams — Function
nparams(fm::FrictionModel{MODEL_IDS}) where {MODEL_IDS}Returns the total number of scalar parameters of all matrix models in the FrictionModel object.
ACEfriction.MatrixModels.set_params! — Function
set_params!(fm::FrictionModel, θ::NamedTuple)Sets the parameters of all matrix models in the FrictionModel object whose ID is contained in θ::NamedTuple to the values specified therein.
set_params!(m::FluxFrictionModel; sigma=1E-8, model_ids::Array{Symbol}=Symbol[])Randomizes the parameters of the model m.
Arguments
m::FluxFrictionModel: The model to set the parameters of.sigma::Float64=1E-8: The standard deviation of the random values.model_ids::Array{Symbol}=[]: The ids of the models to set the parameters of. If empty, all the parameters are set.
set_params!(m::FluxFrictionModel, c_new::NamedTuple)Set the parameters of the model to the values in c_new.
Arguments
m::FluxFrictionModel: The model to set the parameters of.c_new::NamedTuple: The new parameters. The keys ofc_newshould be a subset ofm.model_ids.
ACEfriction.MatrixModels.set_zero! — Function
set_zero!(fm::FrictionModel, model_ids)Sets the parameters of all matrix models in the FrictionModel object to zero.