Xyce  6.1
N_DEV_Neuron7.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_Neuron7.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 : 06/10/09
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_Neuron7_h
47 #define Xyce_N_DEV_Neuron7_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 Neuron7 {
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 7";}
68  static int numNodes() {return 1;}
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 : 06/10/09
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; // ok for this to be static as all devcies of this type have the same form of jacStamp
95 
96 
97  Instance(
98  const Configuration & configuration,
99  const InstanceBlock & IB,
100  Model & Miter,
101  const FactoryBlock & factory_block);
102 
103  ~Instance();
104 
105 private:
106  Instance(const Instance &);
107  Instance &operator=(const Instance &);
108 
109 public:
110  void registerLIDs( const std::vector<int> & intLIDVecRef,
111  const std::vector<int> & extLIDVecRef );
112  void registerStateLIDs( const std::vector<int> & staLIDVecRef );
113 
114  void loadNodeSymbols(Util::SymbolTable &symbol_table) const; // override
115 
116  const std::vector< std::vector<int> > & jacobianStamp() const;
117  void registerJacLIDs( const std::vector< std::vector<int> > & jacLIDVec );
118 
119  bool processParams ();
120  bool updateTemperature(const double & temp_tmp);
121 
122  bool updateIntermediateVars ();
123  bool updatePrimaryState ();
124  bool updateSecondaryState ();
125  bool setIC ();
126 
127  void varTypes( std::vector<char> & varTypeVec );
128 
129  // load functions, residual:
130  bool loadDAEQVector ();
131  bool loadDAEFVector ();
132 
133  void auxDAECalculations ();
134 
135  // load functions, Jacobian:
136  bool loadDAEdQdx ();
137  bool loadDAEdFdx ();
138 
139 public:
140  // iterator reference to the Neuron model which owns this instance.
141  // Getters and setters
143  {
144  return model_;
145  }
146 
147 private:
148  Model & model_; //< Owning model
149 
150  // model level parameters that can be overridden at the instance level
151  double memCap; // membrane capacitance [F]
152  double Vt; // instantaneous threshold potential
153  double Vr; // resting membrane potential
154  double Vpeak; // peak voltage
155  double k; // modeling param []
156  double a; // modeling param
157  double b; // modeling param
158  double c; // modeling param
159  double d; // modeling param
160  double uscale; // u is normally in pico-Amps. Scalling by 1.0e9 improves accuracy
161  double fallRate;// controlls how quickly system resets over the discontinuity
162 
164  bool VtGiven;
165  bool VrGiven;
167  bool kGiven;
168  bool aGiven;
169  bool bGiven;
170  bool cGiven;
171  bool dGiven;
172  bool uscaleGiven; // u is normally in pico-Amps. Scalling by 1.0e9 improves accuracy
173  bool fallRateGiven;// controlls how quickly system resets over the discontinuity
174 
175  // values for loading in the F, Q, dF/dx and dQ/dx
176  //
177  // equations are:
178  // v equation
179  // k * (v-Vr) * (v-Vt) - u + I - C dv/dt = 0
180  // u euqtion
181  // a * ( b * (v-Vr) - u ) - du/dt = 0
182 
183  double vEquFvalue;
184  double vEquQvalue;
185  double vEqudFdv;
186  double vEqudFdu;
187  double vEqudQdv;
188  double uEquFvalue;
189  double uEquQvalue;
190  double uEqudFdv;
191  double uEqudFdu;
192  double uEqudQdu;
193 
194  // these need to be put in the state vector as they
195  // make this device state-dependent
196  bool resetting;
197  double uPeak;
198 
199  // offests
200  int li_V;
201  int li_U;
202 
203  // jacobian offsets
208 
209 
210 };
211 
212 //-----------------------------------------------------------------------------
213 // Class : Model
214 // Purpose :
215 // Special Notes :
216 // Creator : Richard Schiek, SNL, Electrical and Microsystem Modeling
217 // Creation Date : 06/10/09
218 //-----------------------------------------------------------------------------
219 class Model : public DeviceModel
220 {
221  typedef std::vector<Instance *> InstanceVector;
222 
223  friend class ParametricData<Model>;
224  friend class Instance;
225  friend class Traits;
226 
227 public:
228  Model(
229  const Configuration & configuration,
230  const ModelBlock & MB,
231  const FactoryBlock & factory_block);
232  ~Model();
233 
234 private:
235  Model();
236  Model(const Model &);
237  Model &operator=(const Model &);
238 
239 public:
240  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
241 
242  virtual std::ostream &printOutInstances(std::ostream &os) const;
243 
244  bool processParams ();
245  bool processInstanceParams ();
246 
247 private:
248  // model level parameters that can be overridden at the instance level
249  double memCap; // membrane capacitance [F]
250  double Vt; // instantaneous threshold potential
251  double Vr; // resting membrane potential
252  double Vpeak; // peak voltage
253  double k; // modeling param []
254  double a; // modeling param
255  double b; // modeling param
256  double c; // modeling param
257  double d; // modeling param
258  double uscale; // u is normally in pico-Amps. Scalling by 1.0e9 improves accuracy
259  double fallRate;// controlls how quickly system resets over the discontinuity
260 
262  bool VtGiven;
263  bool VrGiven;
265  bool kGiven;
266  bool aGiven;
267  bool bGiven;
268  bool cGiven;
269  bool dGiven;
270  bool uscaleGiven; // u is normally in pico-Amps. Scalling by 1.0e9 improves accuracy
271  bool fallRateGiven;// controlls how quickly system resets over the discontinuity
272 
273 
274 public:
275  void addInstance(Instance *instance)
276  {
277  instanceContainer.push_back(instance);
278  }
279 
280 private:
281  std::vector<Instance*> instanceContainer;
282 };
283 
284 void registerDevice();
285 
286 } // namespace Neuron7
287 } // namespace Device
288 } // namespace Xyce
289 
290 #endif
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Pure virtual class to augment a linear system.
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
Instance & operator=(const Instance &)
std::vector< Instance * > InstanceVector
static void loadModelParameters(ParametricData< Model > &model_parameters)
bool processInstanceParams()
processInstanceParams
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_Neuron7.h:94
bool updateTemperature(const double &temp_tmp)
virtual std::ostream & printOutInstances(std::ostream &os) const
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
void addInstance(Instance *instance)
Model & operator=(const Model &)
const std::vector< std::vector< int > > & jacobianStamp() const
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_Neuron7.C:70
std::vector< Instance * > instanceContainer
bool processParams()
processParams
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
static const char * deviceTypeName()
Definition: N_DEV_Neuron7.h:67
Class Configuration contains device configuration data.
void varTypes(std::vector< char > &varTypeVec)
static const char * name()
Definition: N_DEV_Neuron7.h:66
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
ModelBlock represents a .MODEL line from the netlist.
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
InstanceBlock represent a device instance line from the netlist.