## Figures

## Abstract

Many pathological conditions, such as seizures, stroke, and spreading depression, are associated with substantial changes in ion concentrations in the extracellular space (ECS) of the brain. An understanding of the mechanisms that govern ECS concentration dynamics may be a prerequisite for understanding such pathologies. To estimate the transport of ions due to electrodiffusive effects, one must keep track of both the ion concentrations and the electric potential simultaneously in the relevant regions of the brain. Although this is currently unfeasible experimentally, it is in principle achievable with computational models based on biophysical principles and constraints. Previous computational models of extracellular ion-concentration dynamics have required extensive computing power, and therefore have been limited to either phenomena on very small spatiotemporal scales (micrometers and milliseconds), or simplified and idealized 1-dimensional (1-D) transport processes on a larger scale. Here, we present the 3-D Kirchhoff-Nernst-Planck (KNP) framework, tailored to explore electrodiffusive effects on large spatiotemporal scales. By assuming electroneutrality, the KNP-framework circumvents charge-relaxation processes on the spatiotemporal scales of nanometers and nanoseconds, and makes it feasible to run simulations on the spatiotemporal scales of millimeters and seconds on a standard desktop computer. In the present work, we use the 3-D KNP framework to simulate the dynamics of ion concentrations and the electrical potential surrounding a morphologically detailed pyramidal cell. In addition to elucidating the single neuron contribution to electrodiffusive effects in the ECS, the simulation demonstrates the efficiency of the 3-D KNP framework. We envision that future applications of the framework to more complex and biologically realistic systems will be useful in exploring pathological conditions associated with large concentration variations in the ECS.

## Author summary

Many pathological conditions, such as epilepsy and cortical spreading depression, are linked to abnormal extracellular ion concentrations in the brain. Understanding the underlying principles of such conditions may prove important in developing treatments for these illnesses, which incur societal costs of tens of billions annually. In order to investigate the role of ion-concentration dynamics in the pathological conditions, one must measure the spatial distribution of all ion concentrations over time. This remains challenging experimentally, which makes computational modeling an attractive tool. We have previously introduced the Kirchhoff-Nernst-Planck framework, an efficient framework for modeling electrodiffusion. In this study, we introduce a 3-dimensional version of this framework and use it to model the electrodiffusion of ions surrounding a morphologically detailed neuron. The simulation covered a 1 mm^{3} cylinder of tissue for over a minute and was performed in less than a day on a standard desktop computer, demonstrating the framework’s efficiency. We believe this to be an important step on the way to understanding phenomena involving ion concentration shifts at the tissue level.

**Citation: **Solbrå A, Bergersen AW, van den Brink J, Malthe-Sørenssen A, Einevoll GT, Halnes G (2018) A Kirchhoff-Nernst-Planck framework for modeling large scale extracellular electrodiffusion surrounding morphologically detailed neurons. PLoS Comput Biol 14(10):
e1006510.
https://doi.org/10.1371/journal.pcbi.1006510

**Editor: **Ernest Barreto,
George Mason University, UNITED STATES

**Received: **February 6, 2018; **Accepted: **September 12, 2018; **Published: ** October 4, 2018

**Copyright: ** © 2018 Solbrå et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.

**Data Availability: **All model code will be available at https://github.com/CINPLA/KNPsim.

**Funding: **This work was funded by the Research Council of Norway (BIOTEK2021 Digital Life project ‘DigiBrain’, project 248828). The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

The brain mainly consists of a dense packing of neurons and neuroglia, submerged in the cerebrospinal fluid which fills the *extracellular space* (ECS). Neurons generate their electrical signals by exchanging ions with the ECS through ion-selective channels in their plasma membranes. During normal signaling, this does not lead to significant changes in local ion concentrations, as neuronal and glial transport mechanisms work towards maintaining ion concentrations close to baseline levels. However, endured periods of enhanced neuronal activity or aberrant ion transport may lead to changes in ECS ion concentrations. Local concentration changes often coincide with slow shifts in the ECS potential [1–3], which may be partly evoked by diffusive electrical currents, i.e., currents carried by charged ions moving along ECS concentration gradients [2, 4]. While concentration gradients can influence electrical fields, the reverse is also true, since ions move not only by diffusion but also by electric drift. A better understanding of the electrodiffusive interplay between ECS ion dynamics and ECS potentials may be a prerequisite for understanding the mechanisms behind many pathological conditions linked to substantial concentration shifts in the ECS, such as epilepsy and spreading depression [3, 5–7].

A simultaneous and accurate knowledge of the concentration of all ion species is needed to make reliable estimates of electrodiffusive effects in the ECS. Although this is currently unfeasible experimentally, it is in principle achievable with computational models based on biophysical principles and constraints. However, in most computational models in neuroscience ion-concentration dynamics are only partially modeled, or are ignored altogether. One reason for this is the challenge involved in keeping track of all ion concentrations and their spatiotemporal dynamics. Another reason may be the strong focus within the community on modeling the neuronal membrane dynamics at short timescales, during which both intra- and extracellular concentration changes are relatively small and putatively negligible. Although there exist models that account for ion concentration shifts and their effects on neuronal and glial reversal potentials [8–11], the most common computational models for excitable cells, the multi-compartmental models and the cable equation, are based on the assumptions that (i) the ECS potential is constant (ground), and (ii) the ion concentrations are constant [12, 13]. The NEURON simulator [14, 15] is based on these assumptions, and although they are physically incorrect, they still allow for efficient and fairly accurate predictions of the membrane-potential dynamics.

Because of assumption (i), multi-compartmental models are unsuited for modeling ECS dynamics, and several approaches have been taken to construct models which include ECS effects. A majority of computational studies of ECS potentials are based on *volume conductor* (VC) theory [16–21]. VC-schemes link neuronal membrane dynamics to its signatures in the ECS potential. In contrast to the multi-compartmental models, VC-schemes are derived by allowing the ECS potential to vary, but still assuming that the ion concentrations are constant. VC-schemes are attractive, because they offer closed-form solutions, and allow the calculation of the electric field for arbitrarily large systems. Although it may be reasonable to neglect variations in ECS ion concentrations on short timescales, the accumulative effects of endured neuronal activity may lead to significant concentration changes in the ECS, which are related to the aforementioned pathological conditions. Naturally, models that do not include ion-concentration dynamics are not applicable for exploring such pathologies. Furthermore, VC-schemes neglect the effects from diffusive currents on the ECS potentials [4, 22, 23], and in previous computational studies we have found the low-frequency components of the ECS potential to be dominated by diffusion effects [4, 24].

A simplified approach to modeling concentration dynamics in brain tissue, is to use reaction-diffusion schemes (see e.g., [25–27]). In these schemes, concentration dynamics are simulated under the simplifying assumption that ions move due to diffusion only. This approach has been used for many specific applications, giving results in close agreement with experimental data [26]. However, the net transport of abundant charge carriers such as Na^{+}, K^{+}, Ca^{2+}, and Cl^{−}, is also influenced by electric forces, which is not incorporated in diffusion only (DO)-schemes. Furthermore, DO-schemes do not include the influence that diffusing ions can have on the electrical potential.

To account for the electric interactions between the different ion species, as well as the effect of such electric forces on the ECS potential, an electrodiffusive modeling framework is needed. The most detailed modeling scheme for electrodiffusion is the Poisson-Nernst-Planck (PNP) scheme [28–34]. The PNP-scheme explicitly models charge-relaxation processes, that is, tiny deviations from electroneutrality involving only about 10^{—9} of the total ionic concentration [35]. This requires a prohibitively high spatiotemporal resolution, which makes the PNP-scheme too computationally expensive for modeling the ECS on the tissue scale. Even the state-of-the-art simulations in the literature are on the order of milliseconds on computational domains of micrometers. The PNP-scheme is therefore not suited for simulating processes taking place at the tissue scale [23].

A series of modeling schemes have been developed that circumvent the brief charge-relaxation processes, and solve directly for the ECS potential when the system is in a quasi-steady state [4, 23, 36–42]. Circumventing charge-relaxation allows for simulations on spatiotemporal scales which are larger, compared to what is possible with the PNP-scheme, by several orders of magnitude. The charge-relaxation can be bypassed by replacing Poisson’s equation with the constraint that the bulk solution is electroneutral. These schemes have been shown to deviate from the PNP-scheme very close to the cell membrane (less than 5 Î¼m), but to give a good agreement in the bulk solution [23]. The simplest electroneutral modeling scheme is the *Kirchhoff-Nernst-Planck (KNP)* scheme, previously developed in our group [41, 42]. A similar scheme was developed in parallel in the heart cell community [40].

