Xyce  6.1
N_DEV_DeviceEntity.C
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_DeviceEntity.C,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
33 //
34 // Creation Date : 04/03/00
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.244.2.2 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #include <Xyce_config.h>
47 
48 #include <string>
49 #include <iostream>
50 #if defined(HAVE_UNORDERED_MAP)
51 #include <unordered_map>
52 using std::unordered_map;
53 #elif defined(HAVE_TR1_UNORDERED_MAP)
54 #include <tr1/unordered_map>
55 using std::tr1::unordered_map;
56 #else
57 #error neither unordered_map or tr1/unordered_map found
58 #endif
59 #include <N_DEV_fwd.h>
60 #include <N_DEV_CompositeParam.h>
61 #include <N_DEV_Const.h>
62 #include <N_DEV_DeviceEntity.h>
63 #include <N_DEV_DeviceOptions.h>
64 #include <N_DEV_Message.h>
65 #include <N_DEV_Param.h>
66 #include <N_DEV_SolverState.h>
67 #include <N_LAS_Vector.h>
68 #include <N_UTL_BreakPoint.h>
69 #include <N_UTL_Diagnostic.h>
70 #include <N_UTL_Expression.h>
71 #include <N_UTL_FeatureTest.h>
72 
73 namespace Xyce {
74 namespace Device {
75 
76 //-----------------------------------------------------------------------------
77 // Function : DeviceEntity::DeviceEntity
78 // Purpose : constructor
79 // Special Notes :
80 // Scope : public
81 // Creator : Dave Shirley, PSSI
82 // Creation Date : 12/13/04
83 //-----------------------------------------------------------------------------
85  ParametricData<void> & parametric_data,
86  const SolverState & solver_state,
87  const DeviceOptions & device_options,
88  const std::string & netlist_filename,
89  int netlist_line)
90  : parametricData_(parametric_data),
91  solState_(solver_state),
92  globals_(solver_state.getGlobals()),
93  devOptions_(device_options),
94  defaultParamName_(),
95  netlistLocation_(netlist_filename, netlist_line)
96 {}
97 
98 //-----------------------------------------------------------------------------
99 // Function : DeviceEntity::~DeviceEntity
100 // Purpose : destructor
101 // Special Notes :
102 // Scope : public
103 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
104 // Creation Date : 3/30/00
105 //-----------------------------------------------------------------------------
107 {
108  for (std::vector<Depend>::iterator d = dependentParams_.begin(), end = dependentParams_.end(); d != end; ++d)
109  {
110  delete d->expr;
111  }
112 }
113 
114 //-----------------------------------------------------------------------------
115 // Function : DeviceEntity::scaleParam
116 //
117 // Purpose : Scales the original value of the specified parameter by the specified value.
118 // The parameter is never specified by the user so errors are developer caused.
119 //
120 // Special Notes :
121 //
122 // Scope : public
123 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
124 // Creation Date : 02/21/04
125 //-----------------------------------------------------------------------------
126 bool DeviceEntity::scaleParam( const std::string & paramName, double val, double val0)
127 {
128  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
129  if (p_i == getParameterMap().end())
130  {
131  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Unrecognized parameter " << paramName;
132  return false;
133  }
134 
135  const Descriptor &param = *(*p_i).second;
136  if (!param.hasOriginalValueStored())
137  {
138  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Original value not available for parameter " << paramName;
139  return false;
140  }
141 
142  if (!param.isType<double>())
143  {
144  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Can scale only double parameters, parameter " << paramName << " is not double";
145  return false;
146  }
147 
148  // Scale the parameter
149  setValue<double, DeviceEntity>(*this, param, Xyce::Device::getOriginalValue(*this, param.getSerialNumber())*val + val0*(1.0-val));
150 
151  if (param.hasGivenMember())
152  param.setGiven(*this, true);
153 
154  Xyce::Device::setValueGiven(*this, param.getSerialNumber(), true);
155 
156  return true;
157 }
158 
159 //-----------------------------------------------------------------------------
160 // Function : DeviceEntity::scaleParam
161 //
162 // Purpose : Scales the specified parameter by a specified value.
163 // The parameter is never specified by the user so errors are developer caused.
164 //
165 // Special Notes :
166 //
167 // Scope : public
168 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
169 // Creation Date : 02/21/04
170 //-----------------------------------------------------------------------------
171 bool DeviceEntity::scaleParam( const std::string & paramName, double val)
172 {
173  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
174  if (p_i == getParameterMap().end())
175  {
176  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Unrecognized parameter " << paramName;
177  return false;
178  }
179 
180  const Descriptor &param = *(*p_i).second;
181  if (!param.hasOriginalValueStored())
182  {
183  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Original value not available for parameter " << paramName;
184  return false;
185  }
186 
187  if (!param.isType<double>())
188  {
189  DevelFatal(*this).in("DeviceEntity::scaleParam") << "Can scale only double parameters, parameter " << paramName << " is not double";
190  return false;
191  }
192 
193  // Scale the parameter
194  param.value<double>(*this) = Xyce::Device::getOriginalValue(*this, param.getSerialNumber())*val;
195 
196  if (param.hasGivenMember())
197  param.setGiven(*this, true);
198 
199  Xyce::Device::setValueGiven(*this, param.getSerialNumber(), true);
200 
201  return true;
202 }
203 
204 //-----------------------------------------------------------------------------
205 // Function : DeviceEntity::scaleDefaultParam
206 // Purpose :
207 // The parameter is never specified by the user so errors are developer caused.
208 // Special Notes :
209 // Scope : public
210 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
211 // Creation Date : 5/19/05
212 //-----------------------------------------------------------------------------
214 {
215  if (defaultParamName_.empty())
216  {
217  DevelFatal(*this).in("DeviceEntity::scaleDefaultParam") << "Device does not have a default parameter";
218  return false;
219  }
220 
221  return scaleParam(defaultParamName_, val);
222 }
223 
224 //-----------------------------------------------------------------------------
225 // Function : DeviceEntity::analyticSensitivityAvailable
226 // Purpose :
227 // Special Notes :
228 // Scope : public
229 // Creator : Eric Keiter, SNL
230 // Creation Date : 7/17/2014
231 //-----------------------------------------------------------------------------
232 bool DeviceEntity::analyticSensitivityAvailable (const std::string & paramName)
233 {
234  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
235  if (p_i == getParameterMap().end())
236  {
237  DevelFatal(*this).in("DeviceEntity::analyticSensitivityAvailable") << "Unrecognized parameter " << paramName;
238  return false;
239  }
240 
241  const Descriptor &param = *(*p_i).second;
242  return param.getAnalyticSensitivityAvailable();
243 }
244 
245 //-----------------------------------------------------------------------------
246 // Function : DeviceEntity::getAnalyticSensitivity
247 // Purpose :
248 // Special Notes :
249 // Scope : public
250 // Creator : Eric Keiter, SNL
251 // Creation Date : 7/17/2014
252 //-----------------------------------------------------------------------------
253 bool DeviceEntity::getAnalyticSensitivity ( const std::string & paramName,
254  std::vector<double> & dfdpVec,
255  std::vector<double> & dqdpVec,
256  std::vector<double> & dbdpVec,
257  std::vector<int> & FindicesVec,
258  std::vector<int> & QindicesVec,
259  std::vector<int> & BindicesVec)
260 {
261  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
262  if (p_i == getParameterMap().end())
263  {
264  DevelFatal(*this).in("DeviceEntity::analyticSensitivityAvailable") << "Unrecognized parameter " << paramName;
265  return false;
266  }
267 
268  const Descriptor &param = *(*p_i).second;
269 
270  return param.getAnalyticSensitivity (*this, paramName, dfdpVec, dqdpVec, dbdpVec,
271  FindicesVec, QindicesVec, BindicesVec);
272 }
273 
274 //-----------------------------------------------------------------------------
275 // Function : DeviceEntity::setParam
276 //
277 // Purpose : This function loops over the vector of parameters, and
278 // sets the specified one (if found) to a specified value.
279 //
280 // Special Notes : This is kind of tricky, b/c some parameters are actually
281 // deep inside other classes (like a source class, for
282 // example)
283 //
284 // This function always returns a true, b/c there are many
285 // instances, (for example running in parallel), where one
286 // could set a param that didn't exist locally on
287 // processor.
288 //
289 // Scope : public
290 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
291 // Creation Date : 07/25/03
292 //-----------------------------------------------------------------------------
293 bool DeviceEntity::setParam(const std::string & paramName, double val, bool overrideOriginal)
294 {
295  if (DEBUG_DEVICE)
296  {
297  Xyce::dout() << "DeviceEntity::setParam with paramname" << paramName << " value " << val << " overrideOriginal " << overrideOriginal << std::endl;
298  }
299 
300  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
301  if (p_i == getParameterMap().end())
302  return false;
303 
304  if (isTempParam(paramName))
305  val += CONSTCtoK;
306 
307  const Descriptor &param = *(*p_i).second;
308 
309  if (param.isType<double>())
310  param.value<double>(*this) = val;
311  else if (param.isType<int>())
312  param.value<int>(*this) = static_cast <int> (val);
313  else if (param.isType<long>())
314  param.value<long>(*this) = static_cast <long> (val);
315  else if (param.isType<bool>())
316  param.value<bool>(*this) = (val != 0);
317  else
318  DevelFatal0(*this) << "Illegal type for parameter " << paramName;
319 
320  if (param.hasGivenMember())
321  param.setGiven(*this, true);
322 
323  Xyce::Device::setValueGiven(*this, param.getSerialNumber(), true);
324 
325  if (param.hasOriginalValueStored() && overrideOriginal)
326  {
327  if (DEBUG_DEVICE)
328  {
329  Xyce::dout() << " Overriding original value for parameter " << paramName << " with value " << val << std::endl;
330  }
332  }
333 
334  return true;
335 }
336 
337 //-----------------------------------------------------------------------------
338 // Function : DeviceEntity::getParam
339 //
340 // Purpose : returns the value of the requested param.
341 //
342 // Special Notes : This function currently assumes that the requested
343 // param is a double-precision number.
344 //
345 // Parameters are not case-dependent.
346 //
347 // Scope : public
348 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
349 // Creation Date : 07/25/03
350 //-----------------------------------------------------------------------------
351 bool
353  const std::string & name,
354  double & result) const
355 {
356  double val = 0.0;
357  bool found = false;
358 
359  ParameterMap::const_iterator p_i = getParameterMap().find(name);
360  if (p_i != getParameterMap().end())
361  {
362  found = true;
363  const Descriptor &param = *(*p_i).second;
364  if (param.isType<double>())
365  val = param.value<double>(*this);
366  else if (param.isType<int>())
367  val = static_cast <double> (param.value<int>(*this));
368  else if (param.isType<long>())
369  val = static_cast <double> (param.value<long>(*this));
370  else if (param.isType<bool>())
371  {
372  if (param.value<bool>(*this))
373  val = 1;
374  else
375  val = 0;
376  }
377  else
378  {
379  DevelFatal(*this).in("DeviceEntity::getParam") << "Illegal type for parameter " << name;
380  }
381  if (isTempParam(name))
382  val -= CONSTCtoK;
383  }
384  else
385  {
386  // If not recognized, just do nothing
387  }
388  result = val;
389 
390  return found;
391 }
392 
393 //-----------------------------------------------------------------------------
394 // Function : DeviceEntity::setDefaultParam
395 // Purpose :
396 // Special Notes :
397 // Scope : public
398 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
399 // Creation Date : 11/06/03
400 //-----------------------------------------------------------------------------
401 bool DeviceEntity::setDefaultParam (double val, bool overrideOriginal)
402 {
403  if (defaultParamName_.empty())
404  {
405  DevelFatal(*this).in("DeviceEntity::setDefaultParam") << "Device does not have a default parameter";
406  }
407 
408  return setParam(defaultParamName_, val, overrideOriginal);
409 }
410 
411 //-----------------------------------------------------------------------------
412 // Function : DeviceEntity::getDefaultParam
413 // Purpose :
414 // Special Notes :
415 // Scope : public
416 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
417 // Creation Date : 11/06/03
418 //-----------------------------------------------------------------------------
420 {
421  if (defaultParamName_.empty())
422  {
423  return 0.0;
424  }
425 
426  double result = 0.0;
427 
428  getParam(defaultParamName_, result);
429 
430  return result;
431 }
432 
433 //-----------------------------------------------------------------------------
434 // Function : DeviceEntity::setDependentParameter
435 // Purpose : Add expression, param pairs for future updates
436 // Special Notes : This is an overloaded method, used instead of the old
437 // monolithic one.
438 // Scope : protected
439 // Creator : Tom Russo
440 // Creation Date : 6 Nov 07
441 //-----------------------------------------------------------------------------
442 double DeviceEntity::setDependentParameter (Util::Param & par,
443  double *res,
445 
446 {
447  Depend dependentParam;
448  setDependentParameter(par, dependentParam, depend);
449 
450  dependentParam.resultU.result = res;
451  dependentParam.vectorIndex = -1;
452  dependentParams_.push_back(dependentParam);
453 
454  double rval;
455  dependentParam.expr->evaluateFunction (rval);
456  dependentParam.expr->set_sim_time( getSolverState().currTime );
457 
458  return rval;
459 }
460 
461 //-----------------------------------------------------------------------------
462 // Function : DeviceEntity::setDependentParameter
463 // Purpose : Add expression, param pairs for future updates
464 // Special Notes : This is an overloaded method, used instead of the old
465 // monolithic one, and is specifically to set an element
466 // of a double vector.
467 // Scope : protected
468 // Creator : Tom Russo
469 // Creation Date : 6 Nov 07
470 //-----------------------------------------------------------------------------
471 double DeviceEntity::setDependentParameter (Util::Param & par,
472  std::vector<double> *res,
473  int ind,
475 
476 {
477  Depend dependentParam;
478  setDependentParameter(par,dependentParam, depend);
479 
480  dependentParam.resultU.resVec = res;
481  dependentParam.vectorIndex = ind;
482  dependentParams_.push_back(dependentParam);
483 
484  double rval;
485  dependentParam.expr->evaluateFunction (rval);
486  dependentParam.expr->set_sim_time(getSolverState().currTime);
487 
488  return rval;
489 }
490 
491 //-----------------------------------------------------------------------------
492 // Function : DeviceEntity::setDependentParameter
493 // Purpose : Add expression, param pairs for future updates
494 // Special Notes : This is a utility version, used by overloaded methods.
495 // Scope : protected
496 // Creator : Dave Shirley, PSSI
497 // Creation Date : 11/18/04
498 //-----------------------------------------------------------------------------
499 
500 void DeviceEntity::setDependentParameter (Util::Param & par,
501  Depend & dependentParam,
503 {
504  std::vector<std::string> instances, leads, names, variables;
505 
506  dependentParam.name = par.tag();
507  if (isTempParam(par.tag()))
508  {
509  dependentParam.expr = new Util::Expression ("(" + par.stringValue() + ")+CONSTCtoK");
510  dependentParam.expr->make_constant (std::string("CONSTCTOK"), CONSTCtoK);
511  }
512  else
513  {
514  dependentParam.expr = new Util::Expression (par.getValue<Util::Expression>());
515  }
516 
517  names.clear();
518  leads.clear();
519  instances.clear();
520  variables.clear();
521 
522  dependentParam.expr->get_names(XEXP_NODE, names);
523  dependentParam.expr->get_names(XEXP_LEAD, leads);
524  dependentParam.expr->get_names(XEXP_INSTANCE, instances);
525  dependentParam.expr->get_names(XEXP_VARIABLE, variables);
526 
527  //std::vector<std::string>::iterator s;
528  std::vector<std::string>::iterator iterS;
529 
530  if (!(depend & ParameterType::SOLN_DEP))
531  {
532  if (names.size() > 0 || instances.size() > 0)
533  {
534  UserError0(*this) << "Parameter " << par.tag() << " is not allowed to depend on voltage/current values";
535  return;
536  }
537  if (depend & ParameterType::NO_DEP)
538  {
539  if (dependentParam.expr->get_num(XEXP_SPECIAL) > 0)
540  {
541  UserError0(*this) << "Parameter " << par.tag() << " is not allowed to depend on time";
542  return;
543  }
544  }
545  }
546 
547  if (leads.size() > 0)
548  {
549  char type;
550  int index;
551  for (std::vector<std::string>::const_iterator n_i=leads.begin(); n_i != leads.end(); ++n_i)
552  {
553  index = n_i->find_last_of(":");
554  if (index == std::string::npos )
555  type = (*n_i)[0];
556  else
557  type = (*n_i)[index+1];
558 
559  if (type != 'B' && type != 'E' && type != 'H')
560  {
561  UserError(*this) << "Illegal use of lead current specification in expression '" << dependentParam.expr->get_expression()
562  << "' in parameter " << par.tag();
563  }
564  }
565  names.insert( names.end(), leads.begin(), leads.end() );
566  }
567 
568  names.insert( names.end(), instances.begin(), instances.end() );
569 
570  dependentParam.lo_var = expVarNames.size();
571  dependentParam.n_vars = names.size();
572  dependentParam.vals.resize(dependentParam.n_vars);
573  int expVarLen = dependentParam.lo_var+dependentParam.n_vars;
574  expVarGIDs.resize(expVarLen);
575  expVarLIDs.resize(expVarLen);
576  expVarVals.resize(expVarLen);
577 
578  if (!variables.empty())
579  names.insert( names.end(), variables.begin(), variables.end() );
580 
581  if ( !names.empty() )
582  {
583  // Order the names in the expression so that it agrees with the order
584  // in names.
585  dependentParam.expr->order_names( names );
586  }
587  for (int i=0 ; i<dependentParam.n_vars ; ++i)
588  expVarNames.push_back(names[i]);
589 
590  if (dependentParam.n_vars > 0)
591  {
592  std::vector<double> zeros;
593  zeros.resize(dependentParam.n_vars);
594  for (int i=0 ; i<dependentParam.n_vars ; ++i)
595  zeros[i] = 0;
596  dependentParam.expr->set_vars(zeros);
597  }
598 
599  dependentParam.global_params.clear();
600  if (!variables.empty())
601  {
602  for (iterS=variables.begin() ; iterS!=variables.end() ; ++iterS)
603  {
604  GlobalParameterMap::iterator global_param_it = globals_.global_params.find(*iterS);
605  if (global_param_it == globals_.global_params.end())
606  {
607  UserError(*this) << "Global parameter " << *iterS << " not found";
608  }
609  else {
610  dependentParam.expr->set_var(*iterS, (*global_param_it).second);
611  dependentParam.global_params.push_back(*iterS);
612  }
613  }
614  }
615 }
616 
617 //-----------------------------------------------------------------------------
618 // Function : DeviceEntity::updateDependentParameters
619 // Purpose : Update values of parameters defined as expressions
620 // Special Notes :
621 // Scope : protected
622 // Creator : Dave Shirley, PSSI
623 // Creation Date : 03/15/05
624 //-----------------------------------------------------------------------------
625 bool DeviceEntity::updateDependentParameters(Linear::Vector & vars)
626 {
627  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
628  std::vector<Depend>::iterator end = dependentParams_.end();
629  double rval(0.0);
630  bool changed = false;
631 
632  for ( ; dpIter != end ; ++dpIter)
633  {
634  if (dpIter->expr->set_sim_time( getSolverState().currTime ))
635  changed = true;
636  eVarVals.resize(dpIter->n_vars);
637  if (dpIter->n_vars > 0)
638  {
639  int hi = dpIter->lo_var+dpIter->n_vars;
640  for (int i = dpIter->lo_var; i < hi; ++i)
641  {
642  expVarVals[i] = vars[expVarLIDs[i]];
643  eVarVals[i-dpIter->lo_var] = expVarVals[i];
644  }
645  if (dpIter->expr->set_vars(eVarVals))
646  changed = true;
647  }
648  dpIter->expr->evaluateFunction (rval);
649  if (dpIter->vectorIndex==-1)
650  *(dpIter->resultU.result) = rval;
651  else
652  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
653  }
654 
655  return changed;
656 }
657 
658 //-----------------------------------------------------------------------------
659 // Function : DeviceEntity::updateGlobalParameters
660 // Purpose : Update values of global parameters in expressions
661 // Special Notes :
662 // Scope : protected
663 // Creator : Dave Shirley, PSSI
664 // Creation Date : 11/17/05
665 //-----------------------------------------------------------------------------
667 {
668  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
669  std::vector<Depend>::iterator end = dependentParams_.end();
670  double rval;
671  int i, hi;
672  bool changed = false;
673 
674  for ( ; dpIter != end ; ++dpIter)
675  {
676  if (!dpIter->global_params.empty())
677  {
678  std::vector<std::string>::iterator gp=dpIter->global_params.begin();
679  std::vector<std::string>::iterator gend=dpIter->global_params.end();
680  for ( ; gp != gend; ++gp)
681  {
682  if (global_map.find(*gp) == global_map.end())
683  {
684  DevelFatal(*this).in("DeviceEntity::updateGlobalParameters") << "Failed to find global parameter " << *gp;
685  }
686  if (dpIter->expr->set_var(*gp, global_map[*gp]))
687  changed = true;
688  }
689  }
690  }
691 
692  return changed;
693 }
694 
695 //-----------------------------------------------------------------------------
696 // Function : DeviceEntity::updateDependentParameters
697 // Purpose : Update values of parameters defined as expressions
698 // Special Notes :
699 // Scope : protected
700 // Creator : Dave Shirley, PSSI
701 // Creation Date : 11/18/04
702 //-----------------------------------------------------------------------------
704 {
705  double rval;
706  bool changed = false;
707 
708  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
709  std::vector<Depend>::iterator end = dependentParams_.end();
710  for ( ; dpIter != end; ++dpIter)
711  {
712  if (dpIter->expr->set_sim_time( getSolverState().currTime ))
713  changed = true;
714  dpIter->expr->evaluateFunction (rval);
715  if (dpIter->vectorIndex == -1)
716  *(dpIter->resultU.result) = rval;
717  else
718  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
719  }
720 
721  return changed;
722 }
723 
724 //-----------------------------------------------------------------------------
725 // Function : DeviceEntity::updateDependentParameters
726 // Purpose : Update values of parameters defined as expressions with a
727 // specified temperature
728 // Special Notes :
729 // Scope : protected
730 // Creator : Dave Shirley, PSSI
731 // Creation Date : 01/11/06
732 //-----------------------------------------------------------------------------
734 {
735  double rval;
736  bool changed = false;
737 
738  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
739  std::vector<Depend>::iterator end = dependentParams_.end();
740  for ( ; dpIter != end; ++dpIter)
741  {
742  if (dpIter->expr->set_sim_time( getSolverState().currTime ) || dpIter->expr->set_temp(tempIn))
743  changed = true;
744  dpIter->expr->evaluateFunction (rval);
745  if (dpIter->vectorIndex == -1)
746  *(dpIter->resultU.result) = rval;
747  else
748  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
749 
750  }
751 
752  return changed;
753 }
754 
755 //-----------------------------------------------------------------------------
756 // Function : DeviceEntity::getParamBreakpoints
757 // Purpose : Add breakpoints caused by discontinuities in computed params
758 // Special Notes :
759 // Scope : protected
760 // Creator : Dave Shirley, PSSI
761 // Creation Date : 11/18/04
762 //-----------------------------------------------------------------------------
763 bool DeviceEntity::getParamBreakpoints( std::vector<Util::BreakPoint> & breakPointTimes )
764 {
765  double bTime;
766 
767  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
768  std::vector<Depend>::iterator end = dependentParams_.end();
769  for ( ; dpIter != end; ++dpIter)
770  {
771  bTime = dpIter->expr->get_break_time();
772  if (bTime > getSolverState().currTime)
773  breakPointTimes.push_back(Util::BreakPoint(bTime));
774  }
775 
776  return true;
777 }
778 
779 //-----------------------------------------------------------------------------
780 // Function : DeviceEntity::given
781 // Purpose : Return whether param was given
782 // Special Notes :
783 // Scope : protected
784 // Creator : Dave Shirley, PSSI
785 // Creation Date : 11/23/04
786 //-----------------------------------------------------------------------------
787 bool DeviceEntity::given( const std::string & parameter_name ) const
788 {
789  ParameterMap::const_iterator it = getParameterMap().find(parameter_name);
790  if (it == getParameterMap().end())
791  DevelFatal0(*this).in("DeviceEntity::given") << "Unrecognized parameter " << parameter_name;
792 
793  return Xyce::Device::wasValueGiven(*this, (*it).second->getSerialNumber());
794 }
795 
796 //-----------------------------------------------------------------------------
797 // Function : setParameters
798 // Purpose : Set parameters according to a vector of params. Used to
799 // set instance or model parameter sets to netlist values
800 // Special Notes :
801 // Scope : protected
802 // Creator : Dave Shirley, PSSI
803 // Creation Date : 11/20/04
804 //-----------------------------------------------------------------------------
805 void setParameters(DeviceEntity &entity, std::vector<Param>::const_iterator begin, std::vector<Param>::const_iterator end, const DeviceOptions &device_options)
806 {
807  std::vector<std::string> composite_name_list;
808  unordered_map<std::string, std::vector<CompositeParam *>, HashNoCase, EqualNoCase> composite_parameter_map;
809  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
810  {
811  Xyce::dout() << std::endl << "In DeviceEntity::setParams, for ";
812  entity.printName(Xyce::dout());
813  Xyce::dout() << " parameters are:" << std::endl;
814  for (std::vector<Param>::const_iterator it = begin; it != end; ++it)
815  {
816  const Param &param = *it;
817  Xyce::dout() << "Param = " << param.tag() << ", Type = ";
818  int tmpType = param.getType();
819  switch (tmpType)
820  {
821  case Util::STR:
822  Xyce::dout() << "STR";
823  break;
824  case Util::DBLE:
825  Xyce::dout() << "DBLE";
826  break;
827  case Util::INT:
828  Xyce::dout() << "INT";
829  break;
830  case Util::LNG:
831  Xyce::dout() << "LNG";
832  break;
833  case Util::EXPR:
834  Xyce::dout() << "EXPR";
835  break;
836  case Util::BOOL:
837  Xyce::dout() << "BOOL";
838  break;
839  case Util::STR_VEC:
840  Xyce::dout() << "STR_VEC";
841  break;
842  case Util::INT_VEC:
843  Xyce::dout() << "INT_VEC";
844  break;
845  case Util::DBLE_VEC:
846  Xyce::dout() << "DBLE_VEC";
847  break;
848  case Util::DBLE_VEC_IND:
849  Xyce::dout() << "DBLE_VEC_IND";
850  break;
851  case Util::COMPOSITE:
852  Xyce::dout() << "COMPOSITE";
853  break;
854  default:
855  Xyce::dout() << "Unknown";
856  }
857  Xyce::dout() << ", Value = " << param.stringValue();
858 
859  if (param.given())
860  {
861  Xyce::dout() << " given=TRUE";
862  }
863  else
864  {
865  Xyce::dout() << " given=FALSE";
866  }
867 
868  if (param.default_val())
869  {
870  Xyce::dout() << " default=TRUE" << std::endl;
871  }
872  else
873  {
874  Xyce::dout() << " default=FALSE" << std::endl;
875  }
876  }
877  Xyce::dout() << std::endl;
878  }
879 
880  for (std::vector<Param>::const_iterator param_it = begin; param_it != end; ++param_it)
881  {
882  Param &param = const_cast<Param &>(*param_it);
883 
884  const std::string &tag = param.tag();
885 
886  // Is this parameter in the Entity?
887  ParameterMap::const_iterator entity_parameter_it = entity.getParameterMap().find(tag);
888  if (entity_parameter_it != entity.getParameterMap().end())
889  {
890  const Descriptor &descriptor = *(*entity_parameter_it).second;
891  if (descriptor.hasGivenMember())
892  {
893  if (param.given())
894  {
895  descriptor.setGiven(entity, true);
896  }
897  else if (descriptor.getGiven(entity))
898  {
899  continue;
900  }
901  }
902 
903  Xyce::Device::setValueGiven(entity, descriptor.getSerialNumber(), param.given());
904  if (param.given() || param.default_val())
905  {
906  if ( param.getType() == Util::EXPR )
907  {
908  if (descriptor.isType<double>())
909  {
910  double val = entity.setDependentParameter(param, &(descriptor.value<double>(entity)), descriptor.getExpressionAccess());
911  param.setVal(val);
912  }
913  else if (descriptor.isType<std::vector<double> >())
914  {
915  int ind = (descriptor.value<std::vector<double> >(entity)).size();
916  double val = entity.setDependentParameter (param, &(descriptor.value<std::vector<double> >(entity)), ind, descriptor.getExpressionAccess());
917  (descriptor.value<std::vector<double> >(entity)).push_back(val);
918  }
919  else
920  {
921  DevelFatal(entity).in("DeviceEntity::setParams") << "Non double param " << tag << " cannot be set to expression";
922  }
923  }
924  else
925  {
926  if (descriptor.isType<double>())
927  {
928  if (!param.isNumeric())
929  {
930  UserError(entity) << "Cannot convert parameter " << tag << " to a numeric value from " << param.stringValue();
931  continue;
932  }
933 
934  descriptor.value<double>(entity) = param.getImmutableValue<double>();
935  if (isTempParam(tag))
936  {
937  descriptor.value<double>(entity) += CONSTCtoK;
938  }
939  if (descriptor.hasOriginalValueStored())
940  {
941  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), descriptor.value<double>(entity));
942  }
943  }
944  else if (descriptor.isType<std::string>())
945  {
946  descriptor.value<std::string>(entity) = param.stringValue();
947  }
948  else if (descriptor.isType<int>())
949  {
950  if (!param.isInteger())
951  {
952  UserError(entity) << "Cannot convert parameter " << tag << " to an integer value from " << param.stringValue();
953  continue;
954  }
955  descriptor.value<int>(entity) = param.getImmutableValue<int>();
956  if (descriptor.hasOriginalValueStored())
957  {
958  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), static_cast<double> (descriptor.value<int>(entity)));
959  }
960  }
961  else if (descriptor.isType<long>())
962  {
963  if (!param.isInteger())
964  {
965  UserError(entity) << "Cannot convert parameter " << tag << " to an integer value from " << param.stringValue();
966  continue;
967  }
968  descriptor.value<long>(entity) = param.getImmutableValue<long>();
969  if (descriptor.hasOriginalValueStored())
970  {
971  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), static_cast<double> (descriptor.value<long>(entity)));
972  }
973  }
974  else if (descriptor.isType<bool>())
975  {
976  if (!param.isBool())
977  {
978  UserError(entity) << "Cannot convert parameter " << tag << " to a logical value from " << param.stringValue();
979  continue;
980  }
981  descriptor.value<bool>(entity) = param.getImmutableValue<bool>();
982  if (descriptor.hasOriginalValueStored())
983  {
984  if (descriptor.value<bool>(entity))
985  {
986  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), 1.0);
987  }
988  else
989  {
990  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), 0.0);
991  }
992  }
993  }
994  else if (descriptor.isType<std::vector<int> >())
995  {
996  if (param.getType() == Util::INT_VEC)
997  {
998  (descriptor.value<std::vector<int> >(entity)) = param.getValue<std::vector<int> >();
999  }
1000  else if (param.getType() == Util::INT)
1001  {
1002  (descriptor.value<std::vector<int> >(entity)).push_back(param.getImmutableValue<int>());
1003  }
1004  }
1005  else if (descriptor.isType<std::vector<double> >())
1006  {
1007  if (param.getType() == Util::DBLE_VEC)
1008  {
1009  (descriptor.value<std::vector<double> >(entity)) = param.getValue<std::vector<double> >();
1010  }
1011  else if (param.getType() == Util::DBLE)
1012  {
1013  (descriptor.value<std::vector<double> >(entity)).push_back(param.getImmutableValue<double>());
1014  }
1015  }
1016  else if (descriptor.isType<std::vector<std::string> >())
1017  {
1018  if (param.getType() == Util::STR_VEC)
1019  {
1020  (descriptor.value<std::vector<std::string> >(entity)) = param.getValue<std::vector<std::string> >();
1021  }
1022  else if (param.getType() == Util::STR)
1023  {
1024  (descriptor.value<std::vector<std::string> >(entity)).push_back(param.stringValue());
1025  }
1026  }
1027  else if (descriptor.hasCompositeData())
1028  {
1029  composite_parameter_map[tag].clear();
1030  composite_name_list.push_back(tag);
1031 
1032  // Note: ERK. This push-back is done to process the base-param tag of a vector composite.
1033  // For example, if the composite parameters are things like REGION0.XWIDTH, where REGION
1034  // is the base parameter tag, 0 is the index, and XWIDTH is the subcomponent, the
1035  // tag that should be pushed back is tagES=REGION.
1036  //
1037  // Note: ERK: This function seems to implicitly rely on the base parameter always preceeding
1038  // subcomponent parameters. So REGION (alone) should preceed REGION0.XWIDTH in the
1039  // STL vector params that is passed into this function. If it doesn't then vc_stat will
1040  // stay false and a fatal error will get thrown.
1041  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
1042  {
1043  Xyce::dout() << "pushing back composite " << tag << std::endl;
1044  }
1045  }
1046  else
1047  {
1048  DevelFatal(entity).in("DeviceEntity::setParams") << "Unknown type";
1049  }
1050  }
1051  }
1052  }
1053 
1054  // Is it a vector (why do nothing?)
1055  else if (param.stringValue() == "VECTOR")
1056  {
1057  }
1058 
1059  // Must be a composite
1060  else
1061  {
1062  bool vc_stat = false;
1063 
1064  std::string::size_type dot = tag.find_first_of('.');
1065  if (dot != std::string::npos)
1066  {
1067  for (std::vector<std::string>::const_iterator it = composite_name_list.begin(); it != composite_name_list.end(); ++it)
1068  {
1069  const std::string &composite_name = *it;
1070 
1071  if (tag.find(composite_name) == 0) // Tag starts with the composite parameter name
1072  {
1073  std::string param_name(tag.begin() + dot + 1, tag.end());
1074 
1075  vc_stat = true;
1076 
1077  int n = 0;
1078  {
1079  std::istringstream is(std::string(tag.begin() + composite_name.size(), tag.begin() + dot));
1080  is >> n;
1081  }
1082 
1083  if (param_name == "NAME")
1084  {
1085  if (n != composite_parameter_map[composite_name].size())
1086  {
1087  DevelFatal(entity).in("DeviceEntity::setParams") << "Error filling 'NAME' vector param " << composite_name;
1088  }
1089 
1090  std::string name = param.stringValue();
1091  CompositeParam *composite = entity.constructComposite(composite_name, name);
1092  composite_parameter_map[composite_name].push_back(composite);
1093  setDefaultParameters(*composite, composite->getParameterMap().begin(), composite->getParameterMap().end(), device_options);
1094  }
1095  else
1096  {
1097  if (n >= composite_parameter_map[composite_name].size())
1098  {
1099  DevelFatal(entity).in("DeviceEntity::setParams") << "Internal error in vector-composite, 'NAME' must come first " << composite_name;
1100  }
1101  }
1102  Xyce::Device::setParameters(*composite_parameter_map[composite_name][n], param_name, param);
1103  }
1104  }
1105  }
1106  if (!vc_stat)
1107  {
1108  DevelFatal(entity) << "Undefined parameter " << tag << ", this parameter is in metadata, but not recognized in constructor";
1109  }
1110  }
1111  }
1112 
1113  if (!composite_name_list.empty())
1114  {
1115  for (std::vector<std::string>::const_iterator name_it = composite_name_list.begin(); name_it != composite_name_list.end(); ++name_it)
1116  {
1117  const std::string &vcs = *name_it;
1118 
1119  for (std::vector<CompositeParam *>::iterator it = composite_parameter_map[vcs].begin(); it != composite_parameter_map[vcs].end(); ++it)
1120  {
1121  (*it)->processParams();
1122  }
1123  }
1124  }
1125 }
1126 
1127 
1128 //-----------------------------------------------------------------------------
1129 // Function : setParameters
1130 // Purpose : Set parameter according to input Param. Used to
1131 // set instance or model parameter sets to netlist values
1132 // Special Notes :
1133 // Scope : public
1134 // Creator : Dave Shirley, PSSI
1135 // Creation Date : 05/06/05
1136 //-----------------------------------------------------------------------------
1137 
1138 void setParameters(CompositeParam &composite_param, const std::string & pName, const Param & ndParam )
1139 {
1140  ParameterMap::const_iterator p_i = composite_param.getParameterMap().find(pName);
1141  if (p_i != composite_param.getParameterMap().end())
1142  {
1143  const Descriptor &p = *(*p_i).second;
1144  if (p.hasGivenMember())
1145  {
1146  if (ndParam.given())
1147  p.setGiven(composite_param, true);
1148  else if (p.getGiven(composite_param))
1149  return;
1150  }
1151  Xyce::Device::setValueGiven(composite_param, p.getSerialNumber(), ndParam.given());
1152  if (ndParam.given() || ndParam.default_val())
1153  {
1154  if (p.isType<double>())
1155  {
1156  p.value<double>(composite_param) = ndParam.getImmutableValue<double>();
1157  if (isTempParam(pName))
1158  p.value<double>(composite_param) += CONSTCtoK;
1159  if (p.hasOriginalValueStored())
1160  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), p.value<double>(composite_param));
1161  }
1162  else if (p.isType<std::string>())
1163  {
1164  p.value<std::string>(composite_param) = ndParam.stringValue();
1165  }
1166  else if (p.isType<int>())
1167  {
1168  p.value<int>(composite_param) = ndParam.getImmutableValue<int>();
1169  if (p.hasOriginalValueStored())
1170  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), static_cast<double>(p.value<int>(composite_param)));
1171  }
1172  else if (p.isType<long>())
1173  {
1174  p.value<long>(composite_param) = ndParam.getImmutableValue<long>();
1175  if (p.hasOriginalValueStored())
1176  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), static_cast<double>(p.value<long>(composite_param)));
1177  }
1178  else if (p.isType<bool>())
1179  {
1180  p.value<bool>(composite_param) = (ndParam.getImmutableValue<double>() != 0.0);
1181  if (p.hasOriginalValueStored())
1182  {
1183  if (p.value<bool>(composite_param))
1184  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), 1.0);
1185  else
1186  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), 0.0);
1187  }
1188  }
1189  else if (p.isType<std::vector<double> >())
1190  {
1191  (p.value<std::vector<double> >(composite_param)).push_back(ndParam.getImmutableValue<double>());
1192  }
1193  else if (p.isType<std::vector<std::string> >())
1194  {
1195  p.value<std::vector<std::string> >(composite_param).push_back(ndParam.stringValue());
1196  }
1197  else
1198  {
1199  Report::DevelFatal().in("CompositeParam::setParams") << "Unknown parameter type for " << pName;
1200  }
1201  }
1202  }
1203  else
1204  {
1205  Report::DevelFatal().in("CompositeParam::setParams") << "Undefined parameter " << pName << std::endl
1206  << "This parameter is in metadata, but not recognized in constructor";
1207  }
1208 }
1209 
1210 
1211 void populateParams(const ParameterMap &parameter_map, std::vector<Param> &param_list, CompositeParamMap &composite_param_map)
1212 {
1213  for (ParameterMap::const_iterator it = parameter_map.begin(); it != parameter_map.end(); ++it)
1214  {
1215  const Descriptor &param = *(*it).second;
1216 
1217  if (param.isType<double>())
1218  {
1219  if (param.getVec() == 0)
1220  {
1221  double val;
1222  if (isTempParam((*it).first))
1223  val = getDefaultValue<double>(param) - CONSTCtoK;
1224  else
1225  val = getDefaultValue<double>(param);
1226  param_list.push_back(Param((*it).first, val));
1227  }
1228  else if (param.getVec() > 0)
1229  {
1230  if (param.getVec() == 1)
1231  {
1232  // This converts parameters link IC1, IC2 to just IC and type vector
1233  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1234  param_list.push_back(Param(vPar, "VECTOR"));
1235  }
1236  // We will also output IC1, IC2 as type double so they can
1237  // be specified as individual elements
1238  // This allows TC=a, b to also be specified as TC1=a TC2=b
1239  double val = getDefaultValue<double>(param);
1240  param_list.push_back(Param((*it).first, val));
1241  }
1242  }
1243  else if (param.isType<bool>())
1244  {
1245  if (param.getVec() == 0)
1246  param_list.push_back(Param((*it).first, getDefaultValue<bool>(param)));
1247  else if (param.getVec() > 0)
1248  {
1249  if (param.getVec() == 1)
1250  {
1251  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1252  param_list.push_back(Param(vPar, "VECTOR"));
1253  }
1254  // We will also output IC1, IC2 as type double so they can
1255  // be specified as individual elements
1256  // This allows TC=a, b to also be specified as TC1=a TC2=b
1257  bool val = getDefaultValue<bool>(param);
1258  param_list.push_back(Param((*it).first, val));
1259  }
1260  }
1261  else if (param.isType<int>())
1262  {
1263  if (param.getVec() == 0)
1264  param_list.push_back(Param((*it).first, getDefaultValue<int>(param)));
1265  else if (param.getVec() > 0)
1266  {
1267  if (param.getVec() == 1)
1268  {
1269  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1270  param_list.push_back(Param(vPar, "VECTOR"));
1271  }
1272  int val = getDefaultValue<int>(param);
1273  param_list.push_back(Param((*it).first, val));
1274  }
1275  }
1276  else if (param.isType<std::string>())
1277  {
1278  if (param.getVec() == 0)
1279  param_list.push_back(Param((*it).first, getDefaultValue<std::string>(param)));
1280  else if (param.getVec() > 0)
1281  {
1282  if (param.getVec() == 1)
1283  {
1284  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1285  param_list.push_back(Param(vPar, "VECTOR"));
1286  }
1287  std::string val = getDefaultValue<std::string>(param);
1288  param_list.push_back(Param((*it).first, val));
1289  }
1290  }
1291  else if (param.isType<std::vector<std::string> >())
1292  {
1293  Param vc((*it).first, std::vector<std::string>()); // param.value<std::vector<std::string> >(entity));
1294  param_list.push_back(vc);
1295  }
1296  else if (param.isType<std::vector<double> >())
1297  {
1298  Param vc((*it).first, std::vector<double>()); // param.value<std::vector<double> >(entity));
1299  param_list.push_back(vc);
1300  }
1301  else if (param.hasCompositeData())
1302  {
1303  Param vc2((*it).first, "VECTOR-COMPOSITE");
1304  vc2.setDefault(true);
1305  param_list.push_back(vc2);
1306 
1307  std::vector<Param> compositeParams;
1309 
1310  if (c == 0)
1311  {
1312  Report::DevelFatal().in("populateParams") << "Vector-composite map for device type entity empty.";
1313  }
1314 
1315  // TODO: [DGB] I think when the Descriptor is refactored this will be clearer. But this basically adds the
1316  // type to the composite list with 'NAME' first.
1317  const ParametricData<CompositeParam> &d = *c;
1318  const ParameterMap &e = d.getMap();
1319 
1320  for (ParameterMap::const_iterator it4 = e.find("NAME"); it4 != e.end();) {
1321  const Descriptor &p = *(*it4).second;
1322  if (p.isType<double>())
1323  compositeParams.push_back(Param((*it4).first, getDefaultValue<double>(p)));
1324  else if (p.isType<bool>())
1325  compositeParams.push_back(Param((*it4).first, getDefaultValue<bool>(p)));
1326  else if (p.isType<int>())
1327  compositeParams.push_back(Param((*it4).first, getDefaultValue<int>(p)));
1328  else if (p.isType<std::string>())
1329  compositeParams.push_back(Param((*it4).first, getDefaultValue<std::string>(p)));
1330  if ((*it4).first == "NAME")
1331  it4 = e.begin();
1332  else
1333  it4++;
1334  if (it4 != e.end() && (*it4).first == "NAME")
1335  it4++;
1336  }
1337 
1338  composite_param_map[(*it).first] = compositeParams;
1339  }
1340  else
1341  {
1342  // Just skip these, like list of coupled inductors because not needed for metadata
1343  Xyce::dout() << "In final else clause of DeviceEntity::getParams().";
1344  if( param.isType<std::vector<std::string> >() )
1345  Xyce::dout() << " type is STR_VEC ";
1346  if( param.isType<std::vector<double> >() )
1347  Xyce::dout() << " type is DBLE_VEC ";
1348  Xyce::dout() << it->first << " this item is NOT being added to default parameter list." << std::endl;
1349  }
1350  }
1351 }
1352 
1353 } // namespace Device
1354 } // namespace Xyce
int getVec() const
Gets the vector length of a vectorized parameter.
Definition: N_DEV_Pars.h:801
bool getParam(const std::string &paramName, double &result) const
void setOriginalValue(ParameterBase &parameter_base, int serial_number, double value)
Set a parameter's original value.
Definition: N_DEV_Pars.h:1657
#define CONSTCtoK
Definition: N_DEV_Const.h:52
bool given(const std::string &parameter_name) const
Pure virtual class to augment a linear system.
unordered_map< std::string, Descriptor *, HashNoCase, EqualNoCase > ParameterMap
Definition: N_DEV_fwd.h:159
virtual CompositeParam * constructComposite(const std::string &composite_name, const std::string &param_name)
Parameter can only be set to a constant from netlist.
Definition: N_DEV_Pars.h:66
DeviceEntity(ParametricData< void > &parametric_data, const SolverState &solver_state, const DeviceOptions &device_options, const std::string &netlist_filename, int netlist_line)
bool getAnalyticSensitivityAvailable() const
returns a boolean to indicate if analytic sensitivities are available w.r.t. this parameter...
Definition: N_DEV_Pars.h:1014
bool getGiven(ParameterBase &entity) const
Tests if the parameter has been given by the netlist.
Definition: N_DEV_Pars.h:954
bool getAnalyticSensitivity(const std::string &paramName, std::vector< double > &dfdpVec, std::vector< double > &dqdpVec, std::vector< double > &dbdpVec, std::vector< int > &FindicesVec, std::vector< int > &QindicesVec, std::vector< int > &BindicesVec)
std::vector< double > * resVec
bool isTempParam(const std::string &name)
Returns true if the name is TNOM or TEMP.
Definition: N_DEV_Pars.h:1705
bool scaleDefaultParam(double val)
double setDependentParameter(Util::Param &, double *, ParameterType::ExprAccess)
void setDefault(bool is_default)
Definition: N_DEV_Param.h:107
const ParameterMap & getParameterMap() const
std::vector< double > vals
double getOriginalValue(ParameterBase &parameter_base, int serial_number)
Retrieve a parameter's original value.
Definition: N_DEV_Pars.h:1642
void setParameters(CompositeParam &composite_param, const std::string &pName, const Param &ndParam)
bool hasGivenMember() const
Tests if parameter has a given data member.
Definition: N_DEV_Pars.h:923
bool given() const
Definition: N_DEV_Param.h:112
const T & value(const ParameterBase &entity) const
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:871
union Xyce::Device::Depend::resUnion resultU
Class ParametricData manages the configuration information and the parameter binding map...
Definition: N_DEV_Pars.h:1303
std::vector< std::string > global_params
ExprAccess getExpressionAccess() const
Gets the expression access which describes the usage of the paramter.
Definition: N_DEV_Pars.h:659
bool setDefaultParam(double val, bool overrideOriginal=false)
std::vector< Depend > dependentParams_
const ParametricData< U > * getCompositeParametricData() const
Return the composite parameter.
Definition: N_DEV_Pars.h:774
void setValueGiven(ParameterBase &parameter_base, int serial_number, bool value)
Set the given value state of a parameter.
Definition: N_DEV_Pars.h:1690
Class Descriptor describes the parameters stored in the ParametricData parameter map.
Definition: N_DEV_Pars.h:546
void setDefaultParameters(ParameterBase &parameter_base, ParameterMap::const_iterator begin, ParameterMap::const_iterator end, const DeviceOptions &device_options)
Set the default values for the parameter.
Definition: N_DEV_Pars.C:77
virtual std::ostream & printName(std::ostream &os) const =0
bool wasValueGiven(const ParameterBase &parameter_base, int serial_number)
Return true if a value was provided for the device.
Definition: N_DEV_Pars.h:1674
bool hasCompositeData() const
Definition: N_DEV_Pars.h:605
bool getParamBreakpoints(std::vector< Util::BreakPoint > &)
bool getAnalyticSensitivity(const ParameterBase &entity1, const std::string &name, std::vector< double > &dfdp, std::vector< double > &dqdp, std::vector< double > &dbdp, std::vector< int > &Findices, std::vector< int > &Qindices, std::vector< int > &Bindices) const
returns analytic sensitivity, evaluated at the most recent solve point.
Definition: N_DEV_Pars.h:1028
bool analyticSensitivityAvailable(const std::string &paramName)
std::vector< double > eVarVals
const SolverState & getSolverState() const
bool hasOriginalValueStored() const
Returns whether an original value has been stored.
Definition: N_DEV_Pars.h:632
int getSerialNumber() const
Gets the serial number used to store and retireve given boolean fromt he GivenValueMap.
Definition: N_DEV_Pars.h:854
void populateParams(const ParameterMap &parameter_map, std::vector< Param > &param_list, CompositeParamMap &composite_param_map)
std::map< std::string, std::vector< Param >, LessNoCase > CompositeParamMap
unordered_map< std::string, double, HashNoCase, EqualNoCase > GlobalParameterMap
Definition: N_DEV_fwd.h:161
void setGiven(ParameterBase &entity, bool value) const
Sets the given state of the parameter to value.
Definition: N_DEV_Pars.h:976
std::vector< double > expVarVals
bool scaleParam(const std::string &paramName, double val, double val0)
bool setParam(const std::string &paramName, double val, bool overrideOriginal=false)
bool isType() const
Tests entry data type.
Definition: N_DEV_Pars.h:597
Util::Expression * expr
GlobalParameterMap global_params
Parameter may be specified as a solution dependent expression from netlist.
Definition: N_DEV_Pars.h:68
Manages parameter binding for class C.
Definition: N_DEV_Pars.h:214
bool updateGlobalParameters(GlobalParameterMap &)
std::vector< std::string > expVarNames
bool default_val() const
Definition: N_DEV_Param.h:117
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
const ParameterMap & getParameterMap() const
getParameterMap returns the parameter map which describes the parameters.