From 664cfd381c13e0ff265eb51cfc8a1f0d861cc140 Mon Sep 17 00:00:00 2001 From: DimitriPlotnikov Date: Wed, 29 Jun 2016 16:03:28 +0200 Subject: [PATCH] -Improve existing and add new models --- .../NESTCodeGeneratorIntegrationTest.java | 8 +- .../aeif_cond_exp_implicit.nestml | 99 +++++++++++++++++++ .../iaf_cond_exp_implicit.nestml | 27 ++--- 3 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml diff --git a/src/test/java/org/nest/integration/NESTCodeGeneratorIntegrationTest.java b/src/test/java/org/nest/integration/NESTCodeGeneratorIntegrationTest.java index e950b9c33..005641a45 100644 --- a/src/test/java/org/nest/integration/NESTCodeGeneratorIntegrationTest.java +++ b/src/test/java/org/nest/integration/NESTCodeGeneratorIntegrationTest.java @@ -52,7 +52,11 @@ public class NESTCodeGeneratorIntegrationTest extends GenerationBasedTest { private final List nestmlCondImplicitModels = Lists.newArrayList( "src/test/resources/codegeneration/iaf_cond_alpha_implicit.nestml", - "src/test/resources/codegeneration/aeif_cond_alpha_implicit.nestml" + "src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml", + "src/test/resources/codegeneration/aeif_cond_alpha_implicit.nestml", + "src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml", + "src/test/resources/codegeneration/hh_psc_alpha.nestml" + ); private final List blueGene = Lists.newArrayList( @@ -160,7 +164,7 @@ public void testIzhikevich() { @Ignore("Don't run this tests on github") @Test public void testManually() { - final List modelName = Lists.newArrayList("src/test/resources/codegeneration/hh_psc_alpha.nestml"); + final List modelName = Lists.newArrayList("src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml"); modelName.forEach(this::checkCocos); modelName.forEach(this::invokeCodeGenerator); final List roots = modelName.stream() diff --git a/src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml b/src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml new file mode 100644 index 000000000..0aff07e49 --- /dev/null +++ b/src/test/resources/codegeneration/aeif_cond_exp_implicit.nestml @@ -0,0 +1,99 @@ +neuron aeif_cond_exp_implicit: + + state: + V_m mV = E_L + w real = 0 + alias exp_arg real = (V_m-V_th)/delta_T + alias I_spike real = delta_T*exp(exp_arg) + # alias I_spike = delta_T*exp(min(exp_arg, MAX_EXP_ARG)) + + # inputs from the inh conductance + GI nS = 0 + # inputs from the exc conductance + GE nS = 0 + alias I_syn_exc real = GE * ( V_m - E_ex ) + alias I_syn_inh real = GI * ( V_m - E_in ) + end + + equations: + # Implicit + GI' = -GI/tau_syn_in + # shape GE = (e/tau_syn_ex) * t * exp(-1/tau_syn_ex*t) + GE' = -GE/tau_syn_ex + # Equation as defined in NEST model + + + #NESTML style + # results in worse precision + #V_m' = -1/Tau * (V_m - E_L) - 1/C_m * (Cond_sum(GI, spikeInh)* (V_m-E_in) + Cond_sum(GE, spikeExc) * (V_m-E_ex) - (I_e + I_stim) + w + I_spike) + V_m' = ( -g_L * ( ( V_m - E_L ) - I_spike ) - I_syn_exc - I_syn_inh - w + I_e + I_stim ) / C_m + w' = (a*(V_m - E_L) - w)/tau_w + + end + + parameter: + # membrane parameters + C_m pF = 281.0 # Membrane Capacitance in pF + t_ref ms = 0.0 # Refractory period in ms + V_reset mV = -60.0 # Reset Potential in mV + g_L nS = 30.0 # Leak Conductance in nS + E_L mV = -70.6 # Leak reversal Potential (aka resting potential) in mV + I_e pA = 0 # Constant Current in pA + + # spike adaptation parameters + a nS = 4 + b pA = 80.5 + alias Tau ms = (1 / g_L) * C_m + delta_T mV = 2.0 + tau_w ms = 144.0 + V_th mV = -50.4 # Threshold Potential in mV + V_peak mV = 0 + + # synaptic parameters + E_ex mV = 0 # Excitatory reversal Potential in mV + tau_syn_ex ms = 0.2 # Synaptic Time Constant Excitatory Synapse in ms + E_in mV = -85.0 # Inhibitory reversal Potential in mV + tau_syn_in ms = 2.0 # Synaptic Time Constant for Inhibitory Synapse in ms + # Input current injected by CurrentEvent. + # This variable is used to transport the current applied into the + # _dynamics function computing the derivative of the state vector. + I_stim pA = 0 + end + + internal: + r integer + + # refractory time in steps + RefractoryCounts integer = steps(t_ref) + end + + input: + spikeInh <- inhibitory spike + spikeExc <- excitatory spike + currents <- current + end + + output: spike + + update: + integrate(V_m) + + if r > 0: # refractory + r = r - 1 + end + + if r > 0: # not refractory + V_m = V_reset # clamp potential + elif V_m >= V_peak: + r = RefractoryCounts + V_m = V_reset # clamp potential + w += b + emit_spike() + end + + GE += spikeExc.getSum() + GI += spikeInh.getSum() + I_stim = currents.getSum() + end + +end diff --git a/src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml b/src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml index d90b6b34a..aa89d736d 100644 --- a/src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml +++ b/src/test/resources/codegeneration/iaf_cond_exp_implicit.nestml @@ -2,8 +2,7 @@ neuron iaf_cond_exp_implicit: state: # membrane potential - V mV = 0 - alias V_m mV = V + 0 + V_m mV = E_L # inputs from the inh conductance GI nS = 0 # inputs from the exc conductance @@ -12,10 +11,9 @@ neuron iaf_cond_exp_implicit: equations: # Implicit - GI' = GI' - GI/tau_synI - GE' = GE' -GE/tau_synE - - V' = -1/Tau * (V - E_L) - 1/C_m * ( GI * (V-V_reversalI) + GE * (V-V_reversalE) - (I_e + I_stim)) + GI' = -GI/tau_synI + GE' = -GE/tau_synE + V_m' = -1/Tau * (V_m - E_L) - 1/C_m * ( GI * (V_m-V_reversalI) + GE * (V_m-V_reversalE) - (I_e + I_stim)) end parameter: @@ -50,17 +48,8 @@ neuron iaf_cond_exp_implicit: end internal: - # Impulse to add to DG_EXC on spike arrival to evoke unit-amplitude - # conductance excursion. - PSConInit_E real = 1.0 * e / tau_synE - - # Impulse to add to DG_INH on spike arrival to evoke unit-amplitude - # conductance excursion. - PSConInit_I real = 1.0 * e / tau_synI - # refractory time in steps RefractoryCounts integer = steps(t_ref) - r integer end @@ -74,14 +63,14 @@ neuron iaf_cond_exp_implicit: update: - integrate(V) + integrate(V_m) if r != 0: # not refractory r = r - 1 - V = V_reset # clamp potential + V_m = V_reset # clamp potential - elif V >= V_th: + elif V_m >= V_th: r = RefractoryCounts - V = V_reset # clamp potential + V_m = V_reset # clamp potential emit_spike() end