Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tutorials #322

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 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 @@ -70,9 +70,9 @@ end
suggest_timestep(sys, langevin; tol=1e-2)
langevin.dt = 0.042;

# Plot energy versus time using the [Makie `lines`
# function](https://docs.makie.org/stable/reference/plots/lines). The plateau
# suggests that the system has reached thermal equilibrium.
# Plot energy versus time using the Makie
# [`lines`](https://docs.makie.org/stable/reference/plots/lines) function. The
# plateau suggests that the system has reached thermal equilibrium.

lines(energies, color=:blue, figure=(size=(600,300),), axis=(xlabel="Timesteps", ylabel="Energy (meV)"))

Expand All @@ -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
Loading