ACEsuit / ACEpotentials.jl

Machine Learning Interatomic Potentials with the Atomic Cluster Expansion
MIT License
49 stars 13 forks source link

ACE potential for binary alloys not working in LAMMPS #175

Closed hari-ushankar closed 1 year ago

hari-ushankar commented 1 year ago

Hi @cortner and @tjjarvinen ,

I wanted to get your help on using one of the ACE models developed on a binary alloy Pt-Au, in my case.

I have a ACE model fitted and when I try to use the model to run LAMMPS on simple structure such as fcc Au, I get the following error:

terminate called after throwing an instance of 'YAML_PACE::TypedBadConversion<double>'

my potential.inp file looks like this:

pair_style hybrid/overlay pace table spline 5000
 pair_coeff * * pace fit_4.yace Au
 pair_coeff 1 1 table fit_4_pairpot.table Au_Au

( I don't have the pair potentials written down for Pt_Au and Pt_Pt since I don't have any Pt in my geometry file..)

I just ask the LAMMPS minimizer to relax the structure to its equilibrium lattice constant, but somehow the model does not seem to run.

Lammps versions is 22 Dec 2022.

Any clue to what is going wrong here?

Attached below is the full log message from LAMMPS:

Reading data file ...
  orthogonal box = (0 0 0) to (16 16 16)
  1 by 2 by 2 MPI processor grid
  reading atoms ...
  256 atoms
  read_data CPU = 0.002 seconds
ACE version: 2022.6.27
Recursive evaluator is used
Loading fit_4.yace
terminate called after throwing an instance of 'YAML_PACE::TypedBadConversion<double>'
  what():  bad conversion
terminate called after throwing an instance of 'YAML_PACE::TypedBadConversion<double>'
  what():  bad conversion
terminate called after throwing an instance of 'YAML_PACE::TypedBadConversion<double>'
  what():  bad conversion

===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   PID 3974198 RUNNING AT hari-IdeaPad-5-15ALC05
=   EXIT CODE: 134
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Aborted (signal 6)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
cortner commented 1 year ago

@hari-ushankar -- (1) Please confirm you are using the latest version of ACEpotentials.jl? Post your project's ] status. (2) Post the complete script to specify the ACEpotentials.jl, fit the parameters, and export to yace.

hari-ushankar commented 1 year ago

@cortner , here are the details you asked for:

(1) It is the latest version:

(PtAu) pkg> st Status ~/PtAu/Project.toml [3b96b61c] ACEpotentials v0.6.1 [945c410c] JuLIP v0.14.2

(2)


using Pkg
Pkg.activate("../")

using Distributed
# addprocs(30, exeflags="--project=$(Base.active_project())")

@everywhere using ACEpotentials 
using JuLIP, Statistics, LinearAlgebra, PyPlot

function get_ace(train; order=3, deg=13, nc=20)
    data_keys = (energy_key = "energy", force_key = "forces", virial_key = "virials")
    model = acemodel(elements = [:Pt, :Au],
                    order = order,
                    totaldegree = deg,
                    rcut = 5.0, 
                    Eref = [:Pt => -7.43261575, :Au => -4.3963985]);
    @show length(model.basis);
    P = smoothness_prior(model; p = 4)
    solver = ACEfit.BLR(committee_size=nc, factorization=:svd)
    acefit!(model, train; solver=solver, prior=P, data_keys...);
    return model
end

train = read_extxyz("randspg_output.xyz")[1:650];
model = get_ace(train, deg=13); 
ace = model.potential;
export2json("./data/fit_$K.json", model);
export2lammps("./data/fit_$K.yace", model);
hari-ushankar commented 1 year ago

Also, tried to load the potential (.json file) into Julia:

Pkg.activate(".")
using JuLIP
ace = read_dict(load_dict("fit_4.json")["potential"]);

ERROR: ACEbase.FIO.read_dict no implemented for symbol ACE1_PolyPairPot
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] read_dict(#unused#::Val{:ACE1_PolyPairPot}, D::Dict{String, Any})
    @ ACEbase.FIO ~/miniconda3/envs/ase_env/share/julia/packages/ACEbase/kykzL/src/fio.jl:70
  [3] read_dict(D::Dict{String, Any})
    @ ACEbase.FIO ~/miniconda3/envs/ase_env/share/julia/packages/ACEbase/kykzL/src/fio.jl:67
  [4] _broadcast_getindex_evalf
    @ ./broadcast.jl:683 [inlined]
  [5] _broadcast_getindex
    @ ./broadcast.jl:656 [inlined]
  [6] getindex
    @ ./broadcast.jl:610 [inlined]
  [7] copyto_nonleaf!(dest::Vector{OneBody{Float64}}, bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Tuple{Base.OneTo{Int64}}, typeof(read_dict), Tuple{Base.Broadcast.Extruded{Vector{Any}, Tuple{Bool}, Tuple{Int64}}}}, iter::Base.OneTo{Int64}, state::Int64, count::Int64)
    @ Base.Broadcast ./broadcast.jl:1068
  [8] copy
    @ ./broadcast.jl:920 [inlined]
  [9] materialize(bc::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{1}, Nothing, typeof(read_dict), Tuple{Vector{Any}}})
    @ Base.Broadcast ./broadcast.jl:873
 [10] JuLIP.MLIPs.SumIP(D::Dict{String, Any})
    @ JuLIP.MLIPs ~/miniconda3/envs/ase_env/share/julia/packages/JuLIP/BpQXK/src/mlips.jl:187
 [11] read_dict(#unused#::Val{:JuLIP_SumIP}, D::Dict{String, Any})
    @ JuLIP.MLIPs ~/miniconda3/envs/ase_env/share/julia/packages/JuLIP/BpQXK/src/mlips.jl:188
 [12] read_dict(D::Dict{String, Any})
    @ ACEbase.FIO ~/miniconda3/envs/ase_env/share/julia/packages/ACEbase/kykzL/src/fio.jl:67
 [13] top-level scope
    @ REPL[7]:1

current package status: [8c4e8d19] ACE1pack v0.5.0 [3b96b61c] ACEpotentials v0.6.1 [51974c44] ASE v0.5.4 [945c410c] JuLIP v0.14.2 [438e738f] PyCall v1.96.1 [d330b81b] PyPlot v2.11.2

wcwitt commented 1 year ago

1) Have you installed LAMMPS with the patch as described here? https://acesuit.github.io/ACEpotentials.jl/dev/tutorials/lammps/

2) Does the potential work successfully in LAMMPS if you have both Pt and Au in the simulation?

cortner commented 1 year ago

Regarding loading it in Julia - did you make sure that you used the same environment to load the model as the one you used to save it? We currently don't yet guarantee backward compatibility of model files.

hari-ushankar commented 1 year ago
  1. Have you installed LAMMPS with the patch as described here? https://acesuit.github.io/ACEpotentials.jl/dev/tutorials/lammps/

    1. Does the potential work successfully in LAMMPS if you have both Pt and Au in the simulation?

Thank you for this, @wcwitt ! Didn;t know that patch existed. :)

Regarding loading it in Julia - did you make sure that you used the same environment to load the model as the one you used to save it? We currently don't yet guarantee backward compatibility of model files.

yeah, I did not know this would be a problem as well. Thanks for pointing this out - will keep in mind.

I will now close this comment. :+1: