Skip to content

Commit

Permalink
Merge pull request #60 from cesmix-mit/sw/vecvecvec_fdescr_consistency
Browse files Browse the repository at this point in the history
Consistency with IP.jl vev{vec{vec}} force descriptor output (for ACE)
  • Loading branch information
swyant authored Jan 29, 2024
2 parents f666a97 + 4514643 commit 6a246f1
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ docs/src/generated/
# data too large for github
examples/aHfO2/
*.xyz
!test/data/TiAl_examples.xyz
*.csv
3 changes: 1 addition & 2 deletions src/Data/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ function compute_force_descriptors(
end
f_des = Vector{ForceDescriptors}(undef, length(ds))
Threads.@threads for (j, sys) in iter
f_des[j] = ForceDescriptors([[ fi[i, :] for i = 1:3]
for fi in compute_force_descriptors(sys, basis)])
f_des[j] = ForceDescriptors([fi for fi in compute_force_descriptors(sys,basis)])
end
return f_des
end
Expand Down
72 changes: 72 additions & 0 deletions test/data/TiAl_examples.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
2
Lattice="2.614036117884091 0.0 0.0 0.0 2.6528336296738044 0.0 0.0 0.0 3.8250280122051756" Properties=species:S:1:pos:R:3:forces:R:3 config_type=FLD_TiAl spacegroup="P 1" virial="5.072173561696366 0.1220123768779895 0.6518229755809941 0.1220123768779895 4.667636799854875 0.5969893898844183 0.6518229755809941 0.5969893898844183 4.700422750506493" energy=-1703.64063822 unit_cell=conventional n_minim_iter=2 pbc="T T T"
Ti 1.30924260 1.32316179 1.62637131 0.86219000 0.78737000 2.65969000
Al 0.11095015 0.09471147 -0.05013464 -0.86219000 -0.78737000 -2.65969000
2
Lattice="2.6528336296738044 0.02630779655214213 0.0 0.0 2.6528336296738044 0.0 0.0 0.0 3.8250280122051756" Properties=species:S:1:pos:R:3:forces:R:3 config_type=FLD_TiAl spacegroup="P 1" virial="4.15023781187055 -0.06577612122395084 -0.171170505070969 -0.06577612122395084 4.04967986552191 -0.5378649084927113 -0.171170505070969 -0.5378649084927113 4.042613216415338" energy=-1703.82673644 unit_cell=conventional n_minim_iter=2 pbc="T T T"
Ti 1.33489792 1.43578555 1.86138486 -0.26082000 -0.81162000 2.10994000
Al -0.02858694 -0.01403313 0.14867884 0.26082000 0.81162000 -2.10994000
2
Lattice="2.6528336296738044 0.0 0.06755175285654859 0.0 2.6528336296738044 0.0 0.0 0.0 3.8250280122051756" Properties=species:S:1:pos:R:3:forces:R:3 config_type=FLD_TiAl spacegroup="P 1" virial="4.072891774873278 -0.13349515091838202 -0.939913055098077 -0.13349515091838202 3.4624871924596543 0.6797839218196843 -0.939913055098077 0.6797839218196843 4.678858951924236" energy=-1703.76378253 unit_cell=conventional n_minim_iter=2 pbc="T T T"
Ti 1.23028343 1.55107468 1.99220177 0.37348000 -1.76228000 -1.23099000
Al -0.06003893 -0.04203415 -0.05924850 -0.37348000 1.76228000 1.23099000
2
Lattice="2.6528336296738044 0.0 0.0 -0.1057971256485768 2.6528336296738044 0.0 0.0 0.0 3.8250280122051756" Properties=species:S:1:pos:R:3:forces:R:3 config_type=FLD_TiAl spacegroup="P 1" virial="3.4352149001087975 0.23586814744054302 0.0334390609863217 0.23586814744054302 3.5011123271020055 -0.008344560022040605 0.0334390609863217 -0.008344560022040605 3.7232905640372547" energy=-1704.03703072 unit_cell=conventional n_minim_iter=2 pbc="T T T"
Ti 1.35588383 1.27811402 1.95469642 -0.64417000 0.17368000 -0.14898000
Al -0.01751269 -0.01386901 0.02786533 0.64417000 -0.17368000 0.14898000
54
Lattice="8.45590719458525 0.0 0.0 0.0 8.45590719458525 0.0 0.0 0.0 12.192276788903998" Properties=species:S:1:pos:R:3:forces:R:3 virial="120.41431439548624 1.1960686724332905 -2.9454694870837823 1.1960686724332905 78.3958354257547 -2.98657776724516 -2.9454694870837823 -2.98657776724516 60.957877099758356" config_type=TiAl_T5000 energy=-45948.6377607 pbc="T T T"
Ti -0.17298249 4.51237649 2.35746206 1.31968000 -1.76275000 2.04526000
Al -0.23509113 -3.61596577 -0.13346885 0.20072000 1.70460000 -1.32002000
Ti 4.59253004 0.34393557 7.98575841 1.16692000 3.32997000 -1.25257000
Al 1.12386617 -1.12848309 5.37976898 1.37720000 -5.19451000 -4.45199000
Ti 3.26039487 4.45294838 8.90718973 0.72710000 -0.89265000 -0.72864000
Al -2.47668448 2.57204175 9.20090168 -2.12036000 -0.31778000 -0.49411000
Ti -0.37246580 -2.28332325 -2.16728693 0.15264000 1.25311000 -1.19080000
Al 2.01559232 -0.16474644 -0.56267357 -0.22557000 -0.47455000 0.80492000
Ti 3.23117971 5.44453879 6.10333184 -1.24252000 -1.01376000 0.01516000
Al 3.56856195 -0.27315117 5.82292166 0.21725000 0.05507000 -0.24115000
Ti 2.00468420 3.82812448 12.91523003 0.27457000 2.25122000 -0.33655000
Al -1.00681950 1.15926260 8.15326810 0.82558000 -0.25319000 -1.57647000
Ti 1.27033094 8.97041532 -2.86338059 -0.77440000 0.16854000 -0.84570000
Al 0.25841252 4.88499450 -6.53588943 -0.13398000 -1.40303000 -0.76296000
Ti 4.48839554 5.93245309 3.15973826 -0.85838000 1.23787000 0.48959000
Al 0.83009104 10.36859958 0.96890804 12.56781000 -10.50899000 3.99872000
Ti -0.18543804 3.92146079 8.32775178 1.30849000 -0.50863000 0.48604000
Al -0.74493160 8.23633265 12.66806820 5.02451000 1.70090000 4.45842000
Ti 6.39538864 0.59158372 5.53775650 -1.03975000 -0.22663000 1.32104000
Al -0.65990745 -5.63914304 0.67953655 -8.96466000 5.88005000 -1.21840000
Ti 9.27695887 -1.62467573 1.83599838 -0.33930000 1.17966000 -0.46095000
Al -2.81294209 -4.25672059 1.71951337 0.57322000 2.96223000 -1.13344000
Ti 3.61516246 2.15808281 12.11455102 -0.07193000 0.11896000 1.50074000
Al 5.92554461 3.19798182 11.66789916 -0.96818000 -0.41420000 -2.43040000
Ti 2.90353022 8.44062737 3.39820700 -1.24687000 0.64820000 0.59961000
Al 2.55313434 2.87674191 2.88091308 -5.39321000 -0.55340000 -1.94571000
Ti 4.06171046 2.38484487 5.74196495 0.27462000 -0.04213000 0.42813000
Al 0.78838651 -2.20082742 7.63963187 2.94004000 0.07217000 2.00060000
Ti 6.24383342 4.08431310 6.69482795 -0.92594000 -0.44146000 0.45799000
Al 1.52055814 2.42362366 4.87566710 -1.63606000 -0.23418000 1.56251000
Ti 1.93727371 5.86116134 3.64173554 1.11498000 -2.39466000 -0.90950000
Al -3.14541990 6.93032624 -2.86739185 -4.67402000 -3.27080000 -1.16286000
Ti -0.35232383 9.11903635 3.66234049 1.42770000 -0.00249000 -1.05660000
Al 0.52235521 0.42717552 6.42764640 -2.53445000 5.48035000 3.38268000
Ti 4.08565759 9.39900298 10.18871994 -0.31925000 -0.55807000 0.15152000
Al 2.95276051 7.10261535 8.72275716 -0.84446000 -0.59529000 -0.10663000
Ti 11.31380934 -2.64017099 0.57985249 1.22823000 2.03268000 2.44843000
Al 5.55805089 8.04577033 -0.09311242 -1.83384000 2.15720000 -4.14795000
Ti 10.52322430 2.10619736 7.46157586 1.44122000 1.08201000 1.17332000
Al 3.98690105 -0.18744209 1.24364881 -3.77853000 -0.18586000 2.19438000
Ti 9.97260944 2.86327165 10.64578402 -0.93344000 -0.18069000 -1.14273000
Al 7.09371128 -1.71416459 6.92849294 20.77918000 2.79789000 1.90343000
Ti 6.98110396 5.88857539 3.58389538 0.51742000 1.33802000 1.58749000
Al 5.97901977 1.93850827 1.69108098 -0.69444000 -3.28713000 0.86818000
Ti 5.88448273 8.32705608 3.11776025 -0.97798000 -0.74764000 -0.36773000
Al 6.58684729 -0.18477848 10.08263494 2.91038000 3.17498000 -1.17154000
Ti 4.64129525 5.37027901 11.63632116 -0.65252000 0.60811000 -0.88463000
Al 7.89642210 1.14092173 11.21588269 2.66393000 6.26528000 -5.27142000
Ti 6.89425334 11.52822578 4.49253700 0.54180000 -0.39185000 -0.87902000
Al 4.52094233 11.51331801 3.34306133 4.51339000 -0.30338000 2.94753000
Ti 6.22079953 4.87613271 9.60238116 1.04687000 -0.89976000 0.08242000
Al 6.70728478 6.57027371 0.93943931 -1.78136000 -8.58552000 4.59461000
Ti 1.82533441 5.66774092 10.78765335 0.35860000 0.50566000 -1.42251000
Al 5.46743739 6.55432587 6.80080322 -22.52862000 -2.35977000 -2.58976000
85 changes: 85 additions & 0 deletions test/data/data_utils_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using Unitful
using InteratomicPotentials

# TODO: Many tests needed to be added for structs/fns in Data section

#=
This data is a small subset of the TiAl_tutorial.xyz artifact that was used for
testing and documentation in Ace1pack https://github.com/ACEsuit/ACE1pack.jl
=#
TiAl_ds = load_data("./data/TiAl_examples.xyz", ExtXYZ(u"eV", u"Å"))

ace = ACE(species = [:Ti, :Al],
body_order = 3,
polynomial_degree = 6,
wL = 1.5,
csp = 1.0,
r0 = 2.9,
rcutoff = 5.5 )

e_descr = compute_local_descriptors(TiAl_ds, ace; pbar=false)
@test length(e_descr) == 5
@test typeof(e_descr) <: Vector{LocalDescriptors}
@test length(e_descr[1]) == 2 # num atoms in 1st config
@test length(e_descr[end]) == 54 # num atoms in last config
@test length(e_descr[1][1]) == 104 # number local descrs

#TODO need to document reference better, preferably w/ repro Manifest.toml etc.
#long-run, should do more than spot-checking
@testset "data_utils: local descriptors ref check" begin
#=
spot-checking descriptor values (and order), based off of the above basis
IP.jl v.0.2.7
ACE1 v0.10.7
JuLIP v0.11.5
Julia 1.9.2+0.aarch64.apple.darwin14
=#

ed_vals11 = get_values(e_descr[1][1])
ed_vals32 = get_values(e_descr[3][2])
ed_vals51 = get_values(e_descr[5][1])

@test ed_vals11[10] 0.0
@test ed_vals11[end-15] -5.541800263121354 #TODO should actual specify tols

@test ed_vals32[1] 0.9105447479710141
@test ed_vals32[52] 7.927103583234019

@test ed_vals51[100] -0.3889692376173769
@test ed_vals51[end] 4.344079434030667
end

f_descr = compute_force_descriptors(TiAl_ds,ace; pbar=false)
@test length(f_descr) ==5
@test typeof(f_descr) <: Vector{ForceDescriptors}
@test length(f_descr[1]) == 2
@test length(f_descr[end]) == 54
@test length(f_descr[1][1]) == 3 # 3 cartesian directions
@test length(get_values(f_descr[1][1])[1]) == 104

@testset "data_utils: force descriptors ref check" begin
#=
spot-checking descriptor values (and order), based off of the above basis
IP.jl v.0.2.7
ACE1 v0.10.7
JuLIP v0.11.5
Julia 1.9.2+0.aarch64.apple.darwin14
=#

fd_vals11_1 = get_values(f_descr[1][1])[1]
fd_vals32_2 = get_values(f_descr[3][2])[2]
fd_vals51_3 = get_values(f_descr[5][1])[3]

@test fd_vals11_1[14] 0.0
@test fd_vals11_1[66] 0.21012541753661917
@test fd_vals11_1[90] 0.07680220708487306
@test fd_vals11_1[end] 0.0

@test fd_vals32_2[7] 0.09927939932561863
@test fd_vals32_2[31] -1.1185724606158156
@test fd_vals32_2[80] 1.780519258001138

@test fd_vals51_3[23] 0.0
@test fd_vals51_3[50] 8.247266509962259
@test fd_vals51_3[end] 8.194593298142163
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ using Test
@testset "Learning Tests" begin
include("learning/linear_tests.jl")
end
@testset "Data Tests" begin
include("data/data_utils_tests.jl")
end
end

0 comments on commit 6a246f1

Please sign in to comment.