Skip to content

Commit 66777c1

Browse files
Merge pull request #7 from MatthiasSachs/main
documentation and I/O-functions updated
2 parents 3808017 + 6977e16 commit 66777c1

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

docs/src/fitting-eft.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ R = randf(fm,Σ)
122122
## [Friction Model with a Pairwise Coupling](@id fitting-pairwise-coupling)
123123
Instead of using a row-wise coupling, we can also use a pairwise coupling to construct a friction model. The following code produces a friction model with a pairwise coupling:
124124
```julia
125-
property = EuclideanMatrix()
125+
property = EuclideanMatrix(Float64)
126126
species_friction = [:H]
127-
species_env = [:Cu]
128-
m_equ = RWCMatrixModel(property, species_friction, species_env;
129-
species_substrat = [:Cu],
130-
rcut = 5.0,
131-
maxorder = 2,
132-
maxdeg = 5,
133-
);
127+
species_env = [:Cu,:H]
134128

135129
m_equ = PWCMatrixModel(property, species_friction, species_env;
136130
z2sym = NoZ2Sym(),
@@ -152,4 +146,5 @@ m_equ0 = OnsiteOnlyMatrixModel(property, species_friction, species_env;
152146
);
153147

154148
fm= FrictionModel((mequ_off = m_equ, mequ_on=m_equ0));
149+
155150
```

examples/fit-ACEFrictionModel-new-pw.jl

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ using ACEfriction.FrictionFit
1414

1515
using ACEfriction.MatrixModels
1616

17-
fname = "./test/test-data-large"
17+
fname = "./test/test-data-100"
1818
filename = string(fname,".h5")
1919

2020
rdata = ACEfriction.DataUtils.load_h5fdata(filename);
@@ -25,17 +25,35 @@ shuffle!(rng, rdata)
2525
n_train = Int(ceil(.8 * length(rdata)))
2626
n_test = length(rdata) - n_train
2727

28-
fdata = Dict("train" => FrictionData.(rdata[1:n_train]),
29-
"test"=> FrictionData.(rdata[n_train+1:end]));
28+
fdata = Dict("train" => rdata[1:n_train],
29+
"test"=> rdata[n_train+1:end]);
3030

3131
using ACEfriction.AtomCutoffs: SphericalCutoff
3232
using ACEfriction.MatrixModels: NoZ2Sym, SpeciesUnCoupled
33-
species_friction = [:H]
34-
species_env = [:Cu,:H]
35-
species_substrat = [:Cu]
36-
rcut = 5.0
37-
z2sym= NoZ2Sym()
38-
speciescoupling = SpeciesUnCoupled()
33+
# property = EuclideanMatrix(Float64)
34+
# species_friction = [:H]
35+
# species_env = [:Cu,:H]
36+
37+
# m_equ = PWCMatrixModel(property, species_friction, species_env;
38+
# z2sym = NoZ2Sym(),
39+
# speciescoupling = SpeciesUnCoupled(),
40+
# species_substrat = [:Cu],
41+
# n_rep = 1,
42+
# maxorder=2,
43+
# maxdeg=5,
44+
# rcut= 5.0,
45+
# );
46+
47+
# m_equ0 = OnsiteOnlyMatrixModel(property, species_friction, species_env;
48+
# species_substrat=[:Cu],
49+
# id=:equ0,
50+
# n_rep = 1,
51+
# rcut = rcut,
52+
# maxorder=2,
53+
# maxdeg=5
54+
# );
55+
56+
# fm= FrictionModel((mequ_off = m_equ, mequ_on=m_equ0));
3957

4058
m_equ = PWCMatrixModel(ACE.EuclideanMatrix(Float64),species_friction, species_env;
4159
z2sym = NoZ2Sym(),
@@ -88,6 +106,7 @@ end
88106

89107
loss_traj = Dict("train"=>Float64[], "test" => Float64[])
90108

109+
# Note: the following code only works when run in REPL (scoping of the variable 'epoch' fails if run in a global scope.)
91110
epoch = 0
92111
batchsize = 10
93112
nepochs = 10

src/datautils.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ function save_h5fdata(rdata::Vector{FrictionData}, filename::String )
6565
for (k,x) in enumerate(d.atoms.X)
6666
dset_pos[k,:] = x
6767
end
68+
write_attribute(dset_pos, "column_major", true)
6869
write(ag, "atypes", Int.(d.atoms.Z))
6970
write(ag, "cell", Matrix(d.atoms.cell))
71+
write_attribute(ag["cell"], "column_major", true)
7072
write(ag, "pbc", Array(d.atoms.pbc))
7173
# write friction data
7274
fg = create_group(g, "friction_tensor")
@@ -77,6 +79,7 @@ function save_h5fdata(rdata::Vector{FrictionData}, filename::String )
7779
for (k,v) in enumerate(V)
7880
dset_ft[k,:,:] = v
7981
end
82+
write_attribute(dset_ft, "column_major", true)
8083
write(fg, "ft_mask", d.friction_indices)
8184
end
8285
catch

test/test-data-100.h5

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)