Skip to content
Snippets Groups Projects
Commit 92e424bd authored by Ben Cumming's avatar Ben Cumming Committed by GitHub
Browse files

Merge pull request #37 from halfflat/feature/probe_unit_tests

Unit tests for probe functionality
parents 336e0864 3e19099c
No related branches found
No related tags found
No related merge requests found
......@@ -133,6 +133,9 @@ public:
/// returns voltage at a segment location
value_type voltage(segment_location loc) const;
/// returns current at a segment location
value_type current(segment_location loc) const;
value_type time() const { return t_; }
value_type probe(uint32_t i) const {
......@@ -484,6 +487,12 @@ T fvm_cell<T, I>::voltage(segment_location loc) const
return voltage_[compartment_index(loc)];
}
template <typename T, typename I>
T fvm_cell<T, I>::current(segment_location loc) const
{
return current_[compartment_index(loc)];
}
template <typename T, typename I>
void fvm_cell<T, I>::initialize()
{
......
......@@ -24,6 +24,7 @@ set(TEST_SOURCES
test_optional.cpp
test_parameters.cpp
test_point.cpp
test_probe.cpp
test_segment.cpp
test_spikes.cpp
test_stimulus.cpp
......
#include "gtest.h"
#include "cell.hpp"
#include "fvm_cell.hpp"
TEST(probe, instantiation)
{
using namespace nest::mc;
cell c1;
segment_location loc1{0, 0};
segment_location loc2{1, 0.6};
auto p1 = c1.add_probe(loc1, probeKind::membrane_voltage);
auto p2 = c1.add_probe(loc2, probeKind::membrane_current);
// expect locally provided probe ids to be numbered sequentially from zero.
EXPECT_EQ(0, p1);
EXPECT_EQ(1, p2);
// expect the probes() return to be a collection with these two probes.
auto probes = c1.probes();
EXPECT_EQ(2u, probes.size());
EXPECT_EQ(loc1, probes[0].location);
EXPECT_EQ(probeKind::membrane_voltage, probes[0].kind);
EXPECT_EQ(loc2, probes[1].location);
EXPECT_EQ(probeKind::membrane_current, probes[1].kind);
}
TEST(probe, fvm_cell)
{
using namespace nest::mc;
cell bs;
// ball-and-stick model morphology
bs.add_soma(12.6157/2.0);
bs.add_cable(0, segmentKind::dendrite, 0.5, 0.5, 200);
bs.soma()->set_compartments(5);
segment_location loc0{0, 0};
segment_location loc1{1, 1};
segment_location loc2{1, 0.5};
auto pv0 = bs.add_probe(loc0, probeKind::membrane_voltage);
auto pv1 = bs.add_probe(loc1, probeKind::membrane_voltage);
auto pi2 = bs.add_probe(loc2, probeKind::membrane_current);
i_clamp stim(0, 100, 0.3);
bs.add_stimulus({1, 1}, stim);
fvm::fvm_cell<double, int> lcell(bs);
lcell.setup_matrix(0.01);
lcell.initialize();
EXPECT_EQ(3u, lcell.num_probes());
// expect probe values and direct queries of voltage and current
// to be equal in fvm cell
EXPECT_EQ(lcell.voltage(loc0), lcell.probe(pv0));
EXPECT_EQ(lcell.voltage(loc1), lcell.probe(pv1));
EXPECT_EQ(lcell.current(loc2), lcell.probe(pi2));
lcell.advance(0.05);
EXPECT_EQ(lcell.voltage(loc0), lcell.probe(pv0));
EXPECT_EQ(lcell.voltage(loc1), lcell.probe(pv1));
EXPECT_EQ(lcell.current(loc2), lcell.probe(pi2));
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment