Skip to content

Commit

Permalink
Release 0.1.6 (#56)
Browse files Browse the repository at this point in the history
With this release, the latest changes from `dev` are merged into `main`.
Caused by issues with the git history, the changes seen in this PR also
include commits since release 0.1.4.

### Lesson learned

After merging the release branch into `main`, the former should not been
touched till it's merged into `dev`.
  • Loading branch information
szabo137 authored Jan 30, 2024
2 parents 0bf6beb + f5ac74d commit f2241ee
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 52 deletions.
1 change: 1 addition & 0 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ permissions:
pull-requests: write
jobs:
CompatHelper:
if: github.repository == 'QEDjl-project/QEDbase.jl'
runs-on: ubuntu-latest
steps:
- name: Check if Julia is already available in the PATH
Expand Down
4 changes: 1 addition & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ stages:
script:
- apt update && apt install -y git
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl
- julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));'
- julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));'
- >
if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then
# set name of the commit message from CI_COMMIT_MESSAGE to NO_MESSAGE, that the script does not read accidentally custom packages from the commit message of a merge commit
Expand Down Expand Up @@ -119,4 +117,4 @@ verify-unit-test-deps_julia1.9:
fi
interruptible: true
tags:
- cpuonly
- cpuonly
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## Version 0.1.6

This is a maintenance release, which resolves, among others, some issues with the git history.

### Breaking changes

No breaking changes.

### New features

No new features.

### Maintenance

* Bugfix in base state https://github.com/QEDjl-project/QEDbase.jl/issues/49
* Improve parameter coverage in unit test https://github.com/QEDjl-project/QEDbase.jl/pull/50
* Bugfix in Lorentz interface https://github.com/QEDjl-project/QEDbase.jl/pull/46
* cleanup of the CI https://github.com/QEDjl-project/QEDbase.jl/pull/41 https://github.com/QEDjl-project/QEDbase.jl/pull/47

## Version 0.1.5

