diff --git a/docs/comparison/d2kkk.ipynb b/docs/comparison/d2kkk.ipynb index d960ba24..c119cac1 100644 --- a/docs/comparison/d2kkk.ipynb +++ b/docs/comparison/d2kkk.ipynb @@ -268,28 +268,6 @@ "Latex(aslatex(DPD_MODEL.variables))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "masses = {\n", - " symbol: sp.sympify(value)\n", - " for symbol, value in DPD_MODEL.parameter_defaults.items()\n", - " if symbol.name.startswith(\"m\")\n", - " if len(symbol.name) == 2\n", - "}\n", - "Latex(aslatex(masses))" - ] - }, { "cell_type": "markdown", "metadata": { @@ -390,9 +368,9 @@ "outputs": [], "source": [ "p1, p2, p3 = tuple(FourMomentumSymbol(f\"p{i}\", shape=[]) for i in (0, 1, 2))\n", - "s1, s2, s3 = sp.symbols(\"sigma1:4\", nonnegative=True)\n", + "s1, s2, s3 = sorted(DPD_MODEL.invariants, key=str)\n", "mass_definitions = {\n", - " **masses,\n", + " **DPD_MODEL.masses,\n", " s1: InvariantMass(p2 + p3) ** 2,\n", " s2: InvariantMass(p1 + p3) ** 2,\n", " s3: InvariantMass(p1 + p2) ** 2,\n", diff --git a/docs/comparison/jpsi2phipipi.ipynb b/docs/comparison/jpsi2phipipi.ipynb index 19928907..b812df55 100644 --- a/docs/comparison/jpsi2phipipi.ipynb +++ b/docs/comparison/jpsi2phipipi.ipynb @@ -261,28 +261,6 @@ "Latex(aslatex(DPD_MODEL.variables))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "masses = {\n", - " symbol: sp.sympify(value)\n", - " for symbol, value in DPD_MODEL.parameter_defaults.items()\n", - " if symbol.name.startswith(\"m\")\n", - " if len(symbol.name) == 2\n", - "}\n", - "Latex(aslatex(masses))" - ] - }, { "cell_type": "markdown", "metadata": { @@ -374,9 +352,9 @@ "outputs": [], "source": [ "p1, p2, p3 = tuple(FourMomentumSymbol(f\"p{i}\", shape=[]) for i in (0, 1, 2))\n", - "s1, s2, s3 = sp.symbols(\"sigma1:4\", nonnegative=True)\n", + "s1, s2, s3 = sorted(DPD_MODEL.invariants, key=str)\n", "mass_definitions = {\n", - " **masses,\n", + " **DPD_MODEL.masses,\n", " s1: InvariantMass(p2 + p3) ** 2,\n", " s2: InvariantMass(p1 + p3) ** 2,\n", " s3: InvariantMass(p1 + p2) ** 2,\n", diff --git a/docs/comparison/jpsi2pipipi.ipynb b/docs/comparison/jpsi2pipipi.ipynb index 4f5b77d1..b3a381b7 100644 --- a/docs/comparison/jpsi2pipipi.ipynb +++ b/docs/comparison/jpsi2pipipi.ipynb @@ -261,28 +261,6 @@ "Latex(aslatex(DPD_MODEL.variables))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ - "masses = {\n", - " symbol: sp.sympify(value)\n", - " for symbol, value in DPD_MODEL.parameter_defaults.items()\n", - " if symbol.name.startswith(\"m\")\n", - " if len(symbol.name) == 2\n", - "}\n", - "Latex(aslatex(masses))" - ] - }, { "cell_type": "markdown", "metadata": { @@ -374,9 +352,9 @@ "outputs": [], "source": [ "p1, p2, p3 = tuple(FourMomentumSymbol(f\"p{i}\", shape=[]) for i in (0, 1, 2))\n", - "s1, s2, s3 = sp.symbols(\"sigma1:4\", nonnegative=True)\n", + "s1, s2, s3 = sorted(DPD_MODEL.invariants, key=str)\n", "mass_definitions = {\n", - " **masses,\n", + " **DPD_MODEL.masses,\n", " s1: InvariantMass(p2 + p3) ** 2,\n", " s2: InvariantMass(p1 + p3) ** 2,\n", " s3: InvariantMass(p1 + p2) ** 2,\n", diff --git a/docs/jpsi2ksp.ipynb b/docs/jpsi2ksp.ipynb index a62dffb3..067cd192 100644 --- a/docs/jpsi2ksp.ipynb +++ b/docs/jpsi2ksp.ipynb @@ -39,7 +39,6 @@ "import qrules\n", "import sympy as sp\n", "from ampform.dynamics import BlattWeisskopfSquared, EnergyDependentWidth\n", - "from ampform.kinematics.phasespace import compute_third_mandelstam\n", "from ampform.sympy import perform_cached_doit\n", "from IPython.display import Latex, Markdown\n", "from tensorwaves.data.transform import SympyDataTransformer\n", @@ -409,7 +408,7 @@ { "cell_type": "markdown", "metadata": { - "jp-MarkdownHeadingCollapsed": true + "tags": [] }, "source": [ "## Preparing for input data" @@ -436,29 +435,9 @@ }, { "cell_type": "markdown", - "metadata": {}, - "source": [ - "We set each helicity coupling to $1$, so that each each parameter {class}`~sympy.core.symbol.Symbol` in the expression has a definition:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "couplings = {\n", - " s: 1\n", - " for s in full_intensity_expr.free_symbols\n", - " if isinstance(s, sp.Indexed)\n", - " if \"production\" in str(s) or \"decay\" in str(s)\n", - "}\n", - "model.parameter_defaults.update(couplings)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "With this, the remaining {class}`~sympy.core.symbol.Symbol`s in the full expression are kinematic variables.[^1]\n", "\n", @@ -469,21 +448,22 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ - "sp.Array(full_intensity_expr.free_symbols - set(model.parameter_defaults))" + "sp.Array(\n", + " sorted(full_intensity_expr.free_symbols - set(model.parameter_defaults), key=str)\n", + ")" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "The $\\theta$ and $\\zeta$ angles are defined by the {attr}`~.AmplitudeModel.variables` attribute (they are shown under {ref}`jpsi2ksp:Model formulation`). Those definitions allow us to create a converter that computes kinematic variables from masses and Mandelstam variables:" ] @@ -511,7 +491,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "The data input for this data transformer can be several things. One can compute them from a (generated) data sample of four-momenta. Or one can compute them for a Dalitz plane. We do the latter in this section.\n", "\n", @@ -522,31 +504,11 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "hide-input" - ] + "tags": [] }, "outputs": [], "source": [ - "masses = {\n", - " symbol: value\n", - " for symbol, value in model.parameter_defaults.items()\n", - " if str(symbol).startswith(\"m\")\n", - " if len(str(symbol)) == 2\n", - "}\n", - "Latex(aslatex(masses))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dalitz_data = {str(s): float(v) for s, v in masses.items()}" + "dalitz_data = {str(s): float(v) for s, v in model.masses.items()}" ] }, { @@ -573,7 +535,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "The remaining Mandelstam variable can be expressed in terms of the others as follows:" ] @@ -582,24 +546,21 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ - "s1, s2, s3 = sp.symbols(\"sigma1:4\", nonnegative=True)\n", - "m0, m1, m2, m3 = sp.symbols(\"m:4\", nonnegative=True)\n", - "s1_expr = compute_third_mandelstam(s3, s2, m0, m1, m2, m3)\n", + "(s1, s1_expr), *_ = model.invariants.items()\n", "Latex(aslatex({s1: s1_expr}))" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "That completes the data sample over which we want to evaluate the intensity model defined above:" ] @@ -621,7 +582,9 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [] + }, "source": [ "We can now extend the sample with angle definitions so that we have a data sample over which the intensity can be evaluated." ] @@ -629,7 +592,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "angle_data = masses_to_angles(dalitz_data)\n", @@ -653,7 +618,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "free_parameters = {\n",