The KNP-scheme has previously been used to study electrodiffusive phenomena such as spatial K^{+} buffering by astrocytes [41], effects of ECS diffusion on the local field potential [4], and the implication for current-source density analysis [24]. For simplicity, these previous applications were limited to idealized 1-D setups with a relatively coarse spatial resolution. Furthermore, a comparison between the KNP framework and other simulation frameworks was not included in previous studies.

In the present study, we introduce a 3-D version of the KNP framework which can be used to simulate the electrodiffusive dynamics of ion-concentrations and the electrical potential in the ECS on large spatiotemporal scales. We establish in which situations the assumptions used in the KNP scheme are warranted by comparing it to the more physically detailed PNP scheme. Furthermore, we identify the conditions under which an electrodiffusive formalism is needed by comparing the KNP scheme to the VC and DO schemes. The simplified schemes can be derived from the KNP scheme by assuming, respectively, that (for VC) diffusive effects on the membrane potential and (for DO) migratory effects on the concentration dynamics are negligible. Accordingly, the accuracy of the simplifying assumptions can be assessed by comparing how close their predictions come to the KNP scheme.

We present the results of three distinct simulation setups, which we will refer to as Application 1, Application 2, and Application 3 for the remainder of this study:

In Application 1, we consider an idealized 1-D domain filled with a salt solution, starting with a nonzero ion concentration gradient. We solve the system using the PNP-scheme, the KNP-scheme, and a DO-scheme. We compare results on short and long timescales (nanoseconds and seconds), to highlight the similarities and differences between the schemes.

In Application 2, we consider a 3-D domain with an ion concentration point source and a point sink, of equal magnitude, embedded in a standard ECS ion solution. We compare results obtained with the VC- and KNP-schemes to highlight their similarities and differences.

In Application 3, we consider a morphologically realistic pyramidal neuron model [43]) embedded in a 3-D ECS solution. The neuronal morphology is inserted as a 1-D branching tree, which means that it does not occupy any volume, but gives rise to a morphologically realistic spatial distribution of neuronal membrane current sources or sinks. The ECS dynamics is computed using the KNP-scheme, and show how concentration gradients gradually build up in the ECS due to the neural activity, and how this influences the local potential in the ECS. We compare results obtained with the VC-, DO-, and KNP-schemes to highlight their similarities and differences.

The first two applications are simplified simulation setups, used to better understand the differences between the schemes introduced above, while the third application is the main result of this study, as it illustrates the scales at which the KNP-scheme can be used.

To our knowledge, the KNP-scheme is the first simulation framework which can handle 3-D electrodiffusion in neuronal tissue at relatively large spatiotemporal scales without demanding an insurmountable amount of computer power. For Application 3, the long-term ECS ion-concentration dynamics (about 100 s) in a spatial region of about 1 mm^{3} was run on a standard desktop computer within a day. We expect that the presented simulation framework will be of great use for future studies, especially for modeling tissue dynamics in the context of exploring pathological conditions associated with large shifts in ECS ion concentrations [3, 5–7].

## Materials and methods

This section is thematically split into three parts. We begin by explaining the necessary physical theory, stating and deriving the equations which we implemented. Then, we explain in more detail how the models were implemented, including details such as numerical schemes and boundary conditions. Finally, we give the specific details on each of the three applications used in the study. The source code can be found online, at https://github.com/CINPLA/KNPsim, and the results in this study can be reproduced by checking out the tag PLoS.

### Theory

#### The Nernst-Planck equation for electrodiffusion.

The ion concentration dynamics of an ion species in a solution is described by the continuity equation:
(1)
where *c*_{k} is the concentration of ion species *k*, *f*_{k} represent any source terms in the system, *Ω* is the domain for which the concentrations are defined, and *J*_{k} is the concentration flux of ion species *k*. In the applications in this study, *f*_{k} is implemented as a set of point sources at specified coordinates in the ECS. In the Nernst-Planck equation, *J*_{k} consists of a diffusive and an electric component:
(2)
The diffusive component is given by Fick’s first law,
(3)
where *D*_{k} is the diffusion coefficient of ion species *k*. The electric component is
(4)
where *ϕ* is the electric potential, *z*_{k} is the valency of ion species *k*, and *ψ* = *RT*/*F* is defined by the gas constant (*R*), Faraday’s constant (*F*) and the temperature (*T*) which we assume to be constant (cf. Table 1). Inserting Eqs 2–4 into Eq 1, yields the time evolution of the concentration of ion species *k*:
(5)

We model the ECS as a continuous medium, while in reality, the ECS only takes up roughly 20% of the tissue volume [44] in the brain. To compensate for this, we use the porous medium approximation [45]. This involves two changes to the model. The diffusion constants of the ion species are modified as
(6)
where λ is the tortuosity, which accounts for various hindrances to free diffusion and electrical migration through the ECS. We used the value λ = 1.6 [46]. We denote the fraction of tissue volume belonging to the ECS by *α*, and set the value *α* = 0.2. The sources in the system are modified as
(7) and are the values used in the simulations, and we will refer to these in the remainder of this study. In this study, we included four ion species: Ca^{2+}, K^{+}, Na^{+}, and a general anion X^{−} accounting for all negative ions in the system. Their diffusion constants, as well as their steady-state values assumed for the ECS, are shown in Table 2.

All ion constants were modified as , where λ = 1.6 is the tortuosity. The general anion X^{−} was given the properties of Cl^{−}.

#### Poisson-Nernst-Planck (PNP) framework.

In order to solve the Nernst-Planck equation (Eq 1), we need an expression for the electrical potential. One common approach is to assume Poisson’s equation for electrostatics,
(8)
where *ρ* is the charge concentration in the system, and *ϵ* is the permittivity of the system, given by *ϵ* = *ϵ*_{r} *ϵ*_{0}, where *ϵ*_{0} is the vacuum permittivity, and *ϵ*_{r} is the relative permittivity of the extracellular medium (cf. Table 1).

The charge concentration is given by the sum of contributions from the different ion species, (9)

Poisson’s equation (Eq 8) combined with the Nernst-Planck equation (Eq 5) is referred to as the Poisson-Nernst-Planck equations. The PNP-system is defined at all points in space and gives physically correct results in cases where the continuum approximation for the ions is valid. However, there are a few challenges involved in solving the PNP system. Firstly, when neuronal membranes are present in the system, these need to be defined in terms of appropriate boundary conditions. Secondly, the PNP system is numerically very inefficient, because it models charge-relaxation processes which in the tissue solution take place at the spatiotemporal scales of nanometers and nanoseconds [47, 48].

#### Kirchhoff-Nernst-Planck (KNP) framework.

Several frameworks that assume the system to be electroneutral at all interior points have been developed to overcome the limitations of the PNP framework [23, 36–41]. We will here present one of these frameworks, which we have coined the Kirchhoff-Nernst-Planck framework.

In the KNP framework, the electric field (in Eq 1) is required to be such that:
(10)
at all points in the system. In all the applications of this study, the neural output is implemented as a set of point sources which are known from separate simulations performed in the NEURON simulator. Here, is the capacitive component in the source term, which exclusively stems from the capacitive current across a neuronal membrane. The bulk solution is assumed to be electroneutral, so that ∂*ρ*/∂*t* = 0 at points where there are no neuronal source. In other words, the only allowed nonzero charge density in the KNP-system is that building up the membrane potential across a capacitive membrane.

The rationale behind assuming bulk electroneutrality is that (i) charge concentration will only deviate from zero on nanometer scales, and that (ii) charge-relaxation occurs within a few nanoseconds, after which the system will settle at a quasi-steady state where ∂*ρ*/∂*t* ≈ 0. Furthermore, the number of ions that constitute the net charge density at equilibrium is about nine orders of magnitudes smaller than the number of ions present [35]. Hence, if we simulate neuronal processes that take place at the spatiotemporal resolution of, or larger than, micrometers and microseconds, we would expect the bulk solution to appear electroneutral.

