From ad22c95e7f6a5ab9382a7897626e4d81b3bc6baf Mon Sep 17 00:00:00 2001 From: alessiomarta <81438612+alessiomarta@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:16:27 +0100 Subject: [PATCH] Updated code to Nest 3.1 --- CMakeLists.txt | 127 +- cerebmodule.cpp | 173 +-- cerebmodule.h | 35 +- eglif_cond_alpha_multisyn.cpp | 1237 +++++++--------- eglif_cond_alpha_multisyn.h | 2419 ++++++++++++++++---------------- stdp_connection_alpha.cpp | 6 +- stdp_connection_alpha.h | 15 +- stdp_connection_cosexp.cpp | 6 +- stdp_connection_cosexp.h | 14 +- stdp_connection_sinexp.cpp | 6 +- stdp_connection_sinexp.h | 14 +- volume_transmitter_alberto.cpp | 28 +- volume_transmitter_alberto.h | 12 +- 13 files changed, 1866 insertions(+), 2226 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eed88e9..8dd1ca3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ -# Cereb/CMakeLists.txt + +# cereb/CMakeLists.txt # # This file is part of NEST. # @@ -17,11 +18,10 @@ # You should have received a copy of the GNU General Public License # along with NEST. If not, see . -cmake_minimum_required( VERSION 2.8.12 ) - # This CMakeLists.txt is configured to build your external module for NEST. For # illustrative reasons this module is called 'my' (change SHORT_NAME to your -# preferred module name). NEST requires you to extend the 'SLIModule' and provide a module header +# preferred module name). NEST requires you to extend the 'SLIModule' (see +# mymodule.h and mymodule.cpp as an example) and provide a module header # (see MODULE_HEADER). The subsequent instructions # # The configuration requires a compiled and installed NEST; if `nest-config` is @@ -30,23 +30,30 @@ cmake_minimum_required( VERSION 2.8.12 ) # For more informations on how to extend and use your module see: # https://nest.github.io/nest-simulator/extension_modules -# 1) Name your module here, i.e. add later with -Dexternal-modules=my: -set( SHORT_NAME cereb ) +# 1) Name your module here, i.e. add later with -Dexternal-modules=${moduleName}: +set( SHORT_NAME cerebmodule ) # the complete module name is here: -set( MODULE_NAME ${SHORT_NAME}module ) +set( MODULE_NAME ${SHORT_NAME} ) # 2) Add all your sources here set( MODULE_SOURCES - cerebmodule.h cerebmodule.cpp + + + eglif_cond_alpha_multisyn.cpp eglif_cond_alpha_multisyn.h + + mynames.h mynames.cpp + volume_transmitter_alberto.h volume_transmitter_alberto.cpp - eglif_cond_alpha_multisyn.h eglif_cond_alpha_multisyn.cpp + + stdp_connection_alpha.h stdp_connection_alpha.cpp + stdp_connection_cosexp.h stdp_connection_cosexp.cpp + stdp_connection_sinexp.h stdp_connection_sinexp.cpp - stdp_connection_alpha.h stdp_connection_alpha.cpp - iSTDP.h - Sgritta2017.h - mynames.h mynames.cpp + + cerebmodule.h cerebmodule.cpp + ) # 3) We require a header name like this: @@ -58,9 +65,6 @@ set( MODULE_VERSION_MAJOR 1 ) set( MODULE_VERSION_MINOR 0 ) set( MODULE_VERSION "${MODULE_VERSION_MAJOR}.${MODULE_VERSION_MINOR}" ) -# 5) Leave the rest as is. All files in `sli` will be installed to -# `share/nest/sli/`, so that NEST will find the during initialization. - # Leave the call to "project(...)" for after the compiler is determined. # Set the `nest-config` executable to use during configuration. @@ -100,27 +104,11 @@ set( CMAKE_CXX_COMPILER "${NEST_COMPILER}" ) project( ${MODULE_NAME} CXX ) -# Get the Python executable (for help generation). -execute_process( - COMMAND ${NEST_CONFIG} --python-executable - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE PYTHON_EXECUTABLE - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -# Get the Python executable (for help generation). -execute_process( - COMMAND ${NEST_CONFIG} --python-version - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE PYTHON_VERSION_STRING - OUTPUT_STRIP_TRAILING_WHITESPACE -) - # Get the install prefix. execute_process( COMMAND ${NEST_CONFIG} --prefix RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE NEST_INSTALL_PREFIX + OUTPUT_VARIABLE NEST_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -177,40 +165,30 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -# Get the data install dir. -execute_process( - COMMAND ${NEST_CONFIG} --datadir - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE NEST_INSTALL_DATADIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -# Get the documentation install dir. -execute_process( - COMMAND ${NEST_CONFIG} --docdir - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE NEST_INSTALL_DOCDIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) - -# Get the library install dir. -execute_process( - COMMAND ${NEST_CONFIG} --libdir - RESULT_VARIABLE RES_VAR - OUTPUT_VARIABLE NEST_LIBDIR - OUTPUT_STRIP_TRAILING_WHITESPACE -) - # on OS X set( CMAKE_MACOSX_RPATH ON ) -# Use the NEST_INSTALL_* variables as CMAKE_INSTALL_*, if not set explicitly. -if ( "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr/local" ) - set( CMAKE_INSTALL_PREFIX "${NEST_INSTALL_PREFIX}" CACHE STRING "Install path prefix, prepended onto install directories." FORCE ) + +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + # Use the `NEST_PREFIX` as `CMAKE_INSTALL_PREFIX`. + set( CMAKE_INSTALL_PREFIX ${NEST_PREFIX} CACHE STRING "Install path prefix, prepended onto install directories." FORCE ) + # Retrieve libs folder in nest + execute_process( + COMMAND ${NEST_CONFIG} --libdir + RESULT_VARIABLE RES_VAR + OUTPUT_VARIABLE NEST_LIBDIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + # Append lib/nest to the install_dir set( CMAKE_INSTALL_LIBDIR "${NEST_LIBDIR}/nest" CACHE STRING "object code libraries (lib/nest or lib64/nest or lib//nest on Debian)" FORCE ) - set( CMAKE_INSTALL_DOCDIR "${NEST_INSTALL_DOCDIR}" CACHE STRING "documentation root (DATAROOTDIR/doc/nest)" FORCE ) - set( CMAKE_INSTALL_DATADIR "${NEST_INSTALL_DATADIR}" CACHE STRING "read-only architecture-independent data (DATAROOTDIR/nest)" FORCE ) -endif () +else() + # Check If CMAKE_INSTALL_PREFIX is not empty string + if("${CMAKE_INSTALL_PREFIX}" STREQUAL "") + message(FATAL_ERROR "CMAKE_INSTALL_PREFIX cannot be an empty string") + endif() + # Set lib folder to the given install_dir + set( CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX} CACHE STRING "object code libraries (lib/nest or lib64/nest or lib//nest on Debian)" FORCE ) +endif() + include( GNUInstallDirs ) @@ -219,7 +197,7 @@ set( CPACK_GENERATOR TGZ ) set( CPACK_SOURCE_GENERATOR TGZ ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "NEST Module ${MODULE_NAME}" ) -set( CPACK_PACKAGE_VENDOR "NEST Initiative (https://www.nest-initiative.org/)" ) +set( CPACK_PACKAGE_VENDOR "NEST Initiative (http://www.nest-initiative.org/)" ) set( CPACK_PACKAGE_VERSION_MAJOR ${MODULE_VERSION_MAJOR} ) set( CPACK_PACKAGE_VERSION_MINOR ${MODULE_VERSION_MINOR} ) @@ -282,12 +260,6 @@ set_target_properties( ${MODULE_NAME}_lib LINK_FLAGS "${NEST_LIBS}" OUTPUT_NAME ${MODULE_NAME} ) -# Install library, header and sli init files. -install( TARGETS ${MODULE_NAME}_lib DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -install( FILES ${MODULE_HEADER} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${MODULE_NAME} ) -install( DIRECTORY sli DESTINATION ${CMAKE_INSTALL_DATADIR} ) - - message( "" ) message( "-------------------------------------------------------" ) message( "${MODULE_NAME} Configuration Summary" ) @@ -308,18 +280,7 @@ message( " make install" ) message( "" ) message( "The library file lib${MODULE_NAME}.so will be installed to" ) message( " ${CMAKE_INSTALL_FULL_LIBDIR}" ) -message( "Help files will be installed to" ) -message( " ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}" ) -message( "" ) message( "The module can be loaded into NEST using" ) -message( " (${MODULE_NAME}) Install (in SLI)" ) -message( " nest.Install('${MODULE_NAME}') (in PyNEST)" ) +message( " (${MODULE_NAME}) Install (in SLI)" ) +message( " nest.Install(${MODULE_NAME}) (in PyNEST)" ) message( "" ) - -if( NOT "${CMAKE_INSTALL_PREFIX}" EQUAL "${NEST_INSTALL_PREFIX}" ) - message( "The module will be installed into a non-default location!" ) - message( "Make sure to set the environment variables:" ) - message( " export NEST_MODULE_PATH=${CMAKE_INSTALL_FULL_LIBDIR}:$NEST_MODULE_PATH" ) - message( " export SLI_PATH=${CMAKE_INSTALL_FULL_DATADIR}/sli:$SLI_PATH" ) - message( "" ) -endif () diff --git a/cerebmodule.cpp b/cerebmodule.cpp index 2a972e5..d4aea62 100644 --- a/cerebmodule.cpp +++ b/cerebmodule.cpp @@ -1,45 +1,32 @@ -/* - * cerebmodule.cpp - * - * 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 . - * - */ - -#include "cerebmodule.h" -// Generated includes: -#include "config.h" - -// include headers with your own stuff -#include "volume_transmitter_alberto.h" -#include "eglif_cond_alpha_multisyn.h" -#include "stdp_connection_sinexp.h" -#include "stdp_connection_cosexp.h" -#include "stdp_connection_alpha.h" -#include "iSTDP.h" -#include "Sgritta2017.h" +/* +* cerebmodule.cpp +* +* This file is part of NEST. +* +* Copyright (C) 2004 The NEST Initiative +* +* NEST is free software: you can redistribute it and/or modifyfrozen +* 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 . +* +* 2022-06-14 09:05:14.409772 +*/ // Includes from nestkernel: #include "connection_manager_impl.h" #include "connector_model_impl.h" #include "dynamicloader.h" #include "exceptions.h" -#include "genericmodel.h" #include "genericmodel_impl.h" #include "kernel_manager.h" #include "model.h" @@ -53,34 +40,45 @@ #include "sliexceptions.h" #include "tokenarray.h" +// include headers with your own stuff +#include "cerebmodule.h" + + +#include "eglif_cond_alpha_multisyn.h" +#include "volume_transmitter_alberto.h" +#include "stdp_connection_alpha.h" +#include "stdp_connection_cosexp.h" +#include "stdp_connection_sinexp.h" + // -- Interface to dynamic module loader --------------------------------------- /* - * There are three scenarios, in which CerebModule can be loaded by NEST: - * - * 1) When loading your module with `Install`, the dynamic module loader must - * be able to find your module. You make the module known to the loader by - * defining an instance of your module class in global scope. (LTX_MODULE is - * defined) This instance must have the name - * - * _LTX_mod - * - * The dynamicloader can then load modulename and search for symbol "mod" in it. - * - * 2) When you link the library dynamically with NEST during compilation, a new - * object has to be created. In the constructor the DynamicLoaderModule will - * register your module. (LINKED_MODULE is defined) - * - * 3) When you link the library statically with NEST during compilation, the - * registration will take place in the file `static_modules.h`, which is - * generated by cmake. - */ -#if defined( LTX_MODULE ) | defined( LINKED_MODULE ) -mynest::CerebModule cerebmodule_LTX_mod; +* There are three scenarios, in which MyModule can be loaded by NEST: +* +* 1) When loading your module with `Install`, the dynamic module loader must +* be able to find your module. You make the module known to the loader by +* defining an instance of your module class in global scope. (LTX_MODULE is +* defined) This instance must have the name +* +* _LTX_mod +* +* The dynamicloader can then load modulename and search for symbol "mod" in it. +* +* 2) When you link the library dynamically with NEST during compilation, a new +* object has to be created. In the constructor the DynamicLoaderModule will +* register your module. (LINKED_MODULE is defined) +* +* 3) When you link the library statically with NEST during compilation, the +* registration will take place in the file `static_modules.h`, which is +* generated by cmake. +*/ +#if defined(LTX_MODULE) | defined(LINKED_MODULE) +cerebmodule cerebmodule_LTX_mod; #endif + // -- DynModule functions ------------------------------------------------------ -mynest::CerebModule::CerebModule() +cerebmodule::cerebmodule() { #ifdef LINKED_MODULE // register this module at the dynamic loader @@ -90,63 +88,28 @@ mynest::CerebModule::CerebModule() #endif } -mynest::CerebModule::~CerebModule() -{ -} - -const std::string -mynest::CerebModule::name( void ) const +cerebmodule::~cerebmodule() { - return std::string( "Cereb Module" ); // Return name of the module } const std::string -mynest::CerebModule::commandstring( void ) const +cerebmodule::name(void) const { - // Instruct the interpreter to load cerebmodule-init.sli - return std::string( "(cerebmodule-init) run" ); + return std::string("cerebmodule"); // Return name of the module } //------------------------------------------------------------------------------------- - void -mynest::CerebModule::init( SLIInterpreter* i ) +cerebmodule::init( SLIInterpreter* i ) { - /* Register a neuron or device model. - Give node type as template argument and the name as second argument. - */ - nest::kernel().model_manager.register_node_model< mynest::volume_transmitter_alberto >( - "volume_transmitter_alberto" ); - - nest::kernel().model_manager.register_node_model< eglif_cond_alpha_multisyn >( - "eglif_cond_alpha_multisyn" ); - - - /* - Register a synapse type. - Give synapse type as template argument and the name as second argument. - - There are two choices for the template argument: - - nest::TargetIdentifierPtrRport - - nest::TargetIdentifierIndex - The first is the standard and you should usually stick to it. - nest::TargetIdentifierIndex reduces the memory requirement of synapses - even further, but limits the number of available rports. Please see - Kunkel et al, Front Neurofinfom 8:78 (2014), Sec 3.3.2, for details. - */ - nest::kernel() - .model_manager.register_connection_model< STDPAlphaConnection >( "stdp_synapse_alpha" ); - - nest::kernel() - .model_manager.register_connection_model< STDPSinExpConnection >( "stdp_synapse_sinexp" ); - - nest::kernel() - .model_manager.register_connection_model< STDPCosExpConnection >( "stdp_synapse_cosexp" ); - - nest::kernel() - .model_manager.register_connection_model< iSTDP >( "istdp_synapse" ); + + nest::kernel().model_manager.register_node_model("eglif_cond_alpha_multisyn"); + nest::kernel().model_manager.register_node_model("volume_transmitter_alberto"); + nest::kernel().model_manager.register_connection_model("stdp_synapse_alpha"); + nest::kernel().model_manager.register_connection_model("stdp_connection_cosexp"); + nest::kernel().model_manager.register_connection_model("stdp_connection_sinexp"); + - nest::kernel() - .model_manager.register_connection_model< Sgritta2017 >( "sgritta_synapse" ); + -} // CerebModule::init() +} // cerebmodule::init() diff --git a/cerebmodule.h b/cerebmodule.h index 8eb95ac..a214d95 100644 --- a/cerebmodule.h +++ b/cerebmodule.h @@ -1,3 +1,4 @@ + /* * cerebmodule.h * @@ -18,24 +19,24 @@ * You should have received a copy of the GNU General Public License * along with NEST. If not, see . * + * 2022-06-14 09:05:14.409772 */ #ifndef CEREBMODULE_H #define CEREBMODULE_H -// Includes from sli: -#include "slifunction.h" #include "slimodule.h" +#include "slifunction.h" + +#include "nest.h" +#include "nest_impl.h" -// Put your stuff into your own namespace. -namespace mynest -{ /** - * Class defining your model. - * @note For each model, you must define one such class, with a unique name. - */ -class CerebModule : public SLIModule +* Class defining your model. +* @note For each model, you must define one such class, with a unique name. +*/ +class cerebmodule : public SLIModule { public: // Interface functions ------------------------------------------ @@ -44,15 +45,15 @@ class CerebModule : public SLIModule * @note The constructor registers the module with the dynamic loader. * Initialization proper is performed by the init() method. */ - CerebModule(); + cerebmodule(); /** * @note The destructor does not do much in modules. */ - ~CerebModule(); + ~cerebmodule(); /** - * Initialize module. + * Initialize module by registering models with the network. * @param SLIInterpreter* SLI interpreter */ void init( SLIInterpreter* ); @@ -62,13 +63,9 @@ class CerebModule : public SLIModule */ const std::string name( void ) const; - /** - * Return the name of a sli file to execute when cerebmodule is loaded. - * This mechanism can be used to define SLI commands associated with your - * module, in particular, set up type tries for functions you have defined. - */ - const std::string commandstring( void ) const; +public: + // Classes implementing your functions ----------------------------- + }; -} // namespace mynest #endif diff --git a/eglif_cond_alpha_multisyn.cpp b/eglif_cond_alpha_multisyn.cpp index b10ff76..0c3982f 100644 --- a/eglif_cond_alpha_multisyn.cpp +++ b/eglif_cond_alpha_multisyn.cpp @@ -1,35 +1,32 @@ -/* generated by template org.nest.nestml.neuron.NeuronClass*/ +#define DEBUG 1 /* -* gif_psc_exp_multisynapse_mihalas.cpp -* -* 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 . -* -*/ + * eglif_cond_alpha_multisyn.cpp + * + * 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 . + * + * Generated from NESTML at time: 2022-06-14 09:05:13.763236 +**/ // C++ includes: #include // Includes from libnestutil: #include "numerics.h" -#include "stdio.h" -#include - -#include // Includes from nestkernel: #include "exceptions.h" @@ -45,792 +42,532 @@ #include "eglif_cond_alpha_multisyn.h" -// std::vector spikes_times_; - -/* ---------------------------------------------------------------- -* Recordables map -* ---------------------------------------------------------------- */ -nest::RecordablesMap - eglif_cond_alpha_multisyn::recordablesMap_; - -namespace nest { -// Override the create() method with one call to RecordablesMap::insert_() -// for each quantity to be recorded. -template <> void RecordablesMap::create() { - // use standard names whereever you can for consistency! - /* generated by template org.nest.nestml.function.RecordCallback*/ - - - insert_("I_dep", &eglif_cond_alpha_multisyn::get_I_dep); - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - insert_("I_adap", &eglif_cond_alpha_multisyn::get_I_adap); - - - insert_("V_th", &eglif_cond_alpha_multisyn::get_V_th); - - - //insert_("y_0", &eglif_cond_alpha_multisyn::get_y_0); - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - insert_("V_m", &eglif_cond_alpha_multisyn::get_V_m); - - - insert_("I_gen", &eglif_cond_alpha_multisyn::get_I_gen); - - - insert_("sum_buffer", &eglif_cond_alpha_multisyn::get_sum_buffer); - - - insert_("G1", &eglif_cond_alpha_multisyn::get_G1); - - - insert_("DG1", &eglif_cond_alpha_multisyn::get_DG1); - - - insert_("G2", &eglif_cond_alpha_multisyn::get_G2); - - - insert_("DG2", &eglif_cond_alpha_multisyn::get_DG2); - - - insert_("G3", &eglif_cond_alpha_multisyn::get_G3); - - - insert_("DG3", &eglif_cond_alpha_multisyn::get_DG3); - - - insert_("G4", &eglif_cond_alpha_multisyn::get_G4); - - - insert_("DG4", &eglif_cond_alpha_multisyn::get_DG4); - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - //insert_("time", &eglif_cond_alpha_multisyn::get_time); - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the RefractoryCounts with the domain type long - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the r with the domain type long - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the bufferT with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the tot_cur with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the receptors with the domain type long - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the C_m with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the tau_m with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the tau_syn with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the t_ref with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the E_L with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the V_reset with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the a with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the b with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the V_th with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the k1 with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the k2 with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the A1 with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the A2 with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the I_e with the domain type double - - /* generated by template org.nest.nestml.function.RecordCallback*/ - - // ignores the bT_size with the domain type long +// --------------------------------------------------------------------------- +// Recordables map +// --------------------------------------------------------------------------- +nest::RecordablesMap eglif_cond_alpha_multisyn::recordablesMap_; +namespace nest +{ + + // Override the create() method with one call to RecordablesMap::insert_() + // for each quantity to be recorded. +template <> void RecordablesMap::create() + { + // add state variables to recordables map + insert_(eglif_cond_alpha_multisyn_names::_V_m, &eglif_cond_alpha_multisyn::get_V_m); + insert_(eglif_cond_alpha_multisyn_names::_Iadap, &eglif_cond_alpha_multisyn::get_Iadap); + insert_(eglif_cond_alpha_multisyn_names::_Idep, &eglif_cond_alpha_multisyn::get_Idep); + insert_(eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes, &eglif_cond_alpha_multisyn::get_g_4__X__rec4_spikes); + insert_(eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes__d, &eglif_cond_alpha_multisyn::get_g_4__X__rec4_spikes__d); + insert_(eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes, &eglif_cond_alpha_multisyn::get_g_1__X__rec1_spikes); + insert_(eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes__d, &eglif_cond_alpha_multisyn::get_g_1__X__rec1_spikes__d); + insert_(eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes, &eglif_cond_alpha_multisyn::get_g_2__X__rec2_spikes); + insert_(eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes__d, &eglif_cond_alpha_multisyn::get_g_2__X__rec2_spikes__d); + insert_(eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes, &eglif_cond_alpha_multisyn::get_g_3__X__rec3_spikes); + insert_(eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes__d, &eglif_cond_alpha_multisyn::get_g_3__X__rec3_spikes__d); + + // Add vector variables + } +} - /* generated by template org.nest.nestml.function.RecordCallback*/ +// --------------------------------------------------------------------------- +// Default constructors defining default parameters and state +// Note: the implementation is empty. The initialization is of variables +// is a part of eglif_cond_alpha_multisyn's constructor. +// --------------------------------------------------------------------------- - // ignores the I_tot with the domain type double +eglif_cond_alpha_multisyn::Parameters_::Parameters_() +{ } -} - -/* ---------------------------------------------------------------- -* Default constructors defining default parameters and state -* ---------------------------------------------------------------- */ -eglif_cond_alpha_multisyn::Parameters_::Parameters_() {} +eglif_cond_alpha_multisyn::State_::State_() +{ +} -eglif_cond_alpha_multisyn::State_::State_() {} +// --------------------------------------------------------------------------- +// Parameter and state extractions and manipulation functions +// --------------------------------------------------------------------------- -/* ---------------------------------------------------------------- -* Parameter and state extractions and manipulation functions -* ---------------------------------------------------------------- */ +eglif_cond_alpha_multisyn::Buffers_::Buffers_(eglif_cond_alpha_multisyn &n): + logger_(n) + , spike_inputs_( std::vector< nest::RingBuffer >( SUP_SPIKE_RECEPTOR - 1 ) ) + , __s( 0 ), __c( 0 ), __e( 0 ) +{ + // Initialization of the remaining members is deferred to init_buffers_(). +} -void eglif_cond_alpha_multisyn::Parameters_::set( - const DictionaryDatum &__d) {} +eglif_cond_alpha_multisyn::Buffers_::Buffers_(const Buffers_ &, eglif_cond_alpha_multisyn &n): + logger_(n) + , spike_inputs_( std::vector< nest::RingBuffer >( SUP_SPIKE_RECEPTOR - 1 ) ) + , __s( 0 ), __c( 0 ), __e( 0 ) +{ + // Initialization of the remaining members is deferred to init_buffers_(). +} -void eglif_cond_alpha_multisyn::State_::set(const DictionaryDatum &__d, - const Parameters_ &p) {} +// --------------------------------------------------------------------------- +// Default constructor for node +// --------------------------------------------------------------------------- -eglif_cond_alpha_multisyn::Buffers_::Buffers_( - eglif_cond_alpha_multisyn &n) - : logger_(n), s_(0), c_(0), e_(0) {} +eglif_cond_alpha_multisyn::eglif_cond_alpha_multisyn():ArchivingNode(), P_(), S_(), B_(*this) +{ + const double __resolution = nest::Time::get_resolution().get_ms(); // do not remove, this is necessary for the resolution() function -eglif_cond_alpha_multisyn::Buffers_::Buffers_( - const Buffers_ &, eglif_cond_alpha_multisyn &n) - : logger_(n), s_(0), c_(0), e_(0) {} + calibrate(); -/* ---------------------------------------------------------------- -* Default and copy constructor for node -* ---------------------------------------------------------------- */ -// TODO inner components -eglif_cond_alpha_multisyn::eglif_cond_alpha_multisyn() - : Archiving_Node(), P_(), S_(), B_(*this) { + // use a default "good enough" value for the absolute error. It can be adjusted via `node.set()` + P_.__gsl_error_tol = 1e-3; + // initial values for parameters + + P_.C_m = 281.0; // as pF + + P_.t_ref = 0.0; // as ms + + /* Added for stochasticity*/ + P_.lambda_0 = ((0.001)); // [1/ms] + P_.tau_V = ((0.5)); // [mV] + + P_.V_reset = (-(60.0)); // as mV + + P_.tau_m = 30.0; // as ms + + P_.E_L = (-(70.6)); // as mV + + P_.kadap = 4 / (1.0 * 1.0); // as pA / (ms mV) + + P_.k2 = pow(80.5, (-(1))); // as 1 / ms + + P_.A2 = 100.0; // as pA + + P_.k1 = pow(144.0, (-(1))); // as 1 / ms + + P_.A1 = 100.0; // as pA + + P_.V_th = (-(50.4)); // as mV + + P_.V_min = (-(150.0)); // as mV + + P_.Vinit = ((-60.0)); + + P_.E_rev1 = 0; // as mV + + P_.tau_syn1 = 0.2; // as ms + + P_.E_rev2 = (-(80.0)); // as mV + + P_.tau_syn2 = 2.0; // as ms + + P_.E_rev3 = 0.0; // as mV + + P_.tau_syn3 = 2.0; // as ms + + P_.E_rev4 = (-(80.0)); // as mV + + P_.tau_syn4 = 2.0; // as ms + + P_.I_e = 0; // as pA + // initial values for state variables + + S_.ode_state[State_::V_m] = P_.E_L; // as mV + + S_.ode_state[State_::Iadap] = 0; // as pA + + S_.ode_state[State_::Idep] = 0; // as pA + + S_.time = 0; + + S_.ode_state[State_::g_4__X__rec4_spikes] = 0; // as real + + S_.ode_state[State_::g_4__X__rec4_spikes__d] = 0; // as real + + S_.ode_state[State_::g_1__X__rec1_spikes] = 0; // as real + + S_.ode_state[State_::g_1__X__rec1_spikes__d] = 0; // as real + + S_.ode_state[State_::g_2__X__rec2_spikes] = 0; // as real + + S_.ode_state[State_::g_2__X__rec2_spikes__d] = 0; // as real + + S_.ode_state[State_::g_3__X__rec3_spikes] = 0; // as real + + S_.ode_state[State_::g_3__X__rec3_spikes__d] = 0; // as real recordablesMap_.create(); - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.C_m = 250; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.tau_m = 10; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - //.resize(V_.receptors, 2); - -/* generated by template org.nest.nestml.function.MemberInitialization*/ - //P_.E_rev.resize(V_.receptors, 0.0); - - P_.tau_syn1 = 2.0; - P_.tau_syn2 = 2.0; - P_.tau_syn3 = 2.0; - P_.tau_syn4 = 2.0; - - P_.E_rev1 = 0.0; - P_.E_rev2 = 0.0; - P_.E_rev3 = 0.0; - P_.E_rev4 = 0.0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.t_ref = 2; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.E_L = ((-70.0)); - - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.V_reset = get_E_L(); - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.V_th = ((-45.0)); - - P_.Vinit = ((-60.0)); - - P_.Vmin = ((-110.0)); - - /* Added for stochasticity*/ - P_.lambda_0 = ((0.001)); // [1/ms] - P_.tau_V = ((0.5)); // [mV] - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.k1 = pow((200), (((-1)))); - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.k2 = pow((20), (((-1)))); - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.A1 = 10.0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.A2 = ((-0.6)); - - P_.kadap = 0.0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - P_.I_e = 0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - - P_.bT_size = 200; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::I_dep] = 0.0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::I_adap] = 0.0; - - - - // S_.y_[State_::y_0] = 0.0; - - // S_.y_[State_::y_1] = 0.0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - //S_.y_[State_::V_m] = ((-70.0)); - S_.y_[State_::V_m] = P_.V_reset; - // S_.y_[State_::V_m] = P_.E_L; - - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - //S_.y_[State_::time] = 0; - S_.time = 0; - - -/* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::G1] = 0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::DG1] = 0; - -/* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::G2] = 0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::DG2] = 0; - -/* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::G3] = 0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::DG3] = 0; - -/* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::G4] = 0; - - /* generated by template org.nest.nestml.function.MemberInitialization*/ - - S_.y_[State_::DG4] = 0; - } -eglif_cond_alpha_multisyn::eglif_cond_alpha_multisyn( - const eglif_cond_alpha_multisyn &n) - : Archiving_Node(), P_(n.P_), S_(n.S_), B_(n.B_, *this) {} +// --------------------------------------------------------------------------- +// Copy constructor for node +// --------------------------------------------------------------------------- + +eglif_cond_alpha_multisyn::eglif_cond_alpha_multisyn(const eglif_cond_alpha_multisyn& __n): + ArchivingNode(), P_(__n.P_), S_(__n.S_), B_(__n.B_, *this) { + + // copy parameter struct P_ + P_.C_m = __n.P_.C_m; + P_.t_ref = __n.P_.t_ref; + P_.V_reset = __n.P_.V_reset; + P_.tau_m = __n.P_.tau_m; + P_.E_L = __n.P_.E_L; + P_.kadap = __n.P_.kadap; + P_.k2 = __n.P_.k2; + P_.A2 = __n.P_.A2; + P_.k1 = __n.P_.k1; + P_.A1 = __n.P_.A1; + P_.V_th = __n.P_.V_th; + P_.V_min = __n.P_.V_min; + P_.E_rev1 = __n.P_.E_rev1; + P_.tau_syn1 = __n.P_.tau_syn1; + P_.E_rev2 = __n.P_.E_rev2; + P_.tau_syn2 = __n.P_.tau_syn2; + P_.E_rev3 = __n.P_.E_rev3; + P_.tau_syn3 = __n.P_.tau_syn3; + P_.E_rev4 = __n.P_.E_rev4; + P_.tau_syn4 = __n.P_.tau_syn4; + P_.I_e = __n.P_.I_e; + + // copy state struct S_ + S_.ode_state[State_::V_m] = __n.S_.ode_state[State_::V_m]; + S_.ode_state[State_::Iadap] = __n.S_.ode_state[State_::Iadap]; + S_.ode_state[State_::Idep] = __n.S_.ode_state[State_::Idep]; + S_.ode_state[State_::g_4__X__rec4_spikes] = __n.S_.ode_state[State_::g_4__X__rec4_spikes]; + S_.ode_state[State_::g_4__X__rec4_spikes__d] = __n.S_.ode_state[State_::g_4__X__rec4_spikes__d]; + S_.ode_state[State_::g_1__X__rec1_spikes] = __n.S_.ode_state[State_::g_1__X__rec1_spikes]; + S_.ode_state[State_::g_1__X__rec1_spikes__d] = __n.S_.ode_state[State_::g_1__X__rec1_spikes__d]; + S_.ode_state[State_::g_2__X__rec2_spikes] = __n.S_.ode_state[State_::g_2__X__rec2_spikes]; + S_.ode_state[State_::g_2__X__rec2_spikes__d] = __n.S_.ode_state[State_::g_2__X__rec2_spikes__d]; + S_.ode_state[State_::g_3__X__rec3_spikes] = __n.S_.ode_state[State_::g_3__X__rec3_spikes]; + S_.ode_state[State_::g_3__X__rec3_spikes__d] = __n.S_.ode_state[State_::g_3__X__rec3_spikes__d]; + + + // copy internals V_ + V_.PSConInit_rec1 = __n.V_.PSConInit_rec1; + V_.__h = __n.V_.__h; + V_.PSConInit_rec2 = __n.V_.PSConInit_rec2; + V_.PSConInit_rec3 = __n.V_.PSConInit_rec3; + V_.PSConInit_rec4 = __n.V_.PSConInit_rec4; + V_.RefractoryCounts = __n.V_.RefractoryCounts; + V_.r = __n.V_.r; + V_.__P__Idep__Idep = __n.V_.__P__Idep__Idep; + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes = __n.V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes; + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d = __n.V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d; + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes = __n.V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes; + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d = __n.V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes = __n.V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d = __n.V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d; + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes = __n.V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes; + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d = __n.V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes = __n.V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d = __n.V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d; + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes = __n.V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes; + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d = __n.V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes = __n.V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d = __n.V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d; + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes = __n.V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes; + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d = __n.V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d; +} -/* ---------------------------------------------------------------- -* Destructors -* ---------------------------------------------------------------- */ +// --------------------------------------------------------------------------- +// Destructor for node +// --------------------------------------------------------------------------- -eglif_cond_alpha_multisyn::~eglif_cond_alpha_multisyn() { +eglif_cond_alpha_multisyn::~eglif_cond_alpha_multisyn() +{ // GSL structs may not have been allocated, so we need to protect destruction - if (B_.s_) - gsl_odeiv_step_free(B_.s_); - if (B_.c_) - gsl_odeiv_control_free(B_.c_); - if (B_.e_) - gsl_odeiv_evolve_free(B_.e_); -} - -/* ---------------------------------------------------------------- -* Node initialization functions -* ---------------------------------------------------------------- */ + if (B_.__s) + { + gsl_odeiv_step_free( B_.__s ); + } -void eglif_cond_alpha_multisyn::init_state_( - const Node &proto) { // TODO inner components + if (B_.__c) + { + gsl_odeiv_control_free( B_.__c ); + } - const eglif_cond_alpha_multisyn &pr = - downcast(proto); - S_ = pr.S_; + if (B_.__e) + { + gsl_odeiv_evolve_free( B_.__e ); + } } -/* generated by template org.nest.nestml.function.GSLDifferentiationFunction*/ -extern "C" inline int -eglif_cond_alpha_multisyn_dynamics(double, const double y[], double f[], - void *pnode) { - - //const double tIe = nest::kernel().simulation_manager.get_time().get_ms(); - - typedef eglif_cond_alpha_multisyn::State_ State_; - // get access to node so we can almost work as in a member function - assert(pnode); - const eglif_cond_alpha_multisyn &node = - *(reinterpret_cast(pnode)); - - // y[] here is---and must be---the state vector supplied by the integrator, - // not the state vector in the node, node.S_.y_[]. - - - // Synaptic current: I_syn = - sum_k g_k (V - E_rev_k). - double I_syn = 0.0; - I_syn += y[ State_::G1] * ( node.get_E_rev1() - y[State_::V_m] ); - I_syn += y[ State_::G2] * ( node.get_E_rev2() - y[State_::V_m] ); - I_syn += y[ State_::G3] * ( node.get_E_rev3() - y[State_::V_m] ); - I_syn += y[ State_::G4] * ( node.get_E_rev4() - y[State_::V_m] ); - +// --------------------------------------------------------------------------- +// Node initialization functions +// --------------------------------------------------------------------------- - // Total current - double I_tot = y[State_::I_dep] - y[State_::I_adap] + node.get_I_e() + node.B_.currents_last_value_ + I_syn; - - - // Model currents - f[State_::I_dep] = ((-node.get_k1())) * y[State_::I_dep]; - f[State_::I_adap] = ((-node.get_k2())) * y[State_::I_adap] + node.get_kadap()*(y[State_::V_m] - node.get_E_L()); - - - f[State_::V_m] = - ((1)) / node.get_tau_m() * (y[State_::V_m] - node.get_E_L()) + - 1 / node.get_C_m() * I_tot ; - - // Conductance dynamics - // Synaptic conductance derivative dG/dt - f[State_::DG1] = -y[State_::DG1] / node.get_tau_syn1(); - f[State_::G1] = y[ State_::DG1] - y[ State_::G1] / node.get_tau_syn1(); - - f[State_::DG2] = -y[State_::DG2] / node.get_tau_syn2(); - f[State_::G2] = y[ State_::DG2] - y[ State_::G2] / node.get_tau_syn2(); - - f[State_::DG3] = -y[State_::DG3] / node.get_tau_syn3(); - f[State_::G3] = y[ State_::DG3] - y[ State_::G3] / node.get_tau_syn3(); - - f[State_::DG4] = -y[State_::DG4] / node.get_tau_syn4(); - f[State_::G4] = y[ State_::DG4] - y[ State_::G4] / node.get_tau_syn4(); - - return GSL_SUCCESS; +#if NEST2_COMPAT +void eglif_cond_alpha_multisyn::init_state_(const Node& proto) +{ + const eglif_cond_alpha_multisyn& pr = downcast(proto); + S_ = pr.S_; } - -void eglif_cond_alpha_multisyn::init_buffers_() { - B_.get_spikes_r1().clear(); // includes resize - B_.get_spikes_r2().clear(); - B_.get_spikes_r3().clear(); - B_.get_spikes_r4().clear(); - B_.get_currents().clear(); // includes resize - B_.logger_.reset(); // includes resize - Archiving_Node::clear_history(); - - int state_size = State_::STATE_VEC_SIZE; - - if (B_.s_ == 0) - B_.s_ = gsl_odeiv_step_alloc(gsl_odeiv_step_rkf45, State_::STATE_VEC_SIZE); +#endif + +void eglif_cond_alpha_multisyn::init_buffers_() +{ + get_rec1_spikes().clear(); //includes resize + get_rec2_spikes().clear(); //includes resize + get_rec3_spikes().clear(); //includes resize + get_rec4_spikes().clear(); //includes resize + get_I_stim().clear(); //includes resize + B_.logger_.reset(); // includes resize + + if ( B_.__s == 0 ) + { + B_.__s = gsl_odeiv_step_alloc( gsl_odeiv_step_rkf45, 11 ); + } else - gsl_odeiv_step_reset(B_.s_); + { + gsl_odeiv_step_reset( B_.__s ); + } - if (B_.c_ == 0) { - B_.c_ = gsl_odeiv_control_y_new(1e-6, 0.0); - } else { - gsl_odeiv_control_init(B_.c_, 1e-6, 0.0, 1.0, 0.0); + if ( B_.__c == 0 ) + { + B_.__c = gsl_odeiv_control_y_new( P_.__gsl_error_tol, 0.0 ); + } + else + { + gsl_odeiv_control_init( B_.__c, P_.__gsl_error_tol, 0.0, 1.0, 0.0 ); } - if (B_.e_ == 0) { - B_.e_ = gsl_odeiv_evolve_alloc(State_::STATE_VEC_SIZE); - } else { - gsl_odeiv_evolve_reset(B_.e_); + if ( B_.__e == 0 ) + { + B_.__e = gsl_odeiv_evolve_alloc( 11 ); + } + else + { + gsl_odeiv_evolve_reset( B_.__e ); } + B_.__sys.function = eglif_cond_alpha_multisyn_dynamics; + B_.__sys.jacobian = NULL; + B_.__sys.dimension = 11; + B_.__sys.params = reinterpret_cast< void* >( this ); + B_.__step = nest::Time::get_resolution().get_ms(); + B_.__integration_step = nest::Time::get_resolution().get_ms(); +} - B_.sys_.function = eglif_cond_alpha_multisyn_dynamics; - B_.sys_.jacobian = NULL; - B_.sys_.dimension = state_size; - B_.sys_.params = reinterpret_cast(this); +void eglif_cond_alpha_multisyn::calibrate_variables(bool exclude_timestep) { + const double __resolution = nest::Time::get_resolution().get_ms(); // do not remove, this is necessary for the resolution() function + + if (exclude_timestep) { + V_.PSConInit_rec1 =1.0 * numerics::e / P_.tau_syn1; + V_.PSConInit_rec2 =1.0 * numerics::e / P_.tau_syn2; + V_.PSConInit_rec3 =1.0 * numerics::e / P_.tau_syn3; + V_.PSConInit_rec4 =1.0 * numerics::e / P_.tau_syn4; + V_.RefractoryCounts =nest::Time(nest::Time::ms((double) (P_.t_ref))).get_steps(); + V_.r =0; + V_.__P__Idep__Idep =1.0 * std::exp((-(V_.__h)) * P_.k1); + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes =1.0 * (V_.__h + P_.tau_syn4) * std::exp((-(V_.__h)) / P_.tau_syn4) / P_.tau_syn4; + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn4); + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn4) / pow(P_.tau_syn4, 2); + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn4) * std::exp((-(V_.__h)) / P_.tau_syn4) / P_.tau_syn4; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes =1.0 * (V_.__h + P_.tau_syn1) * std::exp((-(V_.__h)) / P_.tau_syn1) / P_.tau_syn1; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn1); + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn1) / pow(P_.tau_syn1, 2); + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn1) * std::exp((-(V_.__h)) / P_.tau_syn1) / P_.tau_syn1; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes =1.0 * (V_.__h + P_.tau_syn2) * std::exp((-(V_.__h)) / P_.tau_syn2) / P_.tau_syn2; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn2); + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn2) / pow(P_.tau_syn2, 2); + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn2) * std::exp((-(V_.__h)) / P_.tau_syn2) / P_.tau_syn2; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes =1.0 * (V_.__h + P_.tau_syn3) * std::exp((-(V_.__h)) / P_.tau_syn3) / P_.tau_syn3; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn3); + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn3) / pow(P_.tau_syn3, 2); + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn3) * std::exp((-(V_.__h)) / P_.tau_syn3) / P_.tau_syn3; + } + else { + // internals V_ + V_.PSConInit_rec1 =1.0 * numerics::e / P_.tau_syn1; + V_.__h =__resolution; + V_.PSConInit_rec2 =1.0 * numerics::e / P_.tau_syn2; + V_.PSConInit_rec3 =1.0 * numerics::e / P_.tau_syn3; + V_.PSConInit_rec4 =1.0 * numerics::e / P_.tau_syn4; + V_.RefractoryCounts =nest::Time(nest::Time::ms((double) (P_.t_ref))).get_steps(); + V_.r =0; + V_.__P__Idep__Idep =1.0 * std::exp((-(V_.__h)) * P_.k1); + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes =1.0 * (V_.__h + P_.tau_syn4) * std::exp((-(V_.__h)) / P_.tau_syn4) / P_.tau_syn4; + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn4); + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn4) / pow(P_.tau_syn4, 2); + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn4) * std::exp((-(V_.__h)) / P_.tau_syn4) / P_.tau_syn4; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes =1.0 * (V_.__h + P_.tau_syn1) * std::exp((-(V_.__h)) / P_.tau_syn1) / P_.tau_syn1; + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn1); + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn1) / pow(P_.tau_syn1, 2); + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn1) * std::exp((-(V_.__h)) / P_.tau_syn1) / P_.tau_syn1; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes =1.0 * (V_.__h + P_.tau_syn2) * std::exp((-(V_.__h)) / P_.tau_syn2) / P_.tau_syn2; + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn2); + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn2) / pow(P_.tau_syn2, 2); + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn2) * std::exp((-(V_.__h)) / P_.tau_syn2) / P_.tau_syn2; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes =1.0 * (V_.__h + P_.tau_syn3) * std::exp((-(V_.__h)) / P_.tau_syn3) / P_.tau_syn3; + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d =1.0 * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn3); + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes =(-(1.0)) * V_.__h * std::exp((-(V_.__h)) / P_.tau_syn3) / pow(P_.tau_syn3, 2); + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d =1.0 * ((-(V_.__h)) + P_.tau_syn3) * std::exp((-(V_.__h)) / P_.tau_syn3) / P_.tau_syn3; + } } void eglif_cond_alpha_multisyn::calibrate() { B_.logger_.init(); - /* generated by template org.nest.nestml.function.Calibrate*/ - srand(time(NULL)); - V_.rng_ = nest::kernel().rng_manager.get_rng( get_thread() ); - - V_.RefractoryCounts = - nest::Time(nest::Time::ms((double)P_.t_ref)).get_steps(); - - /* generated by template org.nest.nestml.function.Calibrate*/ - - V_.r = 0; - - V_.receptors = 4; // Number of receptor ports - - V_.V_th = P_.V_th; - - V_.I_gen = 0.0; - - V_.sum_buffer = 0.0; - - - V_.G0.resize( V_.receptors); - - /* generated by template org.nest.nestml.function.Calibrate*/ - V_.G0[0] = 1.0*numerics::e / P_.tau_syn1; - V_.G0[1] = 1.0*numerics::e / P_.tau_syn2; - V_.G0[2] = 1.0*numerics::e / P_.tau_syn3; - V_.G0[3] = 1.0*numerics::e / P_.tau_syn4; - - /* generated by template org.nest.nestml.function.Calibrate*/ - - V_.bufferT.resize(P_.bT_size); - for (long i = 0; i < get_bT_size(); i++) { - V_.bufferT[i] = 0; // Non è qui il problema - } - - /* generated by template org.nest.nestml.function.Calibrate*/ - - V_.tot_cur = 0; - - // Receptors initialization - //B_.spikes.resize(V_.receptors); - - B_.receptor_types_.resize(4); - - for (long i = 0; i < V_.receptors; i++) { - B_.receptor_types_[i] = i + 1; // Assign to ports (receptor_type) numbers from 1 to receptors (= receptors number) - } + calibrate_variables(); + // buffers B_ } -/* ---------------------------------------------------------------- -* Update and spike handling functions: adapted from the file generate by NESTML to update the buffer of external currents -* ---------------------------------------------------------------- */ - -/* - - */ -void eglif_cond_alpha_multisyn::update(nest::Time const &origin, - const long from, const long to) { +// --------------------------------------------------------------------------- +// Update and spike handling functions +// --------------------------------------------------------------------------- - double step_ = nest::Time::get_resolution().get_ms(); - double IntegrationStep_ = nest::Time::get_resolution().get_ms(); - double t = 0; +extern "C" inline int eglif_cond_alpha_multisyn_dynamics(double, const double ode_state[], double f[], void* pnode) +{ + typedef eglif_cond_alpha_multisyn::State_ State_; + // get access to node so we can almost work as in a member function + assert( pnode ); + const eglif_cond_alpha_multisyn& node = *( reinterpret_cast< eglif_cond_alpha_multisyn* >( pnode ) ); + + // ode_state[] here is---and must be---the state vector supplied by the integrator, + // not the state vector in the node, node.S_.ode_state[]. + f[State_::V_m] = (-(node.get_E_L())) / node.get_tau_m() + std::max(ode_state[State_::V_m], node.get_V_min()) / node.get_tau_m() + node.get_E_rev1() * ode_state[State_::g_1__X__rec1_spikes] / node.get_C_m() + node.get_E_rev4() * ode_state[State_::g_4__X__rec4_spikes] / node.get_C_m() + node.get_I_e() / node.get_C_m() + node.B_.I_stim_grid_sum_ / node.get_C_m() + (node.get_E_rev2() * ode_state[State_::g_2__X__rec2_spikes] + node.get_E_rev3() * ode_state[State_::g_3__X__rec3_spikes] - ode_state[State_::Iadap] + ode_state[State_::Idep] - ode_state[State_::g_1__X__rec1_spikes] * std::max(ode_state[State_::V_m], node.get_V_min()) - ode_state[State_::g_2__X__rec2_spikes] * std::max(ode_state[State_::V_m], node.get_V_min()) - ode_state[State_::g_3__X__rec3_spikes] * std::max(ode_state[State_::V_m], node.get_V_min()) - ode_state[State_::g_4__X__rec4_spikes] * std::max(ode_state[State_::V_m], node.get_V_min())) / node.get_C_m(); + f[State_::Iadap] = (-(node.get_E_L())) * node.get_kadap() - ode_state[State_::Iadap] * node.get_k2() + node.get_kadap() * std::max(ode_state[State_::V_m], node.get_V_min()); + f[State_::Idep] = (-(ode_state[State_::Idep])) * node.get_k1(); + f[State_::g_4__X__rec4_spikes] = 1.0 * ode_state[State_::g_4__X__rec4_spikes__d]; + f[State_::g_4__X__rec4_spikes__d] = (-(ode_state[State_::g_4__X__rec4_spikes])) / pow(node.get_tau_syn4(), 2) - 2 * ode_state[State_::g_4__X__rec4_spikes__d] / node.get_tau_syn4(); + f[State_::g_1__X__rec1_spikes] = 1.0 * ode_state[State_::g_1__X__rec1_spikes__d]; + f[State_::g_1__X__rec1_spikes__d] = (-(ode_state[State_::g_1__X__rec1_spikes])) / pow(node.get_tau_syn1(), 2) - 2 * ode_state[State_::g_1__X__rec1_spikes__d] / node.get_tau_syn1(); + f[State_::g_2__X__rec2_spikes] = 1.0 * ode_state[State_::g_2__X__rec2_spikes__d]; + f[State_::g_2__X__rec2_spikes__d] = (-(ode_state[State_::g_2__X__rec2_spikes])) / pow(node.get_tau_syn2(), 2) - 2 * ode_state[State_::g_2__X__rec2_spikes__d] / node.get_tau_syn2(); + f[State_::g_3__X__rec3_spikes] = 1.0 * ode_state[State_::g_3__X__rec3_spikes__d]; + f[State_::g_3__X__rec3_spikes__d] = (-(ode_state[State_::g_3__X__rec3_spikes])) / pow(node.get_tau_syn3(), 2) - 2 * ode_state[State_::g_3__X__rec3_spikes__d] / node.get_tau_syn3(); - //std::cout << S_.time << std::endl; + return GSL_SUCCESS; +} - //if (S_.y_[State_::time] < 2){ +void eglif_cond_alpha_multisyn::update(nest::Time const & origin,const long from, const long to) +{ + const double __resolution = nest::Time::get_resolution().get_ms(); // do not remove, this is necessary for the resolution() function if (S_.time < 2){ - V_.V_th = get_V_th(); - S_.y_[State_::V_m] = get_Vinit(); - } - - if ( S_.y_[State_::V_m] < P_.Vmin){ - S_.y_[State_::V_m] = get_Vmin(); - } - V_.old_Vm = V_.new_Vm; - V_.new_Vm = S_.y_[State_::V_m]; - - - for (long lag = from; lag < to; ++lag) { - // std::cout << S_.y_[State_::y_0] << " " << step_ <= S_.y_[State_::V_th]) { // Condition for spike generation without stochasticity - /* generated by template org.nest.spl.Block*/ - /* generated by template org.nest.spl.Statement*/ - // - /* generated by template org.nest.spl.SmallStatement*/ - /* generated by template org.nest.spl.Assignment*/ - - if (lambda > 0.0) + for ( long lag = from ; lag < to ; ++lag ) + { + B_.rec1_spikes_grid_sum_ = get_rec1_spikes().get_value(lag); + B_.rec2_spikes_grid_sum_ = get_rec2_spikes().get_value(lag); + B_.rec3_spikes_grid_sum_ = get_rec3_spikes().get_value(lag); + B_.rec4_spikes_grid_sum_ = get_rec4_spikes().get_value(lag); + B_.I_stim_grid_sum_ = get_I_stim().get_value(lag); + + + if (lag == from) { - if ( ((double) rand() / (RAND_MAX)) //V_.rng_->drand() + //S_.y_[State_::time] += 1; + S_.time += 1; + } + + // NESTML generated code for the update block: + double Idep__tmp = get_Idep() * V_.__P__Idep__Idep; + double g_4__X__rec4_spikes__tmp = V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes * get_g_4__X__rec4_spikes() + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d * get_g_4__X__rec4_spikes__d(); + double g_4__X__rec4_spikes__d__tmp = V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes * get_g_4__X__rec4_spikes() + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d * get_g_4__X__rec4_spikes__d(); + double g_1__X__rec1_spikes__tmp = V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes * get_g_1__X__rec1_spikes() + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d * get_g_1__X__rec1_spikes__d(); + double g_1__X__rec1_spikes__d__tmp = V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes * get_g_1__X__rec1_spikes() + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d * get_g_1__X__rec1_spikes__d(); + double g_2__X__rec2_spikes__tmp = V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes * get_g_2__X__rec2_spikes() + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d * get_g_2__X__rec2_spikes__d(); + double g_2__X__rec2_spikes__d__tmp = V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes * get_g_2__X__rec2_spikes() + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d * get_g_2__X__rec2_spikes__d(); + double g_3__X__rec3_spikes__tmp = V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes * get_g_3__X__rec3_spikes() + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d * get_g_3__X__rec3_spikes__d(); + double g_3__X__rec3_spikes__d__tmp = V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes * get_g_3__X__rec3_spikes() + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d * get_g_3__X__rec3_spikes__d(); + double __t = 0; + // numerical integration with adaptive step size control: + // ------------------------------------------------------ + // gsl_odeiv_evolve_apply performs only a single numerical + // integration step, starting from t and bounded by step; + // the while-loop ensures integration over the whole simulation + // step (0, step] if more than one integration step is needed due + // to a small integration step size; + // note that (t+IntegrationStep > step) leads to integration over + // (t, step] and afterwards setting t to step, but it does not + // enforce setting IntegrationStep to step-t; this is of advantage + // for a consistent and efficient integration across subsequent + // simulation intervals + while ( __t < B_.__step ) + { + const int status = gsl_odeiv_evolve_apply(B_.__e, + B_.__c, + B_.__s, + &B_.__sys, // system of ODE + &__t, // from t + B_.__step, // to t <= step + &B_.__integration_step, // integration step size + S_.ode_state); // neuronal state + + if ( status != GSL_SUCCESS ) + { + throw nest::GSLSolverFailure( get_name(), status ); + } + } + /* replace analytically solvable variables with precisely integrated values */ + S_.ode_state[State_::Idep] = Idep__tmp; + S_.ode_state[State_::g_4__X__rec4_spikes] = g_4__X__rec4_spikes__tmp; + S_.ode_state[State_::g_4__X__rec4_spikes__d] = g_4__X__rec4_spikes__d__tmp; + S_.ode_state[State_::g_1__X__rec1_spikes] = g_1__X__rec1_spikes__tmp; + S_.ode_state[State_::g_1__X__rec1_spikes__d] = g_1__X__rec1_spikes__d__tmp; + S_.ode_state[State_::g_2__X__rec2_spikes] = g_2__X__rec2_spikes__tmp; + S_.ode_state[State_::g_2__X__rec2_spikes__d] = g_2__X__rec2_spikes__d__tmp; + S_.ode_state[State_::g_3__X__rec3_spikes] = g_3__X__rec3_spikes__tmp; + S_.ode_state[State_::g_3__X__rec3_spikes__d] = g_3__X__rec3_spikes__d__tmp; + S_.ode_state[State_::g_4__X__rec4_spikes__d] += (B_.rec4_spikes_grid_sum_) * (numerics::e / P_.tau_syn4) / (1.0); + S_.ode_state[State_::g_1__X__rec1_spikes__d] += (B_.rec1_spikes_grid_sum_) * (numerics::e / P_.tau_syn1) / (1.0); + S_.ode_state[State_::g_2__X__rec2_spikes__d] += (B_.rec2_spikes_grid_sum_) * (numerics::e / P_.tau_syn2) / (1.0); + S_.ode_state[State_::g_3__X__rec3_spikes__d] += (B_.rec3_spikes_grid_sum_) * (numerics::e / P_.tau_syn3) / (1.0); + /* Added for stochasticity*/ + const double lambda = P_.lambda_0 * std::exp( ( S_.ode_state[State_::V_m] - P_.V_th ) / P_.tau_V ); + if (V_.r>0) + { + V_.r -= 1; + S_.ode_state[State_::V_m] = P_.V_reset; + } + else if (lambda > 0.0) + { + if ( ((double) rand() / (RAND_MAX)) < -numerics::expm1( -lambda * nest::Time::get_resolution().get_ms() ) ) - { /////////// Spike generation!!!! /////////// - // std::cout<<"spike!"< 0) end */ - - // Spikes on 1st receptor - S_.y_[ State_::DG1 ] += B_.spikes_r1_last_value_ * V_.G0[ 0 ]; - // std::cout << "spike time: "< 0); -/* - assert( - ( e.get_rport() > 0 ) && ( ( size_t ) e.get_rport() <= P_.get_receptors() ) ); -*/ - - //std::cout << "porta spike: "<< e.get_rport() << " "; - if (e.get_rport()==1) { - get_spikes_r1().add_value( - e.get_rel_delivery_steps( - nest::kernel().simulation_manager.get_slice_origin()), - e.get_weight() * e.get_multiplicity()); - }else if (e.get_rport()==2){ - get_spikes_r2().add_value( - e.get_rel_delivery_steps( - nest::kernel().simulation_manager.get_slice_origin()), - e.get_weight() * e.get_multiplicity()); - }else if (e.get_rport()==3){ - get_spikes_r3().add_value( - e.get_rel_delivery_steps( - nest::kernel().simulation_manager.get_slice_origin()), - e.get_weight() * e.get_multiplicity()); - }else{ - get_spikes_r4().add_value( - e.get_rel_delivery_steps( - nest::kernel().simulation_manager.get_slice_origin()), - e.get_weight() * e.get_multiplicity()); - } + assert( e.get_rport() < static_cast< int >( B_.spike_inputs_.size() ) ); + B_.spike_inputs_[ e.get_rport() ].add_value( + e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin() ), + e.get_weight() * e.get_multiplicity() ); } -void eglif_cond_alpha_multisyn::handle(nest::CurrentEvent &e) { +void eglif_cond_alpha_multisyn::handle(nest::CurrentEvent& e) +{ assert(e.get_delay_steps() > 0); - const double current = e.get_current(); + const double current = e.get_current(); // we assume that in NEST, this returns a current in pA const double weight = e.get_weight(); - - //std::cout<. -* -*/ - +/** + * eglif_cond_alpha_multisyn.h + * + * 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 . + * + * Generated from NESTML at time: 2022-06-14 09:05:14.243707 +**/ #ifndef EGLIF_COND_ALPHA_MULTISYN #define EGLIF_COND_ALPHA_MULTISYN + #include "config.h" -#ifdef HAVE_GSL +#ifndef HAVE_GSL +#error "The GSL library is required for neurons that require a numerical solver." +#endif + +// External includes: #include #include #include -// forwards the declaration of the function -extern "C" inline int -eglif_cond_alpha_multisyn_dynamics(double, const double y[], double f[], - void *pnode); -/* -extern "C" inline int -eglif_cond_alpha_multisyn_dynamics(double, const double*, double*, - void *pnode);*/ // Includes from nestkernel: #include "archiving_node.h" @@ -50,431 +45,860 @@ eglif_cond_alpha_multisyn_dynamics(double, const double*, double*, // Includes from sli: #include "dictdatum.h" -/* BeginDocumentation -Name: eglif_cond_alpha_multisyn . - -// -Name: eglif_cond_alpha_multisyn_nestml - Extended Generalized Leaky -integrate-and-fire neuron model with multiple ports based. Described in [Geminiani et al., Front Neuroinf, 2018]. - -Description (NESTML): - -eglif_cond_alpha_multisyn_nestml from iaf_psc_exp_multisynapse_nestml. - -With respect to first model version, a minimum value of Vm is added here, useful in case of oscillatory solutions - -Sends: SpikeEvent - -Receives: SpikeEvent, CurrentEvent, DataLoggingRequest - -Author: Geminiani Alice - Casellato Claudia, adapted from iaf_psc_exp_multisynapse and iaf_psc_alpha_multisyn and iaf_cond_alpha for the synapses; -Contact: alice.geminiani@polimi.it - -// - -Parameters: +namespace nest +{ +namespace eglif_cond_alpha_multisyn_names +{ + const Name _V_m( "V_m" ); + const Name _Iadap( "Iadap" ); + const Name _Idep( "Idep" ); + const Name _g_4__X__rec4_spikes( "g_4__X__rec4_spikes" ); + const Name _g_4__X__rec4_spikes__d( "g_4__X__rec4_spikes__d" ); + const Name _g_1__X__rec1_spikes( "g_1__X__rec1_spikes" ); + const Name _g_1__X__rec1_spikes__d( "g_1__X__rec1_spikes__d" ); + const Name _g_2__X__rec2_spikes( "g_2__X__rec2_spikes" ); + const Name _g_2__X__rec2_spikes__d( "g_2__X__rec2_spikes__d" ); + const Name _g_3__X__rec3_spikes( "g_3__X__rec3_spikes" ); + const Name _g_3__X__rec3_spikes__d( "g_3__X__rec3_spikes__d" ); + const Name _C_m( "C_m" ); + const Name _t_ref( "t_ref" ); + const Name _lambda_0( "lambda_0" ); + const Name _tau_V( "tau_V" ); + const Name _V_reset( "V_reset" ); + const Name _tau_m( "tau_m" ); + const Name _E_L( "E_L" ); + const Name _kadap( "kadap" ); + const Name _k2( "k2" ); + const Name _A2( "A2" ); + const Name _k1( "k1" ); + const Name _A1( "A1" ); + const Name _V_th( "V_th" ); + const Name _V_min( "V_min" ); + const Name _Vinit( "Vinit" ); + const Name _E_rev1( "E_rev1" ); + const Name _tau_syn1( "tau_syn1" ); + const Name _E_rev2( "E_rev2" ); + const Name _tau_syn2( "tau_syn2" ); + const Name _E_rev3( "E_rev3" ); + const Name _tau_syn3( "tau_syn3" ); + const Name _E_rev4( "E_rev4" ); + const Name _tau_syn4( "tau_syn4" ); + const Name _I_e( "I_e" ); +} +} -Remarks: -Empty -References: -Empty -Sends: nest::SpikeEvent +/** + * Function computing right-hand side of ODE for GSL solver. + * @note Must be declared here so we can befriend it in class. + * @note Must have C-linkage for passing to GSL. Internally, it is + * a first-class C++ function, but cannot be a member function + * because of the C-linkage. + * @note No point in declaring it inline, since it is called + * through a function pointer. + * @param void* Pointer to model neuron instance. +**/ +extern "C" inline int eglif_cond_alpha_multisyn_dynamics( double, const double y[], double f[], void* pnode ); -Receives: Spike, Current, DataLoggingRequest +#include "nest_time.h" -SeeAlso: -Empty -*/ -class eglif_cond_alpha_multisyn : public nest::Archiving_Node { -public: - /** - * The constructor is only used to create the model prototype in the model - * manager. - */ - eglif_cond_alpha_multisyn(); - /** - * The copy constructor is used to create model copies and instances of the - * model. - * @node The copy constructor needs to initialize the parameters and the state. - * Initialization of buffers and interal variables is deferred to - * @c init_buffers_() and @c calibrate(). - */ - eglif_cond_alpha_multisyn(const eglif_cond_alpha_multisyn &); - /** - * Releases resources. - */ - ~eglif_cond_alpha_multisyn(); - /** - * Import sets of overloaded virtual functions. - * This is necessary to ensure proper overload and overriding resolution. - * @see http://www.gotw.ca/gotw/005.htm. - */ - using nest::Node::handles_test_event; - using nest::Node::handle; - /** - * Used to validate that we can send nest::SpikeEvent to desired target:port. - */ - nest::port send_test_event(nest::Node &target, nest::rport receptor_type, - nest::synindex, bool); +/* BeginDocumentation + Name: eglif_cond_alpha_multisyn. - /** - * @defgroup mynest_handle Functions handling incoming events. - * We tell nest that we can handle incoming events of various types by - * defining @c handle() and @c connect_sender() for the given event. - * @{ - */ - void handle(nest::SpikeEvent &); //! accept spikes - void handle(nest::CurrentEvent &); //! accept input current - void handle(nest::DataLoggingRequest &); //! allow recording with multimeter - - nest::port handles_test_event(nest::SpikeEvent &, nest::port); - nest::port handles_test_event(nest::CurrentEvent &, nest::port); - nest::port handles_test_event(nest::DataLoggingRequest &, nest::port); - /** @} */ - - // SLI communication functions: - void get_status(DictionaryDatum &) const; - void set_status(const DictionaryDatum &); + Description: - // Generate function header + """ + eglif_cond_alpha_multisyn - Conductance based extended-generalized leaky integrate-and-fire neuron model############################################################################## - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + Description + +++++++++++ - inline double get_I_dep() const { return S_.y_[State_::I_dep]; } + aeif_cond_alpha is the adaptive exponential integrate and fire neuron according to Brette and Gerstner (2005), with post-synaptic conductances in the form of a bi-exponential ("alpha") function. - inline void set_I_dep(const double v) { S_.y_[State_::I_dep] = v; } + The membrane potential is given by the following differential equation: - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + .. math:: - inline double get_I_adap() const { return S_.y_[State_::I_adap]; } + C_m \frac{dV_m}{dt} = + -g_L(V_m-E_L)+g_L\Delta_T\exp\left(\frac{V_m-V_{th}}{\Delta_T}\right) - + g_e(t)(V_m-E_e) \\ + -g_i(t)(V_m-E_i)-w + I_e - inline void set_I_adap(const double v) { S_.y_[State_::I_adap] = v; } + and - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + .. math:: - inline double get_V_m() const { return S_.y_[State_::V_m]; } + \tau_w \frac{dw}{dt} = a(V_m-E_L) - w - inline void set_V_m(const double v) { S_.y_[State_::V_m] = v; } + Note that the membrane potential can diverge to positive infinity due to the exponential term. To avoid numerical instabilities, instead of :math:`V_m`, the value :math:`\min(V_m,V_{peak})` is used in the dynamical equations. - /* Conductance-based synapses for the 4 receptors*/ - inline double get_G1() const { return S_.y_[State_::G1]; } + References + ++++++++++ - inline void set_G1(const double v) { S_.y_[State_::G1] = v; } + .. [1] Brette R and Gerstner W (2005). Adaptive exponential + integrate-and-fire model as an effective description of neuronal + activity. Journal of Neurophysiology. 943637-3642 + DOI: https://doi.org/10.1152/jn.00686.2005 - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_DG1() const { return S_.y_[State_::DG1]; } + See also + ++++++++ - inline void set_DG1(const double v) { S_.y_[State_::DG1] = v; } + iaf_cond_alpha, aeif_cond_exp + """ - inline double get_G2() const { return S_.y_[State_::G2]; } + Parameters: + The following parameters can be set in the status dictionary. +C_m [pF] membrane parameters + Membrane Capacitance +t_ref [ms] Refractory period +V_reset [mV] Reset Potential +tau_m [ms] Membrane time constant +E_L [mV] Leak reversal Potential (aka resting potential) + spike adaptation parameters +kadap [pA / (ms mV)] spike adaptation parameters + Subthreshold adaptation +k2 [1 / ms] Spike-triggered adaptation +k1 [1 / ms] Adaptation time constant +V_th [mV] Threshold Potential +V_min [mV] Minimum Membrane Potential + synaptic parameters +E_rev1 [mV] synaptic parameters + Receptor 1 reversal Potential +tau_syn1 [ms] Synaptic Time Constant for Synapse on Receptor 1 +E_rev2 [mV] Receptor 2 reversal Potential +tau_syn2 [ms] Synaptic Time Constant for Synapse on Receptor 2 +E_rev3 [mV] Receptor 3 reversal Potential +tau_syn3 [ms] Synaptic Time Constant for Synapse on Receptor 3 +E_rev4 [mV] Receptor 4 reversal Potential +tau_syn4 [ms] Synaptic Time Constant for Synapse on Receptor 4 + constant external input current +I_e [pA] constant external input current - inline void set_G2(const double v) { S_.y_[State_::G2] = v; } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + Dynamic state variables: +V_m [mV] Membrane potential +Iadap [pA] Spike-adaptation current +Idep [pA] Spike-triggered current - inline double get_DG2() const { return S_.y_[State_::DG2]; } - inline void set_DG2(const double v) { S_.y_[State_::DG2] = v; } + Sends: nest::SpikeEvent + Receives: Spike, Current, DataLoggingRequest +*/ +class eglif_cond_alpha_multisyn : public nest::ArchivingNode +{ +public: + /** + * The constructor is only used to create the model prototype in the model manager. + **/ + eglif_cond_alpha_multisyn(); - inline double get_G3() const { return S_.y_[State_::G3]; } + /** + * The copy constructor is used to create model copies and instances of the model. + * @node The copy constructor needs to initialize the parameters and the state. + * Initialization of buffers and interal variables is deferred to + * @c init_buffers_() and @c calibrate(). + **/ + eglif_cond_alpha_multisyn(const eglif_cond_alpha_multisyn &); - inline void set_G3(const double v) { S_.y_[State_::G3] = v; } + /** + * Destructor. + **/ + ~eglif_cond_alpha_multisyn(); - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + // ------------------------------------------------------------------------- + // Import sets of overloaded virtual functions. + // See: Technical Issues / Virtual Functions: Overriding, Overloading, + // and Hiding + // ------------------------------------------------------------------------- - inline double get_DG3() const { return S_.y_[State_::DG3]; } + using nest::Node::handles_test_event; + using nest::Node::handle; - inline void set_DG3(const double v) { S_.y_[State_::DG3] = v; } + /** + * Used to validate that we can send nest::SpikeEvent to desired target:port. + **/ + nest::port send_test_event(nest::Node& target, nest::rport receptor_type, nest::synindex, bool); + // ------------------------------------------------------------------------- + // Functions handling incoming events. + // We tell nest that we can handle incoming events of various types by + // defining handle() for the given event. + // ------------------------------------------------------------------------- - inline double get_G4() const { return S_.y_[State_::G4]; } + void handle(nest::SpikeEvent &); //! accept spikes + void handle(nest::CurrentEvent &); //! accept input current + void handle(nest::DataLoggingRequest &);//! allow recording with multimeter + nest::port handles_test_event(nest::SpikeEvent&, nest::port); + nest::port handles_test_event(nest::CurrentEvent&, nest::port); + nest::port handles_test_event(nest::DataLoggingRequest&, nest::port); - inline void set_G4(const double v) { S_.y_[State_::G4] = v; } + // ------------------------------------------------------------------------- + // Functions for getting/setting parameters and state values. + // ------------------------------------------------------------------------- - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + void get_status(DictionaryDatum &) const; + void set_status(const DictionaryDatum &); - inline double get_DG4() const { return S_.y_[State_::DG4]; } + // ------------------------------------------------------------------------- + // Getters/setters for state block + // ------------------------------------------------------------------------- - inline void set_DG4(const double v) { S_.y_[State_::DG4] = v; } + inline double get_V_m() const + { + return S_.ode_state[State_::V_m]; + } + inline void set_V_m(const double __v) + { + S_.ode_state[State_::V_m] = __v; + } + inline double get_Iadap() const + { + return S_.ode_state[State_::Iadap]; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_Iadap(const double __v) + { + S_.ode_state[State_::Iadap] = __v; + } - inline double get_C_m() const { return P_.C_m; } + inline double get_Idep() const + { + return S_.ode_state[State_::Idep]; + } - inline void set_C_m(const double v) { P_.C_m = v; } + inline void set_Idep(const double __v) + { + S_.ode_state[State_::Idep] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_g_4__X__rec4_spikes() const + { + return S_.ode_state[State_::g_4__X__rec4_spikes]; + } - inline double get_tau_m() const { return P_.tau_m; } + inline void set_g_4__X__rec4_spikes(const double __v) + { + S_.ode_state[State_::g_4__X__rec4_spikes] = __v; + } - inline void set_tau_m(const double v) { P_.tau_m = v; } + inline double get_g_4__X__rec4_spikes__d() const + { + return S_.ode_state[State_::g_4__X__rec4_spikes__d]; + } + inline void set_g_4__X__rec4_spikes__d(const double __v) + { + S_.ode_state[State_::g_4__X__rec4_spikes__d] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_g_1__X__rec1_spikes() const + { + return S_.ode_state[State_::g_1__X__rec1_spikes]; + } - inline double get_tau_syn1() const { return P_.tau_syn1; } + inline void set_g_1__X__rec1_spikes(const double __v) + { + S_.ode_state[State_::g_1__X__rec1_spikes] = __v; + } - inline void set_tau_syn1(const double v) { P_.tau_syn1 = v; } + inline double get_g_1__X__rec1_spikes__d() const + { + return S_.ode_state[State_::g_1__X__rec1_spikes__d]; + } + inline void set_g_1__X__rec1_spikes__d(const double __v) + { + S_.ode_state[State_::g_1__X__rec1_spikes__d] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_E_rev1() const { return P_.E_rev1; } + inline double get_g_2__X__rec2_spikes() const + { + return S_.ode_state[State_::g_2__X__rec2_spikes]; + } - inline void set_E_rev1(const double v) { P_.E_rev1 = v; } + inline void set_g_2__X__rec2_spikes(const double __v) + { + S_.ode_state[State_::g_2__X__rec2_spikes] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_g_2__X__rec2_spikes__d() const + { + return S_.ode_state[State_::g_2__X__rec2_spikes__d]; + } - inline double get_tau_syn2() const { return P_.tau_syn2; } + inline void set_g_2__X__rec2_spikes__d(const double __v) + { + S_.ode_state[State_::g_2__X__rec2_spikes__d] = __v; + } - inline void set_tau_syn2(const double v) { P_.tau_syn2 = v; } + inline double get_g_3__X__rec3_spikes() const + { + return S_.ode_state[State_::g_3__X__rec3_spikes]; + } + inline void set_g_3__X__rec3_spikes(const double __v) + { + S_.ode_state[State_::g_3__X__rec3_spikes] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_E_rev2() const { return P_.E_rev2; } + inline double get_g_3__X__rec3_spikes__d() const + { + return S_.ode_state[State_::g_3__X__rec3_spikes__d]; + } - inline void set_E_rev2(const double v) { P_.E_rev2 = v; } + inline void set_g_3__X__rec3_spikes__d(const double __v) + { + S_.ode_state[State_::g_3__X__rec3_spikes__d] = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_tau_syn3() const { return P_.tau_syn3; } + // ------------------------------------------------------------------------- + // Getters/setters for parameters + // ------------------------------------------------------------------------- - inline void set_tau_syn3(const double v) { P_.tau_syn3 = v; } + inline double get_C_m() const + { + return P_.C_m; + } + inline void set_C_m(const double __v) + { + P_.C_m = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_E_rev3() const { return P_.E_rev3; } + inline double get_t_ref() const + { + return P_.t_ref; + } - inline void set_E_rev3(const double v) { P_.E_rev3 = v; } + inline void set_t_ref(const double __v) + { + P_.t_ref = __v; + } + + inline double get_lambda_0() const + { + return P_.lambda_0; + } + inline void set_lambda_0(const double __v) + { + P_.lambda_0 = __v; + } + + + inline double get_tau_V() const + { + return P_.tau_V; + } - inline double get_tau_syn4() const { return P_.tau_syn4; } + inline void set_tau_V(const double __v) + { + P_.tau_V = __v; + } + - inline void set_tau_syn4(const double v) { P_.tau_syn4 = v; } + inline double get_V_reset() const + { + return P_.V_reset; + } + inline void set_V_reset(const double __v) + { + P_.V_reset = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ - inline double get_E_rev4() const { return P_.E_rev4; } + inline double get_tau_m() const + { + return P_.tau_m; + } - inline void set_E_rev4(const double v) { P_.E_rev4 = v; } + inline void set_tau_m(const double __v) + { + P_.tau_m = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_E_L() const + { + return P_.E_L; + } - inline double get_t_ref() const { return P_.t_ref; } + inline void set_E_L(const double __v) + { + P_.E_L = __v; + } - inline void set_t_ref(const double v) { P_.t_ref = v; } + inline double get_kadap() const + { + return P_.kadap; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_kadap(const double __v) + { + P_.kadap = __v; + } - inline double get_E_L() const { return P_.E_L; } + inline double get_k2() const + { + return P_.k2; + } - inline void set_E_L(const double v) { P_.E_L = v; } + inline void set_k2(const double __v) + { + P_.k2 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_A2() const + { + return P_.A2; + } - inline double get_V_reset() const { return P_.V_reset; } + inline void set_A2(const double __v) + { + P_.A2 = __v; + } - inline void set_V_reset(const double v) { P_.V_reset = v; } + inline double get_k1() const + { + return P_.k1; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_k1(const double __v) + { + P_.k1 = __v; + } - inline double get_V_th() const { return P_.V_th; } + inline double get_A1() const + { + return P_.A1; + } - inline void set_V_th(const double v) { P_.V_th = v; } + inline void set_A1(const double __v) + { + P_.A1 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_V_th() const + { + return P_.V_th; + } + inline void set_V_th(const double __v) + { + P_.V_th = __v; + } - inline double get_Vinit() const { return P_.Vinit; } + inline double get_V_min() const + { + return P_.V_min; + } - inline void set_Vinit(const double v) { P_.Vinit = v; } + inline void set_V_min(const double __v) + { + P_.V_min = __v; + } + + inline double get_Vinit() const + { + return P_.Vinit; + } - inline double get_Vmin() const { return P_.Vmin; } + inline void set_Vinit(const double __v) + { + P_.Vinit = __v; + } - inline void set_Vmin(const double v) { P_.Vmin = v; } + inline double get_E_rev1() const + { + return P_.E_rev1; + } - /* Added for stochasticity*/ - inline double get_lambda_0() const { return P_.lambda_0; } + inline void set_E_rev1(const double __v) + { + P_.E_rev1 = __v; + } - inline void set_lambda_0(const double v) { P_.lambda_0 = v; } + inline double get_tau_syn1() const + { + return P_.tau_syn1; + } - inline double get_tau_V() const { return P_.tau_V; } + inline void set_tau_syn1(const double __v) + { + P_.tau_syn1 = __v; + } - inline void set_tau_V(const double v) { P_.tau_V = v; } + inline double get_E_rev2() const + { + return P_.E_rev2; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_E_rev2(const double __v) + { + P_.E_rev2 = __v; + } - inline double get_k1() const { return P_.k1; } + inline double get_tau_syn2() const + { + return P_.tau_syn2; + } - inline void set_k1(const double v) { P_.k1 = v; } + inline void set_tau_syn2(const double __v) + { + P_.tau_syn2 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_E_rev3() const + { + return P_.E_rev3; + } - inline double get_k2() const { return P_.k2; } + inline void set_E_rev3(const double __v) + { + P_.E_rev3 = __v; + } - inline void set_k2(const double v) { P_.k2 = v; } + inline double get_tau_syn3() const + { + return P_.tau_syn3; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_tau_syn3(const double __v) + { + P_.tau_syn3 = __v; + } - inline double get_A1() const { return P_.A1; } + inline double get_E_rev4() const + { + return P_.E_rev4; + } - inline void set_A1(const double v) { P_.A1 = v; } + inline void set_E_rev4(const double __v) + { + P_.E_rev4 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_tau_syn4() const + { + return P_.tau_syn4; + } - inline double get_A2() const { return P_.A2; } + inline void set_tau_syn4(const double __v) + { + P_.tau_syn4 = __v; + } - inline void set_A2(const double v) { P_.A2 = v; } + inline double get_I_e() const + { + return P_.I_e; + } - inline double get_kadap() const { return P_.kadap; } + inline void set_I_e(const double __v) + { + P_.I_e = __v; + } - inline void set_kadap(const double v) { P_.kadap = v; } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + // ------------------------------------------------------------------------- + // Getters/setters for internals + // ------------------------------------------------------------------------- - inline double get_I_e() const { return P_.I_e; } + inline double get_PSConInit_rec1() const + { + return V_.PSConInit_rec1; + } - inline void set_I_e(const double v) { P_.I_e = v; } + inline void set_PSConInit_rec1(const double __v) + { + V_.PSConInit_rec1 = __v; + } + inline double get___h() const + { + return V_.__h; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set___h(const double __v) + { + V_.__h = __v; + } - inline long get_bT_size() const { return P_.bT_size; } + inline double get_PSConInit_rec2() const + { + return V_.PSConInit_rec2; + } - inline void set_bT_size(const long v) { P_.bT_size = v; } + inline void set_PSConInit_rec2(const double __v) + { + V_.PSConInit_rec2 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get_PSConInit_rec3() const + { + return V_.PSConInit_rec3; + } - inline long get_receptors() const { return V_.receptors; } + inline void set_PSConInit_rec3(const double __v) + { + V_.PSConInit_rec3 = __v; + } - inline void set_receptors(const long v) { V_.receptors = v; } + inline double get_PSConInit_rec4() const + { + return V_.PSConInit_rec4; + } + inline void set_PSConInit_rec4(const double __v) + { + V_.PSConInit_rec4 = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline long get_RefractoryCounts() const + { + return V_.RefractoryCounts; + } - inline long get_RefractoryCounts() const { return V_.RefractoryCounts; } + inline void set_RefractoryCounts(const long __v) + { + V_.RefractoryCounts = __v; + } - inline void set_RefractoryCounts(const long v) { V_.RefractoryCounts = v; } + inline long get_r() const + { + return V_.r; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set_r(const long __v) + { + V_.r = __v; + } - inline long get_r() const { return V_.r; } + inline double get___P__Idep__Idep() const + { + return V_.__P__Idep__Idep; + } - inline void set_r(const long v) { V_.r = v; } + inline void set___P__Idep__Idep(const double __v) + { + V_.__P__Idep__Idep = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get___P__g_4__X__rec4_spikes__g_4__X__rec4_spikes() const + { + return V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes; + } - inline std::vector get_bufferT() const { return V_.bufferT; } + inline void set___P__g_4__X__rec4_spikes__g_4__X__rec4_spikes(const double __v) + { + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes = __v; + } - inline void set_bufferT(const std::vector v) { V_.bufferT = v; } + inline double get___P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d() const + { + return V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d; + } - inline double get_Vth() const { return V_.V_th; } + inline void set___P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d(const double __v) + { + V_.__P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d = __v; + } - inline void set_Vth(const double v) { V_.V_th = v; } + inline double get___P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes() const + { + return V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes; + } - inline double get_I_gen() const { return V_.I_gen; } + inline void set___P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes(const double __v) + { + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes = __v; + } - inline void set_I_gen(const double v) { V_.I_gen = v; } + inline double get___P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d() const + { + return V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d; + } + inline void set___P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d(const double __v) + { + V_.__P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d = __v; + } - inline double get_sum_buffer() const { return V_.sum_buffer; } + inline double get___P__g_1__X__rec1_spikes__g_1__X__rec1_spikes() const + { + return V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes; + } - inline void set_sum_buffer(const double v) { V_.sum_buffer = v; } + inline void set___P__g_1__X__rec1_spikes__g_1__X__rec1_spikes(const double __v) + { + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes = __v; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline double get___P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d() const + { + return V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d; + } - inline double get_tot_cur() const { return V_.tot_cur; } + inline void set___P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d(const double __v) + { + V_.__P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d = __v; + } - inline void set_tot_cur(const double v) { V_.tot_cur = v; } + inline double get___P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes() const + { + return V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes; + } - /* Added for R2 update*/ - inline double get_R2() const {return V_.R2; } + inline void set___P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes(const double __v) + { + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes = __v; + } - inline double set_R2(const double v) {return V_.R2 = v; } + inline double get___P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d() const + { + return V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d; + } - inline double get_old_Vm() const { return V_.old_Vm; } + inline void set___P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d(const double __v) + { + V_.__P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d = __v; + } - inline void set_old_Vm(const double v) { V_.old_Vm = v; } + inline double get___P__g_2__X__rec2_spikes__g_2__X__rec2_spikes() const + { + return V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes; + } - inline double get_new_Vm() const { return V_.new_Vm; } + inline void set___P__g_2__X__rec2_spikes__g_2__X__rec2_spikes(const double __v) + { + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes = __v; + } - inline void set_old_new_Vm(const double v) { V_.new_Vm = v; } + inline double get___P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d() const + { + return V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d; + } - inline double get_old_slope() const { return V_.old_slope; } + inline void set___P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d(const double __v) + { + V_.__P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d = __v; + } - inline void set_old_slope(const double v) { V_.old_slope = v; } + inline double get___P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes() const + { + return V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes; + } - inline double get_new_slope() const { return V_.new_slope; } + inline void set___P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes(const double __v) + { + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes = __v; + } - inline void set_new_slope(const double v) { V_.new_slope = v; } + inline double get___P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d() const + { + return V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d; + } + inline void set___P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d(const double __v) + { + V_.__P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d = __v; + } - inline std::vector get_G0() const { - return V_.G0; + inline double get___P__g_3__X__rec3_spikes__g_3__X__rec3_spikes() const + { + return V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes; } - inline void set_G0(const std::vector v) { - V_.G0 = v; + inline void set___P__g_3__X__rec3_spikes__g_3__X__rec3_spikes(const double __v) + { + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes = __v; } + inline double get___P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d() const + { + return V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d; + } + inline void set___P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d(const double __v) + { + V_.__P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d = __v; + } - inline double get_I_syn() const { return S_.I_syn; } - inline void set_I_syn(const double v) { S_.I_syn = v; } + inline double get___P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes() const + { + return V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set___P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes(const double __v) + { + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes = __v; + } + inline double get___P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d() const + { + return V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d; + } - /* generated by template org.nest.nestml.function.MemberVariableGetterSetter*/ + inline void set___P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d(const double __v) + { + V_.__P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d = __v; + } - inline double get_I_tot() const { return S_.I_tot; } - inline void set_I_tot(const double v) { S_.I_tot = v; } - inline nest::RingBuffer &get_spikes_r1() { - return B_.get_spikes_r1(); - }; - inline nest::RingBuffer &get_spikes_r2() { - return B_.get_spikes_r2(); - }; +protected: - inline nest::RingBuffer &get_spikes_r3() { - return B_.get_spikes_r3(); - }; +private: + void calibrate_variables(bool exclude_timestep=false); + void pre_run_hook(); - inline nest::RingBuffer &get_spikes_r4() { - return B_.get_spikes_r4(); +private: + /** + * Synapse types to connect to + * @note Excluded upper and lower bounds are defined as INF_, SUP_. + * Excluding port 0 avoids accidental connections. + **/ + enum SynapseTypes + { + INF_SPIKE_RECEPTOR = 0, + REC1_SPIKES , + REC2_SPIKES , + REC3_SPIKES , + REC4_SPIKES , + SUP_SPIKE_RECEPTOR }; - inline nest::RingBuffer &get_currents() { return B_.get_currents(); }; - - -protected: - //! Reset parameters and state of neuron. - - //! Reset state of neuron. - void init_state_(const Node &proto); +#if NEST2_COMPAT + /** + * Reset state of neuron. + **/ + void init_state_(const Node& proto); +#endif - //! Reset internal buffers of neuron. + /** + * Reset internal buffers of neuron. + **/ void init_buffers_(); - //! Initialize auxiliary quantities, leave parameters and state untouched. + /** + * Initialize auxiliary quantities, leave parameters and state untouched. + **/ void calibrate(); - //! Take neuron through given time interval + /** + * Take neuron through given time interval + **/ void update(nest::Time const &, const long, const long); // The next two classes need to be friends to access the State_ class/member @@ -482,979 +906,534 @@ class eglif_cond_alpha_multisyn : public nest::Archiving_Node { friend class nest::UniversalDataLogger; /** - * Free parameters of the neuron. - * - * - * - * These are the parameters that can be set by the user through @c SetStatus. - * They are initialized from the model prototype when the node is created. - * Parameters do not change during calls to @c update() and are not reset by - * @c ResetNetwork. - * - * @note Parameters_ need neither copy constructor nor @c operator=(), since - * all its members are copied properly by the default copy constructor - * and assignment operator. Important: - * - If Parameters_ contained @c Time members, you need to define the - * assignment operator to recalibrate all members of type @c Time . You - * may also want to define the assignment operator. - * - If Parameters_ contained members that cannot copy themselves, such - * as C-style arrays, you need to define the copy constructor and - * assignment operator to copy those members. - */ - struct Parameters_ { - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - double C_m; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - double tau_m; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - double tau_syn1; // - - /* Conductance-based synapses*/ - double E_rev1; // + * Free parameters of the neuron. + * + * + * + * These are the parameters that can be set by the user through @c `node.set()`. + * They are initialized from the model prototype when the node is created. + * Parameters do not change during calls to @c update() and are not reset by + * @c ResetNetwork. + * + * @note Parameters_ need neither copy constructor nor @c operator=(), since + * all its members are copied properly by the default copy constructor + * and assignment operator. Important: + * - If Parameters_ contained @c Time members, you need to define the + * assignment operator to recalibrate all members of type @c Time . You + * may also want to define the assignment operator. + * - If Parameters_ contained members that cannot copy themselves, such + * as C-style arrays, you need to define the copy constructor and + * assignment operator to copy those members. + **/ + struct Parameters_ + { + //! membrane parameters + //! Membrane Capacitance + double C_m; + //! Refractory period + double t_ref; + //! Reset Potential + double lambda_0; + //! Random spike generation + double tau_V; + //! Random spike generation + double V_reset; + //! Membrane time constant + double tau_m; + //! Leak reversal Potential (aka resting potential) + //! spike adaptation parameters + double E_L; + //! spike adaptation parameters + //! Subthreshold adaptation + double kadap; + //! Spike-triggered adaptation + double k2; + double A2; + //! Adaptation time constant + double k1; + double A1; + //! Threshold Potential + double V_th; + //! Minimum Membrane Potential + //! synaptic parameters + double V_min; + double Vinit; + //! synaptic parameters + //! Receptor 1 reversal Potential + double E_rev1; + //! Synaptic Time Constant for Synapse on Receptor 1 + double tau_syn1; + //! Receptor 2 reversal Potential + double E_rev2; + //! Synaptic Time Constant for Synapse on Receptor 2 + double tau_syn2; + //! Receptor 3 reversal Potential + double E_rev3; + //! Synaptic Time Constant for Synapse on Receptor 3 + double tau_syn3; + //! Receptor 4 reversal Potential + double E_rev4; + //! Synaptic Time Constant for Synapse on Receptor 4 + //! constant external input current + double tau_syn4; + //! constant external input current + double I_e; - double tau_syn2; // + double __gsl_error_tol; - /* Conductance-based synapses*/ - double E_rev2; // + /** + * Initialize parameters to their default values. + **/ + Parameters_(); + }; - double tau_syn3; // + /** + * Dynamic state of the neuron. + * + * + * + * These are the state variables that are advanced in time by calls to + * @c update(). In many models, some or all of them can be set by the user + * through @c `node.set()`. The state variables are initialized from the model + * prototype when the node is created. State variables are reset by @c ResetNetwork. + * + * @note State_ need neither copy constructor nor @c operator=(), since + * all its members are copied properly by the default copy constructor + * and assignment operator. Important: + * - If State_ contained @c Time members, you need to define the + * assignment operator to recalibrate all members of type @c Time . You + * may also want to define the assignment operator. + * - If State_ contained members that cannot copy themselves, such + * as C-style arrays, you need to define the copy constructor and + * assignment operator to copy those members. + **/ + struct State_ + { + //! Symbolic indices to the elements of the state vector y + enum StateVecElems + { + V_m, + Iadap, + Idep, + g_4__X__rec4_spikes, + g_4__X__rec4_spikes__d, + g_1__X__rec1_spikes, + g_1__X__rec1_spikes__d, + g_2__X__rec2_spikes, + g_2__X__rec2_spikes__d, + g_3__X__rec3_spikes, + g_3__X__rec3_spikes__d, + // moved state variables from synapse + STATE_VEC_SIZE + }; - /* Conductance-based synapses*/ - double E_rev3; // + //! state vector, must be C-array for GSL solver + double ode_state[STATE_VEC_SIZE]; + + double time; + State_(); + }; - double tau_syn4; - /* Conductance-based synapses*/ - double E_rev4; + /** + * Internal variables of the neuron. + * + * + * + * These variables must be initialized by @c calibrate, which is called before + * the first call to @c update() upon each call to @c Simulate. + * @node Variables_ needs neither constructor, copy constructor or assignment operator, + * since it is initialized by @c calibrate(). If Variables_ has members that + * cannot destroy themselves, Variables_ will need a destructor. + **/ + struct Variables_ + { + //! Impulse to add to DG_1 on spike arrival to evoke unit-amplitude conductance excursion + double PSConInit_rec1; + double __h; + //! Impulse to add to DG_2 on spike arrival to evoke unit-amplitude conductance excursion + double PSConInit_rec2; + //! Impulse to add to DG_3 on spike arrival to evoke unit-amplitude conductance excursion + double PSConInit_rec3; + //! Impulse to add to DG_4 on spike arrival to evoke unit-amplitude conductance excursion + double PSConInit_rec4; + //! refractory time in steps + //! counts number of tick during the refractory period + long RefractoryCounts; + //! counts number of tick during the refractory period + long r; + double __P__Idep__Idep; + double __P__g_4__X__rec4_spikes__g_4__X__rec4_spikes; + double __P__g_4__X__rec4_spikes__g_4__X__rec4_spikes__d; + double __P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes; + double __P__g_4__X__rec4_spikes__d__g_4__X__rec4_spikes__d; + double __P__g_1__X__rec1_spikes__g_1__X__rec1_spikes; + double __P__g_1__X__rec1_spikes__g_1__X__rec1_spikes__d; + double __P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes; + double __P__g_1__X__rec1_spikes__d__g_1__X__rec1_spikes__d; + double __P__g_2__X__rec2_spikes__g_2__X__rec2_spikes; + double __P__g_2__X__rec2_spikes__g_2__X__rec2_spikes__d; + double __P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes; + double __P__g_2__X__rec2_spikes__d__g_2__X__rec2_spikes__d; + double __P__g_3__X__rec3_spikes__g_3__X__rec3_spikes; + double __P__g_3__X__rec3_spikes__g_3__X__rec3_spikes__d; + double __P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes; + double __P__g_3__X__rec3_spikes__d__g_3__X__rec3_spikes__d; + }; - /* generated by template org.nest.nestml.function.MemberDeclaration*/ + /** + * Buffers of the neuron. + * Usually buffers for incoming spikes and data logged for analog recorders. + * Buffers must be initialized by @c init_buffers_(), which is called before + * @c calibrate() on the first call to @c Simulate after the start of NEST, + * ResetKernel or ResetNetwork. + * @node Buffers_ needs neither constructor, copy constructor or assignment operator, + * since it is initialized by @c init_nodes_(). If Buffers_ has members that + * cannot destroy themselves, Buffers_ will need a destructor. + **/ + struct Buffers_ + { + Buffers_(eglif_cond_alpha_multisyn &); + Buffers_(const Buffers_ &, eglif_cond_alpha_multisyn &); - double t_ref; // + /** + * Logger for all analog data + **/ + nest::UniversalDataLogger logger_; + std::vector receptor_types_; + // ----------------------------------------------------------------------- + // Buffers and sums of incoming spikes/currents per timestep + // ----------------------------------------------------------------------- + std::vector< nest::RingBuffer > spike_inputs_; + inline nest::RingBuffer& get_rec1_spikes() { return spike_inputs_[REC1_SPIKES - 1]; } + double rec1_spikes_grid_sum_; + inline nest::RingBuffer& get_rec2_spikes() { return spike_inputs_[REC2_SPIKES - 1]; } + double rec2_spikes_grid_sum_; + inline nest::RingBuffer& get_rec3_spikes() { return spike_inputs_[REC3_SPIKES - 1]; } + double rec3_spikes_grid_sum_; + inline nest::RingBuffer& get_rec4_spikes() { return spike_inputs_[REC4_SPIKES - 1]; } + double rec4_spikes_grid_sum_; + //!< Buffer for input (type: pA) + nest::RingBuffer I_stim; + inline nest::RingBuffer& get_I_stim() {return I_stim;} + double I_stim_grid_sum_; + + // ----------------------------------------------------------------------- + // GSL ODE solver data structures + // ----------------------------------------------------------------------- + + gsl_odeiv_step* __s; //!< stepping function + gsl_odeiv_control* __c; //!< adaptive stepsize control function + gsl_odeiv_evolve* __e; //!< evolution function + gsl_odeiv_system __sys; //!< struct describing system + + // __integration_step should be reset with the neuron on ResetNetwork, + // but remain unchanged during calibration. Since it is initialized with + // step_, and the resolution cannot change after nodes have been created, + // it is safe to place both here. + double __step; //!< step size in ms + double __integration_step; //!< current integration time step, updated by GSL + }; - /* generated by template org.nest.nestml.function.MemberDeclaration*/ + // ------------------------------------------------------------------------- + // Getters/setters for inline expressions + // ------------------------------------------------------------------------- + + inline double get_V_bounded() const + { + return std::max(get_V_m(), P_.V_min); + } - double E_L; // + inline double get_I_syn1() const + { + return get_g_1__X__rec1_spikes() * ((std::max(get_V_m(), P_.V_min)) - P_.E_rev1); + } - /* generated by template org.nest.nestml.function.MemberDeclaration*/ + inline double get_I_syn2() const + { + return get_g_2__X__rec2_spikes() * ((std::max(get_V_m(), P_.V_min)) - P_.E_rev2); + } - double V_reset; // + inline double get_I_syn3() const + { + return get_g_3__X__rec3_spikes() * ((std::max(get_V_m(), P_.V_min)) - P_.E_rev3); + } + inline double get_I_syn4() const + { + return get_g_4__X__rec4_spikes() * ((std::max(get_V_m(), P_.V_min)) - P_.E_rev4); + } - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - double V_th; // + // ------------------------------------------------------------------------- + // Getters/setters for input buffers + // ------------------------------------------------------------------------- + + inline nest::RingBuffer& get_rec1_spikes() {return B_.get_rec1_spikes();}; + inline nest::RingBuffer& get_rec2_spikes() {return B_.get_rec2_spikes();}; + inline nest::RingBuffer& get_rec3_spikes() {return B_.get_rec3_spikes();}; + inline nest::RingBuffer& get_rec4_spikes() {return B_.get_rec4_spikes();}; + inline nest::RingBuffer& get_I_stim() {return B_.get_I_stim();}; + + // ------------------------------------------------------------------------- + // Member variables of neuron model. + // Each model neuron should have precisely the following four data members, + // which are one instance each of the parameters, state, buffers and variables + // structures. Experience indicates that the state and variables member should + // be next to each other to achieve good efficiency (caching). + // Note: Devices require one additional data member, an instance of the + // ``Device`` child class they belong to. + // ------------------------------------------------------------------------- + + + Parameters_ P_; //!< Free parameters. + State_ S_; //!< Dynamic state. + Variables_ V_; //!< Internal Variables + Buffers_ B_; //!< Buffers. - /* generated by template org.nest.nestml.function.MemberDeclaration*/ + //! Mapping of recordables names to access functions + static nest::RecordablesMap recordablesMap_; + friend int eglif_cond_alpha_multisyn_dynamics( double, const double y[], double f[], void* pnode ); - double Vinit; // - double Vmin; // - /*Added for stochasticity*/ - double lambda_0; - double tau_V; - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - double k1; // - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - double k2; // +}; /* neuron eglif_cond_alpha_multisyn */ - /* generated by template org.nest.nestml.function.MemberDeclaration*/ +inline nest::port eglif_cond_alpha_multisyn::send_test_event(nest::Node& target, nest::rport receptor_type, nest::synindex, bool) +{ + // You should usually not change the code in this function. + // It confirms that the target of connection @c c accepts @c nest::SpikeEvent on + // the given @c receptor_type. + nest::SpikeEvent e; + e.set_sender(*this); + return target.handles_test_event(e, receptor_type); +} - double A1; // +inline nest::port eglif_cond_alpha_multisyn::handles_test_event(nest::SpikeEvent&, nest::port receptor_type) +{ + assert( B_.spike_inputs_.size() == 4 ); - /* generated by template org.nest.nestml.function.MemberDeclaration*/ + if ( !( INF_SPIKE_RECEPTOR < receptor_type && receptor_type < SUP_SPIKE_RECEPTOR ) ) + { + throw nest::UnknownReceptorType( receptor_type, get_name() ); + return 0; + } + else + { + return receptor_type - 1; + } +} - double A2; // +inline nest::port eglif_cond_alpha_multisyn::handles_test_event(nest::CurrentEvent&, nest::port receptor_type) +{ + // You should usually not change the code in this function. + // It confirms to the connection management system that we are able + // to handle @c CurrentEvent on port 0. You need to extend the function + // if you want to differentiate between input ports. + if (receptor_type != 0) + { + throw nest::UnknownReceptorType(receptor_type, get_name()); + } + return 0; +} - double kadap; +inline nest::port eglif_cond_alpha_multisyn::handles_test_event(nest::DataLoggingRequest& dlr, nest::port receptor_type) +{ + // You should usually not change the code in this function. + // It confirms to the connection management system that we are able + // to handle @c DataLoggingRequest on port 0. + // The function also tells the built-in UniversalDataLogger that this node + // is recorded from and that it thus needs to collect data during simulation. + if (receptor_type != 0) + { + throw nest::UnknownReceptorType(receptor_type, get_name()); + } + return B_.logger_.connect_logging_device(dlr, recordablesMap_); +} - /* generated by template org.nest.nestml.function.MemberDeclaration*/ +inline void eglif_cond_alpha_multisyn::get_status(DictionaryDatum &__d) const +{ + // parameters + def(__d, nest::eglif_cond_alpha_multisyn_names::_C_m, get_C_m()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_t_ref, get_t_ref()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_lambda_0, get_lambda_0()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_V, get_tau_V()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_V_reset, get_V_reset()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_m, get_tau_m()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_E_L, get_E_L()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_kadap, get_kadap()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_k2, get_k2()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_A2, get_A2()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_k1, get_k1()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_A1, get_A1()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_V_th, get_V_th()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_V_min, get_V_min()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_Vinit, get_Vinit()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev1, get_E_rev1()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn1, get_tau_syn1()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev2, get_E_rev2()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn2, get_tau_syn2()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev3, get_E_rev3()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn3, get_tau_syn3()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev4, get_E_rev4()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn4, get_tau_syn4()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_I_e, get_I_e()); + + // initial values for state variables in ODE or kernel + def(__d, nest::eglif_cond_alpha_multisyn_names::_V_m, get_V_m()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_Iadap, get_Iadap()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_Idep, get_Idep()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes, get_g_4__X__rec4_spikes()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes__d, get_g_4__X__rec4_spikes__d()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes, get_g_1__X__rec1_spikes()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes__d, get_g_1__X__rec1_spikes__d()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes, get_g_2__X__rec2_spikes()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes__d, get_g_2__X__rec2_spikes__d()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes, get_g_3__X__rec3_spikes()); + def(__d, nest::eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes__d, get_g_3__X__rec3_spikes__d()); + + ArchivingNode::get_status( __d ); + DictionaryDatum __receptor_type = new Dictionary(); + ( *__receptor_type )[ "REC1_SPIKES" ] = REC1_SPIKES; + ( *__receptor_type )[ "REC2_SPIKES" ] = REC2_SPIKES; + ( *__receptor_type )[ "REC3_SPIKES" ] = REC3_SPIKES; + ( *__receptor_type )[ "REC4_SPIKES" ] = REC4_SPIKES; + ( *__d )[ "receptor_types" ] = __receptor_type; - double I_e; // + (*__d)[nest::names::recordables] = recordablesMap_.get_list(); + def< double >(__d, nest::names::gsl_error_tol, P_.__gsl_error_tol); + if ( P_.__gsl_error_tol <= 0. ){ + throw nest::BadProperty( "The gsl_error_tol must be strictly positive." ); + } +} - /* generated by template org.nest.nestml.function.MemberDeclaration*/ +inline void eglif_cond_alpha_multisyn::set_status(const DictionaryDatum &__d) +{ + // parameters + double tmp_C_m = get_C_m(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_C_m, tmp_C_m); + double tmp_t_ref = get_t_ref(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_t_ref, tmp_t_ref); + double tmp_lambda_0 = get_lambda_0(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_lambda_0, tmp_lambda_0); + double tmp_tau_V = get_tau_V(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_V, tmp_tau_V); + double tmp_V_reset = get_V_reset(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_V_reset, tmp_V_reset); + double tmp_tau_m = get_tau_m(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_m, tmp_tau_m); + double tmp_E_L = get_E_L(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_E_L, tmp_E_L); + double tmp_kadap = get_kadap(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_kadap, tmp_kadap); + double tmp_k2 = get_k2(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_k2, tmp_k2); + double tmp_A2 = get_A2(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_A2, tmp_A2); + double tmp_k1 = get_k1(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_k1, tmp_k1); + double tmp_A1 = get_A1(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_A1, tmp_A1); + double tmp_V_th = get_V_th(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_V_th, tmp_V_th); + double tmp_V_min = get_V_min(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_V_min, tmp_V_min); + double tmp_Vinit = get_Vinit(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_Vinit, tmp_Vinit); + double tmp_E_rev1 = get_E_rev1(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev1, tmp_E_rev1); + double tmp_tau_syn1 = get_tau_syn1(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn1, tmp_tau_syn1); + double tmp_E_rev2 = get_E_rev2(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev2, tmp_E_rev2); + double tmp_tau_syn2 = get_tau_syn2(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn2, tmp_tau_syn2); + double tmp_E_rev3 = get_E_rev3(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev3, tmp_E_rev3); + double tmp_tau_syn3 = get_tau_syn3(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn3, tmp_tau_syn3); + double tmp_E_rev4 = get_E_rev4(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_E_rev4, tmp_E_rev4); + double tmp_tau_syn4 = get_tau_syn4(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_tau_syn4, tmp_tau_syn4); + double tmp_I_e = get_I_e(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_I_e, tmp_I_e); + + // initial values for state variables in ODE or kernel + double tmp_V_m = get_V_m(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_V_m, tmp_V_m); + double tmp_Iadap = get_Iadap(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_Iadap, tmp_Iadap); + double tmp_Idep = get_Idep(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_Idep, tmp_Idep); + double tmp_g_4__X__rec4_spikes = get_g_4__X__rec4_spikes(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes, tmp_g_4__X__rec4_spikes); + double tmp_g_4__X__rec4_spikes__d = get_g_4__X__rec4_spikes__d(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_4__X__rec4_spikes__d, tmp_g_4__X__rec4_spikes__d); + double tmp_g_1__X__rec1_spikes = get_g_1__X__rec1_spikes(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes, tmp_g_1__X__rec1_spikes); + double tmp_g_1__X__rec1_spikes__d = get_g_1__X__rec1_spikes__d(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_1__X__rec1_spikes__d, tmp_g_1__X__rec1_spikes__d); + double tmp_g_2__X__rec2_spikes = get_g_2__X__rec2_spikes(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes, tmp_g_2__X__rec2_spikes); + double tmp_g_2__X__rec2_spikes__d = get_g_2__X__rec2_spikes__d(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_2__X__rec2_spikes__d, tmp_g_2__X__rec2_spikes__d); + double tmp_g_3__X__rec3_spikes = get_g_3__X__rec3_spikes(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes, tmp_g_3__X__rec3_spikes); + double tmp_g_3__X__rec3_spikes__d = get_g_3__X__rec3_spikes__d(); + updateValue(__d, nest::eglif_cond_alpha_multisyn_names::_g_3__X__rec3_spikes__d, tmp_g_3__X__rec3_spikes__d); - long bT_size; // - - /** Initialize parameters to their default values. */ - Parameters_(); - - /** Set parameter values from dictionary. */ - void set(const DictionaryDatum &); - - // TODO only for invariants - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_C_m() const { return C_m; } - inline void set_C_m(const double C_m) { this->C_m = C_m; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_tau_m() const { return tau_m; } - inline void set_tau_m(const double tau_m) { this->tau_m = tau_m; } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_tau_syn1() const { return tau_syn1; } - inline void set_tau_syn1(const double tau_syn1) { - this->tau_syn1 = tau_syn1; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - inline double get_E_rev1() const { return E_rev1; } - inline void set_E_rev1(const double E_rev1) { - this->E_rev1 = E_rev1; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_tau_syn2() const { return tau_syn2; } - inline void set_tau_syn2(const double tau_syn2) { - this->tau_syn2 = tau_syn2; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - inline double get_E_rev2() const { return E_rev2; } - inline void set_E_rev2(const double E_rev2) { - this->E_rev2 = E_rev2; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_tau_syn3() const { return tau_syn3; } - inline void set_tau_syn3(const double tau_syn3) { - this->tau_syn3 = tau_syn3; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - inline double get_E_rev3() const { return E_rev3; } - inline void set_E_rev3(const double E_rev3) { - this->E_rev3 = E_rev3; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_tau_syn4() const { return tau_syn4; } - inline void set_tau_syn4(const double tau_syn4) { - this->tau_syn4 = tau_syn4; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - inline double get_E_rev4() const { return E_rev4; } - inline void set_E_rev4(const double E_rev4) { - this->E_rev4 = E_rev4; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_t_ref() const { return t_ref; } - inline void set_t_ref(const double t_ref) { this->t_ref = t_ref; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_E_L() const { return E_L; } - inline void set_E_L(const double E_L) { this->E_L = E_L; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_V_reset() const { return V_reset; } - inline void set_V_reset(const double V_reset) { this->V_reset = V_reset; } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_V_th() const { return V_th; } - inline void set_V_th(const double V_th) { this->V_th = V_th; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - - inline double get_Vinit() const { return Vinit; } - inline void set_Vinit(const double Vinit) { - this->Vinit = Vinit; - } - - inline double get_Vmin() const { return Vmin; } - inline void set_Vmin(const double Vmin) { - this->Vmin = Vmin; - } - - - /* Added for stochasticity*/ - inline double get_lambda_0() const { return lambda_0; } - inline void set_lambda_0(const double lambda_0) { - this->lambda_0 = lambda_0; - } - - inline double get_tau_V() const { return tau_V; } - inline void set_tau_V(const double tau_V) { - this->tau_V = tau_V; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_k1() const { return k1; } - inline void set_k1(const double k1) { this->k1 = k1; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_k2() const { return k2; } - inline void set_k2(const double k2) { this->k2 = k2; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_A1() const { return A1; } - inline void set_A1(const double A1) { this->A1 = A1; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_A2() const { return A2; } - inline void set_A2(const double A2) { this->A2 = A2; } - - inline double get_kadap() const { return kadap; } - inline void set_kadap(const double kadap) { this->kadap = kadap; } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline double get_I_e() const { return I_e; } - inline void set_I_e(const double I_e) { this->I_e = I_e; } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline long get_bT_size() const { return bT_size; } - inline void set_bT_size(const long bT_size) { this->bT_size = bT_size; } - }; - - /** - * Dynamic state of the neuron. - * - * - * - * These are the state variables that are advanced in time by calls to - * @c update(). In many models, some or all of them can be set by the user - * through @c SetStatus. The state variables are initialized from the model - * prototype when the node is created. State variables are reset by @c - * ResetNetwork. - * - * @note State_ need neither copy constructor nor @c operator=(), since - * all its members are copied properly by the default copy constructor - * and assignment operator. Important: - * - If State_ contained @c Time members, you need to define the - * assignment operator to recalibrate all members of type @c Time . You - * may also want to define the assignment operator. - * - If State_ contained members that cannot copy themselves, such - * as C-style arrays, you need to define the copy constructor and - * assignment operator to copy those members. - */ - - - - struct State_ { - /** - * Enumeration identifying elements in state vector State_::y_. - * This enum identifies the elements of the vector. It must be public to be - * accessible from the iteration function. The last two elements of this - * enum (DG, G) will be repeated - * n times at the end of the state vector State_::y_ with n being the number - * of synapses. - */ - //! Symbolic indices to the elements of the state vector y_ - enum StateVecElems { - V_m, - I_dep, - I_adap, - G1, - DG1, - G2, - DG2, - G3, - DG3, - G4, - DG4, - STATE_VEC_SIZE // This is the minimum state vector size - }; - //! state vector, must be C-array for GSL solver - - double y_[STATE_VEC_SIZE];// - an array of all the state variables undergoing - - double time; - - double I_syn; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - double I_tot; // - - State_(); - - /** - * Set state values from dictionary. - */ - void set(const DictionaryDatum &, const Parameters_ &); - }; - - /** - * Internal variables of the neuron. - * - * - * - * These variables must be initialized by @c calibrate, which is called before - * the first call to @c update() upon each call to @c Simulate. - * @node Variables_ needs neither constructor, copy constructor or assignment - * operator, - * since it is initialized by @c calibrate(). If Variables_ has members - * that - * cannot destroy themselves, Variables_ will need a destructor. - */ - struct Variables_ { - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - librandom::RngPtr rng_; // random number generator of my own thread - - long RefractoryCounts; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - long r; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - long receptors; // Number of receptors - - - std::vector G0; // - - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - std::vector bufferT; // - - /* generated by template org.nest.nestml.function.MemberDeclaration*/ - - double tot_cur; // - - double V_th; - - double I_gen; // To monitor external generator current - - double sum_buffer; - - - // Added for R2 update - double R2; - double old_Vm; - double new_Vm; - double old_slope; // - double new_slope; - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline long get_RefractoryCounts() const { return RefractoryCounts; } - inline void set_RefractoryCounts(const long RefractoryCounts) { - this->RefractoryCounts = RefractoryCounts; - } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline long get_r() const { return r; } - inline void set_r(const long r) { this->r = r; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline long get_receptors() const{return receptors; } - inline void set_receptors(const long receptors) { - this->receptors = receptors; - } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline std::vector get_G0() const { return G0; } - inline void set_G0(const std::vector G0) { - this->G0 = G0; - } - - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - - inline std::vector get_bufferT() const { return bufferT; } - inline void set_bufferT(const std::vector bufferT) { - this->bufferT = bufferT; - } - - inline double get_Vth() const { return V_th; } - inline void set_Vth(const double V_th) { this->V_th = V_th; } - - inline double get_I_gen() const { return I_gen; } - inline void set_I_gen(const double I_gen) { this->I_gen = I_gen; } - - inline double get_sum_buffer() const { return sum_buffer; } - inline void set_sum_buffer(const double sum_buffer) { this->sum_buffer = sum_buffer; } - - /* generated by template org.nest.nestml.function.StructGetterSetter*/ - inline double get_tot_cur() const { return tot_cur; } - inline void set_tot_cur(const double tot_cur) { this->tot_cur = tot_cur; } - - inline double get_R2() const { return R2; } - inline void set_R2(const double R2) { this->R2 = R2; } - - inline double get_old_Vm() const { return old_Vm; } - inline void set_old_Vm(const double old_Vm) { this->old_Vm = old_Vm; } - - inline double get_new_Vm() const { return new_Vm; } - inline void set_new_Vm(const double new_Vm) { this->new_Vm = new_Vm; } - - inline double get_old_slope() const { return old_slope; } - inline void set_old_slope(const double old_slope) { this->old_slope = old_slope; } - - inline double get_new_slope() const { return new_slope; } - inline void set_new_slope(const double new_slope) { this->new_slope = new_slope; } - - }; - - /** - * Buffers of the neuron. - * Ususally buffers for incoming spikes and data logged for analog recorders. - * Buffers must be initialized by @c init_buffers_(), which is called before - * @c calibrate() on the first call to @c Simulate after the start of NEST, - * ResetKernel or ResetNetwork. - * @node Buffers_ needs neither constructor, copy constructor or assignment - * operator, - * since it is initialized by @c init_nodes_(). If Buffers_ has members - * that - * cannot destroy themselves, Buffers_ will need a destructor. - */ - struct Buffers_ { - Buffers_(eglif_cond_alpha_multisyn &); - Buffers_(const Buffers_ &, eglif_cond_alpha_multisyn &); - - inline nest::RingBuffer &get_spikes_r1() { return spikes_r1; } - nest::RingBuffer spikes_r1; - //!< Buffer incoming Buffers through delay, as sum - ; - double spikes_r1_last_value_; - - inline nest::RingBuffer &get_spikes_r2() { return spikes_r2; } - nest::RingBuffer spikes_r2; - //!< Buffer incoming Buffers through delay, as sum - ; - double spikes_r2_last_value_; - - inline nest::RingBuffer &get_spikes_r3() { return spikes_r3; } - nest::RingBuffer spikes_r3; - //!< Buffer incoming Buffers through delay, as sum - ; - double spikes_r3_last_value_; - - inline nest::RingBuffer &get_spikes_r4() { return spikes_r4; } - nest::RingBuffer spikes_r4; - //!< Buffer incoming Buffers through delay, as sum - ; - double spikes_r4_last_value_; - - inline nest::RingBuffer &get_currents() { return currents; } - nest::RingBuffer currents; - //!< Buffer incoming Buffers through delay, as sum - ; - double currents_last_value_; - - /** Logger for all analog data */ - nest::UniversalDataLogger logger_; - - std::vector receptor_types_; - - /* GSL ODE stuff */ - gsl_odeiv_step *s_; //!< stepping function - gsl_odeiv_control *c_; //!< adaptive stepsize control function - gsl_odeiv_evolve *e_; //!< evolution function - gsl_odeiv_system sys_; //!< struct describing system - }; - -private: - /** - * @defgroup pif_members Member variables of neuron model. - * Each model neuron should have precisely the following four data members, - * which are one instance each of the parameters, state, buffers and variables - * structures. Experience indicates that the state and variables member should - * be next to each other to achieve good efficiency (caching). - * @note Devices require one additional data member, an instance of the @c - * Device - * child class they belong to. - * @{ - */ - Parameters_ P_; //!< Free parameters. - State_ S_; //!< Dynamic state. - Variables_ V_; //!< Internal Variables - Buffers_ B_; //!< Buffers. - - //! Mapping of recordables names to access functions - static nest::RecordablesMap recordablesMap_; - - friend int eglif_cond_alpha_multisyn_dynamics(double, const double y[], - double f[], void *pnode); - // friend int eglif_cond_alpha_multisyn_dynamics(double, const double*, - // double*, void *pnode); - - /** @} */ -}; /* neuron eglif_cond_alpha_multisyn */ - -inline nest::port eglif_cond_alpha_multisyn::send_test_event( - nest::Node &target, nest::rport receptor_type, nest::synindex, bool) { - // You should usually not change the code in this function. - // It confirms that the target of connection @c c accepts @c nest::SpikeEvent - // on - // the given @c receptor_type. - nest::SpikeEvent e; - e.set_sender(*this); - - return target.handles_test_event(e, receptor_type); -} - -// Questa funzione non c'è nell'AEIF cond alpha multisyn -inline nest::port -eglif_cond_alpha_multisyn::handles_test_event(nest::SpikeEvent &, - nest::port receptor_type) { - - if (receptor_type <= 0 || - receptor_type > 4 ){ //static_cast(get_receptors())) { - // TODO refactor me. The code assumes that there is only one. Check by coco. - std::cout<(__d, "C_m", get_C_m()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "tau_m", get_tau_m()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "tau_syn1", get_tau_syn1()); - -/* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "E_rev1", get_E_rev1()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "tau_syn2", get_tau_syn2()); - -/* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "E_rev2", get_E_rev2()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "tau_syn3", get_tau_syn3()); - -/* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "E_rev3", get_E_rev3()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "tau_syn4", get_tau_syn4()); - -/* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "E_rev4", get_E_rev4()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "t_ref", get_t_ref()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "E_L", get_E_L()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "V_reset", get_V_reset()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "V_th", get_V_th()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "Vinit", get_Vinit()); - - def(__d, "Vmin", get_Vmin()); - - /* Added for stochasticity*/ - def(__d, "lambda_0", get_lambda_0()); - - def(__d, "tau_V", get_tau_V()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "k1", get_k1()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "k2", get_k2()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "A1", get_A1()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "A2", get_A2()); - - def(__d, "kadap", get_kadap()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "I_e", get_I_e()); - - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "bT_size", get_bT_size()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "I_dep", get_I_dep()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "I_adap", get_I_adap()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "V_m", get_V_m()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - def(__d, "G1", get_G1()); - - def(__d, "DG1", get_DG1()); - - def(__d, "G2", get_G2()); - - def(__d, "DG2", get_DG2()); - - def(__d, "G3", get_G3()); - - def(__d, "DG3", get_DG3()); - - def(__d, "G4", get_G4()); - - def(__d, "DG4", get_DG4()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - //def(__d, "time", get_time()); - - /* generated by template org.nest.nestml.function.WriteInDictionary*/ - - - (*__d)[nest::names::recordables] = recordablesMap_.get_list(); -} - -inline void -eglif_cond_alpha_multisyn::set_status(const DictionaryDatum &__d) { - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_C_m; - if (updateValue(__d, "C_m", tmp_C_m)) { - set_C_m(tmp_C_m); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_tau_m; - if (updateValue(__d, "tau_m", tmp_tau_m)) { - set_tau_m(tmp_tau_m); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_tau_syn1; - if (updateValue(__d, "tau_syn1", tmp_tau_syn1)) { - set_tau_syn1(tmp_tau_syn1); - } - - -/* generated by template org.nest.nestml.function.ReadFromDictionary*/ - double tmp_E_rev1; - if (updateValue(__d, "E_rev1", tmp_E_rev1)) { - set_E_rev1(tmp_E_rev1); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_tau_syn2; - if (updateValue(__d, "tau_syn2", tmp_tau_syn2)) { - set_tau_syn2(tmp_tau_syn2); - } - - -/* generated by template org.nest.nestml.function.ReadFromDictionary*/ - double tmp_E_rev2; - if (updateValue(__d, "E_rev2", tmp_E_rev2)) { - set_E_rev2(tmp_E_rev2); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_tau_syn3; - if (updateValue(__d, "tau_syn3", tmp_tau_syn3)) { - set_tau_syn3(tmp_tau_syn3); - } - - -/* generated by template org.nest.nestml.function.ReadFromDictionary*/ - double tmp_E_rev3; - if (updateValue(__d, "E_rev3", tmp_E_rev3)) { - set_E_rev3(tmp_E_rev3); - } - -/* generated by template org.nest.nestml.function.ReadFromDictionary*/ - double tmp_tau_syn4; - if (updateValue(__d, "tau_syn4", tmp_tau_syn4)) { - set_tau_syn4(tmp_tau_syn4); - } - - -/* generated by template org.nest.nestml.function.ReadFromDictionary*/ - double tmp_E_rev4; - if (updateValue(__d, "E_rev4", tmp_E_rev4)) { - set_E_rev4(tmp_E_rev4); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_t_ref; - if (updateValue(__d, "t_ref", tmp_t_ref)) { - set_t_ref(tmp_t_ref); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_E_L; - if (updateValue(__d, "E_L", tmp_E_L)) { - set_E_L(tmp_E_L); - } - - - - - double tmp_V_reset; - if (updateValue(__d, "V_reset", tmp_V_reset)) { - set_V_reset(tmp_V_reset); - } - - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_V_th; - if (updateValue(__d, "V_th", tmp_V_th)) { - set_V_th(tmp_V_th); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - - double tmp_Vinit; - if (updateValue(__d, "Vinit", tmp_Vinit)) { - set_Vinit(tmp_Vinit); - } - - double tmp_Vmin; - if (updateValue(__d, "Vmin", tmp_Vmin)) { - set_Vmin(tmp_Vmin); - } - - - /*Added for stochasticity*/ - double tmp_lambda_0; - if (updateValue(__d, "lambda_0", tmp_lambda_0)) { - set_lambda_0(tmp_lambda_0); - } - - double tmp_tau_V; - if (updateValue(__d, "tau_V", tmp_tau_V)) { - set_tau_V(tmp_tau_V); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_k1; - if (updateValue(__d, "k1", tmp_k1)) { - set_k1(tmp_k1); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_k2; - if (updateValue(__d, "k2", tmp_k2)) { - set_k2(tmp_k2); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_A1; - if (updateValue(__d, "A1", tmp_A1)) { - set_A1(tmp_A1); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_A2; - if (updateValue(__d, "A2", tmp_A2)) { - set_A2(tmp_A2); - } - - double tmp_kadap; - if (updateValue(__d, "kadap", tmp_kadap)) { - set_kadap(tmp_kadap); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_I_e; - if (updateValue(__d, "I_e", tmp_I_e)) { - set_I_e(tmp_I_e); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - long tmp_bT_size; - if (updateValue(__d, "bT_size", tmp_bT_size)) { - set_bT_size(tmp_bT_size); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_I_dep; - if (updateValue(__d, "I_dep", tmp_I_dep)) { - set_I_dep(tmp_I_dep); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_I_adap; - if (updateValue(__d, "I_adap", tmp_I_adap)) { - set_I_adap(tmp_I_adap); - } - - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ - - double tmp_V_m; - if (updateValue(__d, "V_m", tmp_V_m)) { - set_V_m(tmp_V_m); - } - - - double tmp_G1; - if (updateValue(__d, "G1", tmp_G1)) { - set_G1(tmp_G1); - } - - double tmp_DG1; - if (updateValue(__d, "DG1", tmp_DG1)) { - set_DG1(tmp_DG1); - } - - double tmp_G2; - if (updateValue(__d, "G2", tmp_G2)) { - set_G2(tmp_G2); - } - - double tmp_DG2; - if (updateValue(__d, "DG2", tmp_DG2)) { - set_DG2(tmp_DG2); - } - - double tmp_G3; - if (updateValue(__d, "G3", tmp_G3)) { - set_G3(tmp_G3); - } - - double tmp_DG3; - if (updateValue(__d, "DG3", tmp_DG3)) { - set_DG3(tmp_DG3); - } - - /* generated by template org.nest.nestml.function.ReadFromDictionary*/ -/* - double tmp_time; - if (updateValue(__d, "time", tmp_time)) { - set_time(tmp_time); - } -*/ - - // We now know that (ptmp, stmp) are consistent. We do not - // write them back to (P_, S_) before we are also sure that - // the properties to be set in the parent class are internally - // consistent. - Archiving_Node::set_status(__d); + // We now know that (ptmp, stmp) are consistent. We do not + // write them back to (P_, S_) before we are also sure that + // the properties to be set in the parent class are internally + // consistent. + ArchivingNode::set_status(__d); // if we get here, temporaries contain consistent set of properties - // P_ = ptmp; - // S_ = stmp; + set_C_m(tmp_C_m); + set_t_ref(tmp_t_ref); + set_V_reset(tmp_V_reset); + set_tau_m(tmp_tau_m); + set_E_L(tmp_E_L); + set_kadap(tmp_kadap); + set_k2(tmp_k2); + set_A2(tmp_A2); + set_k1(tmp_k1); + set_A1(tmp_A1); + set_V_th(tmp_V_th); + set_V_min(tmp_V_min); + set_E_rev1(tmp_E_rev1); + set_tau_syn1(tmp_tau_syn1); + set_E_rev2(tmp_E_rev2); + set_tau_syn2(tmp_tau_syn2); + set_E_rev3(tmp_E_rev3); + set_tau_syn3(tmp_tau_syn3); + set_E_rev4(tmp_E_rev4); + set_tau_syn4(tmp_tau_syn4); + set_I_e(tmp_I_e); + set_V_m(tmp_V_m); + set_Iadap(tmp_Iadap); + set_Idep(tmp_Idep); + set_g_4__X__rec4_spikes(tmp_g_4__X__rec4_spikes); + set_g_4__X__rec4_spikes__d(tmp_g_4__X__rec4_spikes__d); + set_g_1__X__rec1_spikes(tmp_g_1__X__rec1_spikes); + set_g_1__X__rec1_spikes__d(tmp_g_1__X__rec1_spikes__d); + set_g_2__X__rec2_spikes(tmp_g_2__X__rec2_spikes); + set_g_2__X__rec2_spikes__d(tmp_g_2__X__rec2_spikes__d); + set_g_3__X__rec3_spikes(tmp_g_3__X__rec3_spikes); + set_g_3__X__rec3_spikes__d(tmp_g_3__X__rec3_spikes__d); + + + updateValue< double >(__d, nest::names::gsl_error_tol, P_.__gsl_error_tol); + if ( P_.__gsl_error_tol <= 0. ) + { + throw nest::BadProperty( "The gsl_error_tol must be strictly positive." ); + } }; -#endif /* #ifndef EGLIF_COND_ALPHA_MULTISYN */ -#endif /* HAVE GSL */ +#endif /* #ifndef EGLIF_COND_ALPHA_MULTISYN */ diff --git a/stdp_connection_alpha.cpp b/stdp_connection_alpha.cpp index d77f431..6511b0e 100644 --- a/stdp_connection_alpha.cpp +++ b/stdp_connection_alpha.cpp @@ -40,7 +40,7 @@ // Includes from sli: #include "dictdatum.h" -namespace mynest +namespace nest { // // Implementation of class STDPAlphaCommonProperties. @@ -62,7 +62,7 @@ STDPAlphaCommonProperties::get_status( DictionaryDatum& d ) const nest::CommonSynapseProperties::get_status( d ); if ( vtC_ != 0 ) { - def< long >( d, nest::names::vt, vtC_->get_gid() ); + def< long >( d, nest::names::vt, vtC_->get_node_id() ); } else @@ -84,7 +84,7 @@ STDPAlphaCommonProperties::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( + vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid, nest::kernel().vp_manager.get_thread_id() ) ); if ( vtC_ == 0 ) { diff --git a/stdp_connection_alpha.h b/stdp_connection_alpha.h index 2a458d4..9ada45d 100644 --- a/stdp_connection_alpha.h +++ b/stdp_connection_alpha.h @@ -54,6 +54,7 @@ */ +#include "config.h" #include "connection.h" #include "spikecounter.h" #include "volume_transmitter_alberto.h" @@ -61,7 +62,7 @@ #include #include "mynames.h" -namespace mynest +namespace nest { /** @@ -94,7 +95,7 @@ STDPAlphaCommonProperties::get_vt_gid() const { if ( vtC_ != 0 ) { - return vtC_->get_gid(); + return vtC_->get_node_id(); } else { @@ -113,7 +114,7 @@ class STDPAlphaConnection : public nest::Connection< targetidentifierT > public: - nest::Node* get_node(); + nest::Node* get_node_or_proxy(); long get_vt_gid() const; @@ -251,7 +252,7 @@ template < typename targetidentifierT > void STDPAlphaConnection< targetidentifi def< double >( d, "vt_num", vt_num_ ); if ( vt_ != 0 ) { - def< long >( d, "modulator", vt_->get_gid() ); + def< long >( d, "modulator", vt_->get_node_id() ); } else { @@ -266,7 +267,7 @@ STDPAlphaConnection< targetidentifierT >::get_vt_gid( ) const { if ( vt_ != 0 ) { - return vt_->get_gid(); + return vt_->get_node_id(); } else { @@ -286,7 +287,7 @@ STDPAlphaConnection< targetidentifierT >::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( vtgid ) ); + vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid ) ); if ( vt_ == 0 ) { throw nest::BadProperty( "vt needs to be a Volume Transmitter" ); @@ -428,7 +429,7 @@ STDPAlphaConnection< targetidentifierT >::trigger_update_weight( template < typename targetidentifierT > inline nest::Node* -STDPAlphaConnection< targetidentifierT >::get_node() +STDPAlphaConnection< targetidentifierT >::get_node_or_proxy() { if ( vt_ == 0 ) { diff --git a/stdp_connection_cosexp.cpp b/stdp_connection_cosexp.cpp index eb55b98..c893cfc 100644 --- a/stdp_connection_cosexp.cpp +++ b/stdp_connection_cosexp.cpp @@ -40,7 +40,7 @@ // Includes from sli: #include "dictdatum.h" -namespace mynest +namespace nest { // // Implementation of class STDPCosExpCommonProperties. @@ -62,7 +62,7 @@ STDPCosExpCommonProperties::get_status( DictionaryDatum& d ) const nest::CommonSynapseProperties::get_status( d ); if ( vtC_ != 0 ) { - def< long >( d, nest::names::vt, vtC_->get_gid() ); + def< long >( d, nest::names::vt, vtC_->get_node_id() ); } else @@ -84,7 +84,7 @@ STDPCosExpCommonProperties::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( + vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid, nest::kernel().vp_manager.get_thread_id() ) ); if ( vtC_ == 0 ) { diff --git a/stdp_connection_cosexp.h b/stdp_connection_cosexp.h index 88afe81..2ddaeb7 100644 --- a/stdp_connection_cosexp.h +++ b/stdp_connection_cosexp.h @@ -60,7 +60,7 @@ #include #include "mynames.h" -namespace mynest +namespace nest { /** @@ -93,7 +93,7 @@ STDPCosExpCommonProperties::get_vt_gid() const { if ( vtC_ != 0 ) { - return vtC_->get_gid(); + return vtC_->get_node_id(); } else { @@ -112,7 +112,7 @@ class STDPCosExpConnection : public nest::Connection< targetidentifierT > public: - nest::Node* get_node(); + nest::Node* get_node_or_proxy(); long get_vt_gid() const; @@ -252,7 +252,7 @@ template < typename targetidentifierT > void STDPCosExpConnection< targetidentif def< double >( d, "vt_num", vt_num_ ); if ( vt_ != 0 ) { - def< long >( d, "modulator", vt_->get_gid() ); + def< long >( d, "modulator", vt_->get_node_id() ); } else { @@ -267,7 +267,7 @@ STDPCosExpConnection< targetidentifierT >::get_vt_gid( ) const { if ( vt_ != 0 ) { - return vt_->get_gid(); + return vt_->get_node_id(); } else { @@ -287,7 +287,7 @@ STDPCosExpConnection< targetidentifierT >::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( vtgid ) ); + vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid ) ); if ( vt_ == 0 ) { throw nest::BadProperty( "vt needs to be a Volume Transmitter" ); @@ -454,7 +454,7 @@ STDPCosExpConnection< targetidentifierT >::trigger_update_weight( template < typename targetidentifierT > inline nest::Node* -STDPCosExpConnection< targetidentifierT >::get_node() +STDPCosExpConnection< targetidentifierT >::get_node_or_proxy() { if ( vt_ == 0 ) { diff --git a/stdp_connection_sinexp.cpp b/stdp_connection_sinexp.cpp index d11a34b..2c3578a 100644 --- a/stdp_connection_sinexp.cpp +++ b/stdp_connection_sinexp.cpp @@ -40,7 +40,7 @@ // Includes from sli: #include "dictdatum.h" -namespace mynest +namespace nest { // // Implementation of class STDPSinExpCommonProperties. @@ -62,7 +62,7 @@ STDPSinExpCommonProperties::get_status( DictionaryDatum& d ) const nest::CommonSynapseProperties::get_status( d ); if ( vtC_ != 0 ) { - def< long >( d, nest::names::vt, vtC_->get_gid() ); + def< long >( d, nest::names::vt, vtC_->get_node_id() ); } else @@ -84,7 +84,7 @@ STDPSinExpCommonProperties::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( + vtC_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid, nest::kernel().vp_manager.get_thread_id() ) ); if ( vtC_ == 0 ) { diff --git a/stdp_connection_sinexp.h b/stdp_connection_sinexp.h index 36cd021..1303d3b 100644 --- a/stdp_connection_sinexp.h +++ b/stdp_connection_sinexp.h @@ -60,7 +60,7 @@ #include #include "mynames.h" -namespace mynest +namespace nest { /** @@ -93,7 +93,7 @@ STDPSinExpCommonProperties::get_vt_gid() const { if ( vtC_ != 0 ) { - return vtC_->get_gid(); + return vtC_->get_node_id(); } else { @@ -112,7 +112,7 @@ class STDPSinExpConnection : public nest::Connection< targetidentifierT > public: - nest::Node* get_node(); + nest::Node* get_node_or_proxy(); long get_vt_gid() const; @@ -251,7 +251,7 @@ template < typename targetidentifierT > void STDPSinExpConnection< targetidentif def< double >( d, "vt_num", vt_num_ ); if ( vt_ != 0 ) { - def< long >( d, "modulator", vt_->get_gid() ); + def< long >( d, "modulator", vt_->get_node_id() ); } else { @@ -266,7 +266,7 @@ STDPSinExpConnection< targetidentifierT >::get_vt_gid( ) const { if ( vt_ != 0 ) { - return vt_->get_gid(); + return vt_->get_node_id(); } else { @@ -286,7 +286,7 @@ STDPSinExpConnection< targetidentifierT >::set_status( const DictionaryDatum& d, long vtgid; if ( updateValue< long >( d, nest::names::vt, vtgid ) ) { - vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node( vtgid ) ); + vt_ = dynamic_cast< volume_transmitter_alberto* >( nest::kernel().node_manager.get_node_or_proxy( vtgid ) ); if ( vt_ == 0 ) { throw nest::BadProperty( "vt needs to be a Volume Transmitter" ); @@ -429,7 +429,7 @@ STDPSinExpConnection< targetidentifierT >::trigger_update_weight( template < typename targetidentifierT > inline nest::Node* -STDPSinExpConnection< targetidentifierT >::get_node() +STDPSinExpConnection< targetidentifierT >::get_node_or_proxy() { if ( vt_ == 0 ) { diff --git a/volume_transmitter_alberto.cpp b/volume_transmitter_alberto.cpp index 76993b4..bfac33c 100644 --- a/volume_transmitter_alberto.cpp +++ b/volume_transmitter_alberto.cpp @@ -43,7 +43,7 @@ * Default constructor defining default parameters * ---------------------------------------------------------------- */ -mynest::volume_transmitter_alberto::Parameters_::Parameters_() +nest::volume_transmitter_alberto::Parameters_::Parameters_() : deliver_interval_( 1 ) // in steps of mindelay , vt_num_ ( 0 ) { @@ -54,13 +54,13 @@ mynest::volume_transmitter_alberto::Parameters_::Parameters_() * ---------------------------------------------------------------- */ void -mynest::volume_transmitter_alberto::Parameters_::get( DictionaryDatum& d ) const +nest::volume_transmitter_alberto::Parameters_::get( DictionaryDatum& d ) const { def< long >( d, nest::names::deliver_interval, deliver_interval_ ); def< long >( d, "vt_num", vt_num_ ); } -void mynest::volume_transmitter_alberto::Parameters_::set( const DictionaryDatum& d ) +void nest::volume_transmitter_alberto::Parameters_::set( const DictionaryDatum& d ) { updateValue< long >( d, nest::names::deliver_interval, deliver_interval_ ); updateValue< long >( d, "vt_num", vt_num_ ); @@ -70,35 +70,35 @@ void mynest::volume_transmitter_alberto::Parameters_::set( const DictionaryDatum * Default and copy constructor for volume transmitter * ---------------------------------------------------------------- */ -mynest::volume_transmitter_alberto::volume_transmitter_alberto() - : Archiving_Node() +nest::volume_transmitter_alberto::volume_transmitter_alberto() + : ArchivingNode() , P_() { } -mynest::volume_transmitter_alberto::volume_transmitter_alberto( const volume_transmitter_alberto& n ) - : Archiving_Node( n ) +nest::volume_transmitter_alberto::volume_transmitter_alberto( const volume_transmitter_alberto& n ) + : ArchivingNode( n ) , P_( n.P_ ) { } void -mynest::volume_transmitter_alberto::init_state_( const Node& ) +nest::volume_transmitter_alberto::init_state_( const Node& ) { } void -mynest::volume_transmitter_alberto::init_buffers_() +nest::volume_transmitter_alberto::init_buffers_() { B_.neuromodulatory_spikes_.clear(); B_.spikecounter_.clear(); B_.spikecounter_.push_back( nest::spikecounter( 0.0, 0.0 ) ); // insert pseudo last dopa spike at t = 0.0 - Archiving_Node::clear_history(); + ArchivingNode::clear_history(); } void -mynest::volume_transmitter_alberto::calibrate() +nest::volume_transmitter_alberto::calibrate() { // +1 as pseudo dopa spike at t_trig is inserted after trigger_update_weight B_.spikecounter_.reserve( @@ -106,7 +106,7 @@ mynest::volume_transmitter_alberto::calibrate() } void -mynest::volume_transmitter_alberto::update( const nest::Time&, const long from, const long to ) +nest::volume_transmitter_alberto::update( const nest::Time&, const long from, const long to ) { // spikes that arrive in this time slice are stored in spikecounter_ double t_spike; @@ -125,7 +125,7 @@ mynest::volume_transmitter_alberto::update( const nest::Time&, const long from, if ( not( B_.spikecounter_.empty() ) ) { //std::cout << P_.vt_num_ << " << P_.vt_num_ " << get_gid() << " << get_gid() " << std::endl; - nest::kernel().connection_manager.trigger_update_weight(get_gid()-P_.vt_num_, B_.spikecounter_, t_trig ); + nest::kernel().connection_manager.trigger_update_weight(get_node_id()-P_.vt_num_, B_.spikecounter_, t_trig ); } // clear spikecounter B_.spikecounter_.clear(); @@ -138,7 +138,7 @@ mynest::volume_transmitter_alberto::update( const nest::Time&, const long from, } void -mynest::volume_transmitter_alberto::handle( nest::SpikeEvent& e ) +nest::volume_transmitter_alberto::handle( nest::SpikeEvent& e ) { B_.neuromodulatory_spikes_.add_value( e.get_rel_delivery_steps( nest::kernel().simulation_manager.get_slice_origin() ), diff --git a/volume_transmitter_alberto.h b/volume_transmitter_alberto.h index 83e14b7..494656f 100644 --- a/volume_transmitter_alberto.h +++ b/volume_transmitter_alberto.h @@ -34,7 +34,7 @@ #include "namedatum.h" -namespace mynest +namespace nest { /** @BeginDocumentation @@ -92,9 +92,11 @@ Receives: SpikeEvent SeeAlso: stdp_dopamine_synapse */ -class ConnectorBase; -class volume_transmitter_alberto : public nest::Archiving_Node + +//class ConnectorBase{} + +class volume_transmitter_alberto : public nest::ArchivingNode { public: @@ -187,7 +189,7 @@ inline void volume_transmitter_alberto::get_status( DictionaryDatum& d ) const { P_.get( d ); - nest::Archiving_Node::get_status( d ); + nest::ArchivingNode::get_status( d ); ( *d )[ nest::names::element_type ] = LiteralDatum( nest::names::other ); } @@ -202,7 +204,7 @@ volume_transmitter_alberto::set_status( const DictionaryDatum& d ) // write them back to (P_, S_) before we are also sure that // the properties to be set in the parent class are internally // consistent. - nest::Archiving_Node::set_status( d ); + nest::ArchivingNode::set_status( d ); // if we get here, temporaries contain consistent set of properties P_ = ptmp;