Modigliani  2.0
A stochastic simulator for axons, neurons, and networks
membrane_compartment.h
1 
28 #ifndef MODIGLIANI_MODIGLIANI_CORE_MEMBRANE_COMPARTMENT_H_
29 #define MODIGLIANI_MODIGLIANI_CORE_MEMBRANE_COMPARTMENT_H_
30 
31 #include <vector>
32 #include <fstream>
33 #include <string>
34 
35 #include "modigliani_core/object.h"
36 #include "modigliani_core/membrane_current.h"
37 #include "modigliani_core/voltage_gated_ion_channel_current.h"
38 
39 namespace modigliani_core {
40 
46  public :
47 
56  Membrane_compartment(const modigliani_base::Real newArea,
57  const modigliani_base::Real newTemperature,
58  const modigliani_base::Real newCm,
59  const modigliani_base::Real newRa);
60 
61  Membrane_compartment(const Membrane_compartment & original) = delete;
62 
63  Membrane_compartment & operator=(const Membrane_compartment & right) =
64  delete;
65 
66  virtual ~Membrane_compartment();
67 
74  virtual modigliani_base::ReturnEnum AttachCurrent(Membrane_current *
75  currentPtr,
76  CurrentType type =
77  IONIC);
78 
109  virtual modigliani_base::ReturnEnum Step(const modigliani_base::Real newVM);
110 
117  virtual modigliani_base::ReturnEnum Step();
118 
127  modigliani_base::ReturnEnum InjectCurrent(modigliani_base::Real current);
128 
139  modigliani_base::
140  Real AttachedConductance(modigliani_base::Size currentIndex) {
141  assert((currentIndex > 0) && (currentIndex - 1 < current_vec_.size()));
142  return (current_vec_[currentIndex - 1]->conductance());
143  }
144 
153  modigliani_base::
154  Real AttachedReversalPotential(modigliani_base::Size currentIndex) {
155  assert((currentIndex > 0) && (currentIndex - 1 < current_vec_.size()));
156  return (current_vec_[currentIndex - 1]->reversal_potential());
157  }
158 
173  virtual modigliani_base::ReturnEnum SetupOutput(std::
174  string
175  output_file_name);
176 
187  virtual modigliani_base::ReturnEnum WriteOutput() const;
188 
195  modigliani_base::Real TimeConstant()const {
196  return ((cm() / WeightedConductance()) * area() * 1.0e8);
197  }
198 
205  const Membrane_current* Current(modigliani_base::Size currentIndex) const {
206  assert((currentIndex > 0) && (currentIndex - 1 < current_vec_.size()));
207  return (current_vec_[currentIndex - 1]);
208  }
209 
215  modigliani_base::Real area() const {
216  return (area_);
217  }
218 
224  modigliani_base::Real vm() const {
225  return (vm_);
226  }
227 
233  void set_vm(modigliani_base::Real newVoltage) {
234  vm_ = newVoltage;
235  }
236 
237 
243  modigliani_base::Real cm() const {
244  return (cm_);
245  }
246 
252  modigliani_base::Real ra() const {
253  return (ra_);
254  }
255 
264  virtual modigliani_base::ReturnEnum set_temperature(
265  modigliani_base::Real newTemp) {
266  temperature_ = newTemp;
267  for (modigliani_base::Size i = 0; i < current_vec_.size(); i++)
268  current_vec_[i]->set_temperature(newTemp);
269  return (modigliani_base::ReturnEnum::SUCCESS);
270  }
271 
277  modigliani_base::Real temperature()const {
278  return (temperature_);
279  }
280 
286  modigliani_base::Real CompartmentMembraneCapacitance() const;
287 
293  modigliani_base::Real CompartmentMembraneNetCurrent()const;
294 
301  modigliani_base::Real CompartmentChannelStateTimeConstant()const;
302 
308  bool GillespieStep();
309 
316  modigliani_base::Size NumberCurrents() const;
317 
324  modigliani_base::Real WeightedConductance() const;
325 
331  const std::vector< Membrane_current * > current_vec() const {
332  return current_vec_;
333  }
334 
335  static bool seed_set_;
336 
337  protected :
338  std::ofstream * output_file = 0;
339 
340  private :
341  // injected current into compartment in nA
342  modigliani_base::Real i_inj_;
343 
344  // Contains pointers to attached currents
345  std::vector < Membrane_current * >current_vec_;
346 
347  // membrane capacity in muFarad/cm^2
348  const modigliani_base::Real cm_;
349 
350  // axoplasmatic resistance in Ohm cm
351  const modigliani_base::Real ra_;
352 
353  // in muMeter^2
354  const modigliani_base::Real area_;
355 
356  // in Celsius
357  modigliani_base::Real temperature_;
358 
359  // membrane voltage in mV
360  modigliani_base::Real vm_;
361 
362  boost::random::mt19937 rng_;
363  boost::random::binomial_distribution <> bin_;
364  boost::random::uniform_01 <> uni_;
365  unsigned int seed_;
366  };
367 } // namespace modigliani_core
368 #endif // MODIGLIANI_MODIGLIANI_CORE_MEMBRANE_COMPARTMENT_H_
modigliani_base::Real CompartmentMembraneCapacitance() const
Returns total compartment capacitance.
Definition: membrane_compartment.cc:155
virtual modigliani_base::ReturnEnum WriteOutput() const
Writes the current flwoing through all attached Membrane_current instances to a binary file...
Definition: membrane_compartment.cc:89
Membrane_current class.
Definition: membrane_current.h:43
const Membrane_current * Current(modigliani_base::Size currentIndex) const
Returns the current object at the given index.
Definition: membrane_compartment.h:205
virtual modigliani_base::ReturnEnum SetupOutput(std::string output_file_name)
Opens an output file and writes the header.
Definition: membrane_compartment.cc:58
modigliani_base::Real CompartmentMembraneNetCurrent() const
Returns net membrane current.
Definition: membrane_compartment.cc:159
CurrentType
Current types.
Definition: object.h:61
bool GillespieStep()
Perform one step of the Gillespie algorithm.
Definition: membrane_compartment.cc:183
modigliani_base::Real temperature() const
Returns temperature in compartment.
Definition: membrane_compartment.h:277
virtual modigliani_base::ReturnEnum Step()
Sets the membrane potential according to membrane current and runs of step of simulation.
Definition: membrane_compartment.cc:111
modigliani_base::Real AttachedReversalPotential(modigliani_base::Size currentIndex)
Returns the reversal potential of the attached conductance source.
Definition: membrane_compartment.h:154
Membrane_compartment class acts as a &quot;container + glue&quot; for the various Membrane_current classes that...
Definition: membrane_compartment.h:45
modigliani_base::Real CompartmentChannelStateTimeConstant() const
Sum of escape rates from current state.
Definition: membrane_compartment.cc:169
modigliani_base::Real cm() const
Sets the membrane capacitance per surface area.
Definition: membrane_compartment.h:243
modigliani_base::Real AttachedConductance(modigliani_base::Size currentIndex)
Returns the current conductance of the attached conductance source.
Definition: membrane_compartment.h:140
virtual modigliani_base::ReturnEnum set_temperature(modigliani_base::Real newTemp)
Set temperature in compartment and for all currents within the compartments.
Definition: membrane_compartment.h:264
modigliani_base::Real ra() const
Sets the axial resistance.
Definition: membrane_compartment.h:252
modigliani_base::Size NumberCurrents() const
Returns the number of currents attached to the compartment.
Definition: membrane_compartment.cc:207
modigliani_base::Real TimeConstant() const
Membrane time constant at instaneous membrane conductivity.
Definition: membrane_compartment.h:195
void set_vm(modigliani_base::Real newVoltage)
Sets the membrane potential.
Definition: membrane_compartment.h:233
Base class for all objects in modigliani_core.
Definition: object.h:113
virtual modigliani_base::ReturnEnum AttachCurrent(Membrane_current *currentPtr, CurrentType type=IONIC)
Adds a new current to the compartment.
Definition: membrane_compartment.cc:127
modigliani_base::ReturnEnum InjectCurrent(modigliani_base::Real current)
Injects current into the compartment.
Definition: membrane_compartment.cc:149
modigliani_base::Real vm() const
Returns the membrane potential.
Definition: membrane_compartment.h:224
modigliani_base::Real area() const
Returns the membrane surface area.
Definition: membrane_compartment.h:215
const std::vector< Membrane_current * > current_vec() const
Returns the vector of attached currents.
Definition: membrane_compartment.h:331
modigliani_base::Real WeightedConductance() const
Returns the sum of attached conductance weighted by the difference between the membrane potential and...
Definition: membrane_compartment.cc:117
Membrane_compartment(const modigliani_base::Real newArea, const modigliani_base::Real newTemperature, const modigliani_base::Real newCm, const modigliani_base::Real newRa)
Constructor.
Definition: membrane_compartment.cc:30