/*
 *  test_rate_neurons_mpi.sli
 *
 *  This file is part of NEST.
 *
 *  Copyright (C) 2004 The NEST Initiative
 *
 *  NEST is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  NEST is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with NEST.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


/* BeginDocumentation
    Name: testsuite::test_rate_neurons_mpi - Test rate model neurons in parallel

    Synopsis: (test_rate_neurons_mpi) run -> - 

    Description:
    test_rate_neurons_mpi.sli checks if simulations with rate neurons
    (lin_rate_ipn, siegert_neuron) and rate connections
    (rate_connection_instantaneous, diffusion_connection) work in parallel.
    
    Author:  Jan Hahne
    SeeAlso: lin_rate_ipn, rate_connection_instantaneous, siegert_neuron, diffusion_connection
*/

(unittest) run
/unittest using

% The following test needs the model siegert_neuron, so
% this test should only run if we have GSL
skip_if_not_threaded
skip_if_without_gsl

/total_vps 4 def

[1 2 4]
{
  0.1 /h Set
  
  0 << 
        /total_num_virtual_procs total_vps 
        /resolution h
        /use_wfr true
        /wfr_tol 0.0001
        /wfr_interpolation_order 3
        /wfr_max_iterations 10
        /wfr_comm_interval 1.0
    >> SetStatus
      
  /lin_rate_ipn << /mean 0.0 /std 0.0 /rate 20.0 >> Create /lin_neuron1 Set
  /siegert_neuron << /rate 20.0 >> Create /siegert_neuron1 Set
  /lin_rate_ipn << /mean 0.0 /std 0.0 >> Create /lin_neuron2 Set
  /siegert_neuron Create /siegert_neuron2 Set
  
  /mm /multimeter << /record_from [/rate]
             /record_to [/memory]
             /interval 1.0
             /withgid true 
             /withtime true >> Create def
  
  mm lin_neuron1 Connect
  mm lin_neuron2 Connect
  mm siegert_neuron1 Connect
  mm siegert_neuron2 Connect
  
  [lin_neuron1] [lin_neuron2]
  << /rule /one_to_one >> 
  << /model /rate_connection_instantaneous /weight 5.0 >> 
  Connect
  
  [siegert_neuron1] [siegert_neuron2]
  << /rule /one_to_one >> 
  << /model /diffusion_connection /diffusion_factor 2.0 /drift_factor 4.0 >> 
  Connect
  
  11 Simulate

  % get events, replace vectors with SLI arrays    
  /ev mm /events get def
  ev keys { /k Set ev dup k get cva k exch put } forall
  ev 

} distributed_process_invariant_events_assert_or_die
