46 #ifndef Xyce_N_DEV_Neuron2_h
47 #define Xyce_N_DEV_Neuron2_h
67 static const char *
name() {
return "Neuron";}
95 static std::vector< std::vector<int> >
jacStamp;
110 void registerLIDs(
const std::vector<int> & intLIDVecRef,
111 const std::vector<int> & extLIDVecRef );
116 const std::vector< std::vector<int> > &
jacobianStamp()
const;
117 void registerJacLIDs(
const std::vector< std::vector<int> > & jacLIDVec );
127 void varTypes( std::vector<char> & varTypeVec );
154 template <
typename ScalarT>
155 static ScalarT
alphaN(
const ScalarT Vin)
157 ScalarT vScaled = 1000.0 * Vin;
158 ScalarT r = 1000.0 * (0.02 * (vScaled + 45.7)) / (1.0 - std::exp(-0.1*(vScaled+45.7)));
163 template <
typename ScalarT>
164 static ScalarT
betaN(
const ScalarT Vin)
166 ScalarT vScaled = 1000.0 * Vin;
167 ScalarT r = 1000.0 * 0.25 * std::exp( -0.0125 * (vScaled + 55.7));
173 template <
typename ScalarT>
174 static ScalarT
alphaM(
const ScalarT Vin)
176 ScalarT vScaled = 1000.0 * Vin;
177 ScalarT r = 1000.0 * (0.38 * (vScaled + 29.7)) / (1.0 - std::exp(-0.1*(vScaled+29.7)));
182 template <
typename ScalarT>
183 static ScalarT
betaM(
const ScalarT Vin)
185 ScalarT vScaled = 1000.0 * Vin;
186 ScalarT r = 1000.0 * 15.2 * std::exp( -0.0556 * (vScaled + 54.7));
191 template <
typename ScalarT>
192 static ScalarT
alphaH(
const ScalarT Vin)
194 ScalarT vScaled = 1000.0 * Vin;
195 ScalarT r = 1000.0 * 0.266 * std::exp( -0.05 * (vScaled + 48.0));
200 template <
typename ScalarT>
201 static ScalarT
betaH(
const ScalarT Vin)
203 ScalarT vScaled = 1000.0 * Vin;
204 ScalarT r = 1000.0 * 3.8 / (1.0 + std::exp(-0.1*(vScaled+18.0)));
210 template <
typename ScalarT>
211 static ScalarT
aInf(
const ScalarT Vin)
213 ScalarT vScaled = 1000.0 * Vin;
214 ScalarT r = std::pow( ((0.0761 * std::exp(0.0314 * (vScaled+94.22))) / (1.0+std::exp(0.0346*(vScaled+1.17)))), 1.0/3.0);
218 template <
typename ScalarT>
219 static ScalarT
aTau(
const ScalarT Vin)
221 ScalarT vScaled = 1000.0 * Vin;
222 ScalarT r = (0.3632 + 1.158 / (1.0 + std::exp(0.0497 * (vScaled + 55.96)))) / 1000.0;
227 template <
typename ScalarT>
228 static ScalarT
bInf(
const ScalarT Vin)
230 ScalarT vScaled = 1000.0 * Vin;
231 ScalarT r = std::pow( (1.0 / (1.0 + std::exp(0.0688*(vScaled+53.3)))), 4.0);
235 template <
typename ScalarT>
236 static ScalarT
bTau(
const ScalarT Vin)
238 ScalarT vScaled = 1000.0 * Vin;
239 ScalarT r = (1.24 + 2.678 / (1.0 + std::exp(0.0624 * (vScaled + 50.0)))) / 1000.0;
244 template <
typename ScalarT>
245 static ScalarT
M_Inf(
const ScalarT Vin)
247 ScalarT vScaled = 1000.0 * Vin;
248 ScalarT r = 1.0/(1.0 + std::exp(-(vScaled+57)/6.2));
252 template <
typename ScalarT>
253 static ScalarT
M_Tau(
const ScalarT Vin)
255 ScalarT vScaled = 1000.0 * Vin;
256 ScalarT r = (0.612 + 1.0/(std::exp(-(vScaled+132)/16.7) + std::exp((vScaled+16.8)/18.2)) ) / 1000.0;
260 template <
typename ScalarT>
261 static ScalarT
H_Inf(
const ScalarT Vin)
263 ScalarT vScaled = 1000.0 * Vin;
264 ScalarT r = 1.0 / (1.0 + std::exp((vScaled+81)/4.0));
268 template <
typename ScalarT>
269 static ScalarT
H_Tau(
const ScalarT Vin)
271 ScalarT vScaled = 1000.0 * Vin;
273 if( vScaled < -80.0 )
275 r = std::exp( (vScaled + 467)/66.6 ) / 1000.0;
279 r = ( 28.0 + std::exp(-(vScaled+22.0)/10.5)) / 1000.0;
285 template <
typename ScalarT>
286 static ScalarT
C_Inf(
const ScalarT Vin,
const ScalarT CaConc)
288 ScalarT vScaled = 1000.0 * Vin;
289 ScalarT r = (CaConc / (CaConc + 3.0)) * (1.0 / (1.0 + std::exp(-(vScaled+28.3)/12.6 )));
293 template <
typename ScalarT>
294 static ScalarT
C_Tau(
const ScalarT Vin)
296 ScalarT vScaled = 1000.0 * Vin;
297 ScalarT r = (90.3 - 75.1/(1.0 + std::exp(-(vScaled+46)/22.7))) / 1000.0;
304 template <
typename ScalarT>
305 static ScalarT
kcl1EquF(
const ScalarT& Vn1,
const ScalarT& Vn2,
const ScalarT& n,
const ScalarT& m,
const ScalarT& h,
306 const ScalarT& a,
const ScalarT& b,
const ScalarT&
MC,
const ScalarT& HC,
const ScalarT& CC,
307 const ScalarT& memG,
const ScalarT& restV,
const ScalarT& Kg,
const ScalarT& Ke,
const ScalarT& NaG,
const ScalarT& NaE,
308 const ScalarT& Ag,
const ScalarT& Ae,
const ScalarT& CaTg,
const ScalarT& CaE,
const ScalarT& KCaG)
310 ScalarT powN = n * n * n * n;
311 ScalarT powM = m * m * m;
312 ScalarT powA = a * a * a;
313 ScalarT powMC = MC *
MC;
314 ScalarT powCC = CC * CC * CC * CC;
315 ScalarT r = memG * (Vn1 - Vn2 - restV) + Kg * powN * (Vn1 - Vn2 - Ke ) + NaG * powM * h * (Vn1 - Vn2 - NaE )
316 + Ag * powA * b * (Vn1 - Vn2 - Ae) + CaTg * powMC * HC * (Vn1 - Vn2 - CaE) + KCaG * powCC * (Vn1 - Vn2 - Ke);
320 template <
typename ScalarT>
321 static ScalarT
kcl1EquQ(
const ScalarT& Vn1,
const ScalarT& Vn2,
const ScalarT& memC )
323 ScalarT r = memC * (Vn1 - Vn2);
328 template <
typename ScalarT>
329 static ScalarT
kcl2EquF(
const ScalarT& Vn1,
const ScalarT& Vn2,
const ScalarT& n,
const ScalarT& m,
const ScalarT& h,
330 const ScalarT& a,
const ScalarT& b,
const ScalarT&
MC,
const ScalarT& HC,
const ScalarT& CC,
331 const ScalarT& memG,
const ScalarT& restV,
const ScalarT& Kg,
const ScalarT& Ke,
const ScalarT& NaG,
const ScalarT& NaE,
332 const ScalarT& Ag,
const ScalarT& Ae,
const ScalarT& CaTg,
const ScalarT& CaE,
const ScalarT& KCaG)
334 ScalarT powN = n * n * n * n;
335 ScalarT powM = m * m * m;
336 ScalarT powA = a * a * a;
337 ScalarT powMC = MC *
MC;
338 ScalarT powCC = CC * CC * CC * CC;
339 ScalarT r = -1.0 * (memG * (Vn1 - Vn2 - restV) + Kg * powN * (Vn1 - Vn2 - Ke ) + NaG * powM * h * (Vn1 - Vn2 - NaE )
340 + Ag * powA * b * (Vn1 - Vn2 - Ae) + CaTg * powMC * HC * (Vn1 - Vn2 - CaE) + KCaG * powCC * (Vn1 - Vn2 - Ke) );
344 template <
typename ScalarT>
345 static ScalarT
kcl2EquQ(
const ScalarT& Vn1,
const ScalarT& Vn2,
const ScalarT& memC )
347 ScalarT r = -1.0 * memC * (Vn1 - Vn2);
352 template <
typename ScalarT>
353 static ScalarT
nEquF(
const ScalarT& Vn1,
const ScalarT& n,
const ScalarT& Vrest )
356 ScalarT alpha = alphaN<ScalarT>(vDiff);
357 ScalarT beta = betaN<ScalarT>(vDiff);
358 ScalarT r = (alpha + beta) * n - alpha;
362 template <
typename ScalarT>
363 static ScalarT
nEquQ(
const ScalarT& n )
370 template <
typename ScalarT>
371 static ScalarT
mEquF(
const ScalarT& Vn1,
const ScalarT& m,
const ScalarT& Vrest )
374 ScalarT alpha = alphaM<ScalarT>(vDiff);
375 ScalarT beta = betaM<ScalarT>(vDiff);
376 ScalarT r = (alpha + beta) * m - alpha;
380 template <
typename ScalarT>
381 static ScalarT
mEquQ(
const ScalarT& m )
388 template <
typename ScalarT>
389 static ScalarT
hEquF(
const ScalarT& Vn1,
const ScalarT& h,
const ScalarT& Vrest )
392 ScalarT alpha = alphaH<ScalarT>(vDiff);
393 ScalarT beta = betaH<ScalarT>(vDiff);
394 ScalarT r = (alpha + beta) * h - alpha;
398 template <
typename ScalarT>
399 static ScalarT
hEquQ(
const ScalarT& h )
406 template <
typename ScalarT>
407 static ScalarT
aEquF(
const ScalarT& Vn1,
const ScalarT& a,
const ScalarT& Vrest )
410 ScalarT Inf = aInf<ScalarT>(vDiff);
411 ScalarT Tau = aTau<ScalarT>(vDiff);
412 ScalarT r = (a - Inf)/Tau;
416 template <
typename ScalarT>
417 static ScalarT
aEquQ(
const ScalarT& a )
424 template <
typename ScalarT>
425 static ScalarT
bEquF(
const ScalarT& Vn1,
const ScalarT& b,
const ScalarT& Vrest )
428 ScalarT Inf = bInf<ScalarT>(vDiff);
429 ScalarT Tau = bTau<ScalarT>(vDiff);
430 ScalarT r = (b - Inf)/Tau;
434 template <
typename ScalarT>
435 static ScalarT
bEquQ(
const ScalarT& b )
442 template <
typename ScalarT>
443 static ScalarT
M_EquF(
const ScalarT& Vn1,
const ScalarT&
M,
const ScalarT& Vrest )
446 ScalarT Inf = M_Inf<ScalarT>(vDiff);
447 ScalarT Tau = M_Tau<ScalarT>(vDiff);
448 ScalarT r = (M - Inf)/Tau;
452 template <
typename ScalarT>
460 template <
typename ScalarT>
461 static ScalarT
H_EquF(
const ScalarT& Vn1,
const ScalarT& H,
const ScalarT& Vrest )
464 ScalarT Inf = H_Inf<ScalarT>(vDiff);
465 ScalarT Tau = H_Tau<ScalarT>(vDiff);
466 ScalarT r = (H - Inf)/Tau;
470 template <
typename ScalarT>
471 static ScalarT
H_EquQ(
const ScalarT& H )
478 template <
typename ScalarT>
479 static ScalarT
C_EquF(
const ScalarT& Vn1,
const ScalarT& C,
const ScalarT& CaConc,
const ScalarT& Vrest )
482 ScalarT Inf = C_Inf<ScalarT>(vDiff, CaConc);
483 ScalarT Tau = C_Tau<ScalarT>(vDiff);
484 ScalarT r = (C - Inf)/Tau;
488 template <
typename ScalarT>
489 static ScalarT
C_EquQ(
const ScalarT& C )
496 template <
typename ScalarT>
497 static ScalarT
Ca_EquF(
const ScalarT& Vn1,
const ScalarT& Vn2,
const ScalarT&
MC,
const ScalarT& HC,
const ScalarT& Ca,
498 const ScalarT& CaTg,
const ScalarT& CaE,
const ScalarT& CaGamma,
const ScalarT& CaTau )
500 ScalarT r = CaGamma * CaTg * MC * MC * HC * (Vn1 - Vn2 - CaE) + Ca / CaTau;
504 template <
typename ScalarT>
void registerLIDs(const std::vector< int > &intLIDVecRef, const std::vector< int > &extLIDVecRef)
Model & operator=(const Model &)
static ScalarT C_EquF(const ScalarT &Vn1, const ScalarT &C, const ScalarT &CaConc, const ScalarT &Vrest)
static ScalarT bEquQ(const ScalarT &b)
static ScalarT H_EquF(const ScalarT &Vn1, const ScalarT &H, const ScalarT &Vrest)
static ScalarT M_Inf(const ScalarT Vin)
static bool isLinearDevice()
static Device * factory(const Configuration &configuration, const FactoryBlock &factory_block)
void registerStateLIDs(const std::vector< int > &staLIDVecRef)
bool updatePrimaryState()
Pure virtual class to augment a linear system.
static ScalarT H_EquQ(const ScalarT &H)
static ScalarT alphaN(const ScalarT Vin)
static const char * name()
static ScalarT kcl2EquF(const ScalarT &Vn1, const ScalarT &Vn2, const ScalarT &n, const ScalarT &m, const ScalarT &h, const ScalarT &a, const ScalarT &b, const ScalarT &MC, const ScalarT &HC, const ScalarT &CC, const ScalarT &memG, const ScalarT &restV, const ScalarT &Kg, const ScalarT &Ke, const ScalarT &NaG, const ScalarT &NaE, const ScalarT &Ag, const ScalarT &Ae, const ScalarT &CaTg, const ScalarT &CaE, const ScalarT &KCaG)
static void loadModelParameters(ParametricData< Model > &model_parameters)
static bool modelRequired()
void auxDAECalculations()
static ScalarT mEquF(const ScalarT &Vn1, const ScalarT &m, const ScalarT &Vrest)
bool processInstanceParams()
processInstanceParams
static ScalarT nEquQ(const ScalarT &n)
static ScalarT M_EquQ(const ScalarT &M)
static ScalarT hEquQ(const ScalarT &h)
void loadNodeSymbols(Util::SymbolTable &symbol_table) const
Populates and returns the store name map.
static ScalarT aEquF(const ScalarT &Vn1, const ScalarT &a, const ScalarT &Vrest)
static ScalarT aInf(const ScalarT Vin)
static void loadInstanceParameters(ParametricData< Instance > &instance_parameters)
static ScalarT aEquQ(const ScalarT &a)
bool processParams()
processParams
static ScalarT Ca_EquQ(const ScalarT &Ca)
The FactoryBlock contains parameters needed by the device, instance and model creation functions...
bool updateIntermediateVars()
static ScalarT alphaH(const ScalarT Vin)
static ScalarT H_Inf(const ScalarT Vin)
void addInstance(Instance *instance)
static ScalarT kcl1EquQ(const ScalarT &Vn1, const ScalarT &Vn2, const ScalarT &memC)
static ScalarT kcl1EquF(const ScalarT &Vn1, const ScalarT &Vn2, const ScalarT &n, const ScalarT &m, const ScalarT &h, const ScalarT &a, const ScalarT &b, const ScalarT &MC, const ScalarT &HC, const ScalarT &CC, const ScalarT &memG, const ScalarT &restV, const ScalarT &Kg, const ScalarT &Ke, const ScalarT &NaG, const ScalarT &NaE, const ScalarT &Ag, const ScalarT &Ae, const ScalarT &CaTg, const ScalarT &CaE, const ScalarT &KCaG)
static ScalarT bInf(const ScalarT Vin)
static ScalarT M_EquF(const ScalarT &Vn1, const ScalarT &M, const ScalarT &Vrest)
bool updateTemperature(const double &temp_tmp)
static ScalarT betaH(const ScalarT Vin)
static ScalarT bEquF(const ScalarT &Vn1, const ScalarT &b, const ScalarT &Vrest)
virtual void forEachInstance(DeviceInstanceOp &op) const
Apply a device instance "op" to all instances associated with this model.
The Device class is an interface for device implementations.
static ScalarT alphaM(const ScalarT Vin)
static ScalarT bTau(const ScalarT Vin)
static ScalarT nEquF(const ScalarT &Vn1, const ScalarT &n, const ScalarT &Vrest)
static ScalarT betaM(const ScalarT Vin)
Class Configuration contains device configuration data.
Instance(const Configuration &configuration, const InstanceBlock &IB, Model &Miter, const FactoryBlock &factory_block)
static ScalarT H_Tau(const ScalarT Vin)
static ScalarT aTau(const ScalarT Vin)
static ScalarT C_Inf(const ScalarT Vin, const ScalarT CaConc)
static ScalarT Ca_EquF(const ScalarT &Vn1, const ScalarT &Vn2, const ScalarT &MC, const ScalarT &HC, const ScalarT &Ca, const ScalarT &CaTg, const ScalarT &CaE, const ScalarT &CaGamma, const ScalarT &CaTau)
static ScalarT C_EquQ(const ScalarT &C)
void registerJacLIDs(const std::vector< std::vector< int > > &jacLIDVec)
static ScalarT mEquQ(const ScalarT &m)
std::vector< Instance * > instanceContainer
static std::vector< std::vector< int > > jacStamp
bool updateSecondaryState()
virtual std::ostream & printOutInstances(std::ostream &os) const
static ScalarT betaN(const ScalarT Vin)
ModelBlock represents a .MODEL line from the netlist.
static ScalarT C_Tau(const ScalarT Vin)
The DeviceTraits template describes the configuration of a device.
Manages parameter binding for class C.
InstanceBlock represent a device instance line from the netlist.
static const char * deviceTypeName()
static ScalarT M_Tau(const ScalarT Vin)
Instance & operator=(const Instance &)
const std::vector< std::vector< int > > & jacobianStamp() const
void varTypes(std::vector< char > &varTypeVec)
static ScalarT kcl2EquQ(const ScalarT &Vn1, const ScalarT &Vn2, const ScalarT &memC)
std::vector< Instance * > InstanceVector
static ScalarT hEquF(const ScalarT &Vn1, const ScalarT &h, const ScalarT &Vrest)