Xyce  6.1
N_DEV_Neuron5.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright (C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-----------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_Neuron5.h,v $
27 //
28 // Purpose : Neuron classes.
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
33 //
34 // Creation Date : 01/02/08
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.27.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:29:37 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Neuron5_h
47 #define Xyce_N_DEV_Neuron5_h
48 
49 // ---------- Xyce Includes ----------
50 #include <N_DEV_Configuration.h>
51 #include <N_DEV_DeviceBlock.h>
52 #include <N_DEV_DeviceInstance.h>
53 #include <N_DEV_DeviceModel.h>
54 
55 #include <N_DEV_Neuron.h>
56 
57 namespace Xyce {
58 namespace Device {
59 namespace Neuron5 {
60 
61 class Model;
62 class Instance;
63 
64 struct Traits : public DeviceTraits<Model, Instance, Neuron::Traits>
65 {
66  static const char *name() {return "Neuron";}
67  static const char *deviceTypeName() {return "YNEURON level 5";}
68  static int numNodes() {return 2;}
69  static bool modelRequired() {return true;}
70  static bool isLinearDevice() {return true;}
71 
72  static Device *factory(const Configuration &configuration, const FactoryBlock &factory_block);
73  static void loadModelParameters(ParametricData<Model> &model_parameters);
74  static void loadInstanceParameters(ParametricData<Instance> &instance_parameters);
75 };
76 
77 //-----------------------------------------------------------------------------
78 // Class : Instance
79 // Purpose : This is class refers to a single instance of the
80 // Neuron device. It has two nodes associated with it, a
81 // positive and a negative node. See the NeuronInstance
82 // class for a more detailed explanation.
83 // Special Notes :
84 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
85 // Creation Date : 01/02/08
86 //-----------------------------------------------------------------------------
87 class Instance : public DeviceInstance
88 {
89  friend class ParametricData<Instance>;
90  friend class Model;
91  friend class Traits;
92 
93 public:
94  static std::vector< std::vector<int> > jacStamp;
95 
96  Instance(
97  const Configuration & configuration,
98  const InstanceBlock & IB,
99  Model & Miter,
100  const FactoryBlock & factory_block);
101 
102  ~Instance();
103 
104 private:
105  Instance(const Instance &);
106  Instance &operator=(const Instance &);
107 
108 public:
109  void registerLIDs( const std::vector<int> & intLIDVecRef,
110  const std::vector<int> & extLIDVecRef );
111  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
112 
113  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
114 
115  const std::vector< std::vector<int> > & jacobianStamp() const;
116  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
117 
118  bool processParams ();
119  bool updateTemperature(const double & temp_tmp);
120 
121  bool updateIntermediateVars ();
122  bool updatePrimaryState ();
123  bool updateSecondaryState ();
124  bool setIC ();
125 
126  void varTypes( std::vector<char> & varTypeVec );
127 
128  // load functions, residual:
129  bool loadDAEQVector ();
130  bool loadDAEFVector ();
131 
132  void auxDAECalculations ();
133 
134  // load functions, Jacobian:
135  bool loadDAEdQdx ();
136  bool loadDAEdFdx ();
137 
138 public:
139  // iterator reference to the Neuron model which owns this instance.
140  // Getters and setters
142  {
143  return model_;
144  }
145 
146 private:
147 
148  Model & model_; //< Owning model
149 
150  // derrived quantities computed in updateIntermediateVars
151  // and used in the load functions
163 
177 
178  // state variables
181 
182  // local state indices (offsets)
185 
186  // local solution indices (offsets)
187  int li_Pos; // local index to positive node on this device
188  int li_Neg; // local index to negative node on this device
189  int li_nPro; // local index to n promoter value (Na current)
190  int li_mPro; // local index to m promoter value (K current)
191  int li_hPro; // local index to h promoter value (K current)
192  int li_aPro; // local index to
193  int li_bPro; // local index
194  int li_M_Pro; // local index
195  int li_H_Pro; // local index
196  int li_cPro; // local index
197  int li_CaPro; // local index
198 
199  // Matrix equation index variables:
200 
201  // Offset variables corresponding to the above declared indices.
212 
223 
226 
229 
232 
235 
238 
241 
244 
248 
254 };
255 
256 //-----------------------------------------------------------------------------
257 // Class : Model
258 // Purpose :
259 // Special Notes :
260 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
261 // Creation Date : 01/02/08
262 //-----------------------------------------------------------------------------
263 class Model : public DeviceModel
264 {
265  typedef std::vector<Instance *> InstanceVector;
266 
267  friend class ParametricData<Model>;
268  friend class Instance;
269  friend class Traits;
270 
271 public:
272  Model(
273  const Configuration & configuration,
274  const ModelBlock & MB,
275  const FactoryBlock & factory_block);
276  ~Model();
277 
278 private:
279  Model();
280  Model(const Model &);
281  Model &operator=(const Model &);
282 
283 public:
284  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
285 
286  virtual std::ostream &printOutInstances(std::ostream &os) const;
287 
288  bool processParams ();
289  bool processInstanceParams ();
290 
291 private:
292 
293  // parameter variables
294  double cMem; // membrane capacitance
295  double gMem; // membrane conductance
296  double vRest; // resting potential
297  double eNa; // sodium rest potential
298  double gNa; // sodium base conductance
299  double eK; // potassium rest potential
300  double gK; // potassium base conductance
301  double eA; // a-current rest potential
302  double gA; // a-current base conductance
303  double eCa; // Calcium rest potential
304  double gCa; // Calcium base conductance
305  double eKCa; // potassium-calcium rest potential
306  double gKCa; // potassium-calcium base conductance
307  double CaInit; // initial intra-cellular calcium concentration
308  double CaGamma; // calcium current to concentration multiplier
309  double CaTau; // calcium removal time constant
310 
311  // flags that parameters were given
312  bool cMemGiven;
313  bool gMemGiven;
315  bool eNaGiven;
316  bool gNaGiven;
317  bool eKGiven;
318  bool gKGiven;
319  bool eAGiven;
320  bool gAGiven;
321  bool eCaGiven;
322  bool gCaGiven;
323  bool eKCaGiven;
324  bool gKCaGiven;
328 
329 
330 public:
331  void addInstance(Instance *instance)
332  {
333  instanceContainer.push_back(instance);
334  }
335 
336 private:
337  std::vector<Instance*> instanceContainer;
338 };
339 
340 void registerDevice();
341 
342 } // namespace Neuron5
343 } // namespace Device
344 } // namespace Xyce
345 
346 #endif
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
virtual std::ostream & printOutInstances(std::ostream &os) const
static const char * name()
Definition: N_DEV_Neuron5.h:66
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_Neuron5.C:74
static void loadModelParameters(ParametricData< Model > &model_parameters)
Definition: N_DEV_Neuron5.C:78
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
Pure virtual class to augment a linear system.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
bool processParams()
processParams
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
Model & operator=(const Model &)
bool processInstanceParams()
processInstanceParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
Instance & operator=(const Instance &)
Class Configuration contains device configuration data.
const std::vector< std::vector< int > > & jacobianStamp() const
bool updateTemperature(const double &temp_tmp)
void addInstance(Instance *instance)
std::vector< Instance * > instanceContainer
void varTypes(std::vector< char > &varTypeVec)
static const char * deviceTypeName()
Definition: N_DEV_Neuron5.h:67
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_Neuron5.h:94
std::vector< Instance * > InstanceVector
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.