Skip to content

Commit

Permalink
Tutorial 2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarros committed Sep 30, 2024
1 parent f5bfd1c commit 9ae0c31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 10 additions & 9 deletions examples/02_LLD_CoRh2O4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ plot_spins(sys; color=[S[3] for S in sys.dipoles])
# We will be using a [`Langevin`](@ref) spin dynamics to thermalize the system.
# This dynamics is a variant of the Landau-Lifshitz equation that incorporates
# noise and dissipation terms, which are linked by a fluctuation-dissipation
# theorem. The temperature 6 K ≈ 1.38 meV is slightly above ordering for this
# theorem. The temperature 16 K ≈ 1.38 meV is slightly above ordering for this
# model. The dimensionless `damping` magnitude sets a timescale for coupling to
# the implicit thermal bath; 0.2 is usually a good choice.

Expand Down Expand Up @@ -88,8 +88,10 @@ plot_spins(sys; color=[S'*S0 for S in sys.dipoles])
# ### Static structure factor

# Use [`SampledCorrelationsStatic`](@ref) to estimate spatial correlations for
# configurations in classical thermal equilibrium. Each call to
# [`add_sample!`](@ref) will accumulate data for the current spin snapshot.
# configurations in classical thermal equilibrium. Measure [`ssf_perp`](@ref),
# which is appropriate for unpolarized neutron scattering. Include the
# [`FormFactor`](@ref) for Co2⁺. Each call to [`add_sample!`](@ref) will
# accumulate data for the current spin snapshot.

formfactors = [1 => FormFactor("Co2")]
measure = ssf_perp(sys; formfactors)
Expand All @@ -112,11 +114,10 @@ end

grid = q_space_grid(cryst, [1, 0, 0], range(-10, 10, 200), [0, 1, 0], (-10, 10))

# Calculate and plot the instantaneous structure factor on the slice by
# integrating over all energy values ω. We employ the appropriate
# [`FormFactor`](@ref) for Co2⁺. Selecting `saturation = 1.0` sets the color
# saturation point to the maximum intensity value. This is reasonable because we
# are above the ordering temperature, and do not have sharp Bragg peaks.
# Calculate and plot the instantaneous structure factor on the slice. Selecting
# `saturation = 1.0` sets the color saturation point to the maximum intensity
# value. This is reasonable because we are above the ordering temperature, and
# do not have sharp Bragg peaks.

res = intensities_static(sc, grid)
plot_intensities(res; saturation=1.0, title="Static Intensities at T = 16 K")
Expand All @@ -132,7 +133,7 @@ plot_intensities(res; saturation=1.0, title="Static Intensities at T = 16 K")

dt = 2*langevin.dt
energies = range(0, 6, 50)
sc = SampledCorrelations(sys; dt, energies, measure=ssf_perp(sys))
sc = SampledCorrelations(sys; dt, energies, measure)

# Like before, use Langevin dynamics to sample spin configurations from thermal
# equilibrium. Now, however, each call to [`add_sample!`](@ref) will run a
Expand Down
2 changes: 0 additions & 2 deletions src/Binning/Binning.jl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,6 @@ function binned_intensities(sc, params::BinningParameters; kT=nothing, integrate
end

# Bin (and broaden) those intensities according to BinningParameters
k = zero(MVector{3, Float64})
v = zero(MVector{4, Float64})
q = view(v,1:3)
coords = zero(MVector{4, Float64})
Expand Down Expand Up @@ -415,7 +414,6 @@ function binned_intensities(sc, params::BinningParameters; kT=nothing, integrate
for cell_ix in eachindex(cells), (iω, ω) in enumerate(energies)
cell = cells[cell_ix]
q .= ((cell.I .- 1) ./ Ls) # q is in R.L.U.
k .= (static_mode ? sc.parent : sc).crystal.recipvecs * q
if isnothing(integrated_kernel) # `Delta-function energy' logic
# Figure out which bin this goes in
v[4] = ω
Expand Down

0 comments on commit 9ae0c31

Please sign in to comment.