Skip to content

Commit

Permalink
fixed rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Hernandez Acosta committed Nov 27, 2024
1 parent 0ac3b24 commit 9fa7847
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 19 deletions.
223 changes: 223 additions & 0 deletions .ipynb_checkpoints/Untitled-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "dd65841c-9106-4e60-93c8-6cae5cff9c04",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"MersenneTwister(1)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using QEDcore\n",
"using Random\n",
"RNG = MersenneTwister(1)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "ad07e5d2-9e2c-4fc3-ab75-87508a442cc7",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n",
"\u001b[32m\u001b[1m No Changes\u001b[22m\u001b[39m to `~/Work/jlProjects/QEDjl-project/forks/QEDcore.jl/Project.toml`\n",
"\u001b[32m\u001b[1m No Changes\u001b[22m\u001b[39m to `~/Work/jlProjects/QEDjl-project/forks/QEDcore.jl/Manifest.toml`\n"
]
}
],
"source": [
"import Pkg\n",
"Pkg.add(\"SpecialFunctions\")\n",
"using SpecialFunctions"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "659b62c6-1ec3-4b43-bd76-f164b0d48b95",
"metadata": {},
"outputs": [],
"source": [
"using BenchmarkTools"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "0fe32a00-322c-41f3-bfc4-fa717e4984d0",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Main.TestImplementation"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"include(\"test/test_implementation/TestImplementation.jl\")\n"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "f4ecc2d4-d3d0-45d6-833a-35be9b336ee3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"TESTSQRTS = 24.53580264675422\n"
]
},
{
"data": {
"text/plain": [
"5-element Vector{SFourMomentum}:\n",
" [15.044106836425321, 13.336070515918811, 1.527307257013702, -6.39153395069551]\n",
" [17.336250415222185, 14.379561966652835, 0.4621811079199091, -9.395220313008341]\n",
" [4.093524330439206, 1.9013732530288348, -2.0798301891956785, -1.8777719724914776]\n",
" [65.80222040736777, 59.00899489001489, 8.728105773351555, -27.75339442697402]\n",
" [23.071168998359795, 19.545379937281332, 1.1076748703459958, -12.148663236743474]"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"MODEL = TestImplementation.TestModel()\n",
"INPSL = TestImplementation.TrivialInPSL()\n",
"\n",
"N_INCOMING = 2\n",
"N_OUTGOING = 5\n",
"\n",
"INCOMING_PARTICLES = Tuple(rand(RNG, TestImplementation.PARTICLE_SET, N_INCOMING))\n",
"IN_MASSES = mass.(INCOMING_PARTICLES)\n",
"SUM_IN_MASSES = sum(IN_MASSES)\n",
"\n",
"OUTGOING_PARTICLES = Tuple(rand(RNG, TestImplementation.PARTICLE_SET, N_OUTGOING))\n",
"OUT_MASSES = mass.(OUTGOING_PARTICLES)\n",
"SUM_OUT_MASSES = sum(OUT_MASSES)\n",
"TESTSQRTS = (1 + rand(RNG)) * (SUM_OUT_MASSES + SUM_IN_MASSES)\n",
"@show TESTSQRTS\n",
"\n",
"PROC = TestImplementation.TestProcess(INCOMING_PARTICLES, OUTGOING_PARTICLES)\n",
"\n",
"INMOMS = TestImplementation._generate_onshell_two_body_moms(\n",
" RNG, IN_MASSES, TESTSQRTS\n",
")\n",
"\n",
"test_out_psl = FlatPhaseSpaceLayout(INPSL)\n",
"\n",
"OUTCOORDS = Tuple(rand(RNG, 4 * N_OUTGOING))\n",
"\n",
"out_moms = build_momenta(\n",
" PROC, MODEL, INMOMS, test_out_psl, OUTCOORDS\n",
")\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "affcc929-b36d-49c8-845e-a6142a98cbb4",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"massless_weight (generic function with 1 method)"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function massless_weight(n_out,sqrt_s)\n",
" return (pi/2)^(n_out-1)*sqrt_s^(2*n_out-4)/(factorial(n_out-1)*factorial(n_out-2))\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "5bf79f89-f703-483c-b060-d641ba075fa8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"BenchmarkTools.Trial: 10000 samples with 999 evaluations.\n",
" Range \u001b[90m(\u001b[39m\u001b[36m\u001b[1mmin\u001b[22m\u001b[39m … \u001b[35mmax\u001b[39m\u001b[90m): \u001b[39m\u001b[36m\u001b[1m8.925 ns\u001b[22m\u001b[39m … \u001b[35m209.918 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmin … max\u001b[90m): \u001b[39m0.00% … 0.00%\n",
" Time \u001b[90m(\u001b[39m\u001b[34m\u001b[1mmedian\u001b[22m\u001b[39m\u001b[90m): \u001b[39m\u001b[34m\u001b[1m9.050 ns \u001b[22m\u001b[39m\u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmedian\u001b[90m): \u001b[39m0.00%\n",
" Time \u001b[90m(\u001b[39m\u001b[32m\u001b[1mmean\u001b[22m\u001b[39m ± \u001b[32mσ\u001b[39m\u001b[90m): \u001b[39m\u001b[32m\u001b[1m9.283 ns\u001b[22m\u001b[39m ± \u001b[32m 2.715 ns\u001b[39m \u001b[90m┊\u001b[39m GC \u001b[90m(\u001b[39mmean ± σ\u001b[90m): \u001b[39m0.00% ± 0.00%\n",
"\n",
" \u001b[39m▄\u001b[39m█\u001b[34m▇\u001b[39m\u001b[39m▅\u001b[39m▂\u001b[39m \u001b[39m▂\u001b[32m▅\u001b[39m\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▃\u001b[39m▂\u001b[39m▃\u001b[39m \u001b[39m▁\u001b[39m \u001b[39m▁\u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m \u001b[39m▂\n",
" \u001b[39m█\u001b[39m█\u001b[34m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m█\u001b[32m█\u001b[39m\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m█\u001b[39m█\u001b[39m▇\u001b[39m▇\u001b[39m▇\u001b[39m▅\u001b[39m▄\u001b[39m▅\u001b[39m▄\u001b[39m▄\u001b[39m▁\u001b[39m▃\u001b[39m▃\u001b[39m▃\u001b[39m▁\u001b[39m▄\u001b[39m▃\u001b[39m▁\u001b[39m▃\u001b[39m▁\u001b[39m▃\u001b[39m▁\u001b[39m▄\u001b[39m▁\u001b[39m▃\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▄\u001b[39m▃\u001b[39m▃\u001b[39m▃\u001b[39m▁\u001b[39m▁\u001b[39m▁\u001b[39m▄\u001b[39m \u001b[39m█\n",
" 8.92 ns\u001b[90m \u001b[39m\u001b[90mHistogram: \u001b[39m\u001b[90m\u001b[1mlog(\u001b[22m\u001b[39m\u001b[90mfrequency\u001b[39m\u001b[90m\u001b[1m)\u001b[22m\u001b[39m\u001b[90m by time\u001b[39m 12.1 ns \u001b[0m\u001b[1m<\u001b[22m\n",
"\n",
" Memory estimate\u001b[90m: \u001b[39m\u001b[33m0 bytes\u001b[39m, allocs estimate\u001b[90m: \u001b[39m\u001b[33m0\u001b[39m."
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"@benchmark massless_weight($N_OUTGOING,$TESTSQRTS)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2a648d3f-add6-495f-bc59-0777e9429594",
"metadata": {},
"outputs": [],
"source": [
"function massive_weight()\n",
"\n",
"end"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.10.5",
"language": "julia",
"name": "julia-1.10"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.10.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
53 changes: 53 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: forbid-crlf
- id: remove-crlf
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=5120'] # 5MB
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: trailing-whitespace
exclude: &exclude_txtfiles >-
(?x)^(
test/.*\.win|
test/.*\.amn|
test/.*\.mmn|
test/.*\.vmn|
test/.*\.eig|
test/.*\.chk.fmt|
test/.*\.nnkp|
test/.*\.wout|
test/.*_band.dat|
test/.*_band.kpt|
test/.*_band.labelinfo.dat|
test/.*_tb.dat|
test/.*_hr.dat|
test/.*_wsvec.dat|
test/.*\.xsf|
test/.*\.cube|
test/.*\.bxsf
)$
- id: mixed-line-ending
exclude: *exclude_txtfiles
- id: end-of-file-fixer
exclude: *exclude_txtfiles
- id: check-merge-conflict
- id: check-yaml
args: [ --unsafe ]
- id: check-json
- id: check-toml
- id: check-xml
- repo: https://github.com/qiaojunfeng/pre-commit-julia-format
rev: v0.2.0
hooks:
- id: julia-format
args: [--project=.formatting]
exclude: >-
(?x)^(
deps/statements.jl
)$
18 changes: 9 additions & 9 deletions src/phase_space_layouts/out_channel/flat_phase_space.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# here we implement RAMBO

"""
FlatPhaseSpaceLayout{INPSL} <: QEDcore.AbstractOutPhaseSpaceLayout{INPSL}
FlatPhaseSpaceLayout{INPSL} <: QEDbase.AbstractOutPhaseSpaceLayout{INPSL}
Defines a flat phase space layout for generating outgoing particle momenta. This layout assumes
that outgoing particles are uniformly distributed in phase space, subject to constraints on
Expand All @@ -17,9 +17,9 @@ and massive particles.
# Usage
`FlatPhaseSpaceLayout` is commonly used in high-energy physics to define phase space configurations
for event generators and cross-section calculations. Key functions include:
- `QEDcore.phase_space_dimension`: Calculates the phase space dimension based on the number of
- `QEDbase.phase_space_dimension`: Calculates the phase space dimension based on the number of
outgoing particles.
- `QEDcore._build_momenta`: Constructs the outgoing momenta using the provided phase space layout
- `QEDbase._build_momenta`: Constructs the outgoing momenta using the provided phase space layout
and RAMBO-based algorithms, ensuring the momenta satisfy energy and momentum conservation laws.
# Example
Expand All @@ -30,29 +30,29 @@ build_momenta(process, model, incoming_momenta, psl, out_coords)
```
`FlatPhaseSpaceLayout` provides a robust setup for defining the final-state phase space in particle
physics simulations, allowing for modularity and compatibility with `QEDcore` routines.
physics simulations, allowing for modularity and compatibility with `QEDbase` routines.
"""
struct FlatPhaseSpaceLayout{INPSL} <: QEDcore.AbstractOutPhaseSpaceLayout{INPSL}
struct FlatPhaseSpaceLayout{INPSL} <: QEDbase.AbstractOutPhaseSpaceLayout{INPSL}
in_psl::INPSL
end

"""
QEDcore.phase_space_dimension(proc::AbstractProcessDefinition, model::AbstractModelDefinition, psl::FlatPhaseSpaceLayout)
QEDbase.phase_space_dimension(proc::AbstractProcessDefinition, model::AbstractModelDefinition, psl::FlatPhaseSpaceLayout)
Calculates the phase space dimensionality for a given process, model, and phase space layout.
This dimension is derived as four times the number of outgoing particles.
"""
function QEDcore.phase_space_dimension(
function QEDbase.phase_space_dimension(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
psl::FlatPhaseSpaceLayout,
)
return 4 * number_outgoing_particles(proc)
end

QEDcore.in_phase_space_layout(psl::FlatPhaseSpaceLayout) = psl.in_psl
QEDbase.in_phase_space_layout(psl::FlatPhaseSpaceLayout) = psl.in_psl

function QEDcore._build_momenta(
function QEDbase._build_momenta(
proc::AbstractProcessDefinition,
model::AbstractModelDefinition,
in_moms::Tuple,
Expand Down
11 changes: 6 additions & 5 deletions test/phase_space_layouts/out_channel/flat_phase_space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ SUM_IN_MASSES = sum(IN_MASSES)
TESTOUTCOORDS = Tuple(rand(RNG, 4 * N_OUTGOING))

@testset "properties" begin
@test phase_space_dimension(TESTPROC, TESTMODEL, test_out_psl) == 4 * N_OUTGOING
@test in_phase_space_layout(test_out_psl) == TESTINPSL
@test QEDbase.phase_space_dimension(TESTPROC, TESTMODEL, test_out_psl) ==
4 * N_OUTGOING
@test QEDbase.in_phase_space_layout(test_out_psl) == TESTINPSL
end

@testset "momentum generation" begin
test_out_moms = build_momenta(
test_out_moms = QEDbase.build_momenta(
TESTPROC, TESTMODEL, TESTINMOMS, test_out_psl, TESTOUTCOORDS
)

Expand Down Expand Up @@ -74,7 +75,7 @@ end
valid_in_particles, invalid_out_particles
)
out_coords = Tuple(rand(RNG, 4))
@test_throws InvalidInputError build_momenta(
@test_throws InvalidInputError QEDbase.build_momenta(
invalid_process, TESTMODEL, valid_in_moms, test_out_psl, out_coords
)
end
Expand All @@ -85,7 +86,7 @@ end
RNG, mass.(valid_in_particles), invalid_sqrt_s
)

@test_throws InvalidInputError build_momenta(
@test_throws InvalidInputError QEDbase.build_momenta(
valid_process, TESTMODEL, invalid_in_moms, test_out_psl, valid_out_coords
)
end
Expand Down
5 changes: 0 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ begin
include("lorentz_transform/lorentz_transform.jl")
end

# TODO: move this to QEDbase
@time @safetestset "phase space layout" begin
include("interfaces/phase_space_layout.jl")
end

@time @safetestset "coordinates" begin
include("coordinates.jl")
end
Expand Down

0 comments on commit 9fa7847

Please sign in to comment.