Skip to content

Commit

Permalink
Track spacegroup setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros committed Nov 1, 2024
1 parent 07a25f7 commit 0f368df
Show file tree
Hide file tree
Showing 30 changed files with 1,021 additions and 500 deletions.
3 changes: 1 addition & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# To build docs, execute `julia --project=@. make.jl`. The JuliaHub build
# environment additionally uses `--compiled-modules=no`.
# julia --project=@. --compiled-modules=existing make.jl

isdraft = false # set `true` to disable cell evaluation

Expand Down
5 changes: 5 additions & 0 deletions docs/src/versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
polynomial order according to an error tolerance.
* Rename mode `:dipole_large_S` to `:dipole_uncorrected` to emphasize that
corrections are missing.
* The [`Crystal`](@ref) constructor, by default, interprets a spacegroup number
in its ITA standard setting, e.g., as used by the [Bilbao crystallographic
server](https://www.cryst.ehu.es/cryst/get_wp.html). The keyword argument
`setting` becomes `choice`, and can typically be omitted.
* Rename `primitive_cell_shape` to [`primitive_cell`](@ref).

## v0.7.2
(Sep 11, 2024)
Expand Down
28 changes: 13 additions & 15 deletions examples/01_LSWT_CoRh2O4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ units = Units(:meV, :angstrom);
a = 8.5031 # (Å)
latvecs = lattice_vectors(a, a, a, 90, 90, 90)

# Construct the [`Crystal`](@ref) cell from the spacegroup number 227 and one
# representative atom of each occupied Wyckoff. In the standard setting of
# spacegroup 227, position `[0, 0, 0]` belongs to Wyckoff 8a, which is the
# diamond cubic crystal.
# Construct a [`Crystal`](@ref) cell from spacegroup 227 in the ITA standard
# setting. Cobalt atoms belong to Wyckoff 8a, which is the diamond cubic
# lattice.

positions = [[0, 0, 0]]
cryst = Crystal(latvecs, positions, 227; types=["Co"], setting="1")
positions = [[1/8, 1/8, 1/8]]
cryst = Crystal(latvecs, positions, 227; types=["Co"])

# [`view_crystal`](@ref) launches an interface for interactive inspection and
# symmetry analysis.
Expand All @@ -80,7 +79,7 @@ sys = System(cryst, [1 => Moment(s=3/2, g=2)], :dipole)
# the antiferromagnetic Heisenberg interactions as blue polkadot spheres.

J = +0.63 # (meV)
set_exchange!(sys, J, Bond(1, 3, [0, 0, 0]))
set_exchange!(sys, J, Bond(2, 3, [0, 0, 0]))
view_crystal(sys)

# ### Optimizing spins
Expand All @@ -104,16 +103,15 @@ plot_spins(sys; color=[S[3] for S in sys.dipoles])

# ### Reshaping the magnetic cell

# The most compact magnetic cell for this Néel order is a primitive unit cell.
# Reduce the magnetic cell size using [`reshape_supercell`](@ref), where columns
# of the `shape` matrix are primitive lattice vectors as multiples of the
# conventional cubic lattice vectors ``(𝐚_1, 𝐚_2, 𝐚_3)``. One could
# alternatively use `shape = cryst.latvecs \ cryst.prim_latvecs`. Verify that
# The most compact magnetic cell for this Néel order is the primitive unit cell.
# Columns of the [`primitive_cell`](@ref) matrix provide the primitive lattice
# vectors as multiples of the conventional cubic lattice vectors.

shape = primitive_cell(cryst)

# Reduce the magnetic cell size using [`reshape_supercell`](@ref). Verify that
# the energy per site is unchanged after the reshaping the supercell.

shape = [0 1 1;
1 0 1;
1 1 0] / 2
sys_prim = reshape_supercell(sys, shape)
@assert energy_per_site(sys_prim) -2J*(3/2)^2

Expand Down
4 changes: 2 additions & 2 deletions examples/02_LLD_CoRh2O4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ using Sunny, GLMakie
units = Units(:meV, :angstrom)
a = 8.5031 # (Å)
latvecs = lattice_vectors(a, a, a, 90, 90, 90)
cryst = Crystal(latvecs, [[0,0,0]], 227, setting="1")
cryst = Crystal(latvecs, [[1/8, 1/8, 1/8]], 227)

sys = System(cryst, [1 => Moment(s=3/2, g=2)], :dipole)
J = 0.63 # (meV)
set_exchange!(sys, J, Bond(1, 3, [0,0,0]))
set_exchange!(sys, J, Bond(2, 3, [0,0,0]))
randomize_spins!(sys)
minimize_energy!(sys)
plot_spins(sys; color=[S[3] for S in sys.dipoles])
Expand Down
9 changes: 4 additions & 5 deletions examples/07_Dipole_Dipole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@

using Sunny, GLMakie

# Create a pyrochlore crystal from spacegroup 227.
# Create a pyrochlore crystal from Wyckoff 16c for spacegroup 227.

units = Units(:K, :angstrom)
latvecs = lattice_vectors(10.19, 10.19, 10.19, 90, 90, 90)
positions = [[1/8, 1/8, 1/8]]
cryst = Crystal(latvecs, positions, 227, setting="1")
positions = [[0, 0, 0]]
cryst = Crystal(latvecs, positions, 227)
view_crystal(cryst)

# Create a system and reshape to the primitive cell, which contains four atoms.
# Add antiferromagnetic nearest neighbor exchange interactions.

primitive_cell = [1/2 1/2 0; 0 1/2 1/2; 1/2 0 1/2]
sys = System(cryst, [1 => Moment(s=7/2, g=2)], :dipole; seed=0)
sys = reshape_supercell(sys, primitive_cell)
sys = reshape_supercell(sys, primitive_cell(cryst))
J1 = 0.304 # (K)
set_exchange!(sys, J1, Bond(1, 2, [0,0,0]))

Expand Down
6 changes: 3 additions & 3 deletions examples/spinw_tutorials/SW13_LiNiPO4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

using Sunny, GLMakie

# Build an orthorhombic lattice and populate the Ni atoms according to
# spacegroup 62 (Pnma).
# Build an orthorhombic lattice and populate the Ni atoms according to Wyckoff
# 4c of spacegroup 62.

units = Units(:meV, :angstrom)
a = 10.02
Expand All @@ -18,7 +18,7 @@ c = 4.68
latvecs = lattice_vectors(a, b, c, 90, 90, 90)
positions = [[1/4, 1/4, 0]]
types = ["Ni"]
cryst = Crystal(latvecs, positions, 62, setting=""; types)
cryst = Crystal(latvecs, positions, 62; types)
view_crystal(cryst)

# Create a system with exchange parameters taken from [T. Jensen, et al., PRB
Expand Down
4 changes: 2 additions & 2 deletions examples/spinw_tutorials/SW15_Ba3NbFe3Si2O14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ set_exchange!(sys, J₁, Bond(3, 2, [1,1,0]))
set_exchange!(sys, J₄, Bond(1, 1, [0,0,1]))
set_exchange!(sys, J₂, Bond(1, 3, [0,0,0]))

# The final two exchanges are setting according to the desired chirality ``ϵ_T``
# of the magnetic structure.
# The final two exchanges are set according to the desired chirality ``ϵ_T`` of
# the magnetic structure.

ϵT = -1
if ϵT == -1
Expand Down
4 changes: 2 additions & 2 deletions examples/spinw_tutorials/SW18_Distorted_kagome.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

using Sunny, GLMakie

# Build the distorted kagome crystal, with spacegroup 12.
# Build the distorted kagome crystal, with spacegroup 12 ("C 1 2/m 1" setting).

units = Units(:meV, :angstrom)
latvecs = lattice_vectors(10.2, 5.94, 7.81, 90, 117.7, 90)
positions = [[0, 0, 0], [1/4, 1/4, 0]]
types = ["Cu1", "Cu2"]
cryst = Crystal(latvecs, positions, 12; types, setting="b1")
cryst = Crystal(latvecs, positions, "C 1 2/m 1"; types)
view_crystal(cryst)

# Define the interactions.
Expand Down
2 changes: 1 addition & 1 deletion ext/PlottingExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function reference_bonds_upto(cryst, nbonds, ndims)
end

function propagate_reference_bond_for_cell(cryst, b_ref)
symops = Sunny.canonical_group_order(cryst.symops)
symops = Sunny.canonical_group_order(cryst.sg.symops)

found = map(_ -> Bond[], cryst.positions)
for s in symops
Expand Down
16 changes: 8 additions & 8 deletions src/FormFactor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ Two special, ``𝐪``-independent form factor values are available:
as a perfect point particle, while the second zeros all contributions from the
magnetic ion.
References:
1. [P. J. Brown, The Neutron Data Booklet, 2nd ed., Sec. 2.5 Magnetic Form
Factors (2003)](https://www.ill.eu/sites/ccsl/ffacts/ffachtml.html)
2. Coefficient tables in [McPhase
documentation](https://www2.cpfs.mpg.de/~rotter/homepage_mcphase/manual/node137.html)
3. [K. Kobayashi, T. Nagao, M. Ito, Acta Cryst. A, 67 pp 473–480
(2011)](https://doi.org/10.1107/S010876731102633X)
## References:
1. [P. J. Brown, The Neutron Data Booklet, 2nd ed., Sec. 2.5 Magnetic Form
Factors (2003)](https://www.ill.eu/sites/ccsl/ffacts/ffachtml.html)
2. Coefficient tables in [McPhase
documentation](https://www2.cpfs.mpg.de/~rotter/homepage_mcphase/manual/node137.html)
3. [K. Kobayashi, T. Nagao, M. Ito, Acta Cryst. A, 67 pp 473–480
(2011)](https://doi.org/10.1107/S010876731102633X)
"""
function FormFactor(ion::String; g_lande=2)
if !haskey(radial_integral_coefficients, ion)
Expand Down
4 changes: 2 additions & 2 deletions src/Integrators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ the dipole in analogy to the vector cross product ``S × 𝐁``. The coupling to
the thermal bath maps as ``λ̃ = |𝐒| λ``. Note, therefore, that the scaling of
the `damping` parameter varies subtly between `:dipole` and `:SUN` modes.
References:
## References:
1. [D. Dahlbom et al., Phys. Rev. B 106, 235154
(2022)](https://arxiv.org/abs/2209.01265).
Expand Down Expand Up @@ -99,7 +99,7 @@ or its generalization to SU(_N_) coherent states [1]. One call to the
This integration scheme is exactly symplectic and eliminates energy drift over
arbitrarily long simulation trajectories.
References:
## References:
1. [H. Zhang and C. D. Batista, Phys. Rev. B 104, 104409
(2021)](https://arxiv.org/abs/2106.14125).
Expand Down
6 changes: 3 additions & 3 deletions src/KPM/SpinWaveTheoryKPM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Reasonable starting points are `1e-1` (more speed) or `1e-2` (more accuracy).
particular, KPM may mask intensities that arise near the Goldstone modes of an
ordered state with continuous symmetry.
References:
## References:
1. H. Lane et al., Kernel Polynomial Method for Linear Spin Wave Theory (2023)
[[arXiv:2312.08349v3](https://arxiv.org/abs/2312.08349)].
1. H. Lane et al., Kernel Polynomial Method for Linear Spin Wave Theory (2023)
[[arXiv:2312.08349v3](https://arxiv.org/abs/2312.08349)].
"""
struct SpinWaveTheoryKPM
swt :: SpinWaveTheory
Expand Down
6 changes: 4 additions & 2 deletions src/MCIF.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ function set_dipoles_from_mcif!(sys::System, filename::AbstractString)
tol = 0.1 * sys.crystal.symprec # Tolerance might need tuning
orig_cryst = orig_crystal(sys)

primvecs = @something orig_cryst.prim_latvecs orig_cryst.latvecs
primcell = @something primitive_cell(orig_cryst) Mat3(I)
primvecs = orig_cryst.latvecs * primcell

suggestion = if all(isinteger.(rationalize.(primvecs \ supervecs2; tol)))
suggested_shape = rationalize.(orig_cryst.latvecs \ supervecs2; tol)
suggestion = if isdiag(suggested_shape)
sz = fractional_vec3_to_string(diag(suggested_shape))
diag_strs = number_to_math_string.(diag(suggested_shape))
sz = "("*join(diag_strs, ", ")*")"
error("Use `resize_supercell(sys, $sz)` to get compatible system")
else
shp = fractional_mat3_to_string(suggested_shape)
Expand Down
11 changes: 5 additions & 6 deletions src/Reshaping.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ function reshape_supercell(sys::System, shape)

orig = orig_crystal(sys)
check_shape_commensurate(orig, shape)

primvecs = @something orig.prim_latvecs orig.latvecs
prim_shape = primvecs \ orig.latvecs * shape
prim_shape′ = round.(Int, prim_shape)
@assert prim_shape′ prim_shape
prim_cell = @something primitive_cell(orig) Mat3(I)
shape_in_prim = prim_cell \ shape
@assert all_integer(shape_in_prim; orig.symprec)
shape_in_prim = round.(Int, shape_in_prim)

# Unit cell for new system, in units of original unit cell.
new_dims = NTuple{3, Int}(gcd.(eachcol(prim_shape′)))
new_dims = NTuple{3, Int}(gcd.(eachcol(shape_in_prim)))
new_shape = Mat3(shape * diagm(collect(inv.(new_dims))))
new_cryst = reshape_crystal(orig_crystal(sys), new_shape)

Expand Down
6 changes: 4 additions & 2 deletions src/Sunny.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export spin_matrices, stevens_matrices, to_product_space, rotate_operator, print
include("Symmetry/LatticeUtils.jl")
include("Symmetry/SymOp.jl")
include("Symmetry/MSymOp.jl")
include("Symmetry/SpacegroupData.jl")
include("Symmetry/WyckoffData.jl")
include("Symmetry/Crystal.jl")
include("Symmetry/Bond.jl")
include("Symmetry/SymmetryAnalysis.jl")
include("Symmetry/AllowedCouplings.jl")
include("Symmetry/AllowedAnisotropy.jl")
include("Symmetry/Parsing.jl")
include("Symmetry/Printing.jl")
export Crystal, subcrystal, standardize, lattice_vectors, lattice_params, primitive_cell_shape, Bond,
export Crystal, subcrystal, standardize, lattice_vectors, lattice_params, primitive_cell, Bond,
reference_bonds, print_site, print_bond, print_symmetry_table, print_suggested_frame

include("Units.jl")
Expand Down Expand Up @@ -174,7 +176,7 @@ PT.@setup_workload begin
PT.@compile_workload begin
# Crystal loading
latvecs = lattice_vectors(1, 1, 1, 90, 90, 90)
cryst = Crystal(latvecs, [[0,0,0]], 227, setting="1")
cryst = Crystal(latvecs, [[1,1,1]/8], 227)
repr("text/plain", cryst)
print_symmetry_table(cryst, 0.8; io=devnull)
end
Expand Down
Loading

0 comments on commit 0f368df

Please sign in to comment.