From 0a4f0c3b1725f5538ade6ec27f6819ed9a970ae7 Mon Sep 17 00:00:00 2001 From: Ben Cumming <bcumming@cscs.ch> Date: Mon, 2 May 2016 09:32:14 +0200 Subject: [PATCH] fix OS X initializer list issue --- .gitignore | 2 ++ src/fvm.hpp | 52 +++++++++++++++++++++++++++++++++++++++++++++- src/ion.hpp | 12 ++++++----- tests/test_run.cpp | 17 +++++++++++++++ 4 files changed, 77 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c23dfde0..cd1f0915 100644 --- a/.gitignore +++ b/.gitignore @@ -47,3 +47,5 @@ CMakeCache.txt cmake_install.cmake Makefile +# mechanism implementations generated my modparser +include/mechanisms diff --git a/src/fvm.hpp b/src/fvm.hpp index c6c458c7..674c7d0e 100644 --- a/src/fvm.hpp +++ b/src/fvm.hpp @@ -88,6 +88,39 @@ class fvm_cell { return mechanisms_; } + /// return reference to list of ions + //std::map<mechanisms::ionKind, ion_type> ions_; + std::map<mechanisms::ionKind, ion_type>& ions() { + return ions_; + } + std::map<mechanisms::ionKind, ion_type> const& ions() const { + return ions_; + } + + /// return reference to sodium ion + ion_type& ion_na() { + return ions_[mechanisms::ionKind::na]; + } + ion_type const& ion_na() const { + return ions_[mechanisms::ionKind::na]; + } + + /// return reference to calcium ion + ion_type& ion_ca() { + return ions_[mechanisms::ionKind::ca]; + } + ion_type const& ion_ca() const { + return ions_[mechanisms::ionKind::ca]; + } + + /// return reference to pottasium ion + ion_type& ion_k() { + return ions_[mechanisms::ionKind::k]; + } + ion_type const& ion_k() const { + return ions_[mechanisms::ionKind::k]; + } + private: /// the linear system for implicit time stepping of cell state @@ -303,6 +336,24 @@ fvm_cell<T, I>::fvm_cell(nest::mc::cell const& cell) } } } + + // FIXME: Hard code parameters for now. + // Take defaults for reversal potential of sodium and potassium from + // the default values in Neuron. + // We don't use the other parameters for the HH model, so I leave the NaN. + // To set them I would have to go spelunking in the Neuron source. + using memory::all; + ion_ca().reversal_potential()(all) = std::numeric_limits<value_type>::quiet_NaN(); + ion_ca().internal_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); + ion_ca().external_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); + + ion_na().reversal_potential()(all) = -50.0; + ion_na().internal_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); + ion_na().external_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); + + ion_k().reversal_potential()(all) = -77.0; + ion_k().internal_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); + ion_k().external_concentration()(all) = std::numeric_limits<value_type>::quiet_NaN(); } template <typename T, typename I> @@ -348,7 +399,6 @@ void fvm_cell<T, I>::setup_matrix(T dt) } } - } // namespace fvm } // namespace mc } // namespace nest diff --git a/src/ion.hpp b/src/ion.hpp index 2f780616..311e8600 100644 --- a/src/ion.hpp +++ b/src/ion.hpp @@ -28,15 +28,17 @@ enum class ionKind {ca, na, k}; [[gnu::unused]] static std::string to_string(ionKind k) { - if(k==ionKind::na) return "sodium"; - if(k==ionKind::ca) return "calcium"; - if(k==ionKind::k) return "pottasium"; - return "unkown ion"; + switch(k) { + case ionKind::na : return "sodium"; + case ionKind::ca : return "calcium"; + case ionKind::k : return "pottasium"; + } + return "unkown"; } /// and a little helper to iterate over them [[gnu::unused]] static -std::initializer_list<ionKind> ion_kinds() +std::vector<ionKind> ion_kinds() { return {ionKind::ca, ionKind::na, ionKind::k}; } diff --git a/tests/test_run.cpp b/tests/test_run.cpp index 55c9c6fc..55fb0d0f 100644 --- a/tests/test_run.cpp +++ b/tests/test_run.cpp @@ -9,6 +9,9 @@ TEST(run, cable) nest::mc::cell cell; + // setup global state for the mechanisms + nest::mc::mechanisms::setup_mechanism_helpers(); + cell.add_soma(6e-4); // 6um in cm // 1um radius and 4mm long, all in cm @@ -44,6 +47,17 @@ TEST(run, cable) fvcell.setup_matrix(0.02); EXPECT_EQ(fvcell.cv_areas().size(), J.size()); + // inspect ion channels + /* + std::cout << "ion na index : " << fvcell.ion_na().node_index() << "\n"; + std::cout << "ion ca index : " << fvcell.ion_ca().node_index() << "\n"; + std::cout << "ion k index : " << fvcell.ion_k().node_index() << "\n"; + + std::cout << "ion na E : " << fvcell.ion_na().reversal_potential() << "\n"; + std::cout << "ion ca E : " << fvcell.ion_ca().reversal_potential() << "\n"; + std::cout << "ion k E : " << fvcell.ion_k().reversal_potential() << "\n"; + */ + //auto& cable_parms = cell.segment(1)->mechanism("membrane"); //std::cout << soma_hh << std::endl; //std::cout << cable_parms << std::endl; @@ -65,6 +79,9 @@ TEST(run, init) nest::mc::cell cell; + // setup global state for the mechanisms + nest::mc::mechanisms::setup_mechanism_helpers(); + cell.add_soma(12.6157/2.0); //auto& props = cell.soma()->properties; -- GitLab