Motivated by this, the KNP-scheme bypasses the rapid equilibration process by assuming that the quasi-steady state is reached instantaneously, and derives the value for *ϕ* associated with the equilibrium state. In doing so, the KNP-scheme implicitly neglects the tiny local charge separation associated with charge-relaxation processes in the bulk. We investigate the magnitude of this charge separation in the Results-section.

To turn Eq 10 into an equation which can be solved for *ϕ*, we combine it with Eq 9 to obtain:
(11)
Inserting this into the Nernst-Planck equation (Eq 5) gives us:
(12)
where *σ* is the conductivity of the medium, defined as [49]:
(13)
and
(14) Eq 12 is similar to Poisson’s equation, in that it is an elliptic equation that can be solved for *ϕ*, assuming that *c*_{k} is known.

The potential can be separated into the contribution from diffusive effects, and the contribution from the membrane currents. In order to analyze these components separately, we replace Eq 12 with the following equivalent set of equations: (15) where (16) and (17)

Eq 10 ensures that balance between positive and negative ions entering a volume in extracellular space during a given time step is always so that the net charge accumulation is identical to the change in the (outside) membrane charge, as determined by . However, the capacitive term is not ion-specific, and does not enter as a source term in the Nernst-Planck equation for ion concentration dynamics (Eq 1). This means that the KNP formalism does not specify which ions that actually accumulate at the membrane, but treats all ions entering a volume as part of the extracellular solution. The inaccuracy introduced by this approximation should be small, as the fraction of ions that are membrane bound should be very small at the spatial resolution that we are interested in.

#### Volume Conductor (VC) framework.

Standard VC-schemes include only the effects of the transmembrane currents, and ignore all other ion-concentration dynamics. Using the standard notation from current source density theory, the electric potential is found from
(18)
where *C* is the current source density [24]. This is the potential found in Eq 16, if we set the current source density as
(19)
As the ECS concentrations are not modeled, *σ* is typically defined to be constant in VC-schemes, and current sources are modeled as either point or line sources [50]. This approach gives a closed-form solution for *ϕ*, which means it can be applied to arbitrarily large systems. In this study, when we refer to *ϕ*_{VC}, we mean *ϕ*_{VC} as found in the KNP-scheme (Eq 16). This is essentially the same as in most common VC-implementations, with the exception that *σ* in Eq 16 is found from the ion concentrations.

#### Diffusion Only (DO) framework.

Reaction-diffusion schemes ignore all electric forces in the system. In our implementation, we obtained this by setting *ϕ* = 0 in Eq 5. The resulting equation for the concentration dynamics is:
(20)
This is the equation used when we refer to the DO-scheme in the Results-section.

### Implementation

The solver for the above modeling schemes was implemented utilizing FEniCS, an open-source platform for solving partial differential equations using the finite element method [51]. The reader is referred to [52] for an extensive introduction to the finite element method. The time derivative was approximated using an implicit Euler time-stepping scheme. We chose to use this method as the PNP equations are highly unstable, and the implicit Euler step offers superior stability to other methods [33]. Employing the implicit Euler step makes the PNP-scheme fairly stable, at the cost of numerical efficiency. Piecewise linear Lagrangian elements were used for all unknowns in all simulations [52].

The system was solved monolithically, using Newton’s method to solve for each time step. Due to limitations of FEniCS’ built-in nonlinear solver, we implemented our own Newton solver, which is found in the source code. Details on the FEniCS implementation are found in S1 Appendix.

#### Boundary conditions.

For the first application, we employed a sealed (no-flow) boundary for the ion concentrations,
(21)
where **n** is a unit vector directed out of the domain, and ∂*Ω* is the boundary of the domain.

For the second and third application, we assumed a concentration-clamp boundary condition,
(22)
where *c*_{k,out} was set to typical ECS baseline concentrations, see Table 2. This can be interpreted as our system interacting with a larger reservoir of ions (the rest of the brain).

In order to maintain overall electroneutrality in the system, the KNP-scheme dictates that no net charge can leave the system on the boundary. In the current application, we have applied this criterion locally to each point at the boundary, using the condition: (23)

Note that this requirement is automatically fulfilled when we use the boundary conditions in Eq 21, but must be given as an additional condition when the concentration-clamp boundary is used. Furthermore, as we split the potential into the components *ϕ*_{diff} and *ϕ*_{VC}, we had to apply boundary conditions to each component. We set the boundary conditions as
(24)
(25)

In order to compare the PNP- and KNP-schemes directly, we chose the same boundary condition for the potential in the PNP-scheme.

To make the system fully determined, we set the additional requirement (26)

### Summary of the KNP-scheme

For readability, we include the complete set of equations used in the KNP-scheme. (27) (28) (29) (30) (31) (32) where we use the following definitions (33) (34) (35) Furthermore, and are assumed to be known quantities.

### Application details

In the following, we go through the details of the three applications presented.

#### Application 1: 1-D step concentration.

In the first application, which was implemented using the PNP-, KNP-, and DO-schemes, we used an idealized 1-D mesh with a resolution sufficiently fine for PNP to be stable. Two ion species were included in this setup; Na^{+} and X^{−}. We present two simulations using this setup.

- The first simulation was performed on a mesh on the interval [−0.1 μm, 0.1 μm]. The mesh had uniformly spaced vertices, with Δ
*x*= 0.02 nm. The time step was set to Δ*t*= 0.1 ns. The simulation was stopped at*t*_{end}= 0.1 μs. - The second simulation was performed on a mesh on the interval [−50 μm, 50 μm], with Δ
*x*= 0.01 μm, and Δ*t*= 1.0 ms. The simulation was stopped at*t*_{end}= 10 μs.

For both simulations, the initial concentration of both ion species was set to a step function, as (36)

#### Application 2: Point source/sink simulation.

For the second application, which was implemented using the KNP-scheme, we generated a 3-D box-shaped mesh with opposing corners located at (0 μm, 0 μm, 0 μm) and (400 μm, 400 μm and 40 μm). The mesh consisted of 27000 linear tetrahedral cells. A K^{+} point source and a K^{+} point sink were placed in the system. They were placed with a distance of 160 *μ*m apart, at **x**_{1} = (120 μm, 200 μm, 20 μm) and **x**_{2} = (280 μm, 200 μ, m20 μm). Both were turned on at *t* = 0 and shut off at *t* = 1 s. The point source/sink pair were given opposites fluxes, of magnitude ±*I*(*Fα*)^{−1}, where *F* is Faraday’s constant, *α* is the ECS fraction, and *I* is the input current, set to *I* = 0.1 nA. The simulation was started at *t*_{start} = 0 s, and stopped at *t*_{end} = 2 s, with a time step of Δ*t* = 2 ms. Two measurement points were chosen to create time series of the potential. These were placed at **x**_{left} = (120 μ, m205 μ, m20 μm) and **x**_{right} = (280 μ, m205 μ, m20 μm) (see Results).

#### Application 3: Input from a morphologically detailed neuron.

In the final simulation we modeled the ion sources from a morphologically detailed neuron [43], using the KNP-scheme. The source terms were generated by simulations run on the NEURON simulator. The spatial location and magnitude of ion specific membrane currents were stored, and used as an external input to the KNP simulation in the form of ion sinks and sources distributed in the 3-D ECS mesh (i.e., ions entering or disappearing from the ECS), as illustrated in Fig 1A and 1B. The NEURON simulations were run independently from the KNP simulation, which means that there was no feedback from the ECS dynamics to the neurons. Apart from determining the distribution of point sources/sinks, the neuronal morphology was not explicitly accounted in the KNP simulations. However, the reduced extracellular volume fraction and the membrane-imposed hindrances (tortuosity) to extracellular transports were accounted for as a tissue-average, as reflected in the porous medium approximation (cf. Eqs 6 and 7).

**(A)** The simulated domain is denoted by *Ω*, and the boundary is denoted by ∂*Ω*. Exchange of ions between the neuron and ECS was modeled as a set of point sources (marked by blue dots). Two measurement points were used to create time series in the Results-section. These are shown as the green and purple points. **(B)** Each point source was included as a sink/source of each ion species, as well as a capacitive current.

