Skip to content

Commit

Permalink
Release 0.2.0 to main (#53)
Browse files Browse the repository at this point in the history
Release version 0.2.0 to main, do not squash/rebase
  • Loading branch information
SimeonEhrig authored Nov 5, 2024
2 parents b9a015c + 80b7b8f commit b2d73f5
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 43 deletions.
20 changes: 12 additions & 8 deletions .github/workflows/BuildDeployDoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Deploy Documentation
on:
push:
branches:
- master
- main
- dev
tags: "*"
pull_request:
Expand All @@ -18,15 +18,19 @@ jobs:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
with:
version: "1.10"
- name: Add custom registry
version: '1.10'
- name: clone integration test tools
run: |
julia --project=docs/ -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));'
julia --project=docs/ -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));'
- name: Install dependencies
git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools/
- name: set dev dependencies
run: |
julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
$(julia --project=. /tmp/integration_test_tools/.ci/integTestGen/src/get_project_name_version_path.jl)
echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME"
echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION"
echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH"
julia --project=docs/ /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl
julia --project=docs/ -e 'import Pkg; Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia --project=docs/ docs/make.jl
6 changes: 0 additions & 6 deletions .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ jobs:
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add("General")
shell: julia --color=yes {0}
- name: "Add QED custom registry"
run: |
import Pkg
ENV["JULIA_PKG_SERVER"] = ""
Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"))
shell: julia --color=yes {0}
- name: "Install CompatHelper"
run: |
import Pkg
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: "3"
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.TAGBOT_PRIV }}
2 changes: 1 addition & 1 deletion .github/workflows/formatter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: install Julia
uses: julia-actions/setup-julia@v1
with:
version: 1.10
version: "1.10"
- name: Install Julia requirements
run: julia --project=${GITHUB_WORKSPACE}/.formatting -e 'import Pkg; Pkg.instantiate()'
- name: Check code style
Expand Down
46 changes: 24 additions & 22 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ stages:
- run_integration_test
- verify-unit-test-deps

.untit_test_template:
.unit_test_template:
stage: unit-test
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"));'
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools/
- $(julia --project=. /tmp/integration_test_tools/.ci/integTestGen/src/get_project_name_version_path.jl)
- echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME"
- echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION"
- echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH"
- >
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
julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE
julia --project=. /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml NO_MESSAGE
else
julia --project=. /QEDjl/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml
julia --project=. /tmp/integration_test_tools/.ci/SetupDevEnv/src/SetupDevEnv.jl ${CI_PROJECT_DIR}/Project.toml
fi
- julia --project=. -e 'import Pkg; Pkg.instantiate()'
- julia --project=. -e 'import Pkg; Pkg.test(; coverage = true)'
Expand All @@ -25,57 +27,57 @@ stages:
- cpuonly

unit_tests_releases:
extends: .untit_test_template
extends: .unit_test_template
parallel:
matrix:
- JULIA_VERSION: ["1.6", "1.7", "1.8", "1.9", "1.10", "rc"]
- JULIA_VERSION: ["1.10", "1.11", "rc"]
image: julia:$JULIA_VERSION

