{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reaction Diffusion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we consider a model where calcium ions interact with a buffer. We also add calcium extrusion." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import sinaps as sn" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Initialization" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Creating a sample neuron:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn = sn.Neuron([(0,1),(1,2),(1,3),(3,4)])\n", "nrn.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Settings channels: note that the `Hodgkin_Huxley_Ca` channel needs to be added to account for calcium entry through voltage-gated calcium channels. The `Hodgkin_Huxley` channels only contains sodium, potassium and leak channels." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn[0].clear_channels()#Reset all channels, useful if you re-run this cell (does nothing the first time)\n", "nrn[0].add_channel(sn.channels.PulseCurrent(500,2,3),0)\n", "nrn[0].add_channel(sn.channels.Hodgkin_Huxley())\n", "nrn[0].add_channel(sn.channels.Hodgkin_Huxley_Ca(gCa=14.5,V_Ca=115)) " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim = sn.Simulation(nrn,dx=10)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.run((0,100))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Chemical reactions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ion species can be added to the model via the function `add_species`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "nrn.add_species(sn.Species.Ca)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Chemical reactions are defined with the reaction equation and the reaction\n", "rates:\n", "$$ Ca + Bf \\rightleftharpoons_{k_2}^{k_1} BfCa $$\n", "\n", "\n", "Reactions are simulated during the electrodiffusion simulation.\n", "\n", "Note that Species are automatically added to the neuron if they are not already\n", "present." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Reset reaction / not useful the first time\n", "nrn.reactions=[]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#shortcuts\n", "Ca=sn.Species.Ca\n", "BF=sn.Species.Buffer\n", "BFB=sn.Species.Buffer_Ca" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "nrn.add_reaction(\n", " {Ca:1,\n", " BF:1},\n", " {BFB:1},\n", " k1=0.2,\n", " k2=0.1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The calcium extrusion is modeled using the equation:\n", "$$ Ca \\rightleftharpoons^{k_1} \\emptyset $$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Calcium extrusion\n", "nrn.add_reaction(\n", " {Ca:1},\n", " {},\n", " k1=0.05,k2=0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Initial concentrations can be set:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Calcium initial concentration\n", "for s in nrn.sections:\n", " s.C0[Ca]=10**(-4)\n", " s.C0[BF]=2*10**(-3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running electro diffusion simulatiom" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.run_diff(max_step=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plotting results" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.C(Ca)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.C(BFB)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "(sim.plot.V().opts(width=900,height=200) \n", " + sim.plot.C(Ca) .opts(width=900,height=200) \n", " + sim.plot.C(BFB).opts(width=900,height=200) \n", ").cols(1).opts(plot={'shared_axes':False})" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "sim.plot.C_field(Ca)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 2 }