PotentialFitting
Reference
PotentialFitting.calculate_potential
— Methodcalculate_potential(potential::AbstractPotential, cluster::AbstractCluster, indices)
Calculates energy from given potential. Needs to be implemented for each potential.
Arguments
potential::AbstractPairPotential
: potentialcluster::AbstractCluster
: molecule clusterindices
: indices for atoms that represent potential
PotentialFitting.fit_potential!
— Methodfit_potential!(solver, mpp::MoleculePairPotential, fdata::FitData)
fit_potential!(mpp::MoleculePairPotential, fdata::FitData)
Fits potential using given solver
. If solver
is not given use default solvers, which is LinearRegression()
.
Arguments
solver
: ScikitLearn solvermpp::MoleculePairPotential
: potentialfdata::FitData
: data used in fitting
PotentialFitting.generate_initial_structure
— Methodgenerate_initial_structure(args, kwargs)
Used to generate initial structures for MD runs
PotentialFitting.get_molecules
— Methodget_molecules(data::Dict)
Returns molecules from data file. This is usability function that is meant to simplify things.
PotentialFitting.get_potential!
— Methodget_potential!(potential, terms)
Function that sets potential term after potential has been fitted. That is this function transforms fitted term to potential terms. Needs to be implemented for each potential.
Arguments
potential
: used potentialterms
: terms from fitting method
PotentialFitting.give_as_potential
— Methodgive_as_potential(T, data)
Returns MoleculePairPotential{T} from given data that must have "c1_molecule"
and "c2_molecule"
fields
PotentialFitting.min_distance
— Methodmin_distance(points, c1::AbstractCluster, c2::AbstractCluster)
Minimum without needing fitted potential.
PotentialFitting.min_distance
— Methodmin_distance(mpp::MoleculePairPotential, points)
Gives minimum distance of molecules in mpp
on given points. Used to help plotting.
PotentialFitting.plot_potential
— Methodplot_potential(points::AbstractVector, mpp::MoleculePairPotential; emax=100u"cm^-1")
Plots given potential on given points.
PotentialFitting.plot_potential
— Methodplot_potential(pes::Dict; mpp::MoleculePairPotential; emax=100u"cm^-1", marker=:circle)
Plots calculated potential values and fitted potential in same figure. pes
is expected to be produced by PotentialCalculation
or PotentialDB
.
PotentialFitting.plot_potential
— Methodplot_potential(pes::Dict; emax=100u"cm^-1")
Plots calculated potential values. Input is expected to be produced by PotentialCalculation or PotentialDB.
PotentialFitting.potential_variables
— Methodpotential_variables(mpp::MoleculePairPotential, points)
Used to transform cluster data to fittable form.
Arguments
mpp::MoleculePairPotential
: potential to be fittedpoints
: array for clusters
Returns
Array holding an array for each potential term in mpp.topology
that can the be used for fitting.
PotentialFitting.save_with_residue_data
— Methodsave_with_residue_data(fname, sys, res_name, indx_range)
Save structure sys
in a CP2K QM/MM format to pdb file.
Background, CP2K needs QM- and MM-parts to have different residue names. This function add residue name res_name
to atoms with index in indx_range
and residue name "LIG" to all other atoms. The result is then saved to file fname
- you should use pdb suffix.
PotentialFitting.scan_potential
— Methodscan_potential(args...; kwargs...)
Plot potentail and visualize structure.
Arguments
data::Dict
- Data generated byPotentialCalculation
orPotentialDB
mpp::MoleculePairPotential
- (optional) fitted potential.
Keywords
scale_radius=0.7
- Parameter for Van der Waals radius.emax=100u"cm^-1"
- Maximum energy in plots. Defines also energy unit.extra_box_size=4
- How much extra space is in molecule visualization box.marker=:circle
- Marker for calculated potential values.
PotentialFitting.set_atomic_symbol!
— Methodset_atomic_symbol!(sys::FlexibleSystem, s, i::Int)
Changes atomic symbol of atom i
. You can use this to edit the symbols so that it is possible to distinquish atoms to different groups in CP2K.
PotentialFitting.setweight_e_less!
— Methodsetweight_e_less!(data::FitData, w, emax)
Sets weigth when energy is more than given one.
Arguments
data::FitData
: data where weigth is adjustedw
: new weigthemax
: maximum energy
PotentialFitting.setweight_e_more!
— Methodsetweight_e_more!(data::FitData, w, emin)
Sets weigth when energy is more than given one.
Arguments
data::FitData
: data where weigth is adjustedw
: new weigthemin
: energy
PotentialFitting.visualize_points
— Methodvisualize_points(points; stdout=devnull, stderr=devnull, command="vmd")
Visualize using external program.
StatsBase.rmsd
— Methodrmsd(points, energy, mpp::MoleculePairPotential; emax=0u"cm^-1")
Calculates root mean square error for potential mpp
.
Atributes
points
: points where potential is testedenergy
: referece energy for given pointsmpp::MoleculePairPotential
: potentialemax=0u"cm^-1"
: cut points where energy is smaller than this
PotentialFitting.AbstractClusterPotential
— TypeAbstractClusterPotential <: AbstractPotential
Potentials between groups of atoms
PotentialFitting.AbstractPairPotential
— TypeAbstractPairPotential <: AbstractPotential
Potential that depends only on distance between two atoms
PotentialFitting.ClusterPotentialTopology
— TypeClusterPotentialTopology{T} <: AbstractClusterPotentialTopology{T}
Container that maps a cluster potential to respective atoms.
Fields
potential::T
:indices::Vector{Vector{Int}}
: Stores information of atoms between which the potentilal exist
PotentialFitting.FitData
— TypeFitData
Structure to help potential parameters fitting.
Fields
variables
: variablesE
: energyw
: weights
Creation
FitData(mpp, points, energy)
FitData(mpp, data::Dict...)
data::Dict
: Dict that is returned byload_data_file
PotentialFitting.GeneralAngle
— TypeGeneralAngle <: AbstractClusterPotential
General potential with customizable powers for both radial polynomials and cosθ.
Fields
constants::Array{Float64,2}
: constantsppowers::Vector{Int}
: powers for radial polynomialscpowers::Vector{Int}
: powers for cosθ
To create potential use:
GeneralAngle(ppowers::AbstractVector{Int}, cpowers::AbstractVector{Int})
PotentialFitting.GeneralPowers
— TypeGeneralPowers
General potential with customizable powers.
Fields
constants::Vector{Float64}
: potential constantspowers::Vector{Int}
: powers for radius
PotentialFitting.LennardJones
— TypeLennardJones <: AbstractPairPotential
Holds constants for Lennard-Jones potential E = C12/R^12 - C6/R^6
PotentialFitting.MoleculePairPotential
— TypeMoleculePairPotential{T<:AbstractPairPotential} <: AbstractClusterPotential
Structure to hold potential information between two molecules
PotentialFitting.PairPotentialTopology
— TypePairPotentialTopology{T} <: AbstractPairPotentialTopology{T}
Container that maps a pair potential to respective atoms.
Fields
indices::Vector{Tuple{Int, Int}}
: Stores information of atom pair(s) between which the potentilal existpotential::T
: Potential structure
PotentialFitting.PairPotentialTopology
— Method(p::PairPotentialTopology)(c1::AbstractCluster, c2::AbstractCluster)
Returns potential for given cluster pair. Index for atom 2 is expected to be in cluster c2
.
PotentialFitting.PairPotentialTopology
— Method(p::PairPotentialTopology)(c::AbstractCluster)
Returns potential for given cluster.
PotentialFitting.PairPotentialTopology
— Method(p::PairPotentialTopology)(r)
Returns potential for given distance.