-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9345719
commit 1886b0f
Showing
7 changed files
with
66 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Plots | ||
using .FewBodyPhysics | ||
|
||
b = 3.9 | ||
S = 41.5 | ||
|
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
module FewBodyPhysics | ||
|
||
export m_pi, m_pi0, m_p, m_n, μ, ħc, m_bare | ||
export jacobi_transform, generate_A_matrix, transform_list, shift_vectors, generate_weight_vector, transform_coordinates, inverse_transform_coordinates | ||
export S_elements, S_wave, S_energy, P_elements, pion_nucleon, ComputeEigenSystem, GetMinimumEnergy, OptimizeGlobalParameters | ||
export corput, halton, run_simulation, run_simulation_nuclear | ||
|
||
include("constants.jl") | ||
include("coordinates.jl") | ||
include("matrix_elements.jl") | ||
include("sampling.jl") | ||
include("constants.jl") | ||
|
||
export m_pi, m_pi0, m_p, m_n, μ, ħc, m_bare | ||
export jacobi_transform, generate_A_matrix, transform_list, shift_vectors, generate_weight_vector, transform_coordinates, inverse_transform_coordinates | ||
export S_elements, S_wave, S_energy, P_elements, pion_nucleon,compute_eigen_system, get_minimum_energy, optimize_global_parameters | ||
export corput, halton, run_simulation, run_simulation_nuclear | ||
|
||
end |
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
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 |
---|---|---|
@@ -1,69 +1,71 @@ | ||
using FewBodyPhysics | ||
using Test | ||
using LinearAlgebra | ||
include("../src/FewBodyPhysics.jl") | ||
|
||
using .FewBodyPhysics | ||
|
||
@testset "FewBodyPhysics.jl" begin | ||
@testset "Coordinate Transformations" begin | ||
masses = [1.0, 2.0, 3.0] | ||
J, U = JacobiTransform(masses) | ||
@test size(J) == (2, 3) | ||
@test size(U) == (3, 2) | ||
|
||
bij = [0.5, 0.8] | ||
w_list = [generate_weight_vector(3, 1, 2), generate_weight_vector(3, 2, 3)] | ||
A = generate_A_matrix(bij, w_list) | ||
@test size(A) == (3, 3) | ||
|
||
α = [1.0, 2.0, 3.0] | ||
transformed_list = transform_list(α) | ||
@test length(transformed_list) == 3 | ||
@test transformed_list[1] == [1.0] | ||
|
||
a = rand(3, 2) | ||
b = rand(3, 2) | ||
sum_val = shift_vectors(a, b) | ||
@test isa(sum_val, Float64) | ||
|
||
w = generate_weight_vector(3, 1, 2) | ||
@test w == [1, -1, 0] | ||
|
||
r = rand(3) | ||
x = transform_coordinates(J, r) | ||
r_back = inverse_transform_coordinates(U, x) | ||
@test norm(r - r_back) < 1e-10 | ||
end | ||
|
||
@testset "corput tests" begin | ||
@testset "Corput Sequence Tests" begin | ||
# Basic tests for base 2 | ||
@test corput(1, 2) ≈ 0.5 | ||
@test corput(2, 2) ≈ 0.25 | ||
@test corput(3, 2) ≈ 0.75 | ||
@test corput(4, 2) ≈ 0.125 | ||
@test corput(5, 2) ≈ 0.625 | ||
|
||
# Additional tests for base 3 | ||
@test corput(1, 3) ≈ 1/3 | ||
@test corput(2, 3) ≈ 2/3 | ||
@test corput(3, 3) ≈ 1/9 | ||
@test corput(4, 3) ≈ 4/9 | ||
@test corput(5, 3) ≈ 7/9 | ||
|
||
# Additional tests for base 5 | ||
@test corput(1, 5) ≈ 0.2 | ||
@test corput(2, 5) ≈ 0.04 | ||
@test corput(3, 5) ≈ 0.6 | ||
@test corput(4, 5) ≈ 0.08 | ||
@test corput(5, 5) ≈ 0.16 | ||
@test corput(10, 5) ≈ 0.32 | ||
|
||
end | ||
|
||
@testset "halton tests" begin | ||
@test halton(1, 2) ≈ [0.5, 0.3333333333333333] | ||
@test halton(2, 2) ≈ [0.25, 0.6666666666666666] | ||
@testset "Halton Sequence Tests" begin | ||
# Basic sequence tests for dimension 2 | ||
@test halton(1, 2) ≈ [0.5, 1/3] | ||
@test halton(2, 2) ≈ [0.25, 2/3] | ||
@test halton(3, 2) ≈ [0.75, 1/9] | ||
@test halton(4, 2) ≈ [0.125, 4/9] | ||
@test halton(5, 2) ≈ [0.625, 7/9] | ||
|
||
# Additional tests for higher dimensions | ||
@test halton(1, 3) ≈ [0.5, 1/3, 0.2] | ||
@test halton(2, 3) ≈ [0.25, 2/3, 0.4] | ||
@test halton(3, 3) ≈ [0.75, 1/9, 0.6] | ||
@test halton(4, 3) ≈ [0.125, 4/9, 0.8] | ||
|
||
|
||
# Edge cases: checking very high `n` | ||
@test halton(1000, 2) ≈ [corput(1000, 2), corput(1000, 3)] | ||
@test halton(5000, 3) ≈ [corput(5000, 2), corput(5000, 3), corput(5000, 5)] | ||
|
||
# Edge case: requesting only 1 dimension | ||
@test halton(1, 1) ≈ [0.5] | ||
@test halton(10, 1) ≈ [corput(10, 2)] | ||
|
||
# Edge case: invalid dimension exceeding base list | ||
@test_throws AssertionError halton(1, 100) | ||
end | ||
|
||
@testset "run_simulation tests" begin | ||
w_transformed = [1, 2, 3] | ||
K_transformed = [1, 2, 3] | ||
p, E_list, bases = run_simulation(15, :quasirandom, w_transformed, K_transformed, false) | ||
@test E_list isa Float64 | ||
@test bases isa Array | ||
@test_throws ErrorException run_simulation(15, :invalidmethod, w_transformed, K_transformed, false) | ||
end | ||
# Edge case: `n = 0` should return zero for any dimension | ||
@test halton(0, 2) ≈ [0.0, 0.0] | ||
@test halton(0, 5) ≈ [0.0, 0.0, 0.0, 0.0, 0.0] | ||
|
||
@testset "run_simulation_nuclear tests" begin | ||
masses = [1, 2, 3] | ||
params = [1, 2, 3] | ||
E_list, gaussians, eigenvectors, coords, masses = run_simulation_nuclear(2, 2, 5, masses, params) | ||
@test E_list isa Array | ||
@test gaussians isa Array | ||
@test eigenvectors isa Array | ||
@test coords isa Array | ||
@test masses isa Array | ||
# Random large n tests for robustness | ||
@test halton(123, 4) ≈ [corput(123, 2), corput(123, 3), corput(123, 5), corput(123, 7)] | ||
@test halton(999, 3) ≈ [corput(999, 2), corput(999, 3), corput(999, 5)] | ||
end | ||
|
||
|
||
end | ||
|