/*
 *  test_sinusoidal_poisson_generator_4.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_sinusoidal_poisson_generator_4 - Test parallel generation of sinusoidally modulate Poissonian trains with individual spike trains

Synopsis: nest_indirect test_sinusoidal_poisson_generator_4.sli -> -

Description:
   Creates a sinusoidally modulated Poisson generator emitting
   individual spike trains to each of its targets and sends spikes to
   spike detector. Identical to ..._2, but with single generator, not one per VP.

Author:  December 2012, May 2013, Plesser, based on test_poisson_generator.sli

See also: test_sinusoidal_poisson_generator_{1,2,3,5,6}, test_sinusoidal_poisson_generator_nostat
*/

(unittest) run
/unittest using


/total_vps 4 def

% run simulation with or without individual trains
% bool spg_tester -> spike detector
/spg_tester
{
  /individual Set

  /nodes total_vps 2 mul def  

  % set resolution and total/local number of threads
  0
  <<
  /resolution  0.1
  /total_num_virtual_procs total_vps
  >> SetStatus

  /sinusoidal_poisson_generator
  << 
    /dc 1000.
    /ac 1000.
    /freq 100.
    /individual_spike_trains individual
  >> SetDefaults

  /gen /sinusoidal_poisson_generator Create def
  /sd /spike_detector << /record_to [/memory] 
                         /withgid true 
                         /withtime true 
                      >> Create def
  /pnet [ nodes ] { ; /parrot_neuron Create } Table def

  gen pnet DivergentConnect
  pnet sd ConvergentConnect
  
  10. Simulate

  sd
} def

% second test: individual spike trains, equality for different splits
[1 2 4]
{
  /sd true spg_tester def

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