|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# test_rate_neurons_mpi.py |
| 4 | +# |
| 5 | +# This file is part of NEST. |
| 6 | +# |
| 7 | +# Copyright (C) 2004 The NEST Initiative |
| 8 | +# |
| 9 | +# NEST is free software: you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU General Public License as published by |
| 11 | +# the Free Software Foundation, either version 2 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# NEST is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU General Public License for more details. |
| 18 | +# |
| 19 | +# You should have received a copy of the GNU General Public License |
| 20 | +# along with NEST. If not, see <http://www.gnu.org/licenses/>. |
| 21 | + |
| 22 | +import pytest |
| 23 | +from mpi_test_wrapper import MPITestAssertEqual |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.skipif_incompatible_mpi |
| 27 | +@pytest.mark.skipif_missing_threads |
| 28 | +@pytest.mark.skipif_missing_gsl |
| 29 | +@pytest.mark.parametrize( |
| 30 | + "neuron_model, params1, params2, synspec", |
| 31 | + [ |
| 32 | + [ |
| 33 | + "lin_rate_ipn", |
| 34 | + {"mu": 0, "sigma": 0, "rate": 20}, |
| 35 | + {"mu": 0, "sigma": 0}, |
| 36 | + {"synapse_model": "rate_connection_instantaneous", "weight": 5}, |
| 37 | + ], |
| 38 | + [ |
| 39 | + "siegert_neuron", |
| 40 | + {"rate": 20}, |
| 41 | + {}, |
| 42 | + {"synapse_model": "diffusion_connection", "diffusion_factor": 2, "drift_factor": 4}, |
| 43 | + ], |
| 44 | + ], |
| 45 | +) |
| 46 | +@MPITestAssertEqual([1, 2], debug=False) |
| 47 | +def test_rate_neurons_mpi(neuron_model, params1, params2, synspec): |
| 48 | + """ |
| 49 | + Test that rate neurons are simulated correctly in parallel. |
| 50 | +
|
| 51 | + The test is performed on the multimeter data recorded to MULTI_LABEL during the simulation. |
| 52 | + """ |
| 53 | + |
| 54 | + import nest |
| 55 | + |
| 56 | + total_vps = 4 |
| 57 | + h = 0.1 |
| 58 | + |
| 59 | + nest.SetKernelStatus( |
| 60 | + { |
| 61 | + "total_num_virtual_procs": total_vps, |
| 62 | + "resolution": h, |
| 63 | + "use_wfr": True, |
| 64 | + "wfr_tol": 0.0001, |
| 65 | + "wfr_interpolation_order": 3, |
| 66 | + "wfr_max_iterations": 10, |
| 67 | + "wfr_comm_interval": 1.0, |
| 68 | + } |
| 69 | + ) |
| 70 | + |
| 71 | + neuron1 = nest.Create(neuron_model, params=params1) |
| 72 | + neuron2 = nest.Create(neuron_model, params=params2) |
| 73 | + mm = nest.Create( |
| 74 | + "multimeter", |
| 75 | + params={ |
| 76 | + "record_from": ["rate"], |
| 77 | + "interval": 1, |
| 78 | + "record_to": "ascii", |
| 79 | + "precision": 8, |
| 80 | + "time_in_steps": True, |
| 81 | + "label": MULTI_LABEL.format(nest.num_processes), # noqa: F821 |
| 82 | + }, |
| 83 | + ) |
| 84 | + |
| 85 | + nest.Connect(mm, neuron1 + neuron2) |
| 86 | + |
| 87 | + nest.Connect(neuron1, neuron2, syn_spec=synspec) |
| 88 | + |
| 89 | + nest.Simulate(11) |
0 commit comments