Assuming a single point source, located at the point **x**_{1} = (*x*_{1}, *y*_{1}, *z*_{1}), with an ion specific current *I*_{k}(*t*), the source term for ion species *k* would be,
(37)
where the 3-D Dirac delta function *δ*^{3}(**x**) is used to make the source local in space. The 3-D neuron in separated into *N*_{C} compartments, with centers at . The source term for ion species *k* is the sum of the current point sources from all these compartments,
(38)
where is the current from compartment *j* specific to ion species *k*, at time *t*. By convention, we define the current to be positive if there is a flow of positive charge out of the cell. In addition to the ionic membrane currents there are also capacitive membrane currents . As capacitive sources are not ion specific, they did not appear as source terms in the Nernst-Planck equation (Eq 5), but gave rise to source terms in the KNP equation for the extracellular field. (cf. Eq 10):
(39)
With these source terms (Eqs 38 and 39), the KNP equation (Eq 12) can be written:
(40)
where *I*^{j} denotes the sum of all ionic and capacitive membrane current at compartment *j*,
(41)

The delta functions were implemented using the PointSource object in FEniCS, which will approximate a Dirac delta function at a given point **x**_{j} by a function using only the closest points in the mesh.

To generate the ion-specific membrane currents, we used a model developed for cortical layer 5 pyramidal cells [43], consisting of 196 sections. All ionic currents, as well as the capacitive current, was recorded for each section. The neuron was driven by Poissonian input trains through 10.000 synapses. The synapses were uniformly distributed over the membrane area, and were tuned to give the model neuron a firing rate of about five action potentials (APs) per second. The NEURON simulation was nearly identical to that used by us previously, and we refer to the original implementation for further details [4]. The only difference is that in the previous paper, the membrane currents were stored in 1-D compartments based on their position in the discretization of the ECS, while in this implementation they were stored as point sources with 3-D coordinates.

The extracellular space was modeled as a 3-D cylinder with a height of roughly 1500 μm and a radius of roughly 500 μm. The mesh was automatically generated using *mshr* [53], yielding a mesh with 53619 linear tetrahedral cells. All ionic concentrations were clamped at the boundary, to their initial background concentrations (cf. Table 2). The time step was Δ*t* = 0.1 s, and the simulation was stopped at *t*_{end} = 80 s. An additional simulation was performed using a smaller time step of Δ*t* = 0.1 ms. Starting with the concentrations found at the end of the 80-second simulation, this secondary simulation was stopped at *t*_{end} = 80.2 s. The NEURON simulations were performed using time steps of 0.025 ms. The neuronal output to the extracellular space during an extracellular time step Δ*t*, was computed by integrating the NEURON simulation outcome over Δ*t*.

Two measurement points were chosen for creating time series of the concentrations. These are referred to as the green and purple measurement points in the Results-section, and are shown in Fig 1A. In the computational mesh, with the soma centered at the origin, the green point was set at **x**_{green} = (20 μm, 20 μm, 20 μm), and the purple point was set near the apical dendrites, at **x**_{purple} = (−100 μm, 1100 μm, 0 μm).

## Results

Below we present the results obtained with the three different applications listed in the introduction and methodology. In the first subsection, we have explored the validity of the KNP framework by comparing it to the PNP framework in a simplified application representing a box filled with a solution containing only two ion species, Na^{+} and X^{−}. We also showed that even for this system, containing no current sources, a DO model gave different results that the other models. In the second subsection, we have highlighted the differences between the KNP- and VC-schemes using an idealized application containing only a single current source and sink, both mediated by K^{+} ions. Finally, in the third subsection, we have used the KNP-scheme to model the ion dynamics and electric potential around a detailed model of a pyramidal neuron. For this final application, we also compared the predictions of the KNP-scheme to those of the simpler DO- and VC-schemes, and analyzed their differences.

### Application 1: Comparison of KNP-, PNP- and DO-schemes for a salt concentration gradient

The differences and similarities between KNP, PNP and DO were illustrated using the simplified 1-D domain representing a box filled with a solution containing two ion species, Na^{+} and X^{−}, with an initial concentration gradient (see Methods).

When we simulated Application 1 using the PNP-scheme, two distinct modes of behavior were revealed. Firstly, an initial charge-relaxation mode occurred. During this mode, the X^{−} concentration spread towards the left side of the box faster than the Na^{+} concentration, since X^{−} had a larger diffusion coefficient than Na^{+}. Due to the charge separation caused by this process, an electrical potential difference rapidly built up in the system (see blue line in Fig 2A). The charge separation process only went on for a few nanoseconds, before the system reached a quasi-steady state. Secondly, a quasi-steady state occurred, in which the potential difference was such that diffusion and electrical drift were in equilibrium, and further charge separation was prevented. The quasi-steady state potential changed on a slow timescale of seconds (Fig 2B). This was the timescale at which the concentration differences in the system evened out.

The system had an initial step concentration of NaX being 140 mM for *x* < 0 and 150 mM for *x* > 0. **(A)** Dynamics of the potential difference between the left and right sides of the system on a short timescale. Δ*ϕ* is defined as Δ*ϕ* = *ϕ*(*x*_{right}) − *ϕ*(*x*_{left}), where *x*_{right} = 0.1 μm and *x*_{left} = −0.1 μm. In PNP simulations, the system spent about 10 ns building up the potential difference across the system. In KNP simulations, the steady-state potential was assumed to occur immediately. After 10 ns, the schemes were virtually indistinguishable. **(B)** Dynamics of the potential between *x*_{right} = 50 μm and *x*_{left} = −50 μm on a long timescale. The PNP- and KNP-schemes gave identical predictions. **(C)** The concentration profiles in the system at *t* = 1.0 s as obtained with KNP, DO and according to the theoretical approximation when NaX develops as a single concentration moving by diffusion with a modified diffusion coefficient.

A comparison between the two lines in Fig 2A and 2B highlights the key difference between the PNP (blue line) and KNP (yellow dashed line) schemes. The KNP-scheme does not model the relaxation of the charge concentration, but derives the quasi-steady state potential directly. The results using KNP therefore deviated from those using PNP only on very short timescales during which the quasi-steady state potential was built up. After the initial charge-relaxation (*t*> 5 ns), the two schemes were in excellent agreement.

In theoretical studies of binary systems of ions, it has been shown that the ion concentrations will develop approximately as a single particle species moving by simple diffusion with a modified diffusion coefficient [54],
(42)
In Fig 2C the ion concentration profiles obtained with this theoretical approximation have been compared to a KNP-based simulation, as well as a DO-simulation where the electric charge of the ions was ignored, so that they were allowed to diffuse independently. The KNP solution was in agreement with Eq 42, and shows that the anion and cation concentrations coincided closely due to the strong electrical forces that would be associated with charge separation. This comparison highlights the shortcomings of the DO-model, which (i) gave inaccurate predictions of the two ion-concentration profiles, and (ii) predicted that the twin ion species were not locally balanced, so that the system contained a charge density *ρ* = *F*(*c*_{Na}−*c*_{X}) which varied over the x-axis. According to the Poisson equation (Eq 8), the charge density associated with the concentration profiles in Fig 2C would amount voltage differences of 247 kV across the system, which is clearly not physically realistic.

### Application 2: Comparison of KNP- and VC-schemes for an ion source-sink pair

We next compared the KNP-scheme with the simpler VC-scheme for computing ECS potentials. We first did this for an idealized setup, using the computational domain of a 3-D box consisting of the extracellular domain. The initial ion concentrations were uniform, with values from Table 2. The box contained one K^{+} point source, and one K^{+} point sink, with equal magnitudes (see Methods).

The electrical potential *ϕ* at the end of the stimulus period (*t* = 1 s) is shown in Fig 3A. The resulting electrical potential could be split into two contributions, i.e., the contribution from the source and sink currents, *ϕ*_{VC} (Fig 3B), and the contribution from the diffusive currents in the ECS, *ϕ*_{diff} (Fig 3C).

The source and sink were turned on at *t* = 0 s, and turned off at *t* = 1 s. The simulation was stopped at *t* = 2 s. **(A)** The total electrical potential *ϕ* at the end of the stimulus period (*t* = 1.0 s) in a plane intersecting the source and sink. **(B)** The volume conductor component of the electrical potential, *ϕ*_{VC}. **(C)** The diffusive component of the electrical potential *ϕ*_{diff}. **(D)** The difference in the electric potential between points close to the point sources (blue line), also shown is the differences in the VC component of the potential (stapled yellow line). Δ*ϕ* is defined as Δ*ϕ* = *ϕ*(**x**_{left}) − *ϕ*(**x**_{right}), where **x**_{left} and **x**_{right} were points 5 μm away from the left and right, respectively (see Methods).