unit_tests_nightly:
extends: .untit_test_template
extends: .unit_test_template
# use the same baseimage like the official julia images
image: debian:bookworm-slim
variables:
# path where julia tar bal should be downloaded
JULIA_DONWLOAD: /julia/download
JULIA_DOWNLOAD: /julia/download
# path where julia should be extracted
JULIA_EXTRACT: /julia/extract
before_script:
- apt update && apt install -y wget
- mkdir -p $JULIA_DONWLOAD
- mkdir -p $JULIA_DOWNLOAD
- mkdir -p $JULIA_EXTRACT
- >
if [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/arm64" ]]; then
wget https://julialangnightlies-s3.julialang.org/bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz
wget https://julialangnightlies-s3.julialang.org/bin/linux/aarch64/julia-latest-linux-aarch64.tar.gz -O $JULIA_DOWNLOAD/julia-nightly.tar.gz
elif [[ $CI_RUNNER_EXECUTABLE_ARCH == "linux/amd64" ]]; then
wget https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz -O $JULIA_DONWLOAD/julia-nightly.tar.gz
wget https://julialangnightlies-s3.julialang.org/bin/linux/x86_64/julia-latest-linux-x86_64.tar.gz -O $JULIA_DOWNLOAD/julia-nightly.tar.gz
else
echo "unknown runner architecture -> $CI_RUNNER_EXECUTABLE_ARCH"
exit 1
fi
- tar -xf $JULIA_DONWLOAD/julia-nightly.tar.gz -C $JULIA_EXTRACT
- tar -xf $JULIA_DOWNLOAD/julia-nightly.tar.gz -C $JULIA_EXTRACT
# we need to search for the julia base folder name, because the second part of the name is the git commit hash
# e.g. julia-b0c6781676f
- JULIA_EXTRACT_FOLDER=${JULIA_EXTRACT}/$(ls $JULIA_EXTRACT | grep -m1 julia)
# copy everything to /usr to make julia public available
# mv is not possible, because it cannot merge folder
- cp -r $JULIA_EXTRACT_FOLDER/* /usr
allow_failure: true
tags:
- cpuonly

generate_integration_tests:
image: julia:1.10
stage: generate_integration_test
script:
# extract package name
- export CI_DEPENDENCY_NAME=$(cat $CI_PROJECT_DIR/Project.toml | grep name | awk '{ print $3 }' | tr -d '"')
- echo "CI_DEPENDENCY_NAME -> $CI_DEPENDENCY_NAME"
- apt update && apt install -y git
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl
- $(julia --project /QEDjl/.ci/integTestGen/src/get_project_name_version_path.jl)
- echo "CI_DEV_PKG_NAME -> $CI_DEV_PKG_NAME"
- echo "CI_DEV_PKG_VERSION -> $CI_DEV_PKG_VERSION"
- echo "CI_DEV_PKG_PATH -> $CI_DEV_PKG_PATH"
- cd /QEDjl/.ci/integTestGen/
# use local registry of the QED project
- julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/QEDjl-project/registry.git"));'
# needs to add General registry again, if local registry was added
- julia --project=. -e 'import Pkg; Pkg.Registry.add(Pkg.RegistrySpec(url="https://github.com/JuliaRegistries/General"));'
- julia --project=. -e 'import Pkg; Pkg.instantiate()'
# paths of artifacts are relative to CI_PROJECT_DIR
- >
Expand Down Expand Up @@ -107,7 +109,7 @@ verify-unit-test-deps_julia1.10:
stage: verify-unit-test-deps
script:
- apt update && apt install -y git
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QED.jl.git /QEDjl
- git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl
- >
if [[ $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_REF_NAME == "dev" ]]; then
# does not check for custom package URLs on the main and dev branch
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
"Tom Jungnickel",
"Anton Reinhard",
]
version = "0.1.0"
version = "0.2.0"

[deps]
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
Expand All @@ -16,11 +16,11 @@ QEDcore = "35dc0263-cb5f-4c33-a114-1d7f54ab753e"
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"

[compat]
QEDbase = "0.2.2"
QEDcore = "0.1"
QEDbase = "0.3"
QEDcore = "0.2"
IntervalSets = "0.7"
QuadGK = "2"
julia = "1.6"
julia = "1.10"

[extras]
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QEDfields

[![Doc Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://qedjl-project.github.io/QEDfields.jl/main)
[![Doc Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://qedjl-project.github.io/QEDfields.jl/stable)
[![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)

Expand Down
3 changes: 2 additions & 1 deletion src/QEDfields.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ export reference_momentum, domain, pulse_length, envelope, amplitude, generic_sp

export polarization_vector, oscillator

export CosSquarePulse
export CosSquarePulse, GaussianPulse

include("interfaces/background_field_interface.jl")
include("polarization.jl")
include("pulses/cos_square.jl")
include("pulses/gaussian.jl")

end
59 changes: 59 additions & 0 deletions src/pulses/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
############################
# Gaussian pulsed plane wave
############################

"""
GaussianPulse(mom::M,pulse_length::T) where {M<:QEDbase.AbstractFourMomentum,T<:Real}
Concrete implementation of an `AbstractPulsedPlaneWaveField` for Gaussian pulses.
Propagates along the direction given by the space-like components of the reference momentum vector k_mu = (omega/speed_of_light, k_x, k_y, k_z), and omega = 2*pi*speed_of_light/wavelength.
The time-like coordinate omega/speed_of_ligth of k_mu defines the field's oscillation frequency.
In order to fulfill the vacuum dispersion relation, k_mu*k^mu=0 is required.
!!! note "Pulse shape"
The longitudinal envelope of a Gaussian pulse is defined as
```math
g(\\phi) = \\exp(-\\frac{\\phi^2}{2\\Delta\\phi^2})
```
for \$\\phi\\in (-\\infty, \\infty) and \$\\Delta\\phi`\$ denotes the `pulse_length`.
There is no envelope in the transverse directions.
"""
struct GaussianPulse{M<:QEDbase.AbstractFourMomentum,T<:Real} <:
AbstractPulsedPlaneWaveField
mom::M
pulse_length::T
end

"""
_unsafe_gaussian_envelope(phi::Real, dphi::Real)
The envelope of the Gaussian background field is defined according to the standard Gaussian distribution with `dphi` representing the distribution's standard deviation.
"""
@inline function _unsafe_gaussian_envelope(phi, dphi)
return exp(-0.5 * (phi / dphi)^2)
end

####
# interface functions
####

reference_momentum(pulse::GaussianPulse) = pulse.mom

function domain(pulse::GaussianPulse)
dphi = pulse.pulse_length
return Interval(-Inf, Inf)
end

pulse_length(pulse::GaussianPulse) = pulse.pulse_length

function _envelope(pulse::GaussianPulse, phi::Real)
return _unsafe_gaussian_envelope(phi, pulse.pulse_length)
end
61 changes: 61 additions & 0 deletions test/pulses/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Random
using IntervalSets
using QEDfields
using QEDbase
using QuadGK

RNG = MersenneTwister(123456789)
ATOL = 0.0
RTOL = sqrt(eps())

DPHIS = [rand(RNG), rand(RNG) * 10, rand(RNG) * 100, rand(RNG) * 1000, rand(RNG) * 10000]

# wrapper implementation to test analytical solutions of the generic spectrum

struct GaussianPulseWrapper{G<:GaussianPulse} <: AbstractPulsedPlaneWaveField
pulse::G
end
QEDfields.reference_momentum(p::GaussianPulseWrapper) = reference_momentum(p.pulse)
QEDfields.domain(p::GaussianPulseWrapper) = domain(p.pulse)
QEDfields.pulse_length(p::GaussianPulseWrapper) = pulse_length(p.pulse)
QEDfields._envelope(p::GaussianPulseWrapper, x) = QEDfields._envelope(p.pulse, x)

@testset "pulse interface" begin
@test hasmethod(reference_momentum, Tuple{GaussianPulse})
@test hasmethod(domain, Tuple{GaussianPulse})
@test hasmethod(pulse_length, Tuple{GaussianPulse})
@test hasmethod(QEDfields._envelope, Tuple{GaussianPulse,Real})
end
@testset "dphi: $dphi" for dphi in DPHIS
test_mom = rand(RNG, SFourMomentum)
test_pulse = GaussianPulse(test_mom, dphi)

@testset "properties" begin
@test reference_momentum(test_pulse) == test_mom
@test domain(test_pulse) == Interval(-Inf, Inf)
@test pulse_length(test_pulse) == dphi
end

@testset "envelope" begin
# unity at the origin
@test envelope(test_pulse, 0.0) == 1.0

# zero at the endpoints
@test isapprox(envelope(test_pulse, -Inf), 0.0, atol=ATOL, rtol=RTOL)
@test isapprox(envelope(test_pulse, Inf), 0.0, atol=ATOL, rtol=RTOL)
end
@testset "generic spectrum" begin
wrapper_pulse = GaussianPulseWrapper(test_pulse)
test_pnums = [1.0, -1.0, 1 + rand(RNG) * 0.1, -1 - rand(RNG) * 0.1]
@testset "pnum: $pnum" for pnum in test_pnums
test_val_xpol = generic_spectrum(test_pulse, PolX(), pnum)
test_val_ypol = generic_spectrum(test_pulse, PolY(), pnum)

groundtruth_xpol = generic_spectrum(wrapper_pulse, PolX(), pnum)
groundtruth_ypol = generic_spectrum(wrapper_pulse, PolY(), pnum)

@test isapprox(test_val_xpol, groundtruth_xpol, atol=ATOL, rtol=RTOL)
@test isapprox(test_val_ypol, groundtruth_ypol, atol=ATOL, rtol=RTOL)
end
end
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ end

@time @safetestset "pulses" begin
include("pulses/cos_square.jl")
include("pulses/gaussian.jl")
end

0 comments on commit b2d73f5

Please sign in to comment.