diff --git a/docs/src/fitting-eft.md b/docs/src/fitting-eft.md index 2185c7f..97de2d3 100644 --- a/docs/src/fitting-eft.md +++ b/docs/src/fitting-eft.md @@ -122,15 +122,9 @@ R = randf(fm,Σ) ## [Friction Model with a Pairwise Coupling](@id fitting-pairwise-coupling) 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: ```julia -property = EuclideanMatrix() +property = EuclideanMatrix(Float64) species_friction = [:H] -species_env = [:Cu] -m_equ = RWCMatrixModel(property, species_friction, species_env; - species_substrat = [:Cu], - rcut = 5.0, - maxorder = 2, - maxdeg = 5, -); +species_env = [:Cu,:H] m_equ = PWCMatrixModel(property, species_friction, species_env; z2sym = NoZ2Sym(), @@ -152,4 +146,5 @@ m_equ0 = OnsiteOnlyMatrixModel(property, species_friction, species_env; ); fm= FrictionModel((mequ_off = m_equ, mequ_on=m_equ0)); + ``` \ No newline at end of file diff --git a/examples/fit-ACEFrictionModel-new-pw.jl b/examples/fit-ACEFrictionModel-new-pw.jl index 581af35..721046b 100644 --- a/examples/fit-ACEFrictionModel-new-pw.jl +++ b/examples/fit-ACEFrictionModel-new-pw.jl @@ -14,7 +14,7 @@ using ACEfriction.FrictionFit using ACEfriction.MatrixModels -fname = "./test/test-data-large" +fname = "./test/test-data-100" filename = string(fname,".h5") rdata = ACEfriction.DataUtils.load_h5fdata(filename); @@ -25,17 +25,35 @@ shuffle!(rng, rdata) n_train = Int(ceil(.8 * length(rdata))) n_test = length(rdata) - n_train -fdata = Dict("train" => FrictionData.(rdata[1:n_train]), - "test"=> FrictionData.(rdata[n_train+1:end])); +fdata = Dict("train" => rdata[1:n_train], + "test"=> rdata[n_train+1:end]); using ACEfriction.AtomCutoffs: SphericalCutoff using ACEfriction.MatrixModels: NoZ2Sym, SpeciesUnCoupled -species_friction = [:H] -species_env = [:Cu,:H] -species_substrat = [:Cu] -rcut = 5.0 -z2sym= NoZ2Sym() -speciescoupling = SpeciesUnCoupled() +# property = EuclideanMatrix(Float64) +# species_friction = [:H] +# species_env = [:Cu,:H] + +# m_equ = PWCMatrixModel(property, species_friction, species_env; +# z2sym = NoZ2Sym(), +# speciescoupling = SpeciesUnCoupled(), +# species_substrat = [:Cu], +# n_rep = 1, +# maxorder=2, +# maxdeg=5, +# rcut= 5.0, +# ); + +# m_equ0 = OnsiteOnlyMatrixModel(property, species_friction, species_env; +# species_substrat=[:Cu], +# id=:equ0, +# n_rep = 1, +# rcut = rcut, +# maxorder=2, +# maxdeg=5 +# ); + +# fm= FrictionModel((mequ_off = m_equ, mequ_on=m_equ0)); m_equ = PWCMatrixModel(ACE.EuclideanMatrix(Float64),species_friction, species_env; z2sym = NoZ2Sym(), @@ -88,6 +106,7 @@ end loss_traj = Dict("train"=>Float64[], "test" => Float64[]) +# Note: the following code only works when run in REPL (scoping of the variable 'epoch' fails if run in a global scope.) epoch = 0 batchsize = 10 nepochs = 10 diff --git a/src/datautils.jl b/src/datautils.jl index f6f90ea..67a2479 100644 --- a/src/datautils.jl +++ b/src/datautils.jl @@ -65,8 +65,10 @@ function save_h5fdata(rdata::Vector{FrictionData}, filename::String ) for (k,x) in enumerate(d.atoms.X) dset_pos[k,:] = x end + write_attribute(dset_pos, "column_major", true) write(ag, "atypes", Int.(d.atoms.Z)) write(ag, "cell", Matrix(d.atoms.cell)) + write_attribute(ag["cell"], "column_major", true) write(ag, "pbc", Array(d.atoms.pbc)) # write friction data fg = create_group(g, "friction_tensor") @@ -77,6 +79,7 @@ function save_h5fdata(rdata::Vector{FrictionData}, filename::String ) for (k,v) in enumerate(V) dset_ft[k,:,:] = v end + write_attribute(dset_ft, "column_major", true) write(fg, "ft_mask", d.friction_indices) end catch diff --git a/test/test-data-100.h5 b/test/test-data-100.h5 index 7b155e9..e3692e9 100644 Binary files a/test/test-data-100.h5 and b/test/test-data-100.h5 differ