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

Refac cleanup #34

Merged
merged 5 commits into from
Jun 28, 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
1 change: 0 additions & 1 deletion .github/workflows/BuildDelopyDoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
julia --project=docs/ -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));'
- name: Install dependencies
run: |
julia --project=docs/ add_QEDcore_dev.jl
julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
Expand Down
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ stages:
- 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"));'
- julia --project=. add_QEDcore_dev.jl
- >
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
[![Doc Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://qedjl-project.github.io/QEDfields.jl/dev)
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle)


:warning: This package is under construction and only contains dummy functionality for testing.

:warning: currently this is based on a dev-version of QEDcore. Please make sure that you use the QEDjl registry below.

## Installation

To install the current stable version of `QEDfields.jl` you may use the standard julia package manager within the julia REPL
Expand Down
11 changes: 1 addition & 10 deletions src/QEDfields.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
module QEDfields

using QEDbase: QEDbase
using QEDbase
using QEDcore

using IntervalSets
using QuadGK

export dummy_QEDbase

# Write your package code here.
function dummy_QEDbase(x::AbstractVector{T}) where {T<:Real}
length(x) == 4 ||
error("The length of the input needs to be four. <$(length(x))> given.")
@inbounds SFourMomentum(x...)
end

export AbstractBackgroundField, AbstractPulsedPlaneWaveField
export reference_momentum, domain, pulse_length, envelope, amplitude, generic_spectrum

Expand Down
18 changes: 6 additions & 12 deletions src/interfaces/background_field_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,14 @@ end
# amplitude functions

function _amplitude(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
phi::Real,
field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, phi::Real
)
return oscillator(pol, phi) * _envelope(field, phi)
end

function _amplitude(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
pol::AbstractDefinitePolarization,
phi::AbstractVector{T},
) where {T<:Real}
# TODO: maybe use broadcasting here
Expand Down Expand Up @@ -150,16 +148,14 @@ Returns the value of the amplitude for a given polarization direction and phase
the value of the amplitude is returned, and zero otherwise.
"""
function amplitude(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
phi::Real,
field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, phi::Real
)
return phi in domain(field) ? _amplitude(field, pol, phi) : zero(phi)
end

function amplitude(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
pol::AbstractDefinitePolarization,
phi::AbstractVector{T},
) where {T<:Real}
# TODO: maybe use broadcasting here
Expand Down Expand Up @@ -191,16 +187,14 @@ Return the generic spectrum of the given field, for the given polarization direc
where ``g(\\phi)`` is the [`envelope`](@ref) and ``l`` the photon number parameter.
"""
function generic_spectrum(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
pnum::Real,
field::AbstractPulsedPlaneWaveField, pol::AbstractDefinitePolarization, pnum::Real
)
return _fourier_transform(t -> _amplitude(field, pol, t), domain(field), pnum)
end

function generic_spectrum(
field::AbstractPulsedPlaneWaveField,
pol::QEDbase.AbstractDefinitePolarization,
pol::AbstractDefinitePolarization,
photon_number_parameter::AbstractVector{T},
) where {T<:Real}
# TODO: maybe use broadcasting here
Expand Down
10 changes: 5 additions & 5 deletions src/polarization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ where as for an indefinite polarization, a tuple of polarization vectors is retu
In the current implementation, we use the `base_state` function for `Photon` provided by `QEDcore.jl`.

"""
@inline function polarization_vector(pol::QEDbase.AbstractPolarization, mom)
return base_state(Photon(), QEDbase.Incoming(), mom, pol)
@inline function polarization_vector(pol::AbstractPolarization, mom)
return base_state(Photon(), Incoming(), mom, pol)
end

"""
Expand All @@ -44,9 +44,9 @@ Return the value of the base oscillator associated with a given polarization `po
"""
function oscillator end

@inline oscillator(::QEDbase.PolX, phi) = cos(phi)
@inline oscillator(::QEDbase.PolY, phi) = sin(phi)
@inline function oscillator(::QEDbase.AbstractIndefinitePolarization, phi)
@inline oscillator(::PolX, phi) = cos(phi)
@inline oscillator(::PolY, phi) = sin(phi)
@inline function oscillator(::AbstractIndefinitePolarization, phi)
sincos_res = sincos(phi)
@inbounds cossin_res = (sincos_res[2], sincos_res[1])
return cossin_res
Expand Down
7 changes: 3 additions & 4 deletions src/pulses/cos_square.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ Concrete implementation of an `AbstractPulsedPlaneWaveField` for cos-square puls
for \$\\phi\\in (-\\Delta\\phi,\\Delta\\phi)\$, where \$\\Delta\\phi\$ denotes the `pulse_length`, and zero otherwise.

"""
struct CosSquarePulse{M<:QEDbase.AbstractFourMomentum,T<:Real} <:
AbstractPulsedPlaneWaveField
struct CosSquarePulse{M<:AbstractFourMomentum,T<:Real} <: AbstractPulsedPlaneWaveField
mom::M
pulse_length::T
end
Expand Down Expand Up @@ -57,12 +56,12 @@ end
return sig * _gsinc(sig * l / pi)
end

function generic_spectrum(field::CosSquarePulse, pol::QEDbase.PolX, pnum::Real)
function generic_spectrum(field::CosSquarePulse, pol::PolX, pnum::Real)
dphi = field.pulse_length
return 0.5 * (_generic_FT(pnum + 1, dphi) + _generic_FT(pnum - 1, dphi))
end

function generic_spectrum(field::CosSquarePulse, pol::QEDbase.PolY, pnum::Real)
function generic_spectrum(field::CosSquarePulse, pol::PolY, pnum::Real)
dphi = field.pulse_length
return -0.5im * (_generic_FT(pnum + 1, dphi) - _generic_FT(pnum - 1, dphi))
end
Loading