/*
 *  test_hh_cond_exp_traub.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_hh_cond_exp_traub - sli script for overall test of hh_cond_exp_traub model

    Synopsis: (test_hh_cond_exp_traub) run -> 

    Description:

    Author:  
    SeeAlso: 
*/

(unittest) run
/unittest using

0.1 /h Set

ResetKernel

0 << 
      /local_num_threads 1 
      /resolution h
    >> SetStatus

%% Test: Node creation

/hh_cond_exp_traub Create /neuron Set

%% Test: Set/GetStatus

<< /V_m 10.0
   /g_Na 19000.0
   /g_K	  5000.0
   /g_L	     9.0
   /C_m	   100.0
   /E_Na    40.0
   /E_K    -80.0   
   /E_L	   -70.0
   %/U_tr   -60.0
   /E_ex     1.0
   /E_in   -90.0
   /tau_syn_ex 0.3
   /tau_syn_in 3.0
   /I_e	     1.0
>> /hh_params Set

neuron hh_params SetStatus
neuron GetStatus /result Set

result /V_m  get 6 ToUnitTestPrecision 10 eq assert_or_die
result /g_Na get 6 ToUnitTestPrecision 19000 eq assert_or_die
result /g_K  get 6 ToUnitTestPrecision 5000 eq assert_or_die
result /g_L  get 6 ToUnitTestPrecision 9 eq assert_or_die
result /C_m  get 6 ToUnitTestPrecision 100 eq assert_or_die
result /E_Na get 6 ToUnitTestPrecision 40 eq assert_or_die
result /E_K  get 6 ToUnitTestPrecision -80 eq assert_or_die
result /E_L  get 6 ToUnitTestPrecision -70 eq assert_or_die
result /E_ex get 6 ToUnitTestPrecision  1 eq assert_or_die
result /E_in get 6 ToUnitTestPrecision -90 eq assert_or_die
result /tau_syn_ex get 6 ToUnitTestPrecision 0.3 eq assert_or_die
result /tau_syn_in get 6 ToUnitTestPrecision 3 eq assert_or_die
result /I_e get 6 ToUnitTestPrecision 1 eq assert_or_die

%% Test: Handling of events

% CurrentEvent
/dc_generator Create /dc_gen Set
dc_gen << /amplitude 100.0 >> SetStatus

% SpikeEvent
/spike_generator Create /sg Set
sg << /precise_times false /spike_times [0.1 1.2] >> SetStatus

% PotentialRequest
/voltmeter Create /vm Set
vm << /withtime true  /time_in_steps true /interval h >> SetStatus

/spike_detector Create /sp_det Set
sp_det << /withtime true /withgid true /time_in_steps true >> SetStatus

% SynapticConductanceRequest
/conductancemeter Create /cm Set
cm << /withtime true /time_in_steps true /interval h >> SetStatus

sg neuron Connect
dc_gen neuron Connect
vm neuron Connect
cm neuron Connect
neuron sp_det Connect

%% Test: Simulation
5 Simulate

vm [/events [/times /V_m]] get cva   % array of recorded data
6 ToUnitTestPrecision Transpose ==                    % to precision of reference

cm [/events [/times /g_exc /g_inh]] get cva   % array of recorded data
6 ToUnitTestPrecision Transpose ==                    % to precision of reference

%% What about spike detector, is that included in the voltmeter output????