SunnySuite / Sunny.jl

Spin dynamics and generalization to SU(N) coherent states
Other
86 stars 19 forks source link

Error reading `.cif` with partial occupation #158

Open Lazersmoke opened 1 year ago

Lazersmoke commented 1 year ago

In my material LaSrCrO4, there is a lattice site where there is 50% of the time a La and 50% of the time a Sr. The .cif I have (attached) lists these both at the same site, but 0.5 occupancy. Sunny complains:

Reference positions [0.0, 0.0, 0.359] and [0.0, 0.0, 0.359] are symmetry equivalent.

Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] crystal_from_symops(latvecs::StaticArraysCore.SMatrix{3, 3, Float64, 9}, positions::Vector{StaticArraysCore.SVector{3, Float64}}, types::Vector{String}, symops::Vector{Sunny.SymOp}, spacegroup::String; symprec::Float64)
   @ Sunny C:\Users\Sam\.julia\dev\Sunny\src\Symmetry\Crystal.jl:358
 [3] crystal_from_symops
   @ C:\Users\Sam\.julia\dev\Sunny\src\Symmetry\Crystal.jl:341 [inlined]
 [4] Crystal(filename::String; symprec::Float64)
   @ Sunny C:\Users\Sam\.julia\dev\Sunny\src\Symmetry\Parsing.jl:168
 [5] top-level scope
   @ In[54]:1

which is completely true, it should just make a Crystal with type "La/Sr" in this situation instead of complaining.

(Maybe related to #31 )

example_cif.zip

kbarros commented 1 year ago

I like the error in the general case, because it forces people to think about what they want. Maybe we should allow "opt in" merging of sites:

Crystal("example.cif"; merge_sites=true)