Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predefined unit variables #348

Merged
merged 31 commits into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
89b4b17
Remove prefixes of d,c,da,h and fix typo
PTraeder Apr 16, 2017
de12e9d
Add predefined variables for each possible SI unit
PTraeder Apr 16, 2017
8aa9053
Drop NESTMLNumericLiteral from grammar
PTraeder Apr 16, 2017
de4cce3
Fix issues arising from removing NESTMLNumericLiteral
PTraeder Apr 17, 2017
f83c3a0
Adapt /models to changes:
PTraeder Apr 17, 2017
037f8ca
Change expressionvisitor system to deal with "literal unit" instead o…
PTraeder Apr 17, 2017
01d33ba
Fix some tests
PTraeder Apr 17, 2017
7d4bc16
Check that "Literal Variable" expressions use only SI-unit variables
PTraeder Apr 19, 2017
84433bc
Change for loop from:
PTraeder Apr 19, 2017
c84171f
Adapt test case to grammar change.
PTraeder Apr 19, 2017
5d331e6
Add "isPredefined" to VariableSymbol to indicate if it is a predefine…
PTraeder Apr 19, 2017
e648429
Drop predefined VariableSymbols from resolved List before testing Var…
PTraeder Apr 19, 2017
96d98f9
Adapt test case.
PTraeder Apr 19, 2017
c2a4085
Change for_stmt step notation again.
PTraeder Apr 19, 2017
434b72d
Fix step notation in models
PTraeder Apr 19, 2017
58f07af
Fix variable name.
PTraeder Apr 19, 2017
8e41d58
fix iteration over symbols
PTraeder Apr 19, 2017
b9a5d74
Implement helper funciton to convert a unit into the literal represen…
PTraeder Apr 20, 2017
a62ae60
Teach various ReferenceConverters to print units as their literal rep…
PTraeder Apr 20, 2017
6dfdca0
Getter for magnitude
PTraeder Apr 20, 2017
81fa348
Teach expressionprinter to print "literal variable" pairs as "literal…
PTraeder Apr 20, 2017
bf4dd1b
Remove debug output
PTraeder Apr 20, 2017
6e84db7
Reinstate "step" notation for for loops. Make step mandatory to avoid…
PTraeder Apr 20, 2017
8d03233
Adapt models to mandatory step notation in for loops
PTraeder Apr 20, 2017
3d35b86
fix variable names
PTraeder May 10, 2017
cb24016
add unit-variable conversion code to one more ReferenceConverter
PTraeder May 10, 2017
b2281a8
Install infrastructure and a NESTML specific filter for units.
PTraeder May 10, 2017
aa7b2f3
Use NESTMLUnitFilter to calculate the modification factors for c++ code.
PTraeder May 10, 2017
ecab368
Merge branch 'master' of https://github.com/nest/nestml into predefin…
PTraeder May 19, 2017
409a6c4
Fix indentation
PTraeder May 19, 2017
189dd14
Fixed spacing again
PTraeder May 20, 2017
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
4 changes: 2 additions & 2 deletions models/aeif_cond_alpha.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ neuron aeif_cond_alpha_neuron:

# Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_E nS/ms = 1.0 nS * e / tau_syn_ex
PSConInit_E nS/ms = nS * e / tau_syn_ex
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a detail, but I would feel more comfortable if units were put at the end, as a general rule (it is more intuitive)

This remark applies throughout the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill fix it in my next pass wherever I find it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the unit should always go with the quantity it applies to. In this case, tau_syn_ex carries its own unit (ms). The question is if one now should consider e as a dimensionless constant, in which case the right-hand side should be 1 nS * e / tau_syn_ex, or assign e units, i.e., e nS / tau_syn_ex. I think I like the first version better; one might want to look again at the derivation of this expression to see where the nS actually comes from.

Copy link
Contributor Author

