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

fix: remove default dynamics #180

Merged
merged 10 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@
"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false,
"yaml.schemas": {
"https://raw.githubusercontent.com/ComPWA/expertsystem/master/expertsystem/schemas/yaml/amplitude-model.json": [
"https://raw.githubusercontent.com/ComPWA/expertsystem/0.6.4/src/expertsystem/schemas/yaml/amplitude-model.json": [
"*recipe.y*ml"
],
"https://raw.githubusercontent.com/ComPWA/expertsystem/master/expertsystem/schemas/yaml/particle-list.json": [
"https://raw.githubusercontent.com/ComPWA/expertsystem/0.6.4/src/expertsystem/schemas/yaml/particle-list.json": [
"*particle.y*ml"
]
}
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
# Intersphinx settings
intersphinx_mapping = {
"expertsystem": (
"https://pwa.readthedocs.io/projects/expertsystem/en/0.6.3",
"https://pwa.readthedocs.io/projects/expertsystem/en/0.6.4",
None,
),
"iminuit": ("https://iminuit.readthedocs.io/en/latest", None),
Expand Down
2 changes: 1 addition & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This goes as follows:

3. Install the project in
{ref}`'editable installation' <pwa:develop:Editable installation>` with
{ref}`additional dependencies <pwa:develop:Optional dependencies>` for the
{ref}`additional dependencies <pwa:develop:Additional dependencies>` for the
developer:

```shell
Expand Down
18 changes: 18 additions & 0 deletions docs/usage/1_create_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,24 @@
"list(model.parameters)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that we have to specify the dynamics for the resonances. We choose to use {class}`~expertsystem.amplitude.model.RelativisticBreitWigner` for all resonances:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for name in result.get_intermediate_particles().names:\n",
" model.dynamics.set_breit_wigner(name)\n",
"{name: type(dyn) for name, dyn in model.dynamics.items()}"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
6 changes: 3 additions & 3 deletions docs/usage/3_perform_fit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@
"initial_parameters = {\n",
" \"Phase_J/psi(1S)_to_f(0)(1500)_0+gamma_1;f(0)(1500)_to_pi0_0+pi0_0;\": 0.0,\n",
" \"Width_f(0)(500)\": 0.1,\n",
" \"Mass_f(0)(980)\": 0.9,\n",
" \"Mass_f(0)(1500)\": 1.55,\n",
" \"Mass_f(0)(1710)\": 1.8,\n",
" \"Position_f(0)(980)\": 0.9,\n",
" \"Position_f(0)(1500)\": 1.55,\n",
" \"Position_f(0)(1710)\": 1.8,\n",
" \"Width_f(0)(1710)\": 0.3,\n",
"}"
]
Expand Down
20 changes: 15 additions & 5 deletions examples/intensity-recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ Parameters:
- Name: &par16 Phase_J/psi_to_f0(1500)_0+gamma_-1;f(0)(1500)_to_pi0_0+pi0_0;
Type: Phase
Value: 0.0
- Name: &par17 MesonRadius_J/psi
Value: 1.0
- Name: &par18 MesonRadius_f(0)(980)
Value: 1.0
- Name: &par19 MesonRadius_f(2)(1270)
Value: 1.0
- Name: &par20 MesonRadius_f(0)(1500)
Value: 1.0
- Name: &par21 MesonRadius_f(2)(1950)
Value: 1.0

Intensity:
Class: NormalizedIntensity
Expand Down Expand Up @@ -1165,28 +1175,28 @@ Dynamics:
Type: NonDynamic
FormFactor:
Type: BlattWeisskopf
MesonRadius: 1.0
MesonRadius: *par17

f(0)(980):
Type: RelativisticBreitWigner
FormFactor:
Type: BlattWeisskopf
MesonRadius: 1.0
MesonRadius: *par18

f(2)(1270):
Type: RelativisticBreitWigner
FormFactor:
Type: BlattWeisskopf
MesonRadius: 1.0
MesonRadius: *par19

f(0)(1500):
Type: RelativisticBreitWigner
FormFactor:
Type: BlattWeisskopf
MesonRadius: 1.0
MesonRadius: *par20

f(2)(1950):
Type: RelativisticBreitWigner
FormFactor:
Type: BlattWeisskopf
MesonRadius: 1.0
MesonRadius: *par21
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ setup_requires =
setuptools_scm
install_requires =
amplitf==0.0.1a2
expertsystem==0.6.3
expertsystem==0.6.4
iminuit==1.4.5
numpy==1.18.0
pandas==1.0.5
Expand Down Expand Up @@ -114,7 +114,7 @@ tox =
tox==3.20.1
tools =
jupyterlab==2.2.9
jupyterlab_code_formatter==1.3.6
jupyterlab_code_formatter==1.3.8
labels==20.1.0
dev =
%(doc)s
Expand Down
5 changes: 1 addition & 4 deletions src/tensorwaves/physics/helicity_formalism/amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ def create_dynamics(
"""Create a dynamics function callable."""
if self._dynamics is None:
raise ValueError("Dynamics has not yet been set")

if decaying_state.name not in self._dynamics:
self._dynamics.set_breit_wigner(decaying_state.name)
decay_dynamics = self._dynamics[decaying_state.name]

kwargs = {}
Expand Down Expand Up @@ -615,7 +612,7 @@ def _create_dynamics(
DynamicsProperties(
orbit_angular_momentum=orbit_angular_momentum,
resonance_mass=builder.register_parameter(
f"Mass_{particle.name}",
f"Position_{particle.name}",
particle.mass,
),
resonance_width=builder.register_parameter(
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ def __create_model(formalism: str) -> AmplitudeModel:
allowed_interaction_types=["EM", "strong"],
number_of_threads=1,
)
return es.generate_amplitudes(result)
model = es.generate_amplitudes(result)
for name in result.get_intermediate_particles().names:
model.dynamics.set_breit_wigner(name)
return model
24 changes: 22 additions & 2 deletions tests/recipe/test_amplitude_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ def test_helicity(helicity_model: es.AmplitudeModel):

builder = IntensityBuilder(model.particles, kinematics, phsp_sample)
intensity = builder.create_intensity(model)
assert len(intensity.parameters) == 9
assert set(intensity.parameters) == {
"strength_incoherent",
"Position_J/psi(1S)",
"Width_J/psi(1S)",
redeboer marked this conversation as resolved.
Show resolved Hide resolved
"MesonRadius_J/psi(1S)",
"Magnitude_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;",
"Phase_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;",
"Position_f(0)(980)",
"Width_f(0)(980)",
"MesonRadius_f(0)(980)",
}


def test_canonical(canonical_model: es.AmplitudeModel):
Expand All @@ -43,4 +53,14 @@ def test_canonical(canonical_model: es.AmplitudeModel):
phsp_sample = _generate_phsp(model, NUMBER_OF_PHSP_EVENTS)
builder = IntensityBuilder(particles, kinematics, phsp_sample)
intensity = builder.create_intensity(model)
assert len(intensity.parameters) == 9
assert set(intensity.parameters) == {
"strength_incoherent",
"Position_J/psi(1S)",
"Width_J/psi(1S)",
"MesonRadius_J/psi(1S)",
"Magnitude_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;",
"Phase_J/psi(1S)_to_f(0)(980)_0+gamma_1;f(0)(980)_to_pi0_0+pi0_0;",
"Position_f(0)(980)",
"Width_f(0)(980)",
"MesonRadius_f(0)(980)",
}