{ "cells": [ { "cell_type": "markdown", "id": "80bc7461-98bf-4a6a-a951-2c1666d43e7b", "metadata": {}, "source": [ "# Elastic scattering with `LocalOpticalPotential`\n", "\n", "`LocalOpticalPotential` provides a useful interface for defining optical potentials. " ] }, { "cell_type": "code", "execution_count": 1, "id": "709f54ea-cd6d-4a2a-9733-65f983b9562d", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from matplotlib import pyplot as plt\n", "from pandas import DataFrame\n", "from tqdm import tqdm" ] }, { "cell_type": "code", "execution_count": 2, "id": "742d1f28-6eb3-4225-ba5d-8cc8b344287e", "metadata": {}, "outputs": [], "source": [ "from jitr.optical_potentials import LocalOpticalPotential\n", "from jitr.reactions.reaction import Reaction\n", "from jitr.rmatrix import Solver as SolverKernel\n", "from jitr.utils import utils\n", "from jitr.xs import elastic" ] }, { "cell_type": "code", "execution_count": 3, "id": "0bdc7e4a-c473-414b-92ea-a8e26683550a", "metadata": {}, "outputs": [], "source": [ "neutron = (1, 0)\n", "proton = (1, 1)" ] }, { "cell_type": "code", "execution_count": 4, "id": "0d708966-dbed-4ca3-a2e3-673aac93d2d8", "metadata": {}, "outputs": [], "source": [ "target = (208, 82)\n", "projectile = proton\n", "energy_lab = 24\n", "reaction = Reaction(target=target, projectile=projectile, process=\"El\")\n", "kinematics = reaction.kinematics(energy_lab)" ] }, { "cell_type": "code", "execution_count": 5, "id": "ff28c9ba-c458-45b7-9318-b807c3768f71", "metadata": {}, "outputs": [], "source": [ "# set the channel radius, number of nodes, and number of partial waves\n", "interaction_range_fm = 1.2 * (208 ** (1 / 3)) + 1\n", "channel_radius_dimensionless = utils.suggested_dimensionless_channel_radius(\n", " interaction_range_fm, kinematics.k\n", ")\n", "channel_radius = channel_radius_dimensionless / kinematics.k\n", "N = utils.suggested_basis_size(channel_radius_dimensionless)\n", "lmax = 50" ] }, { "cell_type": "code", "execution_count": 6, "id": "dd405939-51a3-4768-b5c2-7da5f4d57f52", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Compiling solver for 208-Pb(p,el) at 24 MeV\n", " - channel radius 13.94 fm\n", " - 25 nodes\n", " - 50 partial waves\n", "Done!\n" ] } ], "source": [ "# build a solver for the system and reaction of interest\n", "print(f\"Compiling solver for {reaction} at {energy_lab} MeV\")\n", "print(f\" - channel radius {channel_radius:1.2f} fm\")\n", "print(f\" - {N} nodes\")\n", "print(f\" - {lmax} partial waves\")\n", "\n", "solver = elastic.DifferentialWorkspace.build_from_system(\n", " reaction=reaction,\n", " kinematics=kinematics,\n", " channel_radius_fm=channel_radius,\n", " solver=SolverKernel(N),\n", " lmax=lmax,\n", " angles=np.linspace(0.1, np.pi, 180),\n", ")\n", "rgrid = solver.radial_grid()\n", "print(\"Done!\")" ] }, { "cell_type": "markdown", "id": "ee4c4c55-7a28-4f86-8683-03226733aced", "metadata": {}, "source": [ "## Use the built-in `LocalOpticalPotential` class\n", "\n", "Although, in general, one can define whatever interaction they want. This is just a handy tool." ] }, { "cell_type": "code", "execution_count": 7, "id": "d7c6b33c-d696-4751-94d9-8eb193006a8c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['Vv',\n", " 'rv',\n", " 'av',\n", " 'Wv',\n", " 'rw',\n", " 'aw',\n", " 'Wd',\n", " 'Vd',\n", " 'rd',\n", " 'ad',\n", " 'Vso',\n", " 'Wso',\n", " 'rso',\n", " 'aso',\n", " 'rC']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "omp = LocalOpticalPotential()\n", "omp.params" ] }, { "cell_type": "markdown", "id": "fbc1744e-1b30-44ab-8eae-c7a9e3ea051a", "metadata": {}, "source": [ "## Randomly generate a bunch of parameters" ] }, { "cell_type": "code", "execution_count": 8, "id": "721bd33e-c8c0-485d-8a2f-19e80a48b217", "metadata": {}, "outputs": [], "source": [ "means = np.array([56, 1.2, 0.7, 5, 1.2, 0.7, 13, 6, 1.3, 0.9, 8, 4, 1.1, 0.7, 1.2])\n", "std_devs = np.array(\n", " [3, 0.05, 0.03, 0.1, 0.05, 0.05, 1, 0.1, 0.1, 0.1, 0.2, 1, 0.1, 0.05, 0.1]\n", ")\n", "samples = np.random.multivariate_normal(means, np.diag(std_devs) ** 2, 1000)" ] }, { "cell_type": "code", "execution_count": 9, "id": "01571595-10ac-4d1d-8fdf-9b0967e60f3f", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Vv | \n", "rv | \n", "av | \n", "Wv | \n", "rw | \n", "aw | \n", "Wd | \n", "Vd | \n", "rd | \n", "ad | \n", "Vso | \n", "Wso | \n", "rso | \n", "aso | \n", "rC | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "51.100403 | \n", "1.193229 | \n", "0.694053 | \n", "5.001168 | \n", "1.204845 | \n", "0.698625 | \n", "11.593592 | \n", "6.002358 | \n", "1.180502 | \n", "0.987147 | \n", "8.170491 | \n", "3.076880 | \n", "1.085694 | \n", "0.734179 | \n", "1.339886 | \n", "
| 1 | \n", "52.833976 | \n", "1.219670 | \n", "0.686945 | \n", "4.859437 | \n", "1.260052 | \n", "0.711278 | \n", "11.806969 | \n", "5.940825 | \n", "1.241372 | \n", "0.904550 | \n", "8.085328 | \n", "4.380284 | \n", "1.151938 | \n", "0.721191 | \n", "1.342671 | \n", "
| 2 | \n", "60.490654 | \n", "1.111695 | \n", "0.690334 | \n", "5.017723 | \n", "1.266576 | \n", "0.709783 | \n", "11.567632 | \n", "6.207810 | \n", "1.380022 | \n", "0.802054 | \n", "8.088928 | \n", "3.947422 | \n", "1.042329 | \n", "0.771521 | \n", "1.315199 | \n", "
| 3 | \n", "55.871365 | \n", "1.194629 | \n", "0.746419 | \n", "5.118907 | \n", "1.167164 | \n", "0.682690 | \n", "13.338335 | \n", "6.052000 | \n", "1.309950 | \n", "0.599037 | \n", "7.906294 | \n", "4.470666 | \n", "1.194999 | \n", "0.675212 | \n", "1.157940 | \n", "
| 4 | \n", "55.460503 | \n", "1.117543 | \n", "0.733219 | \n", "4.896455 | \n", "1.210000 | \n", "0.658962 | \n", "14.617597 | \n", "6.307500 | \n", "1.341588 | \n", "0.890594 | \n", "8.172465 | \n", "4.120561 | \n", "1.102040 | \n", "0.620034 | \n", "1.185585 | \n", "