Skip to content
Snippets Groups Projects
Select Git revision
  • 994e9169a37261b0ac6b58cae20a1a1b99d4886d
  • master default protected
  • tut_ring_allen
  • docs_furo
  • docs_reorder_cable_cell
  • docs_graphviz
  • docs_rtd_dev
  • ebrains_mirror
  • doc_recat
  • docs_spike_source
  • docs_sim_sample_clar
  • docs_pip_warn
  • github_template_updates
  • docs_fix_link
  • cv_default_and_doc_clarification
  • docs_add_numpy_req
  • readme_zenodo_05
  • install_python_fix
  • install_require_numpy
  • typofix_propetries
  • docs_recipe_lookup
  • v0.10.0
  • v0.10.1
  • v0.10.0-rc5
  • v0.10.0-rc4
  • v0.10.0-rc3
  • v0.10.0-rc2
  • v0.10.0-rc
  • v0.9.0
  • v0.9.0-rc
  • v0.8.1
  • v0.8
  • v0.8-rc
  • v0.7
  • v0.6
  • v0.5.2
  • v0.5.1
  • v0.5
  • v0.4
  • v0.3
  • v0.2.2
41 results

test_fvm.cpp

Blame
  • test_fvm.cpp 2.75 KiB
    #include <fstream>
    
    #include "gtest.h"
    
    #include <common_types.hpp>
    #include <cell.hpp>
    #include <fvm_cell.hpp>
    
    #include "../test_util.hpp"
    
    TEST(fvm, cable)
    {
        using namespace nest::mc;
    
        nest::mc::cell cell;
    
        cell.add_soma(6e-4); // 6um in cm
    
        // 1um radius and 4mm long, all in cm
        cell.add_cable(0, segmentKind::dendrite, 1e-4, 1e-4, 4e-1);
        cell.add_cable(0, segmentKind::dendrite, 1e-4, 1e-4, 4e-1);
    
        //std::cout << cell.segment(1)->area() << " is the area\n";
        EXPECT_EQ(cell.model().tree.num_segments(), 3u);
    
        // add passive to all 3 segments in the cell
        for(auto& seg :cell.segments()) {
            seg->add_mechanism(pas_parameters());
        }
    
        cell.soma()->add_mechanism(hh_parameters());
        cell.segment(2)->add_mechanism(hh_parameters());
    
        auto& soma_hh = cell.soma()->mechanism("hh");
    
        soma_hh.set("gnabar", 0.12);
        soma_hh.set("gkbar", 0.036);
        soma_hh.set("gl", 0.0003);
        soma_hh.set("el", -54.387);
    
        cell.segment(1)->set_compartments(4);
        cell.segment(2)->set_compartments(4);
    
        using fvm_cell = fvm::fvm_cell<double, cell_lid_type>;
        fvm_cell fvcell(cell);
        auto& J = fvcell.jacobian();
    
        EXPECT_EQ(cell.num_compartments(), 9u);
    
        // assert that the matrix has one row for each compartment
        EXPECT_EQ(J.size(), cell.num_compartments());
    
        fvcell.setup_matrix(0.02);
    
        // assert that the number of cv areas is the same as the matrix size
        // i.e. both should equal the number of compartments
        EXPECT_EQ(fvcell.cv_areas().size(), J.size());
    }
    
    TEST(fvm, init)
    {
        using namespace nest::mc;
    
        nest::mc::cell cell;
    
        cell.add_soma(12.6157/2.0);
        //auto& props = cell.soma()->properties;
    
        cell.add_cable(0, segmentKind::dendrite, 0.5, 0.5, 200);
    
        const auto m = cell.model();
        EXPECT_EQ(m.tree.num_segments(), 2u);
    
        // in this context (i.e. attached to a segment on a high-level cell)
        // a mechanism is essentially a set of parameters
        // - the only "state" is that used to define parameters
        cell.soma()->add_mechanism(hh_parameters());
    
        auto& soma_hh = cell.soma()->mechanism("hh");
    
        soma_hh.set("gnabar", 0.12);
        soma_hh.set("gkbar", 0.036);
        soma_hh.set("gl", 0.0003);
        soma_hh.set("el", -54.3);
    
        // check that parameter values were set correctly
        EXPECT_EQ(cell.soma()->mechanism("hh").get("gnabar").value, 0.12);
        EXPECT_EQ(cell.soma()->mechanism("hh").get("gkbar").value, 0.036);
        EXPECT_EQ(cell.soma()->mechanism("hh").get("gl").value, 0.0003);
        EXPECT_EQ(cell.soma()->mechanism("hh").get("el").value, -54.3);
    
        cell.segment(1)->set_compartments(10);
    
        using fvm_cell = fvm::fvm_cell<double, cell_lid_type>;
        fvm_cell fvcell(cell);
        auto& J = fvcell.jacobian();
        EXPECT_EQ(J.size(), 11u);
    
        fvcell.setup_matrix(0.01);
    }