Xyce  6.1
N_DEV_Neuron8.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_Neuron8.h,v $
27 //
28 // Purpose : Neuron classes.
29 //
30 // Special Notes :
31 //
32 // Creator : Richard Schiek, SNL, Electrical Systems Modeling
33 //
34 // Creation Date : 03/08/2012
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.22.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_Neuron8_h
47 #define Xyce_N_DEV_Neuron8_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 Neuron8 {
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 8";}
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 Systems Modeling
85 // Creation Date : 03/08/2012
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  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  // 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 // Class : Model
212 // Purpose :
213 // Special Notes :
214 // Creator : Richard Schiek, SNL, Electrical Systems Modeling
215 // Creation Date : 03/08/2012
216 //-----------------------------------------------------------------------------
217 class Model : public DeviceModel
218 {
219  typedef std::vector<Instance *> InstanceVector;
220 
221  friend class ParametricData<Model>;
222  friend class Instance;
223  friend class Traits;
224 
225 public:
226  Model(
227  const Configuration & configuration,
228  const ModelBlock & MB,
229  const FactoryBlock & factory_block);
230 
231  ~Model();
232 
233 private:
234  Model();
235  Model(const Model &);
236  Model &operator=(const Model &);
237 
238 public:
239  virtual void forEachInstance(DeviceInstanceOp &op) const /* override */;
240 
241  virtual std::ostream &printOutInstances(std::ostream &os) const;
242 
243  bool processParams ();
244  bool processInstanceParams ();
245 
246 private:
247 
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 Neuron8
287 } // namespace Device
288 } // namespace Xyce
289 
290 #endif
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
Pure virtual class to augment a linear system.
std::vector< Instance * > instanceContainer
Model & operator=(const Model &)
std::vector< Instance * > InstanceVector
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
static const char * name()
Definition: N_DEV_Neuron8.h:66
static std::vector< std::vector< int > > jacStamp
Definition: N_DEV_Neuron8.h:94
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
Definition: N_DEV_Neuron8.C:70
static void loadModelParameters(ParametricData< Model > &model_parameters)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
virtual std::ostream & printOutInstances(std::ostream &os) const
void addInstance(Instance *instance)
The Device class is an interface for device implementations.
Definition: N_DEV_Device.h:101
void varTypes(std::vector< char > &varTypeVec)
bool processInstanceParams()
processInstanceParams
Class Configuration contains device configuration data.
const std::vector< std::vector< int > > & jacobianStamp() const
Instance & operator=(const Instance &)
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
bool updateTemperature(const double &temp_tmp)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
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.
bool processParams()
processParams
static const char * deviceTypeName()
Definition: N_DEV_Neuron8.h:67
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)