From a2211a07fef48dc9b8ea770a4c647beac95f792b Mon Sep 17 00:00:00 2001 From: DimitriPlotnikov Date: Thu, 15 Sep 2016 16:05:52 +0200 Subject: [PATCH 1/3] -Fix error: the parameter of the Time constructor must be a double --- .../codegeneration/converters/NESTReferenceConverter.java | 2 +- .../org/nest/nestml/function/MemberInitialization.ftl | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/nest/codegeneration/converters/NESTReferenceConverter.java b/src/main/java/org/nest/codegeneration/converters/NESTReferenceConverter.java index 8f9048507..bb5f47c0c 100644 --- a/src/main/java/org/nest/codegeneration/converters/NESTReferenceConverter.java +++ b/src/main/java/org/nest/codegeneration/converters/NESTReferenceConverter.java @@ -66,7 +66,7 @@ public String convertFunctionCall(final ASTFunctionCall astFunctionCall) { } // Time.steps -> nest::Time(nest::Time::ms( args )).get_steps()); if ("steps".equals(functionName)) { - return "nest::Time(nest::Time::ms(%s)).get_steps()"; + return "nest::Time(nest::Time::ms((double) %s)).get_steps()"; } if (PredefinedFunctions.POW.equals(functionName)) { diff --git a/src/main/resources/org/nest/nestml/function/MemberInitialization.ftl b/src/main/resources/org/nest/nestml/function/MemberInitialization.ftl index 096798a19..95d439a40 100644 --- a/src/main/resources/org/nest/nestml/function/MemberInitialization.ftl +++ b/src/main/resources/org/nest/nestml/function/MemberInitialization.ftl @@ -1,8 +1,9 @@ <#-- - Generates C++ declaration + In general case creates an - @param variable VariableSymbol - @param tc templatecontroller + @param variable VariableSymbol Variable for which the initialization should be done + @param printer The particular pretty printer which prints expressions. Is used to handel differences where the + variable is declared (inside a struct or in another method) --> ${signature("variable", "printer")} From 5ec5e251bd8aff07bde7bd97e6dfc16bce28a3c7 Mon Sep 17 00:00:00 2001 From: DimitriPlotnikov Date: Thu, 15 Sep 2016 16:06:26 +0200 Subject: [PATCH 2/3] Update models which are used in the NESTML tutorial --- ...1_integrate.nestml => 11.rc_neuron.nestml} | 6 +-- .../tutorial/12.rc_neuron_rel.nestml | 32 +++++++++++++ src/test/resources/tutorial/21_rc_fire.nestml | 37 +++++++++++++++ ...d_reset.nestml => 22_rc_refractory.nestml} | 13 ++--- .../resources/tutorial/23_rc_alpha.nestml | 47 +++++++++++++++++++ 5 files changed, 125 insertions(+), 10 deletions(-) rename src/test/resources/tutorial/{1_integrate.nestml => 11.rc_neuron.nestml} (79%) create mode 100644 src/test/resources/tutorial/12.rc_neuron_rel.nestml create mode 100644 src/test/resources/tutorial/21_rc_fire.nestml rename src/test/resources/tutorial/{2_integrate_and_reset.nestml => 22_rc_refractory.nestml} (75%) create mode 100644 src/test/resources/tutorial/23_rc_alpha.nestml diff --git a/src/test/resources/tutorial/1_integrate.nestml b/src/test/resources/tutorial/11.rc_neuron.nestml similarity index 79% rename from src/test/resources/tutorial/1_integrate.nestml rename to src/test/resources/tutorial/11.rc_neuron.nestml index cba72718e..4778f6c0c 100644 --- a/src/test/resources/tutorial/1_integrate.nestml +++ b/src/test/resources/tutorial/11.rc_neuron.nestml @@ -1,12 +1,10 @@ /* A straight forward implementation of the RC circuit approach */ -neuron iaf: +neuron rc_neuron: state: V_abs mV = 0mV - alias V_m mV = V_abs - E_L - I_syn pA = 0pA end equations: @@ -17,6 +15,7 @@ neuron iaf: E_L mV = -65mV C_m pF = 250pF tau_m ms = 10ms + I_syn pA = 10pA end input: @@ -27,7 +26,6 @@ neuron iaf: update: integrate(V_abs) - I_syn = spikes.get_sum() end end \ No newline at end of file diff --git a/src/test/resources/tutorial/12.rc_neuron_rel.nestml b/src/test/resources/tutorial/12.rc_neuron_rel.nestml new file mode 100644 index 000000000..1adb8920a --- /dev/null +++ b/src/test/resources/tutorial/12.rc_neuron_rel.nestml @@ -0,0 +1,32 @@ +/* + A straight forward implementation of the RC circuit approach +*/ +neuron rc_neuron_rel: + + state: + V_abs mV = 0mV + alias V_m mV = V_abs + E_L + end + + equations: + V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn + end + + parameter: + E_L mV = -70mV + C_m pF = 250pF + tau_m ms = 10ms + I_syn pA = 10pA + end + + input: + spikes <- spike + end + + output: spike + + update: + integrate(V_abs) + end + +end \ No newline at end of file diff --git a/src/test/resources/tutorial/21_rc_fire.nestml b/src/test/resources/tutorial/21_rc_fire.nestml new file mode 100644 index 000000000..c908bf090 --- /dev/null +++ b/src/test/resources/tutorial/21_rc_fire.nestml @@ -0,0 +1,37 @@ +/* + A straight forward implementation of the RC circuit approach. + Extends the integrate method with a threshold and fire behaviour. +*/ +neuron rc_fire: + + state: + V_abs mV = 0mV + alias V_m mV = V_abs + E_L + + end + + equations: + V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn + end + + parameter: + E_L mV = -70mV + C_m pF = 250pF + tau_m ms = 10ms + I_syn pA = 0pA + alias V_th mV = -55mV - E_L + alias V_reset mV = -65mV - E_L + end + + input: + spikes <- spike + end + + output: spike + + update: + integrate(V_abs) + + end + +end \ No newline at end of file diff --git a/src/test/resources/tutorial/2_integrate_and_reset.nestml b/src/test/resources/tutorial/22_rc_refractory.nestml similarity index 75% rename from src/test/resources/tutorial/2_integrate_and_reset.nestml rename to src/test/resources/tutorial/22_rc_refractory.nestml index deb5ada05..6ae79b566 100644 --- a/src/test/resources/tutorial/2_integrate_and_reset.nestml +++ b/src/test/resources/tutorial/22_rc_refractory.nestml @@ -2,12 +2,11 @@ A straight forward implementation of the RC circuit approach. Extends the integrate method with a threshold and fire behaviour. */ -neuron iaf_reset: +neuron rc_refractory: state: V_abs mV = 0mV alias V_m mV = V_abs + E_L - I_syn pA = 0pA end equations: @@ -15,11 +14,12 @@ neuron iaf_reset: end parameter: - E_L mV = -65mV + E_L mV = -70mV C_m pF = 250pF tau_m ms = 10ms - alias V_th mV = 55mV + E_L - alias V_reset mV = 10mV + E_L + I_syn pA = 10pA + alias V_th mV = -55mV - E_L + alias V_reset mV = -65mV - E_L end input: @@ -32,8 +32,9 @@ neuron iaf_reset: integrate(V_abs) if V_abs > V_th: V_abs = V_reset + emit_spike() end - I_syn = spikes.get_sum() end + end \ No newline at end of file diff --git a/src/test/resources/tutorial/23_rc_alpha.nestml b/src/test/resources/tutorial/23_rc_alpha.nestml new file mode 100644 index 000000000..9a24b6d77 --- /dev/null +++ b/src/test/resources/tutorial/23_rc_alpha.nestml @@ -0,0 +1,47 @@ +/* + A straight forward implementation of the RC circuit approach. + Extends firing model with an additional refractory state. It is entered directly after a spike is fired. +*/ +neuron rc_refractory: + + state: + V_abs mV = 0mV + alias V_m mV = V_abs + E_L + end + + equations: + V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn + end + + parameter: + E_L mV = -70mV + C_m pF = 250pF + tau_m ms = 10ms + I_syn pA = 10pA + alias V_th mV = -55mV - E_L + alias V_reset mV = -65mV - E_L + refractory_timeout ms = 5ms + refractory_counts integer = 0 + end + + input: + spikes <- spike + end + + output: spike + + update: + if refractory_counts == 0: + integrate(V_abs) + if V_abs > V_th: + V_abs = V_reset + emit_spike() + refractory_counts = steps(refractory_timeout) + end + else: + refractory_counts -= 1 + end + end + + +end \ No newline at end of file From a010a2e79e837ec985366304774498fcf9245ebb Mon Sep 17 00:00:00 2001 From: DimitriPlotnikov Date: Thu, 15 Sep 2016 16:07:09 +0200 Subject: [PATCH 3/3] Update models which are used in the NESTML tutorial --- src/test/resources/tutorial/21_rc_fire.nestml | 9 ++++++--- .../tutorial/22_rc_refractory.nestml | 19 +++++++++++++------ .../resources/tutorial/23_rc_alpha.nestml | 15 +++++++++++++-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/test/resources/tutorial/21_rc_fire.nestml b/src/test/resources/tutorial/21_rc_fire.nestml index c908bf090..95d418b5e 100644 --- a/src/test/resources/tutorial/21_rc_fire.nestml +++ b/src/test/resources/tutorial/21_rc_fire.nestml @@ -7,7 +7,6 @@ neuron rc_fire: state: V_abs mV = 0mV alias V_m mV = V_abs + E_L - end equations: @@ -18,7 +17,7 @@ neuron rc_fire: E_L mV = -70mV C_m pF = 250pF tau_m ms = 10ms - I_syn pA = 0pA + I_syn pA = 10pA alias V_th mV = -55mV - E_L alias V_reset mV = -65mV - E_L end @@ -31,7 +30,11 @@ neuron rc_fire: update: integrate(V_abs) - + if V_abs > V_th: + V_abs = V_reset + emit_spike() + end end + end \ No newline at end of file diff --git a/src/test/resources/tutorial/22_rc_refractory.nestml b/src/test/resources/tutorial/22_rc_refractory.nestml index 6ae79b566..9a24b6d77 100644 --- a/src/test/resources/tutorial/22_rc_refractory.nestml +++ b/src/test/resources/tutorial/22_rc_refractory.nestml @@ -1,6 +1,6 @@ /* A straight forward implementation of the RC circuit approach. - Extends the integrate method with a threshold and fire behaviour. + Extends firing model with an additional refractory state. It is entered directly after a spike is fired. */ neuron rc_refractory: @@ -10,7 +10,7 @@ neuron rc_refractory: end equations: - V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn + V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn end parameter: @@ -20,6 +20,8 @@ neuron rc_refractory: I_syn pA = 10pA alias V_th mV = -55mV - E_L alias V_reset mV = -65mV - E_L + refractory_timeout ms = 5ms + refractory_counts integer = 0 end input: @@ -29,10 +31,15 @@ neuron rc_refractory: output: spike update: - integrate(V_abs) - if V_abs > V_th: - V_abs = V_reset - emit_spike() + if refractory_counts == 0: + integrate(V_abs) + if V_abs > V_th: + V_abs = V_reset + emit_spike() + refractory_counts = steps(refractory_timeout) + end + else: + refractory_counts -= 1 end end diff --git a/src/test/resources/tutorial/23_rc_alpha.nestml b/src/test/resources/tutorial/23_rc_alpha.nestml index 9a24b6d77..e2f4a2d81 100644 --- a/src/test/resources/tutorial/23_rc_alpha.nestml +++ b/src/test/resources/tutorial/23_rc_alpha.nestml @@ -2,14 +2,19 @@ A straight forward implementation of the RC circuit approach. Extends firing model with an additional refractory state. It is entered directly after a spike is fired. */ -neuron rc_refractory: +neuron rc_alpha: state: V_abs mV = 0mV alias V_m mV = V_abs + E_L + g_in pA = 0pA # inputs from the inh conductance end equations: + # alpha function for the g_in + g_in'' = -g_in'/tau_syn_in + g_in' = g_in' - g_in/tau_syn_in + I_syn pA = g_in V_abs' = -1/tau_m * V_abs + 1/C_m*I_syn end @@ -17,7 +22,7 @@ neuron rc_refractory: E_L mV = -70mV C_m pF = 250pF tau_m ms = 10ms - I_syn pA = 10pA + alias V_th mV = -55mV - E_L alias V_reset mV = -65mV - E_L refractory_timeout ms = 5ms @@ -28,6 +33,11 @@ neuron rc_refractory: spikes <- spike end + internal: + tau_syn_in ms = 2ms + PSConInit_I real = 1.0 * e / tau_syn_in + end + output: spike update: @@ -41,6 +51,7 @@ neuron rc_refractory: else: refractory_counts -= 1 end + g_in' += PSConInit_I*spikes.get_sum() end