-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add number_density restriction on pair-corr
- Loading branch information
1 parent
ef7fb3b
commit 8b08866
Showing
5 changed files
with
100 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Here we calculate a particle configuration from a structure factor | ||
|
||
using ParticleCorrelations | ||
using Test, Statistics | ||
|
||
using Optim | ||
using Plots | ||
|
||
|
||
a = 1.0 | ||
rs = 0.0:0.01:8.0 | ||
|
||
g = 1.0 .+ exp.(-(rs .- 4a).^2) | ||
|
||
dpair = DiscretePairCorrelation(2, rs, g) | ||
|
||
number_density(dpair) | ||
|
||
|
||
plot(rs,g) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@testset "structure-factor" begin | ||
|
||
# use a pair correlation with a known exact formula for the structure factor | ||
α = 1.5; | ||
β = 3.0; | ||
|
||
number_density = 0.5 | ||
dim = 3 | ||
|
||
f(r) = 1 + (exp(im * β * r) + exp(-im * β * r)) * exp(- α * r) / r | ||
|
||
rs = 0.001:0.001:10.0; | ||
|
||
pair = DiscretePairCorrelation(dim, rs, f.(rs); number_density = 0.5) | ||
|
||
@test pair.g[end] - 1.0 < 1e-8 | ||
|
||
ks = 0.2:0.2:20.0 | ||
sfactor = structure_factor(pair, ks) | ||
|
||
S(k) = 1 + 4π * number_density * real(1 / (k^2 + (α - im * β)^2) + 1 / (k^2 + (α + im * β)^2) ) | ||
|
||
@test norm(S.(ks) - sfactor.S) / norm(sfactor.S) < 1e-5 | ||
|
||
end |