Skip to content

Commit

Permalink
Add convenience constructors for particle statefuls
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonReinhard committed Jul 5, 2024
1 parent f6d5c2f commit 37d6125
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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

@inline function ParticleStateful{DIR,SPECIES,EL}(
mom::EL
) where {DIR<:ParticleDirection,SPECIES<:AbstractParticleType,EL<:AbstractFourMomentum}
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

0 comments on commit 37d6125

Please sign in to comment.