Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs!: implement relativistic K-matrix #37

Merged
merged 14 commits into from
Aug 3, 2021
2 changes: 2 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
"darkred",
"displaystyle",
"dotprint",
"elif",
"evaluatable",
"expertsystem",
"facecolor",
Expand Down Expand Up @@ -160,6 +161,7 @@
"pcolormesh",
"pdg's",
"phsp",
"pmatrix",
"preorder",
"py's",
"pygments",
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ repos:
docs/report/005.*|
docs/report/006.*|
docs/report/007.*|
docs/report/009.*|
demo/.*
)$

Expand Down
78 changes: 48 additions & 30 deletions docs/report/005.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"This report investigates how to implement non-relativistic $K$-matrix dynamics with {doc}`SymPy <sympy:index>`. The non-relativistic case is simplest and allows us to check whether the case $n_R=1, n=1$ (single resonance, single channel) reduces to a non-relativistic Breit-Wigner function.[^1] We followed the physics as described by {pdg-review}`Resonances` and {cite}`chungPartialWaveAnalysis1995,petersPartialWaveAnalysis2004,meyerMatrixTutorial2008`.\n",
"This report investigates how to implement non-relativistic $K$-matrix dynamics with {doc}`SymPy <sympy:index>`. The non-relativistic case is simplest and allows us to check whether the case $n_R=1, n=1$ (single resonance, single channel) reduces to a non-relativistic Breit-Wigner function.[^1] We followed the physics as described by {pdg-review}`Resonances` and {cite}`chungPartialWaveAnalysis1995,petersPartialWaveAnalysis2004,meyerMatrixTutorial2008`. For the relativistic version, see {doc}`/report/009`.\n",
"\n",
"[^1]: Of course, there is no need to work with matrices in this $1 \\times 1$ case. To keeps things general, however, we keep using matrices.\n",
"\n",
Expand Down Expand Up @@ -462,7 +462,7 @@
" m0_values = m0_values[1:-1]\n",
"\n",
" def set_default_values():\n",
" sliders.set_ranges({\"i\": (0, n_resonances - 1)})\n",
" sliders.set_ranges({\"i\": (0, n_channels - 1)})\n",
" for R in range(n_resonances):\n",
" # ranges\n",
" sliders.set_ranges({f\"m{R}\": (0, 3, 100)})\n",
Expand All @@ -488,6 +488,9 @@
" sharex=True,\n",
" tight_layout=True,\n",
" )\n",
" fig.canvas.toolbar_visible = False\n",
" fig.canvas.header_visible = False\n",
" fig.canvas.footer_visible = False\n",
" if not title:\n",
" title = (\n",
" fR\"${n_channels} \\times {n_channels}$ $K$-matrix\"\n",
Expand Down Expand Up @@ -527,19 +530,28 @@
"\n",
" # 3D plot\n",
" def plot3(**kwargs):\n",
" imag_real = kwargs.pop(\"imag_real\")\n",
" Z = np_expr(plot_domain_complex, **kwargs)\n",
" Z_imag = cut_off_min(cut_off_max(Z.imag))\n",
" if imag_real == \"imag\":\n",
" Z_values = Z.imag\n",
" ax_title = \"Re $T$\"\n",
" elif imag_real == \"real\":\n",
" Z_values = Z.real\n",
" ax_title = \"Im $T$\"\n",
" elif imag_real == \"abs\":\n",
" Z_values = np.abs(Z)\n",
" ax_title = \"$|T|$\"\n",
" else:\n",
" raise NotImplementedError\n",
" Z_values = cut_off_min(cut_off_max(Z_values))\n",
" for ax in axes[1:]:\n",
" ax.clear()\n",
" axes[-1].pcolormesh(X, Y, Z_imag, cmap=cm.coolwarm)\n",
" if kwargs[\"i\"] == 1:\n",
" axes[-1].set_title(\"Im $T$\")\n",
" axes[-1].pcolormesh(X, Y, Z_values, cmap=cm.coolwarm)\n",
" i = kwargs[\"i\"]\n",
" if n_channels == 1:\n",
" axes[-1].set_title(ax_title)\n",
" else:\n",
" axes[-1].set_title(f\"Im $T$, channel {i}\")\n",
" if len(axes) == 3:\n",
" Z_real = cut_off_min(cut_off_max(Z.real))\n",
" axes[-2].pcolormesh(X, Y, Z_real, cmap=cm.coolwarm)\n",
" axes[-2].set_title(\"Re $T$\")\n",
" axes[-1].set_title(f\"{ax_title}, channel {i}\")\n",
" for ax in axes[1:]:\n",
" ax.axhline(0, linewidth=0.5, c=\"black\", linestyle=\"dotted\")\n",
" for R in range(n_resonances):\n",
Expand All @@ -560,6 +572,14 @@
" axes[-1].set_xlabel(\"Re $m$\")\n",
" fig.canvas.draw_idle()\n",
"\n",
" # Create switch for imag/real/abs\n",
" name = \"imag_real\"\n",
" sliders._sliders[name] = ipywidgets.RadioButtons(\n",
" options=[\"imag\", \"real\", \"abs\"],\n",
" description=\"$s$-plane plot\",\n",
" )\n",
" sliders._arg_to_symbol[name] = name\n",
"\n",
" # Create GUI\n",
" sliders_copy = dict(sliders)\n",
" h_boxes = []\n",
Expand All @@ -576,32 +596,31 @@
" remaining_sliders = sorted(\n",
" sliders_copy.values(), key=lambda s: s.description\n",
" )\n",
" if n_channels == 1:\n",
" remaining_sliders.remove(sliders[\"i\"])\n",
" ui = ipywidgets.VBox(h_boxes + remaining_sliders)\n",
" output = ipywidgets.interactive_output(plot3, controls=sliders)\n",
" display(ui, output)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"{{ run_interactive }}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"remove-output",
"hide-input"
]
"tags": []
},
"outputs": [],
"source": [
"plot_k_matrix(n_resonances=3, n_channels=1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"{{ run_interactive }}"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -621,19 +640,11 @@
" display(Image(output_file))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"{{ run_interactive }}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"tags": [
"hide-input",
"remove-output"
]
},
Expand All @@ -642,6 +653,13 @@
"plot_k_matrix(n_resonances=2, n_channels=2)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"{{ run_interactive }}"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading