MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
SymCompartment.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2007 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 
10 #include "header.h"
11 
12 #include "CompartmentBase.h"
13 #include "Compartment.h"
14 #include "SymCompartment.h"
15 
17  static SrcFinfo2< double, double > distalOut( "distalOut",
18  "Sends out Ra and Vm on each timestep, on the distal end"
19  " of a compartment. This end should be pointed away from the"
20  " soma. Mathematically the same as proximalOut, but gives"
21  " an orientation to the dendrite and helps traversal.");
22  return &distalOut;
23 }
24 
26  static SrcFinfo2< double, double > proximalOut( "proximalOut",
27  "Sends out Ra and Vm on each timestep, on the proximal"
28  " end of a compartment. That is, this end should be "
29  " pointed toward the soma. Mathematically the same as raxialOut"
30  " but provides a logical orientation of the dendrite."
31  " One can traverse proximalOut messages to get to the soma." );
32  return &proximalOut;
33 }
34 
36  static SrcFinfo2< double, double > cylinderOut( "cylinderOut",
37  " Sends out Ra and Vm to compartments (typically spines) on the"
38  " curved surface of a cylinder. Ra is set to nearly zero,"
39  " since we assume that the resistance from axis to surface is"
40  " negligible." );
41  return &cylinderOut;
42 }
43 
45  static SrcFinfo1< double > sumRaxialOut( "sumRaxialOut",
46  "Sends out Ra" );
47  return &sumRaxialOut;
48 }
49 
51 {
52  // process and init and reinit are inherited from Compartment.
54  // Dest Finfos
56 
57  static DestFinfo raxialSphere( "raxialSphere",
58  "Expects Ra and Vm from other compartment. This is a special case when"
59  " other compartments are evenly distributed on a spherical compartment.",
62  );
63  static DestFinfo raxialCylinder( "raxialCylinder",
64  "Expects Ra and Vm from other compartment. This is a special case when"
65  " other compartments are evenly distributed on the curved surface"
66  " of the cylindrical compartment, so we assume that the"
67  " cylinder does not add any further resistance.",
70  );
71  static DestFinfo raxialSym( "raxialSym",
72  "Expects Ra and Vm from other compartment.",
75  );
76  static DestFinfo sumRaxial( "sumRaxial",
77  "Expects Ra from other compartment.",
80  );
82  // Shared Finfos.
84  // The SrcFinfos raxialOut, sumRaxialOut and requestSumAxial
85  // are defined above to get them into file-wide scope.
86 
87  static Finfo* distalShared[] =
88  {
89  &raxialSym, &sumRaxial,// &handleSumRaxialRequest,
90  distalOut(), sumRaxialOut(), //requestSumAxial()
91  };
92 
93  static Finfo* proximalShared[] =
94  {
97  };
98 
99  static SharedFinfo proximal( "proximal",
100  "This is a shared message between symmetric compartments.\n"
101  "It goes from the proximal end of the current compartment to\n"
102  "distal end of the compartment closer to the soma.\n",
103  proximalShared, sizeof( proximalShared ) / sizeof( Finfo* )
104  );
105 
106  static SharedFinfo distal( "distal",
107  "This is a shared message between symmetric compartments.\n"
108  "It goes from the distal end of the current compartment to the \n"
109  "proximal end of one further from the soma. \n"
110  "The Ra values collected from children and\n"
111  "sibling nodes are used for computing the equivalent resistance \n"
112  "between each pair of nodes using star-mesh transformation.\n"
113  "Mathematically this is the same as the proximal message, but\n"
114  "the distinction is important for traversal and clarity.\n",
115  distalShared, sizeof( distalShared ) / sizeof( Finfo* )
116  );
117 
118  static SharedFinfo sibling( "sibling",
119  "This is a shared message between symmetric compartments.\n"
120  "Conceptually, this goes from the proximal end of the current \n"
121  "compartment to the proximal end of a sibling compartment \n"
122  "on a branch in a dendrite. However,\n"
123  "this works out to the same as a 'distal' message in terms of \n"
124  "equivalent circuit. The Ra values collected from siblings \n"
125  "and parent node are used for \n"
126  "computing the equivalent resistance between each pair of\n"
127  "nodes using star-mesh transformation.\n",
128  distalShared, sizeof( distalShared ) / sizeof( Finfo* )
129  );
130 
131  static Finfo* sphereShared[] = {
132  &raxialSphere,
133  distalOut(),
134  };
135 
136  static SharedFinfo sphere( "sphere",
137  "This is a shared message between a spherical compartment \n"
138  "(typically soma) and a number of evenly spaced cylindrical \n"
139  "compartments, typically primary dendrites.\n"
140  "The sphere contributes the usual Ra/2 to the resistance\n"
141  "between itself and children. The child compartments \n"
142  "do not connect across to each other\n"
143  "through sibling messages. Instead they just connect to the soma\n"
144  "through the 'proximalOnly' message\n",
145  sphereShared, sizeof( sphereShared )/sizeof( Finfo* )
146  );
147  static Finfo* cylinderShared[] = {
149  cylinderOut(),
150  };
151 
152  static SharedFinfo cylinder( "cylinder",
153  "This is a shared message between a cylindrical compartment \n"
154  "(typically a dendrite) and a number of evenly spaced child \n"
155  "compartments, typically dendritic spines, protruding from the\n"
156  "curved surface of the cylinder. We assume that the resistance\n"
157  "from the cylinder curved surface to its axis is negligible.\n"
158  "The child compartments do not need to connect across to each \n"
159  "other through sibling messages. Instead they just connect to the\n"
160  "parent dendrite through the 'proximalOnly' message\n",
161  cylinderShared, sizeof( cylinderShared )/sizeof( Finfo* )
162  );
163 
164  static Finfo* proximalOnlyShared[] = {
165  &raxialSphere,
166  proximalOut(),
167  };
168  static SharedFinfo proximalOnly( "proximalOnly",
169  "This is a shared message between a dendrite and a parent\n"
170  "compartment whose offspring are spatially separated from each\n"
171  "other. For example, evenly spaced dendrites emerging from a soma\n"
172  "or spines emerging from a common parent dendrite. In these cases\n"
173  "the sibling dendrites do not need to connect to each other\n"
174  "through 'sibling' messages. Instead they just connect to the\n"
175  "parent compartment (soma or dendrite) through this message\n",
176  proximalOnlyShared, sizeof( proximalOnlyShared )/sizeof( Finfo* )
177  );
178 
180  static Finfo* symCompartmentFinfos[] =
181  {
182 
184  // SharedFinfo definitions
186  // The inherited process and init messages do not need to be
187  // overridden.
188  &proximal,
189  &distal,
190  &sibling,
191  &sphere,
192  &cylinder,
193  &proximalOnly
194 
196  // MsgSrc definitions
198 
200  // DestFinfo definitions
202  };
203 
204  // static SchedInfo schedInfo[] = { { process, 0, 0 }, { init, 0, 1 } };
205 
206  static string doc[] =
207  {
208  "Name", "SymCompartment",
209  "Author", "Upi Bhalla; updated and documented by Subhasis Ray",
210  "Description", "SymCompartment object, for branching neuron models. In symmetric\n"
211  "compartments the axial resistance is equally divided on two sides of\n"
212  "the node. The equivalent circuit of the passive compartment becomes:\n"
213  "(NOTE: you must use a fixed-width font like Courier for correct rendition of the diagrams below)::\n"
214  " \n"
215  " Ra/2 B Ra/2 \n"
216  " A-/\\/\\/\\_____/\\/\\/\\-- C \n"
217  " | \n"
218  " ____|____ \n"
219  " | | \n"
220  " | \\ \n"
221  " | / Rm \n"
222  " ---- Cm \\ \n"
223  " ---- / \n"
224  " | | \n"
225  " | _____ \n"
226  " | --- Em \n"
227  " |_________| \n"
228  " | \n"
229  " __|__ \n"
230  " ///// \n"
231  " \n"
232  " \n\n"
233  "In case of branching, the B-C part of the parent's axial resistance\n"
234  "forms a Y with the A-B part of the children::\n\n"
235  " B' \n"
236  " | \n"
237  " / \n"
238  " \\ \n"
239  " / \n"
240  " \\ \n"
241  " / \n"
242  " |A' \n"
243  " B | \n"
244  " A-----/\\/\\/\\-----/\\/\\/\\------|C \n"
245  " | \n"
246  " |A\" \n"
247  " / \n"
248  " \\ \n"
249  " / \n"
250  " \\ \n"
251  " / \n"
252  " | \n"
253  " B\" \n\n\n"
254  "As per basic circuit analysis techniques, the C node is replaced using\n"
255  "star-mesh transform. This requires all sibling compartments at a\n"
256  "branch point to be connected via 'sibling' messages by the user (or\n"
257  "by the cell reader in case of prototypes). For the same reason, the\n"
258  "child compartment must be connected to the parent by\n"
259  "distal-proximal message pair. The calculation of the\n"
260  "coefficient for computing equivalent resistances in the mesh is done\n"
261  "at reinit.",
262  };
263  static Dinfo< SymCompartment > dinfo;
264 
265  static Cinfo symCompartmentCinfo(
266  "SymCompartment",
268  symCompartmentFinfos,
269  sizeof( symCompartmentFinfos ) / sizeof( Finfo* ),
270  &dinfo,
271  doc, sizeof(doc)/sizeof(string)
272  );
273 
274  return &symCompartmentCinfo;
275 }
276 
278 
280 // Here we put the SymCompartment class functions.
282 
284  coeff_(0.0),
285  RaSum_(0.0)
286 {
287  ;
288 }
289 
291 // Compartment::Dest function definitions.
293 
294 
295 // Alternates with the 'process' message
297 {
298  // cout << "SymCompartment " << e.id().path() << ":: innerInitProc: A = " << A_ << ", B = " << B_ << endl;
299  distalOut()->send( e, Ra_, Vm_ ); // to kids
300  proximalOut()->send( e, Ra_, Vm_ ); // to parent
301  cylinderOut()->send( e, 1e-6, Vm_ ); // to kids
302 }
303 
304 // Virtual func. Must be called after the 'init' phase.
306 {
308  // We don't want to recalculate these every time step - the request... methods are not required
309  // requestSumAxial()->send( e );
310  // requestSumAxial2()->send( e );
311  sumRaxialOut()->send( e, Ra_ );
312  // sumRaxial2Out()->send( e, Ra_ );
313 
314  // cout << "SymCompartment " << e.id().path() << ":: innerReinit: coeff = " << coeff_ << ", coeff2 = " << coeff2_ << endl;
315 }
316 
317 // The Compartment and Symcompartment go through an 'init' and then a 'proc'
318 // during each clock tick. Same sequence applies during reinit.
319 // This function is called during 'init' phase to send Raxial info around.
321 {
322  // cout << "SymCompartment " << e.id().path() << ":: innerInitReinit: coeff = " << coeff_ << ", coeff2 = " << coeff2_ << endl;
323  // coeff_ = 0.0;
324  // coeff2_ = 0.0;
325  // RaSum_ = 0.0;
326  // RaSum2_ = 0.0;
327  // requestSumAxial()->send( e );
328  // requestSumAxial2()->send( e );
329 }
330 
331 void SymCompartment::sumRaxial( double Ra )
332 {
333  RaSum_ += Ra_/Ra;
334  coeff_ = ( 1 + RaSum_ ) / 2.0;
335  // cout << "SymCompartment::sumRaxial: coeff = " << coeff_ << endl;
336 }
337 
338 void SymCompartment::raxialSym( double Ra, double Vm)
339 {
340  // cout << "SymCompartment " << ":: raxialSym: Ra = " << Ra << ", Vm = " << Vm << endl;
341  /*
342  Ra *= coeff_;
343  A_ += Vm / Ra;
344  B_ += 1.0 / Ra;
345  Im_ += ( Vm - Vm_ ) / Ra;
346  */
347 
348  double R = Ra * coeff_;
349  // cout << "raxialSym:R=" << R << endl;
350  A_ += Vm / R;
351  B_ += 1.0 / R;
352  Im_ += (Vm - Vm_) / R;
353  // double invR = 2.0 / ( Ra + Ra_ );
354  // A_ += Vm * invR;
355  // B_ += invR;
356  // Im_ += ( Vm - Vm_ ) * invR;
357 }
358 
359 void SymCompartment::raxialSphere( double Ra, double Vm)
360 {
361  double invR = 2.0 / ( Ra + Ra_ );
362  A_ += Vm * invR;
363  B_ += invR;
364  Im_ += ( Vm - Vm_ ) * invR;
365 }
366 
367 void SymCompartment::raxialCylinder( double Ra, double Vm)
368 {
369  double invR = 2.0 / Ra;
370  A_ += Vm * invR;
371  B_ += invR;
372  Im_ += ( Vm - Vm_ ) * invR;
373 }
374 
static SrcFinfo2< double, double > * cylinderOut()
static SrcFinfo2< double, double > * proximalOut()
void vInitProc(const Eref &e, ProcPtr p)
void raxialSym(double Ra, double Vm)
void vReinit(const Eref &e, ProcPtr p)
static const Cinfo * initCinfo()
Definition: Compartment.cpp:26
void vReinit(const Eref &e, ProcPtr p)
Definition: Dinfo.h:60
void vInitReinit(const Eref &e, ProcPtr p)
Definition: OpFunc.h:40
void raxialSphere(double Ra, double Vm)
static const Cinfo * symCompartmentCinfo
void sumRaxial(double Ra)
static const Cinfo * initCinfo()
Definition: OpFunc.h:27
Definition: Eref.h:26
void raxialCylinder(double Ra, double Vm)
static SrcFinfo2< double, double > * distalOut()
Definition: Cinfo.h:18
Definition: Finfo.h:12
static SrcFinfo1< double > * sumRaxialOut()