Skip to content

Commit

Permalink
Revert extraneous things
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazersmoke committed Oct 24, 2023
1 parent 8d33630 commit bb6e194
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 92 deletions.
110 changes: 18 additions & 92 deletions ext/PlottingExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -318,98 +318,6 @@ function plot_spins!(ax, sys::System; arrowscale=1.0, stemcolor=:lightgray, colo
return ax
end

function plot_eigenmode(displacements, swt::SpinWaveTheory; kwargs...)
fig = Makie.Figure()
ax = Makie.LScene(fig[1, 1]; show_axis = false)
plot_eigenmode!(ax, displacements, swt::SpinWaveTheory; kwargs...)
fig
end

function plot_eigenmode!(ax, displacements, swt::SpinWaveTheory; kwargs...)
plot_spins!(ax,swt.sys;kwargs...)
sys_copy = Sunny.clone_system(swt.sys)
# Requires single-site swt system
for i = 1:size(displacements,2)
sys_copy.coherents[i] = sys_copy.coherents[i] .+ 0.3 .* displacements[:,i]
sys_copy.dipoles[i] = Sunny.expected_spin(sys_copy.coherents[i])
end
plot_spins!(ax,sys_copy;color = :blue,kwargs...)
end

#if !(:eigenmode_viewer_screen ∈ names(PlottingExt))
#global eigenmode_viewer_screen = nothing
#end
function interact_eigenmodes(swt::SpinWaveTheory, qs, formula; kwargs...)
#global eigenmode_viewer_screen
#if isnothing(eigenmode_viewer_screen) || eigenmode_viewer_screen.window_open[] == false
#eigenmode_viewer_screen = Makie.Screen()
#end
fig = Makie.Figure()
ax = Makie.Axis(fig[1,1])
#fig_mode = Makie.Figure()
ax_mode = Makie.LScene(fig[1,2]; show_axis = false)
dispersion, intensity = intensities_bands(swt, qs, formula)
plot_band_intensities!(ax, dispersion, intensity)

marker_points = Makie.Observable(Makie.Point2f[Makie.Point2f(NaN,NaN)])
marker_colors = Makie.Observable(Float64[NaN])

sc_marker = Makie.scatter!(ax, marker_points, color = marker_colors, strokewidth = 1.)

ax.xrectzoom[] = false
ax.yrectzoom[] = false

function do_update(;mp = nothing)
mp = isnothing(mp) ? Makie.events(ax).mouseposition[] : mp
bbox = ax.layoutobservables.computedbbox[]
c = (mp .- bbox.origin) ./ bbox.widths
if 0 < c[1] < 1 && 0 < c[2] < 1
data_bbox = ax.finallimits[]
data_space_c = data_bbox.origin .+ c .* data_bbox.widths
q,ω = data_space_c
q_int = floor(Int64,q)
τ = q - q_int
q_interp = (1-τ) .* qs[q_int] .+ τ .* qs[q_int+1]
H, V, bases, displacements, disp = Sunny.get_eigenmodes(swt,q_interp)
_, ix = findmin(abs.(disp .- ω))

marker_points[][1] = Makie.Point2f(q,disp[ix])
marker_colors[][1] = 1. # TODO
notify(marker_points)
while !isempty(ax_mode.scene.plots)
delete!(ax_mode, ax_mode.scene.plots[end])
end
plot_eigenmode!(ax_mode, displacements[:,:,ix], swt)
end
end

dragging = false
Makie.on(Makie.events(fig).mousebutton) do event
println(event)
if event.button == Makie.Mouse.left
if event.action == Makie.Mouse.press
dragging = true
do_update()
else
dragging = false
#do_update()
end
end
end
#=
Makie.on(Makie.events(fig).mouseposition) do mp
println(mp)
if dragging
do_update(;mp)
end
end
=#

#display(eigenmode_viewer_screen,fig_mode)
fig
end



"""
view_crystal(crystal::Crystal, max_dist::Real; show_axis=true, orthographic=false)
Expand Down Expand Up @@ -655,6 +563,24 @@ function scatter_bin_centers!(ax,params;axes)
end


function plot_band_intensities(dispersion, intensity)
f = Makie.Figure()
ax = Makie.Axis(f[1,1]; xlabel = "Momentum", ylabel = "Energy (meV)", xticklabelsvisible = false)
plot_band_intensities!(ax,dispersion,intensity)
f
end

function plot_band_intensities!(ax, dispersion, intensity)
Makie.ylims!(ax, min(0.0,minimum(dispersion)), maximum(dispersion))
Makie.xlims!(ax, 1, size(dispersion, 1))
colorrange = extrema(intensity)
for i in axes(dispersion)[2]
Makie.lines!(ax, 1:length(dispersion[:,i]), dispersion[:,i]; color=intensity[:,i], colorrange)
end
nothing
end


# The purpose of __init__() below is to make all the internal functions of
# PlottingExt accessible to developers of Sunny.
#
Expand Down
2 changes: 2 additions & 0 deletions src/Intensities/LinearSpinWaveIntensities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,5 @@ function intensities_bin_multisample(swt::SpinWaveTheory, hist_params::BinningPa
end
is, counts
end


0 comments on commit bb6e194

Please sign in to comment.