# Modeling an external input voltage to the circuit?

**URL:** <https://brian.discourse.group/t/modeling-an-external-input-voltage-to-the-circuit/1197>\
**Category:** Support\
**Created:** [14 April 2024 23:25 UTC](https://brian.discourse.group/t/modeling-an-external-input-voltage-to-the-circuit/1197 "2024-04-14T23:25:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mstimberg](https://yyz2.discourse-cdn.com/free1/user_avatar/brian.discourse.group/mstimberg/32/11_2.png) [@mstimberg](https://brian.discourse.group/u/mstimberg)\
**Post date:** [15 April 2024 09:07 UTC](https://brian.discourse.group/t/modeling-an-external-input-voltage-to-the-circuit/1197/2 "2024-04-15T09:07:41Z")

</div>

Hi @itq. Injecting an external current into a neuron with an electrode is actually something that is done quite commonly in experiments (the technical term is “current clamp”). To inject such a current, you include it in the equations. This is what is done in the HH model you linked to:

```python
# The model
eqs = Equations('''
dv/dt = (gl*(El-v) - g_na*(m*m*m)*h*(v-ENa) - g_kd*(n*n*n*n)*(v-EK) + I)/Cm : volt
# ...
I : amp
''')
group = NeuronGroup(...)
group.v = El
group.I = '0.7*nA * i / num_neurons'

```

The `I` is an injected current that is set to a value between 0 and 0.7nA, linearly spaced based on the index `i` of each neuron.

Now, your model is formulated slightly differently for simplicity, basically things are divided by `gl` from the HH equations. In your case, you’d therefore indeed “add a constant voltage” to the neuron, which physics-wise is a bit odd to say, but it’ll do 🙂

You can either do:

```python
    v_ext = 1*mV # external input
    eqs = '''
    dv/dt = (v_0 - v + g + v_ext) / t_mbr : volt (unless refractory)
    dg/dt = -g / tau : volt (unless refractory) 
    rfc : second
    '''

```

for the same input to all neurons, or:

```python
    eqs = '''
    dv/dt = (v_0 - v + g + v_ext) / t_mbr : volt (unless refractory)
    dg/dt = -g / tau : volt (unless refractory) 
    rfc : second
    v_ext : volt (constant)
    '''
    ...
    neu.v_ext = ... # one value for each neuron

```

to have a different input into each neuron.

Hope that helps!

---

_[View the full topic](https://brian.discourse.group/t/modeling-an-external-input-voltage-to-the-circuit/1197)._
