| 1 | package ArrayBug
|
|---|
| 2 | model IzhikevichNetNeuron "Izhikevich neuron model, simplified version <br><br> <cite>Eugene M. Izhikevich, February 25, 2003</cite>"
|
|---|
| 3 | // Parameters:
|
|---|
| 4 | parameter Real a = 0.02;
|
|---|
| 5 | parameter Real b = 0.2;
|
|---|
| 6 | parameter Real c = -65;
|
|---|
| 7 | parameter Real d = 8;
|
|---|
| 8 | // Variables:
|
|---|
| 9 | Real I;
|
|---|
| 10 | Real V(start = c, fixed = true);
|
|---|
| 11 | Real U(start = b * c, fixed = true);
|
|---|
| 12 | // Connectors:
|
|---|
| 13 | Modelica.Blocks.Interfaces.RealInput IN;
|
|---|
| 14 | Modelica.Blocks.Interfaces.RealOutput OUT;
|
|---|
| 15 | equation
|
|---|
| 16 | IN = I;
|
|---|
| 17 | OUT = V / 0.5;
|
|---|
| 18 | //
|
|---|
| 19 | // Eugene M. Izhikevich, February 25, 2003
|
|---|
| 20 | der(V) = 0.04 * V ^ 2 + 5 * V + 140 - U + I;
|
|---|
| 21 | der(U) = a * (b * V - U);
|
|---|
| 22 | when V >= 30 then
|
|---|
| 23 | reinit(V, c);
|
|---|
| 24 | reinit(U, U + d);
|
|---|
| 25 | end when;
|
|---|
| 26 | //
|
|---|
| 27 | end IzhikevichNetNeuron;
|
|---|
| 28 |
|
|---|
| 29 | model IzhNetNeuronTest1 "Basic test of IzhNetNeuron class, working"
|
|---|
| 30 | Modelica.Blocks.Sources.Pulse pulse(amplitude = 60, width = 50, period = 30, startTime = 20);
|
|---|
| 31 | IzhikevichNetNeuron neuron1;
|
|---|
| 32 | IzhikevichNetNeuron neuron2;
|
|---|
| 33 | equation
|
|---|
| 34 | // Connect pulse with the first.
|
|---|
| 35 | connect(pulse.y, neuron1.IN);
|
|---|
| 36 | // Connect t.
|
|---|
| 37 | connect(neuron1.OUT, neuron2.IN);
|
|---|
| 38 | end IzhNetNeuronTest1;
|
|---|
| 39 |
|
|---|
| 40 | model IzhNetNeuronTest2 "Another test of IzhNetNeuron class, this time using arrays - not working in OM"
|
|---|
| 41 | Modelica.Blocks.Sources.Pulse pulse(amplitude = 60, width = 50, period = 30, startTime = 20);
|
|---|
| 42 | parameter Integer num_neurons = 2;
|
|---|
| 43 | IzhikevichNetNeuron[num_neurons] neuron;
|
|---|
| 44 | equation
|
|---|
| 45 | // Connect pulse with the first.
|
|---|
| 46 | connect(pulse.y, neuron[1].IN);
|
|---|
| 47 | // Connect others.
|
|---|
| 48 | for i in 2:num_neurons loop
|
|---|
| 49 | connect(neuron[i - 1].OUT, neuron[i].IN);
|
|---|
| 50 | end for;
|
|---|
| 51 | end IzhNetNeuronTest2;
|
|---|
| 52 | end ArrayBug;
|
|---|