[diff since 0.1.4](https://github.com/QEDjl-project/QEDbase.jl/compare/0c70f66...release-0.1.5)
Expand Down
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "QEDbase"
uuid = "10e22c08-3ccb-4172-bfcf-7d7aa3d04d93"
authors = ["Uwe Hernandez Acosta <[email protected]>", "Simeon Ehrig", "Klaus Steiniger", "Tom Jungnickel", "Anton Reinhard"]
version = "0.1.5"
version = "0.1.6"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand All @@ -24,7 +24,8 @@ StaticArrays = "1.2.13"
julia = "1.6"

[extras]
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["SafeTestsets","Test"]
8 changes: 4 additions & 4 deletions src/lorentz_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ function register_LorentzVectorLike(T::Type)

@eval @traitimpl IsLorentzVectorLike{$T}

if hasmethod(setT!, Tuple{T,Union{}}) &&
hasmethod(setX!, Tuple{T,Union{}}) &&
hasmethod(setY!, Tuple{T,Union{}}) &&
hasmethod(setZ!, Tuple{T,Union{}})
if hasmethod(setT!, Tuple{T,<:Union{}}) &&
hasmethod(setX!, Tuple{T,<:Union{}}) &&
hasmethod(setY!, Tuple{T,<:Union{}}) &&
hasmethod(setZ!, Tuple{T,<:Union{}})
@eval @traitimpl IsMutableLorentzVectorLike{$T}
end
return nothing
Expand Down
6 changes: 3 additions & 3 deletions src/particles/particle_states.jl
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ end
function _photon_state(pol::AllPolarization, mom::QEDbase.AbstractFourMomentum)
cth = getCosTheta(mom)
sth = sqrt(1 - cth^2)
cos_phi = getCosPhi(mom)
sin_phi = getSinPhi(mom)
cos_phi = sqrt(1 - sin_phi^2)
return SVector(
SLorentzVector{Float64}(0.0, cth * cos_phi, cth * sin_phi, -sth),
SLorentzVector{Float64}(0.0, -sin_phi, cos_phi, 0.0),
Expand All @@ -239,14 +239,14 @@ end
function _photon_state(pol::PolarizationX, mom::QEDbase.AbstractFourMomentum)
cth = getCosTheta(mom)
sth = sqrt(1 - cth^2)
cos_phi = getCosPhi(mom)
sin_phi = getSinPhi(mom)
cos_phi = sqrt(1 - sin_phi^2)
return SLorentzVector{Float64}(0.0, cth * cos_phi, cth * sin_phi, -sth)
end

function _photon_state(pol::PolarizationY, mom::QEDbase.AbstractFourMomentum)
cos_phi = getCosPhi(mom)
sin_phi = getSinPhi(mom)
cos_phi = sqrt(1 - sin_phi^2)
return SLorentzVector{Float64}(0.0, -sin_phi, cos_phi, 0.0)
end

Expand Down
2 changes: 1 addition & 1 deletion test/dirac_tensor.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

using QEDbase
using StaticArrays

unary_methods = [-, +]
Expand Down
2 changes: 2 additions & 0 deletions test/four_momentum.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

using QEDbase
using Random

const ATOL = 1e-15
Expand Down
2 changes: 1 addition & 1 deletion test/gamma_matrices.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

using QEDbase
using LinearAlgebra
using Random
using SparseArrays
Expand Down
3 changes: 2 additions & 1 deletion test/lorentz_interface.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using QEDbase

lorentz_getter = [
getT,
Expand Down Expand Up @@ -95,7 +96,7 @@ lorentz_setter = [
QEDbase.register_LorentzVectorLike(MutableCustomType)

for fun in lorentz_setter
@test hasmethod(fun, Tuple{MutableCustomType,Union{}})
@test hasmethod(fun, Tuple{MutableCustomType,<:Union{}})
end
end
end # LorentzVectorInterface
1 change: 1 addition & 0 deletions test/lorentz_vector.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using QEDbase
using StaticArrays

unary_methods = [-, +]
Expand Down
1 change: 1 addition & 0 deletions test/particle_spinors.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using QEDbase
using Random

const ATOL = 1e-15
Expand Down
89 changes: 60 additions & 29 deletions test/particles.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
using QEDbase
using StaticArrays
using Random

include("utils.jl")

FERMION_STATES_GROUNDTRUTH_FACTORY = Dict(
(Incoming, Electron) => IncomingFermionSpinor,
(Outgoing, Electron) => OutgoingFermionSpinor,
(Incoming, Positron) => IncomingAntiFermionSpinor,
(Outgoing, Positron) => OutgoingAntiFermionSpinor,
)

rng = MersenneTwister(708583836976)
x, y, z = rand(rng, 3)
RNG = MersenneTwister(708583836976)
ATOL = eps()
RTOL = 0.0
PHOTON_ENERGIES = (0.0, rand(RNG), rand(RNG) * 10)
COS_THETAS = (-1.0, -rand(RNG), 0.0, rand(RNG), 1.0)
# check every quadrant
PHIS = (
0.0,
rand(RNG) * pi / 2,
pi / 2,
(1.0 + rand(RNG)) * pi / 2,
pi,
(2 + rand(RNG)) * pi / 2,
3 * pi / 2,
(3 + rand(RNG)) * pi / 2,
2 * pi,
)

X, Y, Z = rand(RNG, 3)

@testset "fermion likes" begin
@testset "fermion" begin
Expand All @@ -18,27 +38,27 @@ x, y, z = rand(rng, 3)
@test is_particle(TestFermion())
@test !is_anti_particle(TestFermion())

mom = SFourMomentum(sqrt(x^2 + y^2 + z^2 + mass(Electron())^2), x, y, z)
@testset "$P $D" for (P, D) in
@testset "$p $d" for (p, d) in
Iterators.product((Electron, Positron), (Incoming, Outgoing))
particle_mass = mass(P())
groundtruth_states = FERMION_STATES_GROUNDTRUTH_FACTORY[(D, P)](
mom = SFourMomentum(sqrt(mass(p()) + X^2 + Y^2 + Z^2), X, Y, Z)
particle_mass = mass(p())
groundtruth_states = FERMION_STATES_GROUNDTRUTH_FACTORY[(d, p)](
mom, particle_mass
)
groundtruth_tuple = SVector(groundtruth_states(1), groundtruth_states(2))
@test base_state(P(), D(), mom, AllSpin()) == groundtruth_tuple
@test base_state(P(), D(), mom, SpinUp()) == groundtruth_tuple[1]
@test base_state(P(), D(), mom, SpinDown()) == groundtruth_tuple[2]
@test base_state(p(), d(), mom, AllSpin()) == groundtruth_tuple
@test base_state(p(), d(), mom, SpinUp()) == groundtruth_tuple[1]
@test base_state(p(), d(), mom, SpinDown()) == groundtruth_tuple[2]

@test QEDbase._as_svec(base_state(P(), D(), mom, AllSpin())) isa SVector
@test QEDbase._as_svec(base_state(P(), D(), mom, SpinUp())) isa SVector
@test QEDbase._as_svec(base_state(P(), D(), mom, SpinDown())) isa SVector
@test QEDbase._as_svec(base_state(p(), d(), mom, AllSpin())) isa SVector
@test QEDbase._as_svec(base_state(p(), d(), mom, SpinUp())) isa SVector
@test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown())) isa SVector

@test QEDbase._as_svec(base_state(P(), D(), mom, AllSpin())) ==
@test QEDbase._as_svec(base_state(p(), d(), mom, AllSpin())) ==
groundtruth_tuple
@test QEDbase._as_svec(base_state(P(), D(), mom, SpinUp()))[1] ==
@test QEDbase._as_svec(base_state(p(), d(), mom, SpinUp()))[1] ==
groundtruth_tuple[1]
@test QEDbase._as_svec(base_state(P(), D(), mom, SpinDown()))[1] ==
@test QEDbase._as_svec(base_state(p(), d(), mom, SpinDown()))[1] ==
groundtruth_tuple[2]
end
end
Expand Down Expand Up @@ -98,25 +118,36 @@ end
@test is_particle(TestMajoranaBoson())
@test is_anti_particle(TestMajoranaBoson())
end
end

@testset "photon" begin
@test !is_fermion(Photon())
@test is_boson(Photon())
@test is_particle(Photon())
@test is_anti_particle(Photon())
@test charge(Photon()) == 0.0
@test mass(Photon()) == 0.0
@testset "photon" begin
@test !is_fermion(Photon())
@test is_boson(Photon())
@test is_particle(Photon())
@test is_anti_particle(Photon())
@test charge(Photon()) == 0.0
@test mass(Photon()) == 0.0

mom = SFourMomentum(sqrt(x^2 + y^2 + z^2 + mass(Photon())^2), x, y, z)
@testset "$D" for D in [Incoming, Outgoing]
@testset "$D" for D in [Incoming, Outgoing]
@testset "$om $cth $phi" for (om, cth, phi) in
Iterators.product(PHOTON_ENERGIES, COS_THETAS, PHIS)
#@testset "$x $y $z" for (x,y,z) in Iterators.product(X_arr,Y_arr,Z_arr)

mom = SFourMomentum(_cartesian_coordinates(om, om, cth, phi))
both_photon_states = base_state(Photon(), D(), mom, AllPolarization())

# property test the photon states
@test isapprox((both_photon_states[1] * mom), 0.0, atol=ATOL)
@test isapprox((both_photon_states[2] * mom), 0.0, atol=ATOL)
@test isapprox((both_photon_states[1] * both_photon_states[1]), -1.0)
@test isapprox((both_photon_states[2] * both_photon_states[2]), -1.0)
@test isapprox((both_photon_states[1] * both_photon_states[2]), 0.0, atol=ATOL)
@test isapprox((both_photon_states[1] * mom), 0.0, atol=ATOL, rtol=RTOL)
@test isapprox((both_photon_states[2] * mom), 0.0, atol=ATOL, rtol=RTOL)
@test isapprox(
(both_photon_states[1] * both_photon_states[1]), -1.0, atol=ATOL, rtol=RTOL
)
@test isapprox(
(both_photon_states[2] * both_photon_states[2]), -1.0, atol=ATOL, rtol=RTOL
)
@test isapprox(
(both_photon_states[1] * both_photon_states[2]), 0.0, atol=ATOL, rtol=RTOL
)

# test the single polarization states
@test base_state(Photon(), D(), mom, PolarizationX()) == both_photon_states[1]
Expand Down
33 changes: 25 additions & 8 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
using QEDbase
using Test
using SafeTestsets

@testset "QEDbase.jl" begin
include("dirac_tensor.jl")
include("lorentz_vector.jl")
include("lorentz_interface.jl")
begin
@time @safetestset "Dirac tensors" begin
include("dirac_tensor.jl")
end

include("gamma_matrices.jl")
@time @safetestset "Lorentz Vectors" begin
include("lorentz_vector.jl")
end

include("particle_spinors.jl")
include("four_momentum.jl")
@time @safetestset "Lorentz interface" begin
include("lorentz_interface.jl")
end
@time @safetestset "Gamma matrices" begin
include("gamma_matrices.jl")
end

include("particles.jl")
@time @safetestset "particle spinors" begin
include("particle_spinors.jl")
end

@time @safetestset "four momentum" begin
include("four_momentum.jl")
end

@time @safetestset "particles" begin
include("particles.jl")
end
end
11 changes: 11 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Returns the cartesian coordinates (E,px,py,pz) for given spherical coordiantes
(E, rho, cos_theta, phi), where rho denotes the length of the respective three-momentum,
theta is the polar- and phi the azimuthal angle.
"""
function _cartesian_coordinates(E, rho, cth, phi)
sth = sqrt(1 - cth^2)
sphi, cphi = sincos(phi)
return (E, rho * sth * cphi, rho * sth * sphi, rho * cth)
end

0 comments on commit f2241ee

Please sign in to comment.