From eb66e6f9a903178df6dbbe24096003e72711ef3f Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Wed, 21 Aug 2024 11:42:58 +0200 Subject: [PATCH 01/10] set QED dependencies for the doc build to the dev branch version - only if the target branch is not main --- .github/workflows/BuildDeployDoc.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index dd93194..57f034a 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -26,6 +26,11 @@ jobs: - name: Install dependencies run: | julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + - name: set dependencies to dev branch version + if: (github.event_name == 'push' && github.ref_name != 'main') || (github.event_name == 'pull_request' && github.base_ref != 'main') + run: | + git clone -b dev https://github.com/QEDjl-project/QED.jl.git /tmp/integration_test_tools + julia --project=docs/ /tmp/integration_test_tools/.ci/set_dev_dependencies.jl - name: Build and deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token From f68c8a2c10eb71d94fa781c7a96934c41a87ac59 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 2 Sep 2024 14:17:11 +0200 Subject: [PATCH 02/10] Fix branch names and julia version in CI --- .github/workflows/BuildDeployDoc.yml | 2 +- .github/workflows/formatter.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 57f034a..54a1e2e 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -3,7 +3,7 @@ name: Build and Deploy Documentation on: push: branches: - - master + - main - dev tags: "*" pull_request: diff --git a/.github/workflows/formatter.yaml b/.github/workflows/formatter.yaml index 5cbe730..c5e31e4 100644 --- a/.github/workflows/formatter.yaml +++ b/.github/workflows/formatter.yaml @@ -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 From 66a6c1a9a522d5afdbd53ec6135a71219c4ba0b6 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 2 Sep 2024 19:51:37 +0200 Subject: [PATCH 03/10] Fix stable docs badge link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 44239df..b572196 100644 --- a/README.md +++ b/README.md @@ -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) From 75953cdc13c4e8f59005e3453256ff9617217b6f Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Thu, 12 Sep 2024 14:56:37 +0200 Subject: [PATCH 04/10] Rename project (#45) --- .github/workflows/BuildDeployDoc.yml | 2 +- .github/workflows/CompatHelper.yml | 2 +- .gitlab-ci.yml | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 54a1e2e..72f563c 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -29,7 +29,7 @@ jobs: - name: set dependencies to dev branch version if: (github.event_name == 'push' && github.ref_name != 'main') || (github.event_name == 'pull_request' && github.base_ref != 'main') run: | - git clone -b dev https://github.com/QEDjl-project/QED.jl.git /tmp/integration_test_tools + git clone -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools julia --project=docs/ /tmp/integration_test_tools/.ci/set_dev_dependencies.jl - name: Build and deploy env: diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index 29603a8..a59021c 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -27,7 +27,7 @@ jobs: ENV["JULIA_PKG_SERVER"] = "" Pkg.Registry.add("General") shell: julia --color=yes {0} - - name: "Add QED custom registry" + - name: "Add QEDjl-project custom registry" run: | import Pkg ENV["JULIA_PKG_SERVER"] = "" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 15680d2..a2883dc 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,7 @@ stages: 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 + - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.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"));' - > @@ -70,7 +70,7 @@ generate_integration_tests: - 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 - 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"));' @@ -107,7 +107,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 From a2f035592505f318ca14a70ac17854be5e981dd7 Mon Sep 17 00:00:00 2001 From: Simeon Ehrig Date: Fri, 13 Sep 2024 18:51:06 +0200 Subject: [PATCH 05/10] remove custom registry in CI (#46) --- .github/workflows/BuildDeployDoc.yml | 4 ---- .github/workflows/CompatHelper.yml | 6 ------ .gitlab-ci.yml | 6 ------ 3 files changed, 16 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 72f563c..5c0550a 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -19,10 +19,6 @@ jobs: - uses: julia-actions/setup-julia@v1 with: version: "1.10" - - name: Add custom registry - 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 run: | julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' diff --git a/.github/workflows/CompatHelper.yml b/.github/workflows/CompatHelper.yml index a59021c..5d1669e 100644 --- a/.github/workflows/CompatHelper.yml +++ b/.github/workflows/CompatHelper.yml @@ -27,12 +27,6 @@ jobs: ENV["JULIA_PKG_SERVER"] = "" Pkg.Registry.add("General") shell: julia --color=yes {0} - - name: "Add QEDjl-project 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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2883dc..759e128 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,6 @@ stages: script: - apt update && apt install -y git - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.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 @@ -72,10 +70,6 @@ generate_integration_tests: - apt update && apt install -y git - git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /QEDjl - 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 - > From e59bba41f0e9fe787a74dd7307b14b6fa5642a44 Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Mon, 23 Sep 2024 14:24:45 +0200 Subject: [PATCH 06/10] Add tagbot (#47) I already set up the deploy key and the private ssh key as a repository secret. --- .github/workflows/TagBot.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/TagBot.yml diff --git a/.github/workflows/TagBot.yml b/.github/workflows/TagBot.yml new file mode 100644 index 0000000..a3d77f7 --- /dev/null +++ b/.github/workflows/TagBot.yml @@ -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 }} From b329b103a40aceaf2d4824a6e467cc38c79fecd0 Mon Sep 17 00:00:00 2001 From: Uwe Hernandez Acosta Date: Wed, 9 Oct 2024 17:38:49 +0200 Subject: [PATCH 07/10] dropped Julia <1.10 in CI, bumped combat to Juila1.10 (#48) Co-authored-by: Uwe Hernandez Acosta --- .gitlab-ci.yml | 2 +- Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 759e128..ac08889 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -26,7 +26,7 @@ unit_tests_releases: extends: .untit_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: diff --git a/Project.toml b/Project.toml index 025be2e..9f04808 100644 --- a/Project.toml +++ b/Project.toml @@ -20,7 +20,7 @@ QEDbase = "0.2.2" QEDcore = "0.1" IntervalSets = "0.7" QuadGK = "2" -julia = "1.6" +julia = "1.10" [extras] Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" From e4c74f4983aa1a463f780343a5515b5ac6dee432 Mon Sep 17 00:00:00 2001 From: Anton Reinhard Date: Tue, 29 Oct 2024 08:22:52 +0100 Subject: [PATCH 08/10] Fix CI and update compat (#51) Same as https://github.com/QEDjl-project/QEDprocesses.jl/pull/106 Makes #50 and #49 redundant, but we need to update the compat together with the update of the CI scripts to be able to merge. --- .github/workflows/BuildDeployDoc.yml | 19 +++++++++------- .gitlab-ci.yml | 34 +++++++++++++++++----------- Project.toml | 4 ++-- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/.github/workflows/BuildDeployDoc.yml b/.github/workflows/BuildDeployDoc.yml index 5c0550a..f177603 100644 --- a/.github/workflows/BuildDeployDoc.yml +++ b/.github/workflows/BuildDeployDoc.yml @@ -18,16 +18,19 @@ jobs: - uses: actions/checkout@v4 - uses: julia-actions/setup-julia@v1 with: - version: "1.10" - - name: Install dependencies + version: '1.10' + - name: clone integration test tools run: | - julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' - - name: set dependencies to dev branch version - if: (github.event_name == 'push' && github.ref_name != 'main') || (github.event_name == 'pull_request' && github.base_ref != 'main') + git clone --depth 1 -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools/ + - name: set dev dependencies run: | - git clone -b dev https://github.com/QEDjl-project/QuantumElectrodynamics.jl.git /tmp/integration_test_tools - julia --project=docs/ /tmp/integration_test_tools/.ci/set_dev_dependencies.jl + $(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 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ac08889..2aefd42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,17 +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/QuantumElectrodynamics.jl.git /QEDjl + - 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)' @@ -23,35 +27,35 @@ stages: - cpuonly unit_tests_releases: - extends: .untit_test_template + extends: .unit_test_template parallel: matrix: - 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) @@ -59,16 +63,20 @@ unit_tests_nightly: # 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/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/ - julia --project=. -e 'import Pkg; Pkg.instantiate()' # paths of artifacts are relative to CI_PROJECT_DIR diff --git a/Project.toml b/Project.toml index 9f04808..802f9b7 100644 --- a/Project.toml +++ b/Project.toml @@ -16,8 +16,8 @@ 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.10" From e9504e7026cd7722c53d9f80107f1a8b73f8a695 Mon Sep 17 00:00:00 2001 From: Klaus Steiniger Date: Fri, 17 May 2024 20:11:43 +0200 Subject: [PATCH 09/10] Add Gaussian Pulsed Plane Wave field --- src/QEDfields.jl | 3 +- src/pulses/gaussian.jl | 59 +++++++++++++++++++++++++++++++++++++++ test/pulses/gaussian.jl | 61 +++++++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 src/pulses/gaussian.jl create mode 100644 test/pulses/gaussian.jl diff --git a/src/QEDfields.jl b/src/QEDfields.jl index aeb8a7d..e9435e1 100644 --- a/src/QEDfields.jl +++ b/src/QEDfields.jl @@ -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 diff --git a/src/pulses/gaussian.jl b/src/pulses/gaussian.jl new file mode 100644 index 0000000..dd35823 --- /dev/null +++ b/src/pulses/gaussian.jl @@ -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 diff --git a/test/pulses/gaussian.jl b/test/pulses/gaussian.jl new file mode 100644 index 0000000..b4c91cb --- /dev/null +++ b/test/pulses/gaussian.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index e570804..79e2139 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,4 +17,5 @@ end @time @safetestset "pulses" begin include("pulses/cos_square.jl") + include("pulses/gaussian.jl") end From 80b7b8f92ea39105225f25d453a419b739fe9018 Mon Sep 17 00:00:00 2001 From: AntonReinhard Date: Mon, 4 Nov 2024 17:47:56 +0100 Subject: [PATCH 10/10] Update version to 0.2.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 802f9b7..d88ddb2 100644 --- a/Project.toml +++ b/Project.toml @@ -7,7 +7,7 @@ authors = [ "Tom Jungnickel", "Anton Reinhard", ] -version = "0.1.0" +version = "0.2.0" [deps] IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"