In this simulation, *ϕ*_{VC} had a constant value which was reached immediately when the source and sink were turned on, and remained constant throughout the stimulus period since the source and sink were constant. This was not the case for *ϕ*_{diff}, which was close to zero at *t* = 0, but increased gradually throughout the simulation, as concentration gradients built up in the system. The diffusion potential *ϕ*_{diff} was quite local, and gave strongest contribution close to the source and sink (Fig 3C).

The differences between the KNP scheme and VC scheme are illustrated in Fig 3D, which shows the potential difference between two points close to the source and sink. VC and KNP gave similar estimates of the potential *ϕ* only for a brief period after the source and sink had been turned on, when the contribution from diffusion was still small. As the simulation progressed, the local build-up of ion concentrations evoked a shift in the KNP-simulated potential *ϕ*, but left *ϕ*_{VC} unaffected. The difference between the schemes *ϕ* − *ϕ*_{VC} is identical to the diffusion potential *ϕ*_{diff}, which is not accounted for by the VC scheme. The diffusion component had a sort of screening effect, reducing the potential difference between the source and sink compared to what we would predict in the absence of diffusion (i.e. |*ϕ*| < |*ϕ*_{VC}|). After roughly 0.1 seconds, *ϕ*_{diff} had lowered *ϕ* by about 5%, compared to what the VC model predicted. This effect lasted until the source and sink were turned off (Fig 3D). After this, *ϕ*_{VC} immediately dropped to zero, while in the KNP-scheme, a diffusion potential *ϕ*_{diff} remained. In the absence of sources, *ϕ*_{diff} decayed gradually until system reached a steady state.

### Application 3: Ion dynamics in the ECS of a morphologically detailed neuron

Finally, we used the KNP-scheme to model electrodiffusion in a 3-D cylinder containing a morphologically detailed neuron (Fig 1A). The neuron was represented as a set of point sources and sinks that had a spatial distribution representing the neuronal morphology, and which exchanged ions with the system as illustrated in Fig 1B (see Methods for details). Since ECS ion concentrations generally vary on a slow timescale (order of seconds), the system was simulated for 80 s. Due to the efficiency of the KNP-scheme, we could run this simulation in less than 15 hours using 4 CPU cores in parallel on a standard desktop computer.

#### Concentration gradients in the ECS caused by neuronal membrane currents.

Due to the slow nature of diffusion, the concentration changes clearly reflected the presence of neuronal sources/sinks. This can be seen in the snapshots of the ion-concentration profile surrounding the neuron after *t* = 80.0 s of neural activity (Fig 4). The largest changes were seen for the Na^{+} and K^{+} concentrations near the soma and axon hillock. This reflects the strong neuronal output of K^{+} and uptake of Na^{+} from the soma-near regions during action potentials. Animations that show the time evolution of the concentrations were also created (see S1 Animations).

Δ*c*_{k} is the change in concentration from the initial value, defined as Δ*c*_{k} = *c*_{k}(*t*) − *c*_{k}(0). The concentrations were measured in a 2-D slice going through the center of the computational mesh, and the neuron morphology was stenciled in. The green and purple dots signify selected measurement points in the ECS near the soma (green) and apical dendrites (purple) of the neuron, which are reference points for the analysis in the following sections.

#### The effect of electrical fields on extracellular ion dynamics.

In general, ions move both by electrical drift and diffusion. To explore the relative effect of these transport processes on the ECS ion-concentration dynamics, we compared two simulations where (i) ions moved by independent diffusion as predicted by the DO-scheme, and (ii) where ions moved due to electrodiffusion as predicted by the KNP-scheme. The two schemes were compared by looking at time series for the ion concentrations at two selected measurement points, one near the soma (green), and one near the apical dendrites (purple), as indicated in Fig 4. The concentration time series obtained with the KNP-scheme are shown in Fig 5A and 5B, for the green and purple measurement points, respectively. In the remaining panels of Fig 5, the KNP and DO-schemes are compared.

The locations of the measurement points were in the ECS near the soma (green) and apical dendrites (purple) of the neuron. Δ*c*(*t*) is the change in concentration from the initial value, defined as Δ*c*(*t*) = *c*(*t*) − *c*(0). **(A)-(B)** Dynamics of all ion species as predicted by the KNP-scheme. **(C)-(F)** A comparison between the KNP and DO predictions at the measurement point near the soma. **(G)-(J)** A comparison between the KNP and DO predictions at the measurement point near the apical dendrites. **(C)-(J)** To generate the DO predictions, we set the ECS field to zero, which ensured that the ECS dynamics was due to diffusion only.

At the measurement point near the soma (Fig 5C–5F), the KNP- and DO-schemes gave similar predictions for all ion species except X^{−} (Fig 5E). To explain this, we separate the local concentration dynamics into (i) a component due to neuronal uptake/efflux, (ii) a component due to ECS diffusion, and (iii) a component due to ECS electrical drift. The first two components (i-ii) were shared between the KNP- and DO-schemes, and the differences between the schemes were due to the latter component, which was absent from the DO-scheme. The component (iii) represents ions being electrically forced into a local region to ensure local electroneutrality, and would in principle affect the dynamics of all ion species. The reason why the effect was small in the case of Na^{+} and K^{+}, is that the concentration changes of these ions were dominated by (i) the neuronal uptake and output during AP firing, and less so by (ii-iii) electrodiffusion in the ECS. The reason why the relative effect of electrical drift was larger for X^{−} than for Ca^{2+} is twofold. First, X^{−} had a larger diffusion constant than Ca^{2+}, and was therefore more mobile (cf. Table 2). Secondly, the number of electrically migrating ions is proportional to the abundance of a given ion species (cf. Eq 4), as well as the valence of the ion species. Even though Ca^{2+} has a larger valence than X^{−}, as X^{−} was a significantly more abundant than Ca^{2+} in the ECS (cf. Table 2), we would expect X^{−} to be most affected by electrical drift.

In the apical dendrites, the membrane currents were not dominated by the AP exchange of Na^{+} and K^{+}, and shifts in the different ion concentrations were more similar in magnitude. At the measurement point near the apical dendrites, the KNP and DO predictions deviated for all ion species (Fig 5G–5J). The deviations were largest for Na^{+} and X^{−}, which again reflects the fact that these were the two most abundant ion species in the ECS (cf. Table 2).

The exact nature of the ECS dynamics in Fig 5 depended on the specific distribution of ion channels in the selected neuronal model. Although this model choice was somewhat arbitrary, these simulations still serve as a clear demonstration that ECS ion dynamics in general is of electrodiffusive nature, and thus depend on effects that are not accounted for by a DO-scheme.

#### Local effects of diffusion on the extracellular potential.

Above, we saw that the ECS potential could influence the local ion-concentration dynamics. Here, we explore how the ion-concentration dynamics can influence the local potential *ϕ*. We first study a low-pass filtered version of *ϕ* by taking the average over a 100 ms interval. Fig 6A shows the spatial profile of the low-pass filtered *ϕ* at *t* = 80 s, while Fig 6B and 6C show the diffusion component (*ϕ*_{diff}) and VC component (*ϕ*_{VC}) of *ϕ*, respectively. Evidently, the two components had similar amplitudes, which means that ECS diffusion gave a substantial contribution to the total potential *ϕ*. It should be noted that this conclusion is based on the low-pass filtered version of the signal, and that the higher frequency components are studied below.

The ECS potential was averaged over a 100 ms interval between *t* = 79.9 s and 80 s. This averaging low-pass filters the potential. **(A)** ECS potential as predicted by the KNP-scheme. **(B)** The VC component of the potential. **(C)** The diffusive component of the potential.

Interestingly, the simulations demonstrated that *ϕ*_{diff} was much more local than *ϕ*_{VC}. Whereas the membrane currents generated potential fluctuations over the entire simulated region, the *ϕ*_{diff} contributions were confined to the regions of space where concentration gradients were nonzero. Since diffusion is a slow process, only a relatively small region of about 200 μm around the neuron was affected during the 80 s simulation. The local nature of *ϕ*_{diff} implies that *ϕ*_{VC} gives a good estimate of *ϕ* in regions where concentration gradients are small, even if diffusive effects are present in other regions of the system.

To compare *ϕ*_{VC} to other common implementations of the VC-scheme, we note that for other implementations, *σ* is usually kept constant in the entire domain. We measured *σ* throughout the domain for the whole simulation, and found that it varied by about at most 0.001%, which means that this result is essentially the same as what would be found by the traditional implementation of the VC-scheme, given that the same boundary conditions are used.

#### Diffusive currents affect the low-frequency part of the LFP.

To gain further insight in how diffusion can affect ECS potentials, we also explored the temporal development of *ϕ* at two selected measurement points (marked in green and purple in Fig 6). Fig 7A and 7B show the dynamics of *ϕ* (blue curve) during an 80 seconds simulation, as well as its components *ϕ*_{VC} (orange curve) and *ϕ*_{diff} (green curve). Again, each data point represents the average over a 100 ms interval, so that *ϕ* was effectively low-pass filtered. As we also saw above, the low-frequency contributions of *ϕ*_{VC} and *ϕ*_{diff} were similar in magnitude (and opposite in sign).

The selected measurement points were in the ECS near the soma (green) and apical dendrites (purple) of the neuron. **(A)-(B)** Dynamics of the ECS potential for the first 80 s of the simulation. Each data point represent an average over a 100 ms time interval, which effectively low-pass filtered the signal. **(C)-(D)** High resolution time series for the ECS potential during a neural AP. The data were not low-pass filtered, but had a temporal resolution of 0.1 ms.

The time series clearly showed that *ϕ*_{VC} varied more rapidly in time than *ϕ*_{diff}. Even when low-pass filtered, *ϕ*_{VC} fluctuated several times between about 0.5 and 1.5 μV during the 80 s simulation, while *ϕ*_{diff} underwent an almost monotonous decrease from zero towards -1 μV (Fig 7A).

Due to the slow nature of the diffusive currents, their contribution to the ECS potentials was close to DC-like, and we would therefore not expect diffusion to have an impact on brief signals, such as extracellular AP signatures. We verified this in an additional simulation, which started (with the ECS concentrations) at *t* = 80 s, and which used a smaller time step (0.1 ms) in order to simulate an AP with sufficient temporal resolution. The simulation was run for 200 ms, and an AP was observed at roughly *t* = 80.18 s.

Fig 7C and 7D shows the time course of *ϕ* (blue curve) and *ϕ*_{VC} (orange curve) during the AP. The constant offset between the two curves was due to the diffusive contribution *ϕ*_{diff}, which was accounted for by *ϕ*, but not by *ϕ*_{VC}. In the apical dendritic region, the offset was of comparable magnitude to the amplitude of the AP signature (Fig 7C). The diffusion evoked offset was even larger outside the soma, but its relative impact on *ϕ* was smaller, since *ϕ*_{VC} there varied by more than 100 μV during the AP (Fig 7D). The offset was seen to distort the shape of the AP signature at either of these points. Hence, we can conclude that diffusion can have a strong effect on the low-frequency components of *ϕ*, but that the high frequency components are unaffected by diffusion. This conclusion is in line with what we found in previous studies based on simpler, 1-D implementations of the KNP-scheme [4, 24].

## Discussion

In the current work we presented a 3-D version of the electrodiffusive KNP-scheme, and used it to simultaneously simulate the dynamics of ion concentrations and the electrical potential in the ECS of a piece of tissue containing a morphologically realistic distribution of neuronal current sources/sinks. We demonstrated the applicability of this simulation framework by comparing it to the more physically detailed, but more computationally demanding PNP-scheme (Fig 2). Furthermore, we demonstrated the need for an electrodiffusive simulation framework by showing (i) how its predicted ion concentrations deviated from predictions obtained with the diffusion only (DO) scheme, which ignores concentration variations due to electrical drift in the ECS (Figs 2 and 5), and (ii) how its predicted potentials deviated from predictions obtained with the volume conductor (VC) schemes, which ignores voltage variations due to diffusive currents in the ECS (Figs 3, 6 and 7).

To our knowledge, the presented model is the first in the field of computational neuroscience that can handle electrodiffusive processes in 3-D on spatiotemporal scales spanning over millimeters and seconds without demanding an insurmountable amount of computer power. Even the most resource-demanding simulations presented here could be performed in about 15 hours on a normal stationary computer, and we believe that simulation efficiency can be improved even further if we select an optimal numerical scheme for KNP. In the current work, all simulations were run using an implicit Euler time-stepping scheme. This choice was mainly based on the requirements of the PNP-scheme, which requires an implicit scheme in order to not become unstable. The KNP-scheme is, however, much more stable than the PNP-scheme, and in future KNP implementations we will investigate the possibility of using an operator-splitting approach for the numerical solver, which would likely improve the efficiency of the simulations.

### Model limitations

The presented implementation of the 3-D KNP-scheme was limited to a relatively small piece of neural tissue, which included only a single pyramidal neuron modeled with the NEURON simulator. Although this approach provided clarity regarding the possible single-neuron contribution to the ECS electro- and concentration dynamics, there are many reasons why this simulation setup was far from representative for any biologically realistic scenario.

Firstly, the brain is packed with neurons and glial cells, and even the small volume considered here would in reality be populated by thousands of neurons that would contribute to the ECS dynamics. In a realistic scenario, ECS concentration shifts may become much larger than for the single-neuron case, where the maximal changes in ion concentration were roughly 1% (for K^{+} near the soma). Accordingly, the effects of electrodiffusion in the single neuron-setup used here were small, and the simulations in Application 3 should predominantly be regarded as a proof of principle, and as a precursor for what could be expected in more realistic scenarios with additive contributions from networks of neurons to extracellular ion dynamics.

Secondly, the simulations were performed under the simplifying assumption that there was no feedback from the ECS dynamics to the neurodynamics. This assumption gave us the advantage that the neuronal output did not depend on the modelling scheme used for the ECS dynamics, meaning that VC-, DO- and KNP-schemes could be compared under identical input/output conditions. In reality, however, shifts in extracellular (or intracellular) concentrations would influence the reversal potential of transmembrane currents, which in turn would have an impact on the neurodynamics (see [8–11]), and these effects are not accounted for in the current model. In addition, simulations based on the NEURON simulator do not account for ephaptic feedback from extracellular fields onto neurons, which could also have moderate impact on neurodynamics (see [55]).

Thirdly, the neuron model used in our study did not include the Na^{+}/K^{+}-exchanger pump [43]. This is the case for most neuron models currently available in NEURON (for a model with ion pumps, see [56]). Together with astrocytic uptake mechanisms, the exchanger pump would strive towards maintaining extra- and intracellular ion concentrations close to baseline levels. For a biophysical modeling scheme that derives the transmembrane transport through channels and pumps from first principles, see e.g., [57, 58]. In the presence of such mechanisms, the single-neuron contribution to ECS concentration shifts would likely be smaller than in the simulations presented here, or would require a higher neural activity level in order to occur. The model limitations mentioned above were also present in the previous 1-D implementation of the KNP-scheme, and we refer to this previous work for a more thorough discussion [4].

### Previous models of ECS electrodiffusion

Several previous studies have explored ECS electrodiffusion on small spatiotemporal scales [23, 28–34, 36–39]. Electrodiffusive models tailored to explore larger spatiotemporal scales have to our knowledge so far only been implemented in 1-D [4, 24, 40–42].

We have previously used a 1-D implementation of the KNP-scheme to explore the effect of diffusive currents on ECS potentials [4]. Qualitatively, the results from the 1-D simulations were similar to those found in the current 3-D model, and in both cases it was concluded that diffusive currents affected the low-frequency components of ECS potentials (Fig 7). In the 1-D implementation, diffusion and electrical drift were confined to the spatial direction along the neuronal extension, i.e. along the basal dendrite-soma-apical dendrite axis, and did not occur in the lateral direction. As discussed in [4], the 1-D assumption is equivalent to assuming lateral homogeneity, which means that any neuron is surrounded by neighboring neurons with identical activity patterns as itself. Clearly, this is would not apply to most biological scenarios, which means that the results obtained with the 3-D implementation are generally more reliable. In contrast to the 1-D model, the 3-D model predicts how ion concentrations vary in all spatial directions surrounding the neuronal sources, and can thus be applied to a broader range of biological problems.

The diffusion potentials addressed by the KNP-scheme are those that arise due to ECS concentration gradients on relatively large spatial scales. Diffusion potentials of this kind are often referred to as liquid junction potentials, since they are most pronounced at the boundary between two solutions of different ion compositions [35, 59]. These diffusion potentials are unrelated to filtering effects hypothesized to arise due to diffusion in the vicinity of the membrane when electric charge is transferred from the intracellular to the extracellular space [60, 61].

