Skip to content

Commit

Permalink
add/fix checks that inline expressions, parameters and internals cann…
Browse files Browse the repository at this point in the history
…ot be assigned to
  • Loading branch information
C.A.P. Linssen committed Sep 14, 2023
1 parent 4849881 commit af78bc8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
14 changes: 9 additions & 5 deletions models/neurons/ignore_and_fire.nestml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ neuron ignore_and_fire:

state:
phase real = 1. # relative time to next spike (in (0,1])
phase_steps integer = firing_period_steps
phase_steps integer = firing_period_steps / 2 # start halfway through the interval by default

parameters:
firing_rate Bq = 10. Bq # firing rate
Expand All @@ -38,12 +38,16 @@ neuron ignore_and_fire:

update:
res real = resolution()
println("-----")
println("resolution: {res}")
println("firing_period_steps: {firing_period_steps}")
println("phase_steps: {phase_steps}")
integrate_odes()
if phase_steps == 0:
if phase_steps >= firing_period_steps - 1:
emit_spike()
phase_steps = firing_period_steps - 1
#println("spike")
phase_steps = 0
println("emited spike")
else:
phase_steps -= 1
phase_steps += 1

phase = phase_steps / firing_period_steps
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// #define DEBUG 1
#define DEBUG 1
{#
NeuronClass.jinja2
Expand Down Expand Up @@ -319,16 +319,17 @@ void {{neuronName}}::init_state_(const Node& proto)
}
{%- endif %}

{%- if not nest_version.startswith("v2") %}
void {{neuronName}}::calibrate_time( const nest::TimeConverter& tc )
{
LOG( nest::M_WARNING,
"{{neuronName}}",
"Simulation resolution has changed. Internal state and parameters of the"
"model have been reset!" );
"Simulation resolution has changed. Internal state and parameters of the model have been reset!" );

init_state_internal_();
}

{%- endif %}
void {{neuronName}}::init_state_internal_()
{
#ifdef DEBUG
Expand All @@ -355,6 +356,8 @@ void {{neuronName}}::init_state_internal_()
{%- endfilter %}
{%- endif %}

recompute_internal_variables();

{%- if neuron.get_state_symbols()|length > 0 %}
// initial values for state variables
{%- filter indent(2) %}
Expand All @@ -365,6 +368,7 @@ void {{neuronName}}::init_state_internal_()
{%- endfilter %}
{%- endif %}


{%- if paired_synapse is defined %}
// state variables for archiving state for paired synapse
n_incoming_ = 0;
Expand Down Expand Up @@ -496,6 +500,7 @@ void {{neuronName}}::pre_run_hook() {
{%- endif %}
B_.logger_.init();

// parameters might have changed -- recompute internals
recompute_internal_variables();

// buffers B_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ public:
// Initialization functions
// -------------------------------------------------------------------------

{%- if not nest_version.startswith("v2") %}
void calibrate_time( const nest::TimeConverter& tc ) override;
{%- endif %}

protected:
{%- if paired_synapse is defined %}
Expand Down
2 changes: 2 additions & 0 deletions tests/nest_tests/test_ignore_and_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ def test_ignore_and_fire_with_stdp(self, resolution: float):
pre_neuron = nest.Create(self.neuron_model_name)
post_neuron = nest.Create(self.neuron_model_name)
pre_neuron.firing_rate = 10.
pre_neuron.phase_steps = 50
post_neuron.firing_rate = 100.
post_neuron.phase_steps = 5
pre_sr = nest.Create("spike_recorder")
post_sr = nest.Create("spike_recorder")
nest.Connect(pre_neuron, pre_sr)
Expand Down

0 comments on commit af78bc8

Please sign in to comment.