@PTraeder PTraeder May 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, @Silmathoron, this would leave us with "e / tau_syn_ex * 1.0 nS". I would not be too comfortable with that without adding parents. i.e. "(e / tau_syn_ex ) * 1.0 nS" I am not certain these are necessarily improvements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @heplesser and also think that 1 nS * e / tau_syn_ex looks cleaner than (e / tau_syn_ex ) * 1.0 nS or similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have opened #356 to discuss conventions around unit notation.


# Impulse to add to DG_INH on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_I nS/ms = 1.0 nS * e / tau_syn_in
PSConInit_I nS/ms = nS * e / tau_syn_in

# refractory time in steps
RefractoryCounts integer = steps(t_ref)
Expand Down
4 changes: 2 additions & 2 deletions models/aeif_cond_alpha_implicit.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ neuron aeif_cond_alpha_implicit:

# Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_E nS/ms = 1.0 nS * e / tau_syn_ex
PSConInit_E nS/ms = nS * e / tau_syn_ex

# Impulse to add to DG_INH on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_I nS/ms = 1.0 nS * e / tau_syn_in
PSConInit_I nS/ms = nS * e / tau_syn_in

# refractory time in steps
RefractoryCounts integer = steps(t_ref)
Expand Down
4 changes: 2 additions & 2 deletions models/aeif_cond_exp_implicit.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ neuron aeif_cond_exp_implicit:
emit_spike()
end

g_ex += spikeExc * 1 nS
g_in += spikeInh * 1 nS
g_ex += spikeExc * nS
g_in += spikeInh * nS
I_stim = currents
end

Expand Down
24 changes: 12 additions & 12 deletions models/hh_cond_exp_traub.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ neuron hh_cond_exp_traub_neuron:
V_m mV = E_L # Membrane potential

# equilibrium values for (in)activation variables
function alpha_n_init 1/ms = 0.032/(1 ms* 1 mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n_init 1/ms = 0.5 /1 ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m_init 1/ms = 0.32/(1 ms* 1 mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m_init 1/ms = 0.28/(1 ms* 1 mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h_init 1/ms = 0.128/1 ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h_init 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / 1 ms
function alpha_n_init 1/ms = 0.032/(ms* mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n_init 1/ms = 0.5 / ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m_init 1/ms = 0.32/(ms* mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m_init 1/ms = 0.28/(ms* mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h_init 1/ms = 0.128/ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h_init 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / ms

Act_m real = alpha_m_init / ( alpha_m_init + beta_m_init )
Act_h real = alpha_h_init / ( alpha_h_init + beta_h_init )
Expand All @@ -67,12 +67,12 @@ neuron hh_cond_exp_traub_neuron:

# channel dynamics
function V_rel mV = V_m - V_T
function alpha_n 1/ms = 0.032/(1 ms* 1 mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n 1/ms = 0.5 /1 ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m 1/ms = 0.32/(1 ms* 1 mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m 1/ms = 0.28/(1 ms* 1 mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h 1/ms = 0.128/1 ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / 1 ms
function alpha_n 1/ms = 0.032/(ms* mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n 1/ms = 0.5 /ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m 1/ms = 0.32/(ms* mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m 1/ms = 0.28/(ms* mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h 1/ms = 0.128/ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / ms

Act_m' = ( alpha_m - ( alpha_m + beta_m ) * Act_m )
Act_h' = ( alpha_h - ( alpha_h + beta_h ) * Act_h )
Expand Down
28 changes: 14 additions & 14 deletions models/hh_cond_exp_traub_implicit.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ neuron hh_cond_exp_traub_implicit:
g_ex nS = 0nS # Excitatory synaptic conductance

# TODO: it should be possible, to define these variables in the internal block
function alpha_n_init 1/ms = 0.032/(1 ms* 1 mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n_init 1/ms = 0.5 /1 ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m_init 1/ms = 0.32/(1 ms* 1 mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m_init 1/ms = 0.28/(1 ms* 1 mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h_init 1/ms = 0.128/1 ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h_init 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / 1 ms
function alpha_n_init 1/ms = 0.032/(ms* mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n_init 1/ms = 0.5 /ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m_init 1/ms = 0.32/(ms* mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m_init 1/ms = 0.28/(ms* mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h_init 1/ms = 0.128/ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h_init 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / ms

Act_m real = alpha_m_init / ( alpha_m_init + beta_m_init )
Act_h real = alpha_h_init / ( alpha_h_init + beta_h_init )
Expand All @@ -64,12 +64,12 @@ neuron hh_cond_exp_traub_implicit:

# equilibrium values for (in)activation variables
function V_rel mV = V_m - V_T
function alpha_n 1/ms = 0.032/(1 ms* 1 mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n 1/ms = 0.5 /1 ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m 1/ms = 0.32/(1 ms* 1 mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m 1/ms = 0.28/(1 ms* 1 mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h 1/ms = 0.128/1 ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / 1 ms
function alpha_n 1/ms = 0.032/(ms* mV ) * ( 15. mV - V_m) / ( exp( ( 15. mV - V_m) / 5. mV ) - 1. )
function beta_n 1/ms = 0.5 /ms * exp( ( 10. mV - V_m ) / 40. mV )
function alpha_m 1/ms = 0.32/(ms* mV ) * ( 13. mV - V_m) / ( exp( ( 13. mV - V_m) / 4. mV ) - 1. )
function beta_m 1/ms = 0.28/(ms* mV ) * ( V_m - 40. mV ) / ( exp( ( V_m - 40. mV ) / 5. mV ) - 1. )
function alpha_h 1/ms = 0.128/ms * exp( ( 17. mV - V_m) / 18. mV )
function beta_h 1/ms = ( 4. / ( 1. + exp( ( 40. mV - V_m ) / 5. mV) ) ) / ms

Act_m' = ( alpha_m - ( alpha_m + beta_m ) * Act_m )
Act_h' = ( alpha_h - ( alpha_h + beta_h ) * Act_h )
Expand Down Expand Up @@ -126,8 +126,8 @@ neuron hh_cond_exp_traub_implicit:
# set new input current
I_stim = currents

g_ex += spikeExc * 1 nS
g_in += spikeInh * 1 nS
g_ex += spikeExc * nS
g_in += spikeInh * nS
end

end
36 changes: 18 additions & 18 deletions models/hh_psc_alpha.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ neuron hh_psc_alpha_neuron:
state:
V_m mV = -65. mV # Membrane potential

function alpha_n_init real = ( 0.01 * ( V_m / 1 mV + 55. ) ) / ( 1. - exp( -( V_m / 1 mV + 55. ) / 10. ) )
function beta_n_init real = 0.125 * exp( -( V_m / 1 mV + 65. ) / 80. )
function alpha_m_init real = ( 0.1 * ( V_m / 1 mV + 40. ) ) / ( 1. - exp( -( V_m / 1 mV + 40. ) / 10. ) )
function beta_m_init real = 4. * exp( -( V_m / 1 mV + 65. ) / 18. )
function alpha_h_init real = 0.07 * exp( -( V_m / 1 mV + 65. ) / 20. )
function beta_h_init real = 1. / ( 1. + exp( -( V_m / 1 mV + 35. ) / 10. ) )
function alpha_n_init real = ( 0.01 * ( V_m / mV + 55. ) ) / ( 1. - exp( -( V_m / mV + 55. ) / 10. ) )
function beta_n_init real = 0.125 * exp( -( V_m / mV + 65. ) / 80. )
function alpha_m_init real = ( 0.1 * ( V_m / mV + 40. ) ) / ( 1. - exp( -( V_m / mV + 40. ) / 10. ) )
function beta_m_init real = 4. * exp( -( V_m / mV + 65. ) / 18. )
function alpha_h_init real = 0.07 * exp( -( V_m / mV + 65. ) / 20. )
function beta_h_init real = 1. / ( 1. + exp( -( V_m / mV + 35. ) / 10. ) )

Act_m real = alpha_m_init / ( alpha_m_init + beta_m_init ) # Activation variable m
Act_h real = alpha_h_init / ( alpha_h_init + beta_h_init ) # Activation variable h
Expand All @@ -74,19 +74,19 @@ neuron hh_psc_alpha_neuron:
V_m' =( -( I_Na + I_K + I_L ) + currents + I_e + I_syn_inh + I_syn_exc ) / C_m

# Inact_n
function alpha_n real = ( 0.01 * ( V_m / 1 mV + 55. ) ) / ( 1. - exp( -( V_m / 1 mV + 55. ) / 10. ) )
function beta_n real = 0.125 * exp( -( V_m / 1 mV + 65. ) / 80. )
Inact_n' = ( alpha_n * ( 1 - Inact_n ) - beta_n * Inact_n ) / 1 ms # n-variable
function alpha_n real = ( 0.01 * ( V_m / mV + 55. ) ) / ( 1. - exp( -( V_m / mV + 55. ) / 10. ) )
function beta_n real = 0.125 * exp( -( V_m / mV + 65. ) / 80. )
Inact_n' = ( alpha_n * ( 1 - Inact_n ) - beta_n * Inact_n ) / ms # n-variable

# Act_m
function alpha_m real = ( 0.1 * ( V_m / 1 mV + 40. ) ) / ( 1. - exp( -( V_m / 1 mV + 40. ) / 10. ) )
function beta_m real = 4. * exp( -( V_m / 1 mV + 65. ) / 18. )
Act_m' = ( alpha_m * ( 1 - Act_m ) - beta_m * Act_m ) / 1 ms # m-variable
function alpha_m real = ( 0.1 * ( V_m / mV + 40. ) ) / ( 1. - exp( -( V_m / mV + 40. ) / 10. ) )
function beta_m real = 4. * exp( -( V_m / mV + 65. ) / 18. )
Act_m' = ( alpha_m * ( 1 - Act_m ) - beta_m * Act_m ) / ms # m-variable

# Act_h
function alpha_h real = 0.07 * exp( -( V_m / 1 mV + 65. ) / 20. )
function beta_h real = 1. / ( 1. + exp( -( V_m / 1 mV + 35. ) / 10. ) )
Act_h' = ( alpha_h * ( 1 - Act_h ) - beta_h * Act_h ) / 1 ms # h-variable
function alpha_h real = 0.07 * exp( -( V_m / mV + 65. ) / 20. )
function beta_h real = 1. / ( 1. + exp( -( V_m / mV + 35. ) / 10. ) )
Act_h' = ( alpha_h * ( 1 - Act_h ) - beta_h * Act_h ) / ms # h-variable
end

parameters:
Expand All @@ -106,11 +106,11 @@ neuron hh_psc_alpha_neuron:
internals:
# Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_E pA/ms = 1.0 pA * e / tau_syn_ex
PSConInit_E pA/ms = pA * e / tau_syn_ex

# Impulse to add to DG_INH on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_I pA/ms = 1.0 pA * e / tau_syn_in
PSConInit_I pA/ms = pA * e / tau_syn_in


RefractoryCounts integer = steps(t_ref) # refractory time in steps
Expand All @@ -131,7 +131,7 @@ neuron hh_psc_alpha_neuron:
# sending spikes: crossing 0 mV, pseudo-refractoriness and local maximum...
if r > 0: # is refractory?
r -= 1
elif V_m > 0mV and U_old > V_m: # threshold && maximum
elif V_m > 0 mV and U_old > V_m: # threshold && maximum
r = RefractoryCounts
emit_spike()
end
Expand Down
34 changes: 17 additions & 17 deletions models/hh_psc_alpha_implicit.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ neuron hh_psc_alpha_implicit:
I_syn_ex pA # inputs from the exc spikes
I_syn_in pA # inputs from the inh spikes

function alpha_n_init real = ( 0.01 * ( V_m / 1 mV + 55. ) ) / ( 1. - exp( -( V_m / 1 mV + 55. ) / 10. ) )
function beta_n_init real = 0.125 * exp( -( V_m / 1 mV + 65. ) / 80. )
function alpha_m_init real = ( 0.1 * ( V_m / 1 mV + 40. ) ) / ( 1. - exp( -( V_m / 1 mV + 40. ) / 10. ) )
function beta_m_init real = 4. * exp( -( V_m / 1 mV + 65. ) / 18. )
function alpha_h_init real = 0.07 * exp( -( V_m / 1 mV + 65. ) / 20. )
function beta_h_init real = 1. / ( 1. + exp( -( V_m / 1 mV + 35. ) / 10. ) )
function alpha_n_init real = ( 0.01 * ( V_m / mV + 55. ) ) / ( 1. - exp( -( V_m / mV + 55. ) / 10. ) )
function beta_n_init real = 0.125 * exp( -( V_m / mV + 65. ) / 80. )
function alpha_m_init real = ( 0.1 * ( V_m / mV + 40. ) ) / ( 1. - exp( -( V_m / mV + 40. ) / 10. ) )
function beta_m_init real = 4. * exp( -( V_m / mV + 65. ) / 18. )
function alpha_h_init real = 0.07 * exp( -( V_m / mV + 65. ) / 20. )
function beta_h_init real = 1. / ( 1. + exp( -( V_m / mV + 35. ) / 10. ) )

Act_m real = alpha_m_init / ( alpha_m_init + beta_m_init ) # Activation variable m
Act_h real = alpha_h_init / ( alpha_h_init + beta_h_init ) # Activation variable h
Expand All @@ -79,19 +79,19 @@ neuron hh_psc_alpha_implicit:
V_m' =( -( I_Na + I_K + I_L ) + I_stim + I_e + I_syn_inh + I_syn_exc ) / C_m

# Inact_n
function alpha_n real = ( 0.01 * ( V_m / 1 mV + 55. ) ) / ( 1. - exp( -( V_m / 1 mV + 55. ) / 10. ) )
function beta_n real = 0.125 * exp( -( V_m / 1 mV + 65. ) / 80. )
Inact_n' = ( alpha_n * ( 1 - Inact_n ) - beta_n * Inact_n ) / 1 ms # n-variable
function alpha_n real = ( 0.01 * ( V_m / mV + 55. ) ) / ( 1. - exp( -( V_m / mV + 55. ) / 10. ) )
function beta_n real = 0.125 * exp( -( V_m / mV + 65. ) / 80. )
Inact_n' = ( alpha_n * ( 1 - Inact_n ) - beta_n * Inact_n ) / ms # n-variable

# Act_m
function alpha_m real = ( 0.1 * ( V_m / 1 mV + 40. ) ) / ( 1. - exp( -( V_m / 1 mV + 40. ) / 10. ) )
function beta_m real = 4. * exp( -( V_m / 1 mV + 65. ) / 18. )
Act_m' = ( alpha_m * ( 1 - Act_m ) - beta_m * Act_m ) / 1 ms # m-variable
function alpha_m real = ( 0.1 * ( V_m / mV + 40. ) ) / ( 1. - exp( -( V_m / mV + 40. ) / 10. ) )
function beta_m real = 4. * exp( -( V_m / mV + 65. ) / 18. )
Act_m' = ( alpha_m * ( 1 - Act_m ) - beta_m * Act_m ) / ms # m-variable

# Act_h'
function alpha_h real = 0.07 * exp( -( V_m / 1 mV + 65. ) / 20. )
function beta_h real = 1. / ( 1. + exp( -( V_m / 1 mV + 35. ) / 10. ) )
Act_h' = ( alpha_h * ( 1 - Act_h ) - beta_h * Act_h ) / 1 ms # h-variable
function alpha_h real = 0.07 * exp( -( V_m / mV + 65. ) / 20. )
function beta_h real = 1. / ( 1. + exp( -( V_m / mV + 35. ) / 10. ) )
Act_h' = ( alpha_h * ( 1 - Act_h ) - beta_h * Act_h ) / ms # h-variable
end

parameters:
Expand All @@ -111,11 +111,11 @@ neuron hh_psc_alpha_implicit:
internals:
# Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_E pA/ms = 1.0 pA * e / tau_syn_ex
PSConInit_E pA/ms = pA * e / tau_syn_ex

# Impulse to add to DG_INH on spike arrival to evoke unit-amplitude
# conductance excursion.
PSConInit_I pA/ms = 1.0 pA * e / tau_syn_in
PSConInit_I pA/ms = pA * e / tau_syn_in


RefractoryCounts integer = steps(t_ref) # refractory time in steps
Expand Down
38 changes: 19 additions & 19 deletions models/ht_neuron.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ neuron ht_neuron_nestml:
function I_syn pA = I_syn_ampa + I_syn_nmda + I_syn_gaba_a + I_syn_gaba_b

# I_Na(p), m_inf^3 according to Compte et al, J Neurophysiol 2003 89:2707
function INaP_thresh mV = -55.7pA
function INaP_slope mV = 7.7pA
function INaP_thresh mV = -55.7 pA
function INaP_slope mV = 7.7 pA
function m_inf_NaP real = 1.0 / ( 1.0 + exp( -( V_m - INaP_thresh ) / INaP_slope ) )
# Persistent Na current; member only to allow recording
recordable function I_NaP pA = -NaP_g_peak * pow( m_inf_NaP, 3.0 )* ( V_m - NaP_E_rev )
Expand All @@ -82,14 +82,14 @@ neuron ht_neuron_nestml:
recordable function I_h pA = -h_g_peak * Ih_m * ( V_m - h_E_rev )
# The spike current is only activate immediately after a spike.
function I_spike mV = (g_spike) ? -( V_m - E_K ) / Tau_spike : 0
V_m' = ( ( I_Na + I_K + I_syn + I_NaP + I_KNa + I_T + I_h + I_stim ) / Tau_m + I_spike * 1 [pA/(ms * mV)] ) * 1 [s/nF]
V_m' = ( ( I_Na + I_K + I_syn + I_NaP + I_KNa + I_T + I_h + I_stim ) / Tau_m + I_spike * pA/(ms * mV) ) * s/nF
#############
# Intrinsic currents
#############
# I_T
function m_inf_T real = 1.0 / ( 1.0 + exp( -( V_m / 1 mV + 59.0 ) / 6.2 ) )
function h_inf_T real = 1.0 / ( 1.0 + exp( ( V_m / 1 mV + 83.0 ) / 4 ) )
function tau_m_h real = 1.0 / ( exp( -14.59 - 0.086 * V_m / 1 mV ) + exp( -1.87 + 0.0701 * V_m / 1 mV ) )
function m_inf_T real = 1.0 / ( 1.0 + exp( -( V_m / mV + 59.0 ) / 6.2 ) )
function h_inf_T real = 1.0 / ( 1.0 + exp( ( V_m / mV + 83.0 ) / 4 ) )
function tau_m_h real = 1.0 / ( exp( -14.59 - 0.086 * V_m / mV ) + exp( -1.87 + 0.0701 * V_m / mV ) )
# I_KNa
function D_influx_peak real = 0.025
function tau_D real = 1250.0 # yes, 1.25s
Expand All @@ -104,14 +104,14 @@ neuron ht_neuron_nestml:

# equation modified from y[](1-D_eq) to (y[]-D_eq), since we'd not
# be converging to equilibrium otherwise
IKNa_D' = ( D_influx_peak * D_influx * 1 nS - ( IKNa_D - KNa_D_EQ * 1 [1/mV] ) / tau_D ) /1 ms
function tau_m_T real = 0.22 / ( exp( -( V_m / 1 mV + 132.0 ) / 16.7 ) + exp( ( V_m / 1 mV + 16.8 ) / 18.2 ) ) + 0.13
function tau_h_T real = 8.2 + ( 56.6 + 0.27 * exp( ( V_m / 1 mV + 115.2 ) / 5.0 ) ) / ( 1.0 + exp( ( V_m / 1 mV + 86.0 ) / 3.2 ) )
IKNa_D' = ( D_influx_peak * D_influx * nS - ( IKNa_D - KNa_D_EQ / mV ) / tau_D ) / ms
function tau_m_T real = 0.22 / ( exp( -( V_m / mV + 132.0 ) / 16.7 ) + exp( ( V_m / mV + 16.8 ) / 18.2 ) ) + 0.13
function tau_h_T real = 8.2 + ( 56.6 + 0.27 * exp( ( V_m / mV + 115.2 ) / 5.0 ) ) / ( 1.0 + exp( ( V_m / mV + 86.0 ) / 3.2 ) )
function I_h_Vthreshold real = -75.0
function m_inf_h real = 1.0 / ( 1.0 + exp( ( V_m / 1 mV - I_h_Vthreshold ) / 5.5 ) )
IT_m' = ( m_inf_T * 1 nS - IT_m ) / tau_m_T /1 ms
IT_h' = ( h_inf_T * 1 nS - IT_h ) / tau_h_T /1 ms
Ih_m' = ( m_inf_h * 1 nS - Ih_m ) / tau_m_h /1 ms
function m_inf_h real = 1.0 / ( 1.0 + exp( ( V_m / mV - I_h_Vthreshold ) / 5.5 ) )
IT_m' = ( m_inf_T * nS - IT_m ) / tau_m_T / ms
IT_h' = ( h_inf_T * nS - IT_h ) / tau_h_T / ms
Ih_m' = ( m_inf_h * nS - Ih_m ) / tau_m_h / ms

#############
# Synapses
Expand Down Expand Up @@ -204,10 +204,10 @@ neuron ht_neuron_nestml:
end
r_potassium -= 1

g_AMPA' += AMPAInitialValue * AMPA * 1 [nS/ms]
g_NMDA' += NMDAInitialValue * NMDA * 1 [nS/ms]
g_GABAA' += GABA_AInitialValue * GABA_A * 1 [nS/ms]
g_GABAB' += GABA_BInitialValue * GABA_B * 1 [nS/ms]
g_AMPA' += AMPAInitialValue * AMPA * nS/ms
g_NMDA' += NMDAInitialValue * NMDA * nS/ms
g_GABAA' += GABA_AInitialValue * GABA_A * nS/ms
g_GABAB' += GABA_BInitialValue * GABA_B * nS/ms

if (not g_spike) and V_m >= Theta:
# Set V and Theta to the sodium reversal potential.
Expand Down Expand Up @@ -237,9 +237,9 @@ neuron ht_neuron_nestml:
# See: Exact digital simulation of time-invariant linear systems
# with applications to neuronal modeling, Rotter and Diesmann,
# section 3.1.2.
exact_integration_adjustment real = ( ( 1 / Tau_2 ) - ( 1 / Tau_1 ) ) * 1 ms
exact_integration_adjustment real = ( ( 1 / Tau_2 ) - ( 1 / Tau_1 ) ) * ms

t_peak real = ( Tau_2 * Tau_1 ) * log( Tau_2 / Tau_1 ) / ( Tau_2 - Tau_1 ) / 1 ms
t_peak real = ( Tau_2 * Tau_1 ) * log( Tau_2 / Tau_1 ) / ( Tau_2 - Tau_1 ) / ms
normalisation_factor real = 1 / ( exp( -t_peak / Tau_1 ) - exp( -t_peak / Tau_2 ) )

return g_peak * normalisation_factor * exact_integration_adjustment
Expand Down
Loading