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

Add convenience constructors for particle statefuls #33

Merged
merged 1 commit into from
Jul 13, 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
19 changes: 18 additions & 1 deletion src/phase_spaces/create.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# PSP constructors from particle statefuls
"""
ParticleStateful{DIR, SPECIES}(mom::AbstractFourMomentum)
ParticleStateful{DIR, SPECIES, EL}(mom::EL)
Construct a [`ParticleStateful`](@ref) from the given momentum on a fully or partially specified type.
"""
@inline function ParticleStateful{DIR,SPECIES}(
mom::AbstractFourMomentum
) where {DIR<:ParticleDirection,SPECIES<:AbstractParticleType}
return ParticleStateful(DIR(), SPECIES(), mom)
end
szabo137 marked this conversation as resolved.
Show resolved Hide resolved

@inline function ParticleStateful{DIR,SPECIES,EL}(
mom::EL
) where {DIR<:ParticleDirection,SPECIES<:AbstractParticleType,EL<:AbstractFourMomentum}
szabo137 marked this conversation as resolved.
Show resolved Hide resolved
return ParticleStateful(DIR(), SPECIES(), mom)
end

# PSP constructors from particle statefuls
"""
InPhaseSpacePoint(
proc::AbstractProcessDefinition,
Expand Down
3 changes: 3 additions & 0 deletions test/phase_spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ end
mom = rand(RNG, SFourMomentum)

particle_stateful = ParticleStateful(dir, species, mom)
@test particle_stateful == ParticleStateful{typeof(dir),typeof(species)}(mom)
@test particle_stateful ==
ParticleStateful{typeof(dir),typeof(species),typeof(mom)}(mom)

# particle interface
@test is_fermion(particle_stateful) == is_fermion(species)
Expand Down
Loading