Skip to content
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
220 changes: 217 additions & 3 deletions docs/docs/tutorials/diffusion_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"metadata": {},
"source": [
"# Diffusion Model\n",
"We support several standard models of diffusion. Here we show an example of Brownian Translational Diffusion, where the scattering is a Lorentzian with width ($\\Gamma$) given by $\\Gamma = D Q^2$, where $D$ is the diffusion coefficient (in m$^2$/s) and $Q$ is the momentum transfer."
"We support several standard models of diffusion. Here we show examples of Brownian Translational Diffusion, Jump Translational Diffusion and Chudley-Elliott Jump Diffusion. In each model the scattering is a Lorentzian for every $Q$, and the models differ in how the width $\\Gamma(Q)$ depends on $Q$. For Brownian Translational Diffusion, the width is given by $\\Gamma = D Q^2$, where $D$ is the diffusion coefficient (in m$^2$/s) and $Q$ is the momentum transfer."
]
},
{
Expand All @@ -24,10 +24,26 @@
"%matplotlib widget"
]
},
{
"cell_type": "markdown",
"id": "2",
"metadata": {},
"source": [
"## Brownian Translational Diffusion"
]
},
{
"cell_type": "markdown",
"id": "3",
"metadata": {},
"source": [
"### Model for different Q values"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -62,10 +78,18 @@
"plt.title('Brownian Translational Diffusion Model')"
]
},
{
"cell_type": "markdown",
"id": "5",
"metadata": {},
"source": [
"### Width as a function of Q"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -81,6 +105,196 @@
"plt.ylim(0, max(HWHM) * 1.1)\n",
"plt.title('HWHM vs Q for Brownian Translational Diffusion')"
]
},
{
"cell_type": "markdown",
"id": "7",
"metadata": {},
"source": [
"## Jump Translational Diffusion\n",
"In Jump Translational Diffusion, the particle waits for a relaxation time $t$ between jumps. At low $Q$ the width follows the Brownian result, $\\Gamma \\approx \\hbar D Q^2$, but at high $Q$ it levels off:\n",
"\n",
"$$\\Gamma(Q) = \\frac{\\hbar D Q^2}{1 + D t Q^2},$$\n",
"\n",
"where $D$ is the diffusion coefficient (in m$^2$/s) and $t$ is the relaxation time (in ps)."
]
},
{
"cell_type": "markdown",
"id": "8",
"metadata": {},
"source": [
"### Model for different Q values"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"# Create Jump Translational Diffusion model\n",
"# and plot the model for different Q values.\n",
"# Q is in Angstrom^-1 and energy in meV.\n",
"\n",
"Q = np.linspace(0.5, 2, 7)\n",
"energy = np.linspace(-2, 2, 501)\n",
"scale = 1.0\n",
"diffusion_coefficient = 2.4e-9 # m^2/s\n",
"relaxation_time = 1.0 # ps\n",
"\n",
"jump_diffusion_model = edyn.JumpTranslationalDiffusion(\n",
" display_name='JumpDiffusionModel',\n",
" scale=scale,\n",
" diffusion_coefficient=diffusion_coefficient,\n",
" relaxation_time=relaxation_time,\n",
" Q=Q,\n",
")\n",
"\n",
"component_collections = jump_diffusion_model.get_component_collections()\n",
"\n",
"cmap = plt.cm.jet\n",
"nQ = len(component_collections)\n",
"plt.figure()\n",
"for Q_index in range(len(component_collections)):\n",
" color = cmap(Q_index / (nQ - 1))\n",
" y = component_collections[Q_index].evaluate(energy)\n",
" plt.plot(energy, y, label=f'Q={Q[Q_index]} Å^-1', color=color)\n",
"\n",
"plt.legend()\n",
"plt.xlabel('Energy (meV)')\n",
"plt.ylabel('Intensity (arb. units)')\n",
"plt.title('Jump Translational Diffusion Model')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "10",
"metadata": {},
"source": [
"### Width as a function of Q"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"metadata": {},
"outputs": [],
"source": [
"# Calculate and plot the half width at half maximum (HWHM) as function\n",
"# of Q\n",
"Q = np.linspace(0.1, 2, 101)\n",
"HWHM = jump_diffusion_model.calculate_width(Q)\n",
"plt.figure()\n",
"plt.plot(Q, HWHM)\n",
"plt.xlabel('Q (Å$^{-1}$)')\n",
"plt.ylabel('HWHM (meV)')\n",
"plt.xlim(0, 2.5)\n",
"plt.ylim(0, max(HWHM) * 1.1)\n",
"plt.title('HWHM vs Q for Jump Translational Diffusion')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "12",
"metadata": {},
"source": [
"## Chudley-Elliott Jump Diffusion\n",
"The Chudley-Elliott model of\n",
"\n",
"> C. T. Chudley and R. J. Elliott, *Neutron Scattering from a Liquid on a Jump Diffusion Model*,\n",
"> Proc. Phys. Soc. **77**, 353 (1961),\n",
"> [doi:10.1088/0370-1328/77/2/319](https://doi.org/10.1088/0370-1328/77/2/319).\n",
"\n",
"describes a particle that sits on a site for a residence time $\\tau$ and then jumps a fixed distance $l$. The width is\n",
"\n",
"$$\\Gamma(Q) = \\frac{\\hbar}{\\tau}\\left(1 - \\frac{\\sin(Ql)}{Ql}\\right),$$\n",
"\n",
"where $\\tau$ is the residence time (in ps) and $l$ is the jump length (in Å). The width oscillates with $Q$ and approaches $\\hbar/\\tau$ at high $Q$."
]
},
{
"cell_type": "markdown",
"id": "13",
"metadata": {},
"source": [
"### Model for different Q values"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"metadata": {},
"outputs": [],
"source": [
"# Create Chudley-Elliott Jump Diffusion model\n",
"# and plot the model for different Q values.\n",
"# Q is in Angstrom^-1 and energy in meV.\n",
"\n",
"Q = np.linspace(0.5, 2, 7)\n",
"energy = np.linspace(-2, 2, 501)\n",
"scale = 1.0\n",
"residence_time = 1.0 # ps\n",
"jump_length = 1.5 # Å\n",
"\n",
"chudley_elliott_model = edyn.ChudleyElliottJumpDiffusion(\n",
" display_name='ChudleyElliottModel',\n",
" scale=scale,\n",
" residence_time=residence_time,\n",
" jump_length=jump_length,\n",
" Q=Q,\n",
")\n",
"\n",
"component_collections = chudley_elliott_model.get_component_collections()\n",
"\n",
"cmap = plt.cm.jet\n",
"nQ = len(component_collections)\n",
"plt.figure()\n",
"for Q_index in range(len(component_collections)):\n",
" color = cmap(Q_index / (nQ - 1))\n",
" y = component_collections[Q_index].evaluate(energy)\n",
" plt.plot(energy, y, label=f'Q={Q[Q_index]} Å^-1', color=color)\n",
"\n",
"plt.legend()\n",
"plt.xlabel('Energy (meV)')\n",
"plt.ylabel('Intensity (arb. units)')\n",
"plt.title('Chudley-Elliott Jump Diffusion Model')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "15",
"metadata": {},
"source": [
"### Width as a function of Q"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16",
"metadata": {},
"outputs": [],
"source": [
"# Calculate and plot the half width at half maximum (HWHM) as function\n",
"# of Q\n",
"Q = np.linspace(0.1, 4, 201)\n",
"HWHM = chudley_elliott_model.calculate_width(Q)\n",
"plt.figure()\n",
"plt.plot(Q, HWHM)\n",
"plt.xlabel('Q (Å$^{-1}$)')\n",
"plt.ylabel('HWHM (meV)')\n",
"plt.xlim(0, 4.2)\n",
"plt.ylim(0, max(HWHM) * 1.1)\n",
"plt.title('HWHM vs Q for Chudley-Elliott Jump Diffusion')\n",
"plt.show()"
]
}
],
"metadata": {
Expand Down
3 changes: 2 additions & 1 deletion docs/docs/tutorials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ tutorials.
- [Detailed balance](detailed_balance.ipynb) – Learn about detailed
balancing.
- [Diffusion model](diffusion_model.ipynb) – Learn how to create and use
a model of diffusion.
models of diffusion: Brownian translational, jump translational and
Chudley-Elliott jump diffusion.
- [DeltaLorentz](delta_lorentz.ipynb) – Learn how to create and use a
model with a Delta function and a Lorentzian that have a shared
Debye-Waller-like Q-dependence.
Expand Down
Loading
Loading