|
50 | 50 | "```"
|
51 | 51 | ]
|
52 | 52 | },
|
| 53 | + { |
| 54 | + "cell_type": "markdown", |
| 55 | + "metadata": {}, |
| 56 | + "source": [ |
| 57 | + ":::{warning}\n", |
| 58 | + "Currently the main user-interface is the ```StateTransitionManager```. There is work in progress to remove it and split its functionality into several functions/classes to separate concerns\n", |
| 59 | + "and to facilitate the modification of intermediate results like the filtering of ```QNProblemSet```s, setting allowed interaction types, etc. (see below)\n", |
| 60 | + ":::" |
| 61 | + ] |
| 62 | + }, |
53 | 63 | {
|
54 | 64 | "cell_type": "markdown",
|
55 | 65 | "metadata": {},
|
|
103 | 113 | "from IPython.display import display\n",
|
104 | 114 | "\n",
|
105 | 115 | "import qrules\n",
|
| 116 | + "from qrules.conservation_rules import (\n", |
| 117 | + " parity_conservation,\n", |
| 118 | + " spin_magnitude_conservation,\n", |
| 119 | + " spin_validity,\n", |
| 120 | + ")\n", |
106 | 121 | "from qrules.particle import Spin\n",
|
| 122 | + "from qrules.quantum_numbers import EdgeQuantumNumbers, NodeQuantumNumbers\n", |
| 123 | + "from qrules.solving import (\n", |
| 124 | + " CSPSolver,\n", |
| 125 | + " dict_set_intersection,\n", |
| 126 | + " filter_quantum_number_problem_set,\n", |
| 127 | + ")\n", |
107 | 128 | "from qrules.topology import create_isobar_topologies, create_n_body_topology\n",
|
108 | 129 | "from qrules.transition import State"
|
109 | 130 | ]
|
|
315 | 336 | "graphviz.Source(dot)"
|
316 | 337 | ]
|
317 | 338 | },
|
| 339 | + { |
| 340 | + "cell_type": "markdown", |
| 341 | + "metadata": {}, |
| 342 | + "source": [ |
| 343 | + "### Filtering quantum number problem sets" |
| 344 | + ] |
| 345 | + }, |
| 346 | + { |
| 347 | + "cell_type": "markdown", |
| 348 | + "metadata": {}, |
| 349 | + "source": [ |
| 350 | + "Sometimes, only a certain subset of quantum numbers and conservation rules are relevant, or the number of solutions the {class}`.StateTransitionManager` gives by default is too large for the follow-up analysis.\n", |
| 351 | + "The {func}`.filter_quantum_number_problem_set` function can be used to produce a {class}`.QNProblemSet` where only the desired quantum numbers and conservation rules are considered when fed back to the solver." |
| 352 | + ] |
| 353 | + }, |
| 354 | + { |
| 355 | + "cell_type": "code", |
| 356 | + "execution_count": null, |
| 357 | + "metadata": {}, |
| 358 | + "outputs": [], |
| 359 | + "source": [ |
| 360 | + "desired_edge_properties = {EdgeQuantumNumbers.spin_magnitude, EdgeQuantumNumbers.parity}\n", |
| 361 | + "desired_node_properties = {\n", |
| 362 | + " NodeQuantumNumbers.l_magnitude,\n", |
| 363 | + " NodeQuantumNumbers.s_magnitude,\n", |
| 364 | + "} # has to be reused in the CSPSolver-constructor\n", |
| 365 | + "filtered_qn_problem_set = filter_quantum_number_problem_set(\n", |
| 366 | + " qn_problem_set,\n", |
| 367 | + " edge_rules={spin_validity},\n", |
| 368 | + " node_rules={spin_magnitude_conservation, parity_conservation},\n", |
| 369 | + " edge_properties=desired_edge_properties,\n", |
| 370 | + " node_properties=desired_node_properties,\n", |
| 371 | + ")" |
| 372 | + ] |
| 373 | + }, |
| 374 | + { |
| 375 | + "cell_type": "code", |
| 376 | + "execution_count": null, |
| 377 | + "metadata": { |
| 378 | + "jupyter": { |
| 379 | + "source_hidden": true |
| 380 | + }, |
| 381 | + "tags": [ |
| 382 | + "hide-output" |
| 383 | + ] |
| 384 | + }, |
| 385 | + "outputs": [], |
| 386 | + "source": [ |
| 387 | + "dot = qrules.io.asdot(filtered_qn_problem_set, render_node=True)\n", |
| 388 | + "graphviz.Source(dot)" |
| 389 | + ] |
| 390 | + }, |
| 391 | + { |
| 392 | + "cell_type": "markdown", |
| 393 | + "metadata": {}, |
| 394 | + "source": [ |
| 395 | + ":::{warning}\n", |
| 396 | + "The next cell will use some (currently) internal functionality. As statet at the top, a workflow similar to this will be used in future versions of ```qrules```. Manual setup of the {obj}`.CSPSolver` like in here will then also not be necessary.\n", |
| 397 | + ":::" |
| 398 | + ] |
| 399 | + }, |
| 400 | + { |
| 401 | + "cell_type": "code", |
| 402 | + "execution_count": null, |
| 403 | + "metadata": {}, |
| 404 | + "outputs": [], |
| 405 | + "source": [ |
| 406 | + "solver = CSPSolver([\n", |
| 407 | + " dict_set_intersection(\n", |
| 408 | + " qrules.system_control.create_edge_properties(part),\n", |
| 409 | + " desired_edge_properties,\n", |
| 410 | + " )\n", |
| 411 | + " for part in qrules.particle.load_pdg()\n", |
| 412 | + "])\n", |
| 413 | + "\n", |
| 414 | + "filtered_qn_solutions = solver.find_solutions(filtered_qn_problem_set)\n", |
| 415 | + "filtered_qn_result = filtered_qn_solutions.solutions[6]" |
| 416 | + ] |
| 417 | + }, |
| 418 | + { |
| 419 | + "cell_type": "code", |
| 420 | + "execution_count": null, |
| 421 | + "metadata": { |
| 422 | + "jupyter": { |
| 423 | + "source_hidden": true |
| 424 | + }, |
| 425 | + "tags": [ |
| 426 | + "hide-input" |
| 427 | + ] |
| 428 | + }, |
| 429 | + "outputs": [], |
| 430 | + "source": [ |
| 431 | + "dot = qrules.io.asdot(filtered_qn_result, render_node=True)\n", |
| 432 | + "graphviz.Source(dot)" |
| 433 | + ] |
| 434 | + }, |
318 | 435 | {
|
319 | 436 | "cell_type": "markdown",
|
320 | 437 | "metadata": {},
|
|
672 | 789 | "name": "python",
|
673 | 790 | "nbconvert_exporter": "python",
|
674 | 791 | "pygments_lexer": "ipython3",
|
675 |
| - "version": "3.11.7" |
| 792 | + "version": "3.9.20" |
676 | 793 | }
|
677 | 794 | },
|
678 | 795 | "nbformat": 4,
|
|
0 commit comments