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

Fix test for repeated wave vectors in SampledCorrelations #314

Merged
merged 4 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions docs/src/versions.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Version History

## v0.7.2
(In development)

* Fix error in `SampledCorrelations` with a coarse ``𝐪``-grid. ([PR
#314](https://github.com/SunnySuite/Sunny.jl/pull/314))

## v0.7.1
(Sep 3, 2024)

Expand Down
6 changes: 4 additions & 2 deletions src/SampledCorrelations/DataRetrieval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ function pruned_wave_vector_info(sc::SampledCorrelations, qs)
# Convert to absolute units (for form factors)
qabs_rounded = map(m -> sc.crystal.recipvecs * (m ./ sc.sys_dims), ms)

# List of "starting" pointers i where idcs[i-1] != idcs[i]
starts = findall(i -> i == 1 || idcs[i-1] != idcs[i], eachindex(idcs))
# List of "starting" pointers i where qabs_rounded[i-1] != qabs_rounded[i],
# i.e., indices where the desired wave vector is distinct from the previous
# one.
starts = findall(i -> i == 1 || !isapprox(qabs_rounded[i-1], qabs_rounded[i]), eachindex(qabs_rounded))

# Length of each run of repeated values
counts = starts[2:end] - starts[1:end-1]
Expand Down
7 changes: 7 additions & 0 deletions test/test_correlation_sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@
true_static_vals = intensities_static(res, qgrid)
true_static_total = sum(true_static_vals.data)
@test isapprox(true_static_total / prod(sys.dims), 1.0; atol=1e-12)

# Test whether two distinct wave vectors referencing the same underlying
# data point in sc.data are in fact treated differently.
formfactors = [1 => FormFactor("Fe2")]
sc.measure = ssf_trace(sys; apply_g=false, formfactors)
res = intensities_static(sc, [[0, 0, 1/2], [1, 0, 1/2]]; kT=nothing)
@test res.data[1] != res.data[2]
end

@testitem "Merge correlations" begin
Expand Down
Loading