Some Experimental Features

This tutorial will go through a few experimental features that are made available but may not be fully tested and should note be relied upon.

using ACEpotentials

We do a quick fit of a TiAl potential following the same steps as in the TiAl model tutorial.

model = acemodel(elements = [:Ti, :Al], order = 3, totaldegree = 6,
					  rcut = 5.5, Eref = [:Ti => -1586.0195, :Al => -105.5954])
weights = Dict("FLD_TiAl" => Dict("E" => 60.0, "F" => 1.0 , "V" => 1.0 ),
               "TiAl_T5000" => Dict("E" => 5.0, "F" => 1.0 , "V" => 1.0 ))
solver = ACEfit.LSQR(damp = 1e-2, atol = 1e-6);
P = smoothness_prior(model; p = 4)
data, _, meta = ACEpotentials.example_dataset("TiAl_tutorial")
data_train = data[1:5:end]
acefit!(model, data_train; solver=solver, prior = P);
┌────────────┬──────────┬───────┬────┬──────┬─────┐
│       Type  #Configs  #Envs  #E    #F   #V │
├────────────┼──────────┼───────┼────┼──────┼─────┤
│   FLD_TiAl │       63 │   126 │ 63 │  378 │ 378 │
│ TiAl_T5000 │        3 │   310 │  3 │  930 │  18 │
├────────────┼──────────┼───────┼────┼──────┼─────┤
│      total │       66 │   436 │ 66 │ 1308 │ 396 │
│    missing │        0 │     0 │  0 │    0 │   0 │
└────────────┴──────────┴───────┴────┴──────┴─────┘
[ Info: Assembling linear problem.
[ Info:   - Creating feature matrix with size (1770, 190).
[ Info:   - Beginning assembly with processor count:  1.

Progress:   3%|█▎                                       |  ETA: 0:00:23
Progress:   8%|███▏                                     |  ETA: 0:00:19
Progress:  23%|█████████▍                               |  ETA: 0:00:15
Progress:  27%|███████████▏                             |  ETA: 0:00:14
Progress:  42%|█████████████████▍                       |  ETA: 0:00:11
Progress:  58%|███████████████████████▋                 |  ETA: 0:00:08
Progress:  62%|█████████████████████████▌               |  ETA: 0:00:07
Progress:  67%|███████████████████████████▍             |  ETA: 0:00:06
Progress:  82%|█████████████████████████████████▌       |  ETA: 0:00:03
Progress:  86%|███████████████████████████████████▍     |  ETA: 0:00:03
Progress:  91%|█████████████████████████████████████▎   |  ETA: 0:00:02
Progress: 100%|█████████████████████████████████████████| Time: 0:00:19
[ Info:   - Assembly completed.
[ Info: Assembling full weight vector.
┌ Warning: Need to apply preconditioner in LSQR.
@ ACEfit ~/.julia/packages/ACEfit/9u2t5/src/solvers.jl:94
damp  0.01
atol  1.0e-6
maxiter  100000
Converged after 272 iterations.
relative RMS error  0.004399960492435998

Next we convert the model to a new experimental evaluator that should be a lot faster - at least for small models.

fpot = ACEpotentials.Experimental.fast_evaluator(model);
[ Info: Importing pair potential model
[ Info: Importing many-body potential
[ Info: Importing 1-body potential

The predictions should be correct to within 10-13 digits.

for ntest = 1:10
   at = rattle!(rand(data), 0.01)
   E = energy(model.potential, at)
   E_fast = energy(fpot, at)
   @show abs(E - E_fast)
end;
abs(E - E_fast) = 0.0
abs(E - E_fast) = 2.2737367544323206e-13
abs(E - E_fast) = 0.0
abs(E - E_fast) = 0.0
abs(E - E_fast) = 2.2737367544323206e-13
abs(E - E_fast) = 2.2737367544323206e-13
abs(E - E_fast) = 2.2737367544323206e-13
abs(E - E_fast) = 2.2737367544323206e-13
abs(E - E_fast) = 0.0
abs(E - E_fast) = 0.0

Now let's look at timings, they should be significantly faster for the new evaluator. Note that the speedup will be different depending on the size of the model and the architecture of the computer.

forces(model.potential, data[1]);
forces(fpot, data[1]);
print("Energy, old evaluator: ")
@time for d in data; energy(model.potential, d); end
print("Energy, new evaluator: ")
@time for d in data; energy(fpot, d); end
print("Forces, old evaluator: ")
@time for d in data; forces(model.potential, d); end
print("Forces, new evaluator: ")
@time for d in data; forces(fpot, d); end
Energy, old evaluator:   0.113376 seconds (2.00 M allocations: 92.506 MiB)
Energy, new evaluator:   0.015397 seconds (1.65 k allocations: 479.297 KiB)
Forces, old evaluator:   0.231537 seconds (4.32 M allocations: 151.540 MiB, 26.75% gc time)
Forces, new evaluator:   0.030301 seconds (1.98 k allocations: 993.656 KiB)

This page was generated using Literate.jl.