Пример #1
0
void
nest::iaf_tum_2000::calibrate()
{
  B_.logger_.init();

  const double h = Time::get_resolution().get_ms();

  // numbering of state vaiables: i_0 = 0, i_syn_ = 1, V_m_ = 2

  // commented out propagators: forward Euler
  // needed to exactly reproduce Tsodyks network

  // these P are independent
  V_.P11ex_ = std::exp( -h / P_.tau_ex_ );
  // P11ex_ = 1.0-h/tau_ex_;

  V_.P11in_ = std::exp( -h / P_.tau_in_ );
  // P11in_ = 1.0-h/tau_in_;

  V_.P22_ = std::exp( -h / P_.Tau_ );
  // P22_ = 1.0-h/Tau_;

  // these are determined according to a numeric stability criterion
  V_.P21ex_ = propagator_32( P_.tau_ex_, P_.Tau_, P_.C_, h );
  V_.P21in_ = propagator_32( P_.tau_in_, P_.Tau_, P_.C_, h );

  // P21ex_ = h/C_;
  // P21in_ = h/C_;

  V_.P20_ = P_.Tau_ / P_.C_ * ( 1.0 - V_.P22_ );
  // P20_ = h/C_;

  // TauR specifies the length of the absolute refractory period as
  // a double_t in ms. The grid based iaf_tum_2000 can only handle refractory
  // periods that are integer multiples of the computation step size (h).
  // To ensure consistency with the overall simulation scheme such conversion
  // should be carried out via objects of class nest::Time. The conversion
  // requires 2 steps:
  //     1. A time object r is constructed defining  representation of
  //        TauR in tics. This representation is then converted to computation time
  //        steps again by a strategy defined by class nest::Time.
  //     2. The refractory time in units of steps is read out get_steps(), a member
  //        function of class nest::Time.
  //
  // Choosing a TauR that is not an integer multiple of the computation time
  // step h will leed to accurate (up to the resolution h) and self-consistent
  // results. However, a neuron model capable of operating with real valued spike
  // time may exhibit a different effective refractory time.
  //

  V_.RefractoryCountsAbs_ = Time( Time::ms( P_.tau_ref_abs_ ) ).get_steps();

  V_.RefractoryCountsTot_ = Time( Time::ms( P_.tau_ref_tot_ ) ).get_steps();

  if ( V_.RefractoryCountsAbs_ < 1 )
    throw BadProperty( "Absolute refractory time must be at least one time step." );

  if ( V_.RefractoryCountsTot_ < 1 )
    throw BadProperty( "Total refractory time must be at least one time step." );
}
void
iaf_psc_alpha::calibrate()
{
  // ensures initialization in case mm connected after Simulate
  B_.logger_.init();

  const double h = Time::get_resolution().get_ms();

  // these P are independent
  V_.P11_ex_ = V_.P22_ex_ = std::exp( -h / P_.tau_ex_ );
  V_.P11_in_ = V_.P22_in_ = std::exp( -h / P_.tau_in_ );

  V_.P33_ = std::exp( -h / P_.Tau_ );

  V_.expm1_tau_m_ = numerics::expm1( -h / P_.Tau_ );

  // these depend on the above. Please do not change the order.
  V_.P30_ = -P_.Tau_ / P_.C_ * numerics::expm1( -h / P_.Tau_ );
  V_.P21_ex_ = h * V_.P11_ex_;
  V_.P21_in_ = h * V_.P11_in_;

  // these are determined according to a numeric stability criterion
  V_.P31_ex_ = propagator_31( P_.tau_ex_, P_.Tau_, P_.C_, h );
  V_.P32_ex_ = propagator_32( P_.tau_ex_, P_.Tau_, P_.C_, h );
  V_.P31_in_ = propagator_31( P_.tau_in_, P_.Tau_, P_.C_, h );
  V_.P32_in_ = propagator_32( P_.tau_in_, P_.Tau_, P_.C_, h );

  V_.EPSCInitialValue_ = 1.0 * numerics::e / P_.tau_ex_;
  V_.IPSCInitialValue_ = 1.0 * numerics::e / P_.tau_in_;

  // TauR specifies the length of the absolute refractory period as
  // a double in ms. The grid based iaf_psc_alpha can only handle refractory
  // periods that are integer multiples of the computation step size (h).
  // To ensure consistency with the overall simulation scheme such conversion
  // should be carried out via objects of class nest::Time. The conversion
  // requires 2 steps:
  //     1. A time object is constructed defining representation of
  //        TauR in tics. This representation is then converted to computation
  //        time steps again by a strategy defined by class nest::Time.
  //     2. The refractory time in units of steps is read out get_steps(), a
  //        member function of class nest::Time.
  //
  // The definition of the refractory period of the iaf_psc_alpha is consistent
  // the one of iaf_psc_alpha_ps.
  //
  // Choosing a TauR that is not an integer multiple of the computation time
  // step h will lead to accurate (up to the resolution h) and self-consistent
  // results. However, a neuron model capable of operating with real valued
  // spike time may exhibit a different effective refractory time.

  V_.RefractoryCounts_ = Time( Time::ms( P_.TauR_ ) ).get_steps();
  // since t_ref_ >= 0, this can only fail in error
  assert( V_.RefractoryCounts_ >= 0 );
}
void
nest::iaf_psc_alpha_canon::calibrate()
{
  B_.logger_.init();

  V_.h_ms_ = Time::get_resolution().get_ms();

  V_.PSCInitialValue_ = 1.0 * numerics::e / P_.tau_syn_;

  V_.gamma_ = 1 / P_.c_m_ / ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ );
  V_.gamma_sq_ = 1 / P_.c_m_ / ( ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ )
                                 * ( 1 / P_.tau_syn_ - 1 / P_.tau_m_ ) );

  // pre-compute matrix for full time step
  V_.expm1_tau_m_ = numerics::expm1( -V_.h_ms_ / P_.tau_m_ );
  V_.expm1_tau_syn_ = numerics::expm1( -V_.h_ms_ / P_.tau_syn_ );
  V_.P30_ = -P_.tau_m_ / P_.c_m_ * V_.expm1_tau_m_;
  // these are determined according to a numeric stability criterion
  V_.P31_ = propagator_31( P_.tau_syn_, P_.tau_m_, P_.c_m_, V_.h_ms_ );
  V_.P32_ = propagator_32( P_.tau_syn_, P_.tau_m_, P_.c_m_, V_.h_ms_ );

  // t_ref_ is the refractory period in ms
  // refractory_steps_ is the duration of the refractory period in whole
  // steps, rounded down
  V_.refractory_steps_ = Time( Time::ms( P_.t_ref_ ) ).get_steps();
  // since t_ref_ >= sim step size, this can only fail in error
  assert( V_.refractory_steps_ >= 1 );
}
void
nest::iaf_psc_exp_multisynapse::calibrate()
{
  // ensures initialization in case mm connected after Simulate
  B_.logger_.init();

  const double h = Time::get_resolution().get_ms();

  V_.P11_syn_.resize( P_.n_receptors_() );
  V_.P21_syn_.resize( P_.n_receptors_() );

  S_.i_syn_.resize( P_.n_receptors_() );

  B_.spikes_.resize( P_.n_receptors_() );

  V_.P22_ = std::exp( -h / P_.Tau_ );
  V_.P20_ = P_.Tau_ / P_.C_ * ( 1.0 - V_.P22_ );

  for ( size_t i = 0; i < P_.n_receptors_(); i++ )
  {
    V_.P11_syn_[ i ] = std::exp( -h / P_.tau_syn_[ i ] );
    // these are determined according to a numeric stability criterion
    V_.P21_syn_[ i ] = propagator_32( P_.tau_syn_[ i ], P_.Tau_, P_.C_, h );

    B_.spikes_[ i ].resize();
  }

  V_.RefractoryCounts_ = Time( Time::ms( P_.refractory_time_ ) ).get_steps();
}
void
nest::gif_psc_exp_multisynapse::calibrate()
{
  B_.logger_.init();

  const double h = Time::get_resolution().get_ms();
  V_.rng_ = kernel().rng_manager.get_rng( get_thread() );

  const double tau_m = P_.c_m_ / P_.g_L_;

  V_.P33_ = std::exp( -h / tau_m );
  V_.P30_ = -1 / P_.c_m_ * numerics::expm1( -h / tau_m ) * tau_m;
  V_.P31_ = -numerics::expm1( -h / tau_m );

  V_.RefractoryCounts_ = Time( Time::ms( P_.t_ref_ ) ).get_steps();
  // since t_ref_ >= 0, this can only fail in error
  assert( V_.RefractoryCounts_ >= 0 );


  // initializing adaptation (stc/sfa) variables
  V_.P_sfa_.resize( P_.tau_sfa_.size(), 0.0 );
  V_.P_stc_.resize( P_.tau_stc_.size(), 0.0 );

  for ( size_t i = 0; i < P_.tau_sfa_.size(); i++ )
  {
    V_.P_sfa_[ i ] = std::exp( -h / P_.tau_sfa_[ i ] );
  }
  S_.sfa_elems_.resize( P_.tau_sfa_.size(), 0.0 );

  for ( size_t i = 0; i < P_.tau_stc_.size(); i++ )
  {
    V_.P_stc_[ i ] = std::exp( -h / P_.tau_stc_[ i ] );
  }
  S_.stc_elems_.resize( P_.tau_stc_.size(), 0.0 );

  V_.P11_syn_.resize( P_.n_receptors_() );
  V_.P21_syn_.resize( P_.n_receptors_() );

  S_.i_syn_.resize( P_.n_receptors_() );

  B_.spikes_.resize( P_.n_receptors_() );

  for ( size_t i = 0; i < P_.n_receptors_(); i++ )
  {
    V_.P11_syn_[ i ] = std::exp( -h / P_.tau_syn_[ i ] );
    V_.P21_syn_[ i ] = propagator_32( P_.tau_syn_[ i ], tau_m, P_.c_m_, h );

    B_.spikes_[ i ].resize();
  }
}
void
iaf_psc_alpha_multisynapse::calibrate()
{
  B_.logger_.init(); // ensures initialization in case mm connected after Simulate

  const double h = Time::get_resolution().get_ms();

  P_.receptor_types_.resize( P_.num_of_receptors_ );
  for ( size_t i = 0; i < P_.num_of_receptors_; i++ )
  {
    P_.receptor_types_[ i ] = i + 1;
  }

  V_.P11_syn_.resize( P_.num_of_receptors_ );
  V_.P21_syn_.resize( P_.num_of_receptors_ );
  V_.P22_syn_.resize( P_.num_of_receptors_ );
  V_.P31_syn_.resize( P_.num_of_receptors_ );
  V_.P32_syn_.resize( P_.num_of_receptors_ );

  S_.y1_syn_.resize( P_.num_of_receptors_ );
  S_.y2_syn_.resize( P_.num_of_receptors_ );

  V_.PSCInitialValues_.resize( P_.num_of_receptors_ );

  B_.spikes_.resize( P_.num_of_receptors_ );

  V_.P33_ = std::exp( -h / P_.Tau_ );
  V_.P30_ = 1 / P_.C_ * ( 1 - V_.P33_ ) * P_.Tau_;

  for ( size_t i = 0; i < P_.num_of_receptors_; i++ )
  {
    V_.P11_syn_[ i ] = V_.P22_syn_[ i ] = std::exp( -h / P_.tau_syn_[ i ] );
    V_.P21_syn_[ i ] = h * V_.P11_syn_[ i ];

    // these are determined according to a numeric stability criterion
    V_.P31_syn_[ i ] = propagator_31( P_.tau_syn_[ i ], P_.Tau_, P_.C_, h );
    V_.P32_syn_[ i ] = propagator_32( P_.tau_syn_[ i ], P_.Tau_, P_.C_, h );

    V_.PSCInitialValues_[ i ] = 1.0 * numerics::e / P_.tau_syn_[ i ];
    B_.spikes_[ i ].resize();
  }

  Time r = Time::ms( P_.TauR_ );
  V_.RefractoryCounts_ = r.get_steps();

  if ( V_.RefractoryCounts_ < 1 )
    throw BadProperty( "Absolute refractory time must be at least one time step." );
}
void
iaf_psc_alpha_multisynapse::calibrate()
{
  // ensures initialization in case mm connected after Simulate
  B_.logger_.init();

  const double h = Time::get_resolution().get_ms();

  V_.P11_syn_.resize( P_.n_receptors_() );
  V_.P21_syn_.resize( P_.n_receptors_() );
  V_.P22_syn_.resize( P_.n_receptors_() );
  V_.P31_syn_.resize( P_.n_receptors_() );
  V_.P32_syn_.resize( P_.n_receptors_() );

  S_.y1_syn_.resize( P_.n_receptors_() );
  S_.y2_syn_.resize( P_.n_receptors_() );

  V_.PSCInitialValues_.resize( P_.n_receptors_() );

  B_.spikes_.resize( P_.n_receptors_() );

  V_.P33_ = std::exp( -h / P_.Tau_ );
  V_.P30_ = 1 / P_.C_ * ( 1 - V_.P33_ ) * P_.Tau_;

  for ( size_t i = 0; i < P_.n_receptors_(); i++ )
  {
    V_.P11_syn_[ i ] = V_.P22_syn_[ i ] = std::exp( -h / P_.tau_syn_[ i ] );
    V_.P21_syn_[ i ] = h * V_.P11_syn_[ i ];

    // these are determined according to a numeric stability criterion
    V_.P31_syn_[ i ] = propagator_31( P_.tau_syn_[ i ], P_.Tau_, P_.C_, h );
    V_.P32_syn_[ i ] = propagator_32( P_.tau_syn_[ i ], P_.Tau_, P_.C_, h );

    V_.PSCInitialValues_[ i ] = 1.0 * numerics::e / P_.tau_syn_[ i ];
    B_.spikes_[ i ].resize();
  }

  V_.RefractoryCounts_ = Time( Time::ms( P_.refractory_time_ ) ).get_steps();
}