### Outlook

The presented version of the KNP-scheme was developed for use in a hybrid simulation setup where the dynamics of ion concentrations and the electrical potential in the ECS were computed with KNP, while the neurodynamics was computed with the NEURON simulator tool. By necessity, this scheme shares the limitations of the NEURON simulator in terms of handling intracellular ion dynamics, which by default is not electrodiffusive in the NEURON environment [14]. A natural future endeavor will therefore be to derive a computational scheme that in a consistent way couples both the intra- and extracellular ion-concentration and voltage dynamics based on the KNP-scheme. Such a scheme will represent a generalization of the previously developed *extracellular-membrane-intracellular* (EMI) model [55, 62], which in a consistent way couples the intra- and extracellular electrodynamics, but so far does not include ion-concentration dynamics and thus not diffusive currents.

This being said, the hybrid KNP/NEURON version presented here is valuable in its own right, since it allows the KNP framework to be combined with the many models that are already available in the NEURON software. Although we here only studied a single neuron’s contribution to the ECS electro- and concentration dynamics, we envision future applications of the 3-D KNP to more complex systems. The 3-D version of the KNP-scheme is generally applicable, and could be used to simulate the dynamics of ion concentrations and the electrical potential in the ECS surrounding arbitrary complex models of neurons or populations of neurons. It could, for example, be used to account for extracellular transport processes in the Blue Brain Simulator [63]. If combined with a cellular system of neurons and glial cells tailored to represent a specific experimental condition, the KNP-scheme could be used to explore the mechanisms behind spreading depression [3, 7, 64], epilepsy [5, 65], or other pathological conditions associated with large shifts in extracellular ion concentrations. In such applications, however, the hybrid KNP framework would need to be expanded to also account for the effect of ECS concentration dynamics on neuronal reversal potentials. This would require the development of an application programming interface that allows two-way communication between the simulator tools NEURON (for neurons) and FEniCS (for ECS). Since neurodynamics typically occurs at a much faster time scale (millisceonds) than changes in ECS ion concentrations (seconds), the interface could be based on using multiple time scales in order to keep the computational cost manageable. For example, a millisecond resolution could be used in NEURON simulations, while ECS concentrations could be computed (and updated in NEURON) at a slower temporal resolution of e.g., seconds.

## Supporting information

### S1 Animations. Animations of the ion-concentration dynamics.

Animations of the temporal evolution of the ion concentrations were created using ParaView. The neuron morphology was stenciled in.

https://doi.org/10.1371/journal.pcbi.1006510.s001

(ZIP)

### S1 Appendix. Details on the FEniCS implementation.

https://doi.org/10.1371/journal.pcbi.1006510.s002

(PDF)

## References

