14 #ifdef ENABLE_SONATA_REPORTS
15 #include "bbp/sonata/reports.h"
20 #ifdef ENABLE_SONATA_REPORTS
21 ReportEvent::ReportEvent(
double dt,
23 const VarsToReport& filtered_gids,
30 , report_dt(report_dt)
32 , vars_to_report(filtered_gids) {
35 reporting_period =
static_cast<int>(report_dt /
dt);
36 gids_to_report.reserve(filtered_gids.size());
37 for (
const auto& gid: filtered_gids) {
38 gids_to_report.push_back(gid.first);
40 std::sort(gids_to_report.begin(), gids_to_report.end());
43 void ReportEvent::summation_alu(
NrnThread* nt) {
44 auto& summation_report = nt->summation_report_handler_->summation_reports_[report_path];
46 for (
const auto& kv: summation_report.currents_) {
48 int segment_id = kv.first;
49 for (
const auto&
value: kv.second) {
50 double current_value = *
value.first;
51 int scale =
value.second;
52 sum += current_value * scale;
54 summation_report.summation_[segment_id] = sum;
58 if (!summation_report.gid_segments_.empty()) {
59 for (
const auto& kv: summation_report.gid_segments_) {
60 double sum_soma = 0.0;
62 for (
const auto& segment_id: kv.second) {
63 sum_soma += summation_report.summation_[segment_id];
65 *(vars_to_report[gid].front().var_value) = sum_soma;
70 void ReportEvent::lfp_calc(
NrnThread* nt) {
71 auto*
mapinfo =
static_cast<NrnThreadMappingInfo*
>(nt->mapping);
72 double* fast_imem_rhs = nt->nrn_fast_imem->nrn_sav_rhs;
73 auto& summation_report = nt->summation_report_handler_->summation_reports_[report_path];
74 for (
const auto& kv: vars_to_report) {
76 const auto& to_report = kv.second;
78 int num_electrodes = cell_mapping->num_electrodes();
79 std::vector<double> lfp_values(num_electrodes, 0.0);
80 for (
const auto& kv: cell_mapping->lfp_factors) {
81 int segment_id = kv.first;
82 const auto& factors = kv.second;
84 for (
const auto& factor: factors) {
86 for (
const auto&
value: summation_report.currents_[segment_id]) {
87 double current_value = *
value.first;
88 int scale =
value.second;
89 iclamp += current_value * scale;
91 lfp_values[electrode_id] += (fast_imem_rhs[segment_id] + iclamp) * factor;
95 for (
int i = 0;
i < to_report.size();
i++) {
96 *(to_report[
i].var_value) = lfp_values[
i];
107 if (
step > 0 && (
static_cast<int>(
step) % reporting_period) == 0) {
115 #ifdef ENABLE_SONATA_REPORTS
116 sonata_record_node_data(
step,
117 gids_to_report.size(),
118 gids_to_report.data(),
121 send(
t +
dt, nc, nt);
126 bool ReportEvent::require_checkpoint() {
THIS FILE IS AUTO GENERATED DONT MODIFY IT.
#define nrn_assert(x)
assert()-like macro, independent of NDEBUG status
NrnMappingInfo mapinfo
mapping information
CellMapping * get_cell_mapping(int gid)
get cell mapping information for given gid if exist otherwise return NULL.
Represent main neuron object computed by single thread.