Skip to content

Commit

Permalink
Tests compile; poisson offset/reset broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenhater committed Nov 28, 2023
1 parent 809fa2d commit efb612d
Show file tree
Hide file tree
Showing 34 changed files with 713 additions and 760 deletions.
53 changes: 38 additions & 15 deletions arbor/include/arbor/cable_cell_param.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,29 @@ struct cable_cell_ion_data {
std::optional<double> diffusivity;
};

// Clamp current is described by a sine wave with amplitude governed by a
// piecewise linear envelope. A frequency of zero indicates that the current is
// simply that given by the envelope.
//
// The envelope is given by a series of envelope_point values:
// * The time points must be monotonically increasing.
// * Onset and initial amplitude is given by the first point.
// * The amplitude for time after the last time point is that of the last
// amplitude point; an explicit zero amplitude point must be provided if the
// envelope is intended to have finite support.
//
// Periodic envelopes are not supported, but may well be a feature worth
// considering in the future.

/**
* Current clamp; described by a sine wave with amplitude governed by a
* piecewise linear envelope. A frequency of zero indicates that the current is
* simply that given by the envelope.
*
* The envelope is given by a series of envelope_point values:
* * The time points must be monotonically increasing.
* * Onset and initial amplitude is given by the first point.
* * The amplitude for time after the last time point is that of the last
* amplitude point; an explicit zero amplitude point must be provided if the
* envelope is intended to have finite support.
*
* Periodic envelopes are not supported, but may well be a feature worth
* considering in the future.
*/
struct ARB_SYMBOL_VISIBLE i_clamp {
struct envelope_point {
/**
* Current at point in time
*
* @param t, must be convertible to time
* @param amplitude must be convertible to current
*/
envelope_point(const units::quantity& t,
const units::quantity& amplitude):
t(t.value_as(units::ms)),
Expand All @@ -70,7 +77,14 @@ struct ARB_SYMBOL_VISIBLE i_clamp {
// a trivial stimulus, providing no current at all.
i_clamp() = default;

// The simple constructor describes a constant amplitude stimulus starting from t=0.
/**
* Constant amplitude stimulus starting at t = 0.
*
* @param amplitude must be convertible to current
* @param frequency, must be convertible to frequency; gives a sine current if not zero
* @param frequency, must be convertible to radians, phase shift of sine.
*/

explicit i_clamp(const units::quantity& amplitude,
const units::quantity& frequency = 0*units::kHz,
const units::quantity& phase = 0*units::rad):
Expand Down Expand Up @@ -112,6 +126,15 @@ struct ARB_SYMBOL_VISIBLE init_membrane_potential {
iexpr value = NAN; // [mV]
};

struct ARB_SYMBOL_VISIBLE init_membrane_potential_ {
double value = NAN; // [mV]
iexpr scale = 1; // [1]

init_membrane_potential_(const units::quantity& m, iexpr scale=1): value(m.value_as(units::mV)), scale{scale} {}

};


struct ARB_SYMBOL_VISIBLE temperature_K {
iexpr value = NAN; // [K]
};
Expand Down
48 changes: 22 additions & 26 deletions arbor/include/arbor/event_generator.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#pragma once

#include <algorithm>
#include <cstdint>
#include <memory>
#include <random>
#include <type_traits>
#include <optional>

#include <arbor/assert.hpp>
Expand Down Expand Up @@ -101,34 +96,29 @@ struct event_generator {
inline
event_generator empty_generator(
cell_local_label_type target,
float weight)
{
float weight) {
return event_generator(std::move(target), weight, schedule());
}


// Generate events at integer multiples of dt that lie between tstart and tstop.

inline event_generator regular_generator(
cell_local_label_type target,
float weight,
time_type tstart,
time_type dt,
time_type tstop=terminal_time)
{
inline event_generator regular_generator(cell_local_label_type target,
float weight,
const units::quantity& tstart,
const units::quantity& dt,
const units::quantity& tstop=terminal_time*units::ms) {
return event_generator(std::move(target), weight, regular_schedule(tstart, dt, tstop));
}

template <typename RNG>
inline event_generator poisson_generator(
cell_local_label_type target,
float weight,
time_type tstart,
time_type rate_kHz,
const RNG& rng,
time_type tstop=terminal_time)
{
return event_generator(std::move(target), weight, poisson_schedule(tstart, rate_kHz, rng, tstop));
inline event_generator poisson_generator(cell_local_label_type target,
float weight,
const units::quantity& tstart,
const units::quantity& rate_kHz,
seed_type seed = default_seed,
const units::quantity& tstop=terminal_time*units::ms) {
// TODO(TH) handle seed
return event_generator(std::move(target), weight, poisson_schedule(tstart, rate_kHz, seed, tstop));
}


Expand All @@ -137,10 +127,16 @@ inline event_generator poisson_generator(
template<typename S> inline
event_generator explicit_generator(cell_local_label_type target,
float weight,
const S& s)
{
const S& s) {
return event_generator(std::move(target), weight, explicit_schedule(s));
}

template<typename S> inline
event_generator explicit_generator_from_milliseconds(cell_local_label_type target,
float weight,
const S& s) {
return event_generator(std::move(target), weight, explicit_schedule_from_milliseconds(s));
}

} // namespace arb

Loading

0 comments on commit efb612d

Please sign in to comment.