- 1. Cordingley GE, Somjen GG. The clearing of excess potassium from extracellular space in spinal cord and cerebral cortex. Brain research. 1978;151:291–306. pmid:209864
- 2. Dietzel I, Heinemann U, Lux HD. Relations between slow extracellular potential changes, glial potassium buffering, and electrolyte and cellular volume changes during neuronal hyperactivity in cat. Glia. 1989;2:25–44. pmid:2523337
- 3. Syková E, Nicholson C. Diffusion in Brain Extracellular Space. Physiol Rev. 2008;88:1277–1340. pmid:18923183
- 4. Halnes G, Mäki-Marttunen T, Keller D, Pettersen KH, Andreassen OA, Einevoll GT. Effect of ionic diffusion on extracellular potentials in neural tissue. PLoS computational biology. 2016;12(11):e1005193. pmid:27820827
- 5. Park EH, Durand DM. Role of potassium lateral diffusion in non-synaptic epilepsy: a computational study. Journal of theoretical biology. 2006;238(3):666–82. pmid:16085109
- 6. Florence G, Dahlem Ma, Almeida ACG, Bassani JWM, Kurths J. The role of extracellular potassium dynamics in the different stages of ictal bursting and spreading depression: a computational study. Journal of theoretical biology. 2009;258(2):219–28. pmid:19490858
- 7. Enger R, Tang W, Vindedal GF, Jensen V, Johannes Helm P, Sprengel R, et al. Dynamics of Ionic Shifts in Cortical Spreading Depression. Cerebral cortex (New York, NY: 1991). 2015; p. 1–8.
- 8. Cressman JR, Ullah G, Ziburkus J, Schiff SJ, Barreto E. The influence of sodium and potassium dynamics on excitability, seizures, and the stability of persistent states: I. Single neuron dynamics. Journal of computational neuroscience. 2009;26(2):159–70. pmid:19169801
- 9. Ullah G, Cressman JR Jr, Barreto E, Schiff SJ. The influence of sodium and potassium dynamics on excitability, seizures, and the stability of persistent states: II. Network and glial dynamics. Journal of computational neuroscience. 2009;26(2):171–183. pmid:19083088
- 10. Barreto E, Cressman JR. Ion concentration dynamics as a mechanism for neuronal bursting. Journal of biological physics. 2011;37(3):361–373. pmid:22654181
- 11. Øyehaug L, Østby I, Lloyd CM, Omholt SW, Einevoll GT. Dependence of spontaneous neuronal firing and depolarisation block on astroglial membrane transport mechanisms. Journal of computational neuroscience. 2012;32(1):147–65. pmid:21667153
- 12.
Rall W. Core conductor theory and cable properties of neurons. In: Handbook of Physiology. American Physiological Society, Bethesda; 1977. p. 39–97. Available from: http://onlinelibrary.wiley.com/doi/10.1002/cphy.cp010103/full.
- 13.
Rall W. Cable theory for dendritic neurons. In: Methods in neuronal modeling. MIT Press; 1989. p. 9–92.
- 14. Hines ML, Carnevale NT. The NEURON simulation environment. NEURON. 2006;9(6).
- 15. Hines ML, Davison AP, Muller E. NEURON and Python. Frontiers in neuroinformatics. 2009;3(January):1. pmid:19198661
- 16. Mitzdorf U. Current source-density method and application in cat cerebral cortex: investigation of evoked potentials and EEG phenomena. Physiological reviews. 1985;65(1):37–100. pmid:3880898
- 17. Holt GR, Koch C. Electrical interactions via the extracellular potential near cell bodies. Journal of computational neuroscience. 1999;6:169–184. pmid:10333161
- 18. Pettersen KH, Hagen E, Einevoll GT. Estimation of population firing rates and current source densities from laminar electrode recordings. Journal of computational neuroscience. 2008;24(3):291–313. pmid:17926125
- 19. Pettersen KH, Einevoll GT. Amplitude variability and extracellular low-pass filtering of neuronal spikes. Biophysical journal. 2008;94(3):784–802. pmid:17921225
- 20. Reimann MW, Anastassiou C, Perin R, Hill SL, Markram H, Koch C. A biophysically detailed model of neocortical local field potentials predicts the critical role of active membrane currents. Neuron. 2013;79(2):375–90. pmid:23889937
- 21. Łȩski S, Lindén H, Tetzlaff T, Pettersen KH, Einevoll GT. Frequency dependence of signal power and spatial reach of the local field potential. PLoS Comput Biol. 2013;9(7):e1003137. pmid:23874180
- 22. Gratiy SL, Halnes G, Denman D, Hawrylycz MJ, Koch C, Einevoll GT, et al. From Maxwell’s equations to the theory of current-source density analysis. European Journal of Neuroscience. 2017;45(8):1013–1023. pmid:28177156
- 23. Pods J. A comparison of computational models for the extracellular potential of neurons. Journal of Integrative Neuroscience. 2017;16(1):19–32. pmid:28891501
- 24. Halnes G, Mäki-Marttunen T, Pettersen KH, Andreassen OA, Einevoll GT. Ion diffusion may introduce spurious current sources in current-source density (CSD) analysis. Journal of Neurophysiology. 2017;118(1):114–120. pmid:28298307
- 25. Kerr RA, Bartol TM, Kaminsky B, Dittrich M, Chang JCJ, Baden SB, et al. Fast Monte Carlo Simulation Methods for Biological Reaction-Diffusion Systems in Solution and on Surfaces. SIAM J Sci Comput. 2008;30(6):3126. pmid:20151023
- 26.
Fleidervish IA, Lasser-Ross N, Gutnick MJ, Ross WN. Na
^{+}imaging reveals little difference in action potential-evoked Na^{+}influx between axon and soma. Nature neuroscience. 2010;13(7):852–860. pmid:20543843 - 27. McDougal RA, Hines ML, Lytton WW. Reaction-diffusion in the NEURON simulator. Frontiers in neuroinformatics. 2013;7. pmid:24298253
- 28. Léonetti M, Dubois-Violette E. Theory of Electrodynamic Instabilities in Biological Cells. Physical Review Letters. 1998;81(9):1977–1980.
- 29. Léonetti M, Dubois-Violette E, Homblé F. Pattern formation of stationary transcellular ionic currents in Fucus. Proceedings of the National Academy of Sciences of the United States of America. 2004;101(28):10243–8. pmid:15232004
- 30. Lu B, Zhou YC, Huber GA, Bond SD, Holst MJ, McCammon JA. Electrodiffusion: a continuum modeling framework for biomolecular systems with realistic spatiotemporal resolution. The Journal of chemical physics. 2007;127(13):135102. pmid:17919055
- 31. Lopreore CL, Bartol TM, Coggan JS, Keller DX, Sosinsky GE, Ellisman MH, et al. Computational modeling of three-dimensional electrodiffusion in biological systems: application to the node of Ranvier. Biophysical journal. 2008;95(6):2624–35. pmid:18556758
- 32. Nanninga PM. A computational neuron model based on Poisson-Nernst-Planck theory. ANZIAM Journal. 2008;50:46–59.
- 33. Pods J, Schönke J, Bastian P. Electrodiffusion models of neurons and extracellular space using the Poisson-Nernst-Planck equations–numerical simulation of the intra- and extracellular potential for an axon model. Biophysical journal. 2013;105(1):242–54. pmid:23823244
- 34. Gardner CL, Jones JR, Baer SM, Crook SM. Drift-diffusion simulation of the ephaptic effect in the triad synapse of the retina. Journal of computational neuroscience. 2015;38(1):129–42. pmid:25260382
- 35. Aguilella VM, Mafé S, Pellicer J. On the nature of the diffusion potential derived from Nernst-Planck flux equations by using the electroneutrality assumption. Electrochimica acta. 1987;32(3):483–488.
- 36. Mori Y, Fishman GI, Peskin CS. Ephaptic conduction in a cardiac strand model with 3D electrodiffusion. Proceedings of the National Academy of Sciences of the United States of America. 2008;105(17):6463–8. pmid:18434544
- 37.
Mori Y. From three-dimensional electrophysiology to the cable model: an asymptotic study. arXiv preprint arXiv:09013914. 2009; p. 1–39.
- 38. Mori Y, Peskin C. A numerical method for cellular electrophysiology based on the electrodiffusion equations with internal boundary conditions at membranes. Communications in Applied Mathematics and Computational Science. 2009;4.1:85–134.
- 39. Mori Y, Liu C, Eisenberg RS. A model of electrodiffusion and osmotic water flow and its energetic structure. Physica D: Nonlinear Phenomena. 2011;240(22):1835–1852.
- 40. Niederer S. Regulation of ion gradients across myocardial ischemic border zones: a biophysical modelling analysis. PloS one. 2013;8(4):e60323. pmid:23577101
- 41. Halnes G, Østby I, Pettersen KH, Omholt SW, Einevoll GT. Electrodiffusive model for astrocytic and neuronal ion concentration dynamics. PLoS computational biology. 2013;9(12):e1003386. pmid:24367247
- 42.
Halnes G, Østby I, Pettersen KH, Omholt SW, Einevoll GT. An Electrodiffusive Formalism for Ion Concentration Dynamics in Excitable Cells and the Extracellular Space Surrounding Them. In: Advances in cognitive neurodynamics (IV). Springer Netherlands; 2015. p. 353–360. Available from: http://link.springer.com/chapter/10.1007/978-94-017-9548-7_50.
- 43. Hay E, Hill S, Schürmann F, Markram H, Segev I. Models of neocortical layer 5b pyramidal cells capturing a wide range of dendritic and perisomatic active properties. PLoS computational biology. 2011;7(7):e1002107. pmid:21829333
- 44. Lehmenkühler A, Syková E, Svoboda J, Zilles K, Nicholson C. Extracellular space parameters in the rat neocortex and subcortical white matter during postnatal development determined by diffusion analysis. Neuroscience. 1993;55(2):339–351. pmid:8377929
- 45. Nicholson C, Phillips JM. Ion diffusion modified by tortuosity and volume fraction in the extracellular microenvironment of the rat cerebellum. The Journal of Physiology. 1981;8:225–257.
- 46. Chen KC, Nicholson C. Spatial buffering of potassium ions in brain extracellular space. Biophysical journal. 2000;78(6):2776–97. pmid:10827962
- 47.
Grodzinsky F. Fields, Forces, and Flows in Biological Systems. Garland Science, Taylor & Francis Group, London & New York.; 2011.
- 48. Britz D, Strutwolf J. Several ways to simulate time dependent liquid junction potentials by finite differences. Electrochimica Acta. 2014;137:328–335.
- 49.
Koch C. Biophysics of computation: information processing in single neurons. 1st ed. Oxford University Press: New York; 1999.
- 50. Lindén H, Hagen E, Łȩski S. LFPy: a tool for biophysical simulation of extracellular potentials generated by detailed model neurons. Frontiers in neuroinformatics. 2014;7(41). pmid:24474916
- 51.
Logg A, Mardal KA, Wells GN, et al. Automated Solution of Differential Equations by the Finite Element Method. Springer; 2012.
- 52.
Larson MG, Bengzon F. The finite element method: Theory, implementation, and applications. vol. 10. Springer Science & Business Media; 2013.
- 53. Alnæs M, Blechta J, Hake J, Johansson A, Kehlet B, Logg A, et al. The FEniCS project version 1.5. Archive of Numerical Software. 2015;3(100):9–23.
- 54. Henderson P. Zur Thermodynamik der Flüssigkeitsketten. Zeitschrift für Physikalische Chemie. 1907;59(1):118–127.
- 55. Tveito A, Jæger KH, Lines GT, Paszkowski Ł, Sundnes J, Edwards AG, et al. An evaluation of the accuracy of classical models for computing the membrane potential and extracellular potential for neurons. Frontiers in computational neuroscience. 2017;11. pmid:28484385
- 56. Hübel N, Dahlem MA. Dynamics from seconds to hours in Hodgkin-Huxley model with time-dependent ion concentrations and buffer reservoirs. PLoS computational biology. 2014;10(12):e1003941. pmid:25474648
- 57.
Herrera-Valdez MA. Geometry and nonlinear dynamics underlying excitability phenotypes in biophysical models of membrane potential. Ph.D. Thesis. The University of Arizona. 2014. Available from: https://repository.arizona.edu/handle/10150/312741
- 58. Herrera-Valdez MA. A thermodynamic description for physiological transmembrane transport. PeerJ PrePrints. 2018;.
- 59. Perram JW, Stiles PJ. On the nature of liquid junction and membrane potentials. Physical chemistry chemical physics: PCCP. 2006;8(36):4200–13. pmid:16971988
- 60. Bédard C, Rodrigues S, Roy N, Contreras D, Destexhe A. Evidence for frequency-dependent extracellular impedance from the transfer function between extracellular and intracellular potentials: Intracellular-LFP transfer function. Journal of Computational Neuroscience. 2010;29(3):389–403. pmid:20559865
- 61. Bédard C, Destexhe A. Generalized theory for current-source-density analysis in brain tissue. Physical Review E. 2011;84(4):041909.
- 62. Agudelo-Toro A, Neef A. Computationally efficient simulation of electrical activity at cell membranes interacting with self-generated and externally imposed electric fields. Journal of neural engineering. 2013;10(2):026019. pmid:23503026
- 63. Markram H. The blue brain project. Nature Reviews Neuroscience. 2006; p. 159–174.
- 64. Spong KE, Andrew RD, Robertson RM. Mechanisms of spreading depolarization in vertebrate and insect central nervous systems. Journal of Neurophysiology. 2016;116(3):1117–1127. pmid:27334953
- 65. Raimondo JV, Burman RJ, Katz AA, Akerman CJ. Ion dynamics during seizures. Frontiers in Cellular Neuroscience. 2015;9:419. pmid:26539081