Skip to content

Commit

Permalink
FEAT: implement set_initial_state_polarization()
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer committed Mar 13, 2023
1 parent 4fad1db commit 61e4203
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
19 changes: 16 additions & 3 deletions docs/jpsi2pipipi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"from typing import Iterable\n",
"\n",
"import ampform\n",
"import attrs\n",
"import graphviz\n",
"import jax.numpy as jnp\n",
"import matplotlib.pyplot as plt\n",
Expand All @@ -61,7 +62,11 @@
"from tensorwaves.data.transform import SympyDataTransformer\n",
"from tensorwaves.interface import DataSample, ParameterValue, ParametrizedFunction\n",
"\n",
"from ampform_dpd import DalitzPlotDecompositionBuilder, simplify_latex_rendering\n",
"from ampform_dpd import (\n",
" DalitzPlotDecompositionBuilder,\n",
" set_initial_state_polarization,\n",
" simplify_latex_rendering,\n",
")\n",
"from ampform_dpd.decay import (\n",
" IsobarNode,\n",
" Particle,\n",
Expand Down Expand Up @@ -149,7 +154,7 @@
"outputs": [],
"source": [
"reaction = qrules.generate_transitions(\n",
" initial_state=INITIAL_STATE.name,\n",
" initial_state=(INITIAL_STATE.name, [-1, +1]),\n",
" final_state=[p.name for p in FINAL_STATE],\n",
" allowed_intermediate_particles=[\"a(0)(980)\", \"rho(770)\"],\n",
" mass_conservation_factor=0,\n",
Expand Down Expand Up @@ -282,7 +287,6 @@
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
Expand All @@ -303,7 +307,16 @@
"outputs": [],
"source": [
"model_builder = DalitzPlotDecompositionBuilder(DECAY, min_ls=True)\n",
"initial_polarization = {\n",
" t.initial_states[-1].spin_projection for t in reaction.transitions\n",
"}\n",
"dpd_model = model_builder.formulate(reference_subsystem=1)\n",
"dpd_model = attrs.evolve(\n",
" dpd_model,\n",
" intensity=set_initial_state_polarization(\n",
" dpd_model.intensity, initial_polarization\n",
" ),\n",
")\n",
"dpd_model.intensity"
]
},
Expand Down
14 changes: 14 additions & 0 deletions src/ampform_dpd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys
from functools import lru_cache
from itertools import product
from typing import Iterable

import sympy as sp
from ampform.sympy import PoolSum
Expand Down Expand Up @@ -348,6 +349,19 @@ def _print_Indexed_latex(self, printer, *args):
sp.Indexed._latex = _print_Indexed_latex


def set_initial_state_polarization(
intensity: PoolSum, spin_projections: Iterable[sp.Rational | float | int]
) -> PoolSum:
"""Set the spin projections of the initial state."""
helicity_symbol, _ = intensity.indices[0]
helicity_values = tuple(sp.Rational(i) for i in spin_projections)
new_indices = (
(helicity_symbol, helicity_values),
*intensity.indices[1:],
)
return PoolSum(intensity.expression, *new_indices)


def _formulate_clebsch_gordan_factors(
isobar: IsobarNode,
helicities: dict[Particle, sp.Rational | sp.Symbol],
Expand Down

0 comments on commit 61e4203

Please sign in to comment.