Comments (6)
JuLIP is quite old and possibly not flexible enough to easily adapt to abstract number types. E.g. I've long wanted to allow dual and hyer-dual numbers. Those would give you the same I think. I was planning to re-work Stillinger-Weber and EAM to allow this, but within the new EmpiricalPotentials.jl
instead of JuLIP.jl
from julip.jl.
Sounds good, I will keep an eye on EmpiricalPotentials.jl
then. Would it work with ACEpotentials.jl
?
from julip.jl.
that's the goal
from julip.jl.
If you look at EmpiricalPotentials now, the SW potential can already accept general number types as inputs.
from julip.jl.
I had a look and indeed types are no longer the problem, but, as expected, conditional statements involving cut-offs are. Here is a MWE, adapted from the tests in EmpiricalPotentials:
using Symbolics
using LinearAlgebra
using AtomsBase
using AtomsCalculators
using AtomsCalculators.AtomsCalculatorsTesting
using EmpiricalPotentials
using ExtXYZ
using FiniteDiff
using Test
using Unitful
using JSON, StaticArrays
sw = StillingerWeber()
fname = joinpath(pkgdir(EmpiricalPotentials),"test", "data", "test_sw.json")
D = JSON.parsefile(fname)
tests = D["tests"]
function read_test(t::Dict)
Rs = SVector{3, Float64}.(t["Rs"])
Zs = Int.(t["Zs"])
z0 = Int(t["z0"])
v = Float64(t["val"])
return Rs, Zs, z0, v
end
Rs, Zs, z0, _ = read_test(tests[2])
YY = Symbolics.variables(:YY, 1:3, 1:3)
Rs_sym = [YY* rs for rs in Rs] # create symbolic Rs
EmpiricalPotentials.eval_site(sw, Rs_sym, Zs, z0) # evaluate the site potential
Then we get an error
ERROR: TypeError: non-boolean (Num) used in boolean context
Stacktrace:
[1] (::EmpiricalPotentials.var"#60#62"{Float64, Float64, Float64, Float64, Float64, Float64})(r::Num)
@ EmpiricalPotentials ~/.julia/packages/EmpiricalPotentials/APr5T/src/stillingerweber/stillingerweber.jl:124
[2] eval_site(calc::StillingerWeber{…}, Rs::Vector{…}, Zs::Vector{…}, z0::Int64)
@ EmpiricalPotentials ~/.julia/packages/EmpiricalPotentials/APr5T/src/stillingerweber/stillingerweber.jl:154
Some type information was truncated. Use `show(err)` to see complete types.
and the responsible line is
V3 = r -> r >= rcut ? 0.0 : sqrt(ϵ * λ) * exp( γ / (r/σ - a) ).
When I remove the conditional statements in the definition of V2
and V3
manually (by defining a new function StillingerWeber_sym
mimicking the in the repo), everything works though!
w_sym = StillingerWeber_sym()
Es = EmpiricalPotentials.eval_site(sw_sym,Rs_sym,Zs,z0)
dd1 = Symbolics.derivative(Es,YY[1,1])
dd2 = Symbolics.derivative(dd1,YY[1,1])
dd3 = Symbolics.derivative(dd2,YY[1,1])
dd2_sub = substitute(dd2, Dict([YY[1,1] => 1.0, YY[1,2] => 0.0, YY[1,3] => 0.0,
YY[2,1] => 0.0, YY[2,2] => 1.0, YY[2,3] => 0.0,
YY[3,1] => 0.0, YY[3,2] => 0.0, YY[3,3] => 1.0]))
dd3_sub = substitute(dd3, Dict([YY[1,1] => 1.0, YY[1,2] => 0.0, YY[1,3] => 0.0,
YY[2,1] => 0.0, YY[2,2] => 1.0, YY[2,3] => 0.0,
YY[3,1] => 0.0, YY[3,2] => 0.0, YY[3,3] => 1.0]))
The output for dd3
is ridiculously gigantic and it seems like the computation of dd3
takes about a minute, but in fact it is the printing of the output that takes so long! If the output is suppressed, it is almost instantaneous! Ultimately it spells out numbers, which are kind of believeable, dd3_sub = -4.166279257769397e6
and dd2_sub = 151351.422520672
. The magnitude makes a bit worried that it is not correct though... Also entries such as C[1,1,1,2]
come out as non-zero too, but I guess it might have something to do that the system is a multi-lattice, so the Cauchy-Born rule works differently?
But the bottom line is, it is super quick and works (at least in principle), provided that we ensure no conditional statements are supplied :)
from julip.jl.
We could remove the cutoff check by multiplying with a characteristic function that could then be overloaded for your number type. In principle I'm open to this, but I suspect this won't go well for more general potentials especially of ACE-like complexity ...
Have you considered symbolic regression instead?
from julip.jl.
Related Issues (20)
- EAM Hessians Incorrect with PBC HOT 14
- Cache Forces and Virials
- Energy changes with cell in non periodic case HOT 5
- XYZ HOT 8
- Dierckx.jl dependency causes problems on ARM chipset HOT 2
- XYZ files and missing `pbc` key HOT 6
- Multithreading bug HOT 5
- Sync with General Registry HOT 6
- New NeighbourList
- AtomsBase Compatibility
- Redesign Multi-threading HOT 13
- Future of JuLIP HOT 1
- Fix CI on Mac
- Problem with `read_extxyz` HOT 5
- `read_extxyz` does something strange with the virials for 3-atom cells HOT 6
- Need Cutoff for SumIP HOT 1
- Cached Neighourlists Issue
- site_energy_d gives back MethodError! HOT 5
- Site energy evaluation not working when SumIP has OneBody{Float64} component HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from julip.jl.