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.251 $
40 //
41 // Revision Date : $Date: 2015/08/16 23:19:21 $
42 //
43 // Current Owner : $Author: erkeite $
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::analyticSensitivityAvailableDefaultParam
247 // Purpose :
248 // Special Notes :
249 // Scope : public
250 // Creator : Eric Keiter, SNL
251 // Creation Date : 8/16/2015
252 //-----------------------------------------------------------------------------
254 {
255  if (defaultParamName_.empty())
256  {
257  DevelFatal(*this).in("DeviceEntity::analyticSensitivityAvailableDefaultParam")
258  << "Device does not have a default parameter";
259  return false;
260  }
261 
263 }
264 
265 //-----------------------------------------------------------------------------
266 // Function : DeviceEntity::getAnalyticSensitivity
267 // Purpose :
268 // Special Notes :
269 // Scope : public
270 // Creator : Eric Keiter, SNL
271 // Creation Date : 7/17/2014
272 //-----------------------------------------------------------------------------
273 bool DeviceEntity::getAnalyticSensitivity ( const std::string & paramName,
274  std::vector<double> & dfdpVec,
275  std::vector<double> & dqdpVec,
276  std::vector<double> & dbdpVec,
277  std::vector<int> & FindicesVec,
278  std::vector<int> & QindicesVec,
279  std::vector<int> & BindicesVec)
280 {
281  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
282  if (p_i == getParameterMap().end())
283  {
284  DevelFatal(*this).in("DeviceEntity::analyticSensitivityAvailable") << "Unrecognized parameter " << paramName;
285  return false;
286  }
287 
288  const Descriptor &param = *(*p_i).second;
289 
290  return param.getAnalyticSensitivity (*this, paramName, dfdpVec, dqdpVec, dbdpVec,
291  FindicesVec, QindicesVec, BindicesVec);
292 }
293 
294 
295 //-----------------------------------------------------------------------------
296 // Function : DeviceEntity::getAnalyticSensitivityDefaultParam
297 // Purpose :
298 // Special Notes :
299 // Scope : public
300 // Creator : Eric Keiter, SNL
301 // Creation Date : 7/17/2014
302 //-----------------------------------------------------------------------------
304  std::vector<double> & dfdpVec,
305  std::vector<double> & dqdpVec,
306  std::vector<double> & dbdpVec,
307  std::vector<int> & FindicesVec,
308  std::vector<int> & QindicesVec,
309  std::vector<int> & BindicesVec)
310 {
311  if (defaultParamName_.empty())
312  {
313  DevelFatal(*this).in("DeviceEntity::getAnalyticSensitivityDefaultParam")
314  << "Device does not have a default parameter";
315  return false;
316  }
317 
319  dfdpVec, dqdpVec, dbdpVec, FindicesVec, QindicesVec, BindicesVec);
320 }
321 
322 //-----------------------------------------------------------------------------
323 // Function : DeviceEntity::setParam
324 //
325 // Purpose : This function loops over the vector of parameters, and
326 // sets the specified one (if found) to a specified value.
327 //
328 // Special Notes : This is kind of tricky, b/c some parameters are actually
329 // deep inside other classes (like a source class, for
330 // example)
331 //
332 // This function always returns a true, b/c there are many
333 // instances, (for example running in parallel), where one
334 // could set a param that didn't exist locally on
335 // processor.
336 //
337 // Scope : public
338 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
339 // Creation Date : 07/25/03
340 //-----------------------------------------------------------------------------
341 bool DeviceEntity::setParam(const std::string & paramName, double val, bool overrideOriginal)
342 {
343  if (DEBUG_DEVICE)
344  {
345  Xyce::dout() << "DeviceEntity::setParam with paramname = " << paramName << " value = " << val << " overrideOriginal = " << overrideOriginal << std::endl;
346  }
347 
348  ParameterMap::const_iterator p_i = getParameterMap().find(paramName);
349  if (p_i == getParameterMap().end())
350  return false;
351 
352  if (isTempParam(paramName))
353  val += CONSTCtoK;
354 
355  const Descriptor &param = *(*p_i).second;
356 
357  if (param.isType<double>())
358  param.value<double>(*this) = val;
359  else if (param.isType<int>())
360  param.value<int>(*this) = static_cast <int> (val);
361  else if (param.isType<long>())
362  param.value<long>(*this) = static_cast <long> (val);
363  else if (param.isType<bool>())
364  param.value<bool>(*this) = (val != 0);
365  else
366  DevelFatal0(*this) << "Illegal type for parameter " << paramName;
367 
368  if (param.hasGivenMember())
369  param.setGiven(*this, true);
370 
371  Xyce::Device::setValueGiven(*this, param.getSerialNumber(), true);
372 
373  if (param.hasOriginalValueStored() && overrideOriginal)
374  {
375  if (DEBUG_DEVICE)
376  {
377  Xyce::dout() << " Overriding original value for parameter " << paramName << " with value " << val << std::endl;
378  }
380  }
381 
382  return true;
383 }
384 
385 //-----------------------------------------------------------------------------
386 // Function : DeviceEntity::getParam
387 //
388 // Purpose : returns true if parameter exists for device
389 //
390 // Scope : public
391 // Creator : David G. Baur, Raytheon
392 // Creation Date : 07/01/2016
393 //-----------------------------------------------------------------------------
394 bool
396  const std::string & param_name) const
397 {
398  return getParameterMap().find(param_name) != getParameterMap().end();
399 }
400 
401 //-----------------------------------------------------------------------------
402 // Function : DeviceEntity::getParam
403 //
404 // Purpose : returns the value of the requested param.
405 //
406 // Special Notes : This function currently assumes that the requested
407 // param is a double-precision number.
408 //
409 // Parameters are not case-dependent.
410 //
411 // Scope : public
412 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
413 // Creation Date : 07/25/03
414 //-----------------------------------------------------------------------------
415 bool
417  const std::string & name,
418  double & result) const
419 {
420  double val = 0.0;
421  bool found = false;
422 
423  ParameterMap::const_iterator p_i = getParameterMap().find(name);
424  if (p_i != getParameterMap().end())
425  {
426  found = true;
427  const Descriptor &param = *(*p_i).second;
428  if (param.isType<double>())
429  val = param.value<double>(*this);
430  else if (param.isType<int>())
431  val = static_cast <double> (param.value<int>(*this));
432  else if (param.isType<long>())
433  val = static_cast <double> (param.value<long>(*this));
434  else if (param.isType<bool>())
435  {
436  if (param.value<bool>(*this))
437  val = 1;
438  else
439  val = 0;
440  }
441  else
442  {
443  DevelFatal(*this).in("DeviceEntity::getParam") << "Illegal type for parameter " << name;
444  }
445  if (isTempParam(name))
446  val -= CONSTCtoK;
447  }
448  else
449  {
450  // If not recognized, just do nothing
451  }
452  result = val;
453 
454  return found;
455 }
456 
457 //-----------------------------------------------------------------------------
458 // Function : DeviceEntity::setDefaultParam
459 // Purpose :
460 // Special Notes :
461 // Scope : public
462 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
463 // Creation Date : 11/06/03
464 //-----------------------------------------------------------------------------
465 bool DeviceEntity::setDefaultParam (double val, bool overrideOriginal)
466 {
467  if (defaultParamName_.empty())
468  {
469  DevelFatal(*this).in("DeviceEntity::setDefaultParam") << "Device does not have a default parameter";
470  }
471 
472  return setParam(defaultParamName_, val, overrideOriginal);
473 }
474 
475 //-----------------------------------------------------------------------------
476 // Function : DeviceEntity::getDefaultParam
477 // Purpose :
478 // Special Notes :
479 // Scope : public
480 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
481 // Creation Date : 11/06/03
482 //-----------------------------------------------------------------------------
484 {
485  if (defaultParamName_.empty())
486  {
487  return 0.0;
488  }
489 
490  double result = 0.0;
491 
492  getParam(defaultParamName_, result);
493 
494  return result;
495 }
496 
497 //-----------------------------------------------------------------------------
498 // Function : DeviceEntity::setDependentParameter
499 // Purpose : Add expression, param pairs for future updates
500 // Special Notes : This is an overloaded method, used instead of the old
501 // monolithic one.
502 // Scope : protected
503 // Creator : Tom Russo
504 // Creation Date : 6 Nov 07
505 //-----------------------------------------------------------------------------
506 double DeviceEntity::setDependentParameter (Util::Param & par,
507  double *res,
509 
510 {
511  Depend dependentParam;
512  setDependentParameter(par, dependentParam, depend);
513 
514  dependentParam.resultU.result = res;
515  dependentParam.vectorIndex = -1;
516  dependentParams_.push_back(dependentParam);
517 
518  double rval;
519  dependentParam.expr->evaluateFunction (rval);
520  dependentParam.expr->set_sim_time(getSolverState().currTime_);
521 
522  return rval;
523 }
524 
525 //-----------------------------------------------------------------------------
526 // Function : DeviceEntity::setDependentParameter
527 // Purpose : Add expression, param pairs for future updates
528 // Special Notes : This is an overloaded method, used instead of the old
529 // monolithic one, and is specifically to set an element
530 // of a double vector.
531 // Scope : protected
532 // Creator : Tom Russo
533 // Creation Date : 6 Nov 07
534 //-----------------------------------------------------------------------------
535 double DeviceEntity::setDependentParameter (Util::Param & par,
536  std::vector<double> *res,
537  int ind,
539 
540 {
541  Depend dependentParam;
542  setDependentParameter(par,dependentParam, depend);
543 
544  dependentParam.resultU.resVec = res;
545  dependentParam.vectorIndex = ind;
546  dependentParams_.push_back(dependentParam);
547 
548  double rval;
549  dependentParam.expr->evaluateFunction (rval);
550  dependentParam.expr->set_sim_time(getSolverState().currTime_);
551 
552  return rval;
553 }
554 
555 //-----------------------------------------------------------------------------
556 // Function : DeviceEntity::setDependentParameter
557 // Purpose : Add expression, param pairs for future updates
558 // Special Notes : This is a utility version, used by overloaded methods.
559 // Scope : protected
560 // Creator : Dave Shirley, PSSI
561 // Creation Date : 11/18/04
562 //-----------------------------------------------------------------------------
563 
564 void DeviceEntity::setDependentParameter (Util::Param & par,
565  Depend & dependentParam,
567 {
568  std::vector<std::string> instances, leads, names, variables;
569 
570  dependentParam.name = par.tag();
571  if (isTempParam(par.tag()))
572  {
573  dependentParam.expr = new Util::Expression ("(" + par.stringValue() + ")+CONSTCtoK");
574  dependentParam.expr->make_constant (std::string("CONSTCTOK"), CONSTCtoK);
575  }
576  else
577  {
578  dependentParam.expr = new Util::Expression (par.getValue<Util::Expression>());
579  }
580 
581  names.clear();
582  leads.clear();
583  instances.clear();
584  variables.clear();
585 
586  dependentParam.expr->get_names(XEXP_NODE, names);
587  dependentParam.expr->get_names(XEXP_LEAD, leads);
588  dependentParam.expr->get_names(XEXP_INSTANCE, instances);
589  dependentParam.expr->get_names(XEXP_VARIABLE, variables);
590 
591  //std::vector<std::string>::iterator s;
592  std::vector<std::string>::iterator iterS;
593 
594  if (!(depend & ParameterType::SOLN_DEP))
595  {
596  if (names.size() > 0 || instances.size() > 0)
597  {
598  UserError0(*this) << "Parameter " << par.tag() << " is not allowed to depend on voltage/current values";
599  return;
600  }
601  if (depend & ParameterType::NO_DEP)
602  {
603  if (dependentParam.expr->get_num(XEXP_SPECIAL) > 0)
604  {
605  UserError0(*this) << "Parameter " << par.tag() << " is not allowed to depend on time";
606  return;
607  }
608  }
609  }
610 
611  if (leads.size() > 0)
612  {
613  char type;
614  int index;
615  for (std::vector<std::string>::const_iterator n_i=leads.begin(); n_i != leads.end(); ++n_i)
616  {
617  index = n_i->find_last_of(":");
618  if (index == std::string::npos )
619  type = (*n_i)[0];
620  else
621  type = (*n_i)[index+1];
622 
623  if (type != 'B' && type != 'E' && type != 'H')
624  {
625  UserError(*this) << "Illegal use of lead current specification in expression '" << dependentParam.expr->get_expression()
626  << "' in parameter " << par.tag();
627  }
628  }
629  names.insert( names.end(), leads.begin(), leads.end() );
630  }
631 
632  names.insert( names.end(), instances.begin(), instances.end() );
633 
634  dependentParam.lo_var = expVarNames.size();
635  dependentParam.n_vars = names.size();
636  dependentParam.vals.resize(dependentParam.n_vars);
637  int expVarLen = dependentParam.lo_var+dependentParam.n_vars;
638  expVarGIDs.resize(expVarLen);
639  expVarLIDs.resize(expVarLen);
640  expVarVals.resize(expVarLen);
641 
642  if (!variables.empty())
643  names.insert( names.end(), variables.begin(), variables.end() );
644 
645  if ( !names.empty() )
646  {
647  // Order the names in the expression so that it agrees with the order
648  // in names.
649  dependentParam.expr->order_names( names );
650  }
651  for (int i=0 ; i<dependentParam.n_vars ; ++i)
652  expVarNames.push_back(names[i]);
653 
654  if (dependentParam.n_vars > 0)
655  {
656  std::vector<double> zeros;
657  zeros.resize(dependentParam.n_vars);
658  for (int i=0 ; i<dependentParam.n_vars ; ++i)
659  zeros[i] = 0;
660  dependentParam.expr->set_vars(zeros);
661  }
662 
663  dependentParam.global_params.clear();
664  if (!variables.empty())
665  {
666  for (iterS=variables.begin() ; iterS!=variables.end() ; ++iterS)
667  {
668  GlobalParameterMap::iterator global_param_it = globals_.global_params.find(*iterS);
669  if (global_param_it == globals_.global_params.end())
670  {
671  UserError(*this) << "Global parameter " << *iterS << " not found";
672  }
673  else {
674  dependentParam.expr->set_var(*iterS, (*global_param_it).second);
675  dependentParam.global_params.push_back(*iterS);
676  }
677  }
678  }
679 }
680 
681 //-----------------------------------------------------------------------------
682 // Function : DeviceEntity::updateDependentParameters
683 // Purpose : Update values of parameters defined as expressions
684 // Special Notes :
685 // Scope : protected
686 // Creator : Dave Shirley, PSSI
687 // Creation Date : 03/15/05
688 //-----------------------------------------------------------------------------
689 bool DeviceEntity::updateDependentParameters(const Linear::Vector & vars)
690 {
691  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
692  std::vector<Depend>::iterator end = dependentParams_.end();
693  double rval(0.0);
694  bool changed = false;
695 
696  for ( ; dpIter != end ; ++dpIter)
697  {
698  if (dpIter->expr->set_sim_time(getSolverState().currTime_))
699  changed = true;
700  eVarVals.resize(dpIter->n_vars);
701  if (dpIter->n_vars > 0)
702  {
703  int hi = dpIter->lo_var+dpIter->n_vars;
704  for (int i = dpIter->lo_var; i < hi; ++i)
705  {
706  expVarVals[i] = vars[expVarLIDs[i]];
707  eVarVals[i-dpIter->lo_var] = expVarVals[i];
708  }
709  if (dpIter->expr->set_vars(eVarVals))
710  changed = true;
711  }
712  dpIter->expr->evaluateFunction (rval);
713  if (dpIter->vectorIndex==-1)
714  *(dpIter->resultU.result) = rval;
715  else
716  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
717  }
718 
719  return changed;
720 }
721 
722 //-----------------------------------------------------------------------------
723 // Function : DeviceEntity::updateGlobalParameters
724 // Purpose : Update values of global parameters in expressions
725 // Special Notes :
726 // Scope : protected
727 // Creator : Dave Shirley, PSSI
728 // Creation Date : 11/17/05
729 //-----------------------------------------------------------------------------
731 {
732  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
733  std::vector<Depend>::iterator end = dependentParams_.end();
734  double rval;
735  int i, hi;
736  bool changed = false;
737 
738  for ( ; dpIter != end ; ++dpIter)
739  {
740  if (!dpIter->global_params.empty())
741  {
742  std::vector<std::string>::iterator gp=dpIter->global_params.begin();
743  std::vector<std::string>::iterator gend=dpIter->global_params.end();
744  for ( ; gp != gend; ++gp)
745  {
746  if (global_map.find(*gp) == global_map.end())
747  {
748  DevelFatal(*this).in("DeviceEntity::updateGlobalParameters") << "Failed to find global parameter " << *gp;
749  }
750  if (dpIter->expr->set_var(*gp, global_map[*gp]))
751  changed = true;
752  }
753  }
754  }
755 
756  return changed;
757 }
758 
759 //-----------------------------------------------------------------------------
760 // Function : DeviceEntity::updateDependentParameters
761 // Purpose : Update values of parameters defined as expressions
762 // Special Notes :
763 // Scope : protected
764 // Creator : Dave Shirley, PSSI
765 // Creation Date : 11/18/04
766 //-----------------------------------------------------------------------------
768 {
769  double rval;
770  bool changed = false;
771 
772  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
773  std::vector<Depend>::iterator end = dependentParams_.end();
774  for ( ; dpIter != end; ++dpIter)
775  {
776  if (dpIter->expr->set_sim_time( getSolverState().currTime_))
777  changed = true;
778  dpIter->expr->evaluateFunction (rval);
779  if (dpIter->vectorIndex == -1)
780  *(dpIter->resultU.result) = rval;
781  else
782  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
783  }
784 
785  return changed;
786 }
787 
788 //-----------------------------------------------------------------------------
789 // Function : DeviceEntity::updateDependentParameters
790 // Purpose : Update values of parameters defined as expressions with a
791 // specified temperature
792 // Special Notes :
793 // Scope : protected
794 // Creator : Dave Shirley, PSSI
795 // Creation Date : 01/11/06
796 //-----------------------------------------------------------------------------
798 {
799  double rval;
800  bool changed = false;
801 
802  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
803  std::vector<Depend>::iterator end = dependentParams_.end();
804  for ( ; dpIter != end; ++dpIter)
805  {
806  if (dpIter->expr->set_sim_time( getSolverState().currTime_ ) || dpIter->expr->set_temp(tempIn))
807  changed = true;
808  dpIter->expr->evaluateFunction (rval);
809  if (dpIter->vectorIndex == -1)
810  *(dpIter->resultU.result) = rval;
811  else
812  (*(dpIter->resultU.resVec))[dpIter->vectorIndex] = rval;
813 
814  }
815 
816  return changed;
817 }
818 
819 //-----------------------------------------------------------------------------
820 // Function : DeviceEntity::getParamBreakpoints
821 // Purpose : Add breakpoints caused by discontinuities in computed params
822 // Special Notes :
823 // Scope : protected
824 // Creator : Dave Shirley, PSSI
825 // Creation Date : 11/18/04
826 //-----------------------------------------------------------------------------
827 bool DeviceEntity::getParamBreakpoints( std::vector<Util::BreakPoint> & breakPointTimes )
828 {
829  double bTime;
830 
831  std::vector<Depend>::iterator dpIter = dependentParams_.begin();
832  std::vector<Depend>::iterator end = dependentParams_.end();
833  for ( ; dpIter != end; ++dpIter)
834  {
835  bTime = dpIter->expr->get_break_time();
836  if (bTime > getSolverState().currTime_)
837  breakPointTimes.push_back(Util::BreakPoint(bTime));
838  }
839 
840  return true;
841 }
842 
843 //-----------------------------------------------------------------------------
844 // Function : DeviceEntity::given
845 // Purpose : Return whether param was given
846 // Special Notes :
847 // Scope : protected
848 // Creator : Dave Shirley, PSSI
849 // Creation Date : 11/23/04
850 //-----------------------------------------------------------------------------
851 bool DeviceEntity::given( const std::string & parameter_name ) const
852 {
853  ParameterMap::const_iterator it = getParameterMap().find(parameter_name);
854  if (it == getParameterMap().end())
855  DevelFatal0(*this).in("DeviceEntity::given") << "Unrecognized parameter " << parameter_name;
856 
857  return Xyce::Device::wasValueGiven(*this, (*it).second->getSerialNumber());
858 }
859 
860 //-----------------------------------------------------------------------------
861 // Function : setParameters
862 // Purpose : Set parameters according to a vector of params. Used to
863 // set instance or model parameter sets to netlist values
864 // Special Notes :
865 // Scope : protected
866 // Creator : Dave Shirley, PSSI
867 // Creation Date : 11/20/04
868 //-----------------------------------------------------------------------------
869 void setParameters(DeviceEntity &entity, std::vector<Param>::const_iterator begin, std::vector<Param>::const_iterator end, const DeviceOptions &device_options)
870 {
871  std::vector<std::string> composite_name_list;
872  unordered_map<std::string, std::vector<CompositeParam *>, HashNoCase, EqualNoCase> composite_parameter_map;
873  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
874  {
875  Xyce::dout() << std::endl << "In DeviceEntity::setParams, for ";
876  entity.printName(Xyce::dout());
877  Xyce::dout() << " parameters are:" << std::endl;
878  for (std::vector<Param>::const_iterator it = begin; it != end; ++it)
879  {
880  const Param &param = *it;
881  Xyce::dout() << "Param = " << param.tag() << ", Type = ";
882  int tmpType = param.getType();
883  switch (tmpType)
884  {
885  case Util::STR:
886  Xyce::dout() << "STR";
887  break;
888  case Util::DBLE:
889  Xyce::dout() << "DBLE";
890  break;
891  case Util::INT:
892  Xyce::dout() << "INT";
893  break;
894  case Util::LNG:
895  Xyce::dout() << "LNG";
896  break;
897  case Util::EXPR:
898  Xyce::dout() << "EXPR";
899  break;
900  case Util::BOOL:
901  Xyce::dout() << "BOOL";
902  break;
903  case Util::STR_VEC:
904  Xyce::dout() << "STR_VEC";
905  break;
906  case Util::INT_VEC:
907  Xyce::dout() << "INT_VEC";
908  break;
909  case Util::DBLE_VEC:
910  Xyce::dout() << "DBLE_VEC";
911  break;
912  case Util::DBLE_VEC_IND:
913  Xyce::dout() << "DBLE_VEC_IND";
914  break;
915  case Util::COMPOSITE:
916  Xyce::dout() << "COMPOSITE";
917  break;
918  default:
919  Xyce::dout() << "Unknown";
920  }
921  Xyce::dout() << ", Value = " << param.stringValue();
922 
923  if (param.given())
924  {
925  Xyce::dout() << " given=TRUE";
926  }
927  else
928  {
929  Xyce::dout() << " given=FALSE";
930  }
931 
932  if (param.default_val())
933  {
934  Xyce::dout() << " default=TRUE" << std::endl;
935  }
936  else
937  {
938  Xyce::dout() << " default=FALSE" << std::endl;
939  }
940  }
941  Xyce::dout() << std::endl;
942  }
943 
944  for (std::vector<Param>::const_iterator param_it = begin; param_it != end; ++param_it)
945  {
946  Param &param = const_cast<Param &>(*param_it);
947 
948  const std::string &tag = param.tag();
949 
950  // Is this parameter in the Entity?
951  ParameterMap::const_iterator entity_parameter_it = entity.getParameterMap().find(tag);
952  if (entity_parameter_it != entity.getParameterMap().end())
953  {
954  const Descriptor &descriptor = *(*entity_parameter_it).second;
955  if (descriptor.hasGivenMember())
956  {
957  if (param.given())
958  {
959  descriptor.setGiven(entity, true);
960  }
961  else if (descriptor.getGiven(entity))
962  {
963  continue;
964  }
965  }
966 
967  Xyce::Device::setValueGiven(entity, descriptor.getSerialNumber(), param.given());
968  if (param.given() || param.default_val())
969  {
970  if ( param.getType() == Util::EXPR )
971  {
972  if (descriptor.isType<double>())
973  {
974  double val = entity.setDependentParameter(param, &(descriptor.value<double>(entity)), descriptor.getExpressionAccess());
975  param.setVal(val);
976  }
977  else if (descriptor.isType<std::vector<double> >())
978  {
979  int ind = (descriptor.value<std::vector<double> >(entity)).size();
980  double val = entity.setDependentParameter (param, &(descriptor.value<std::vector<double> >(entity)), ind, descriptor.getExpressionAccess());
981  (descriptor.value<std::vector<double> >(entity)).push_back(val);
982  }
983  else
984  {
985  DevelFatal(entity).in("DeviceEntity::setParams") << "Non double param " << tag << " cannot be set to expression";
986  }
987  }
988  else
989  {
990  if (descriptor.isType<double>())
991  {
992  if (!param.isNumeric())
993  {
994  UserError(entity) << "Cannot convert parameter " << tag << " to a numeric value from " << param.stringValue();
995  continue;
996  }
997 
998  descriptor.value<double>(entity) = param.getImmutableValue<double>();
999  if (isTempParam(tag))
1000  {
1001  descriptor.value<double>(entity) += CONSTCtoK;
1002  }
1003  if (descriptor.hasOriginalValueStored())
1004  {
1005  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), descriptor.value<double>(entity));
1006  }
1007  }
1008  else if (descriptor.isType<std::string>())
1009  {
1010  descriptor.value<std::string>(entity) = param.stringValue();
1011  }
1012  else if (descriptor.isType<int>())
1013  {
1014  if (!param.isInteger())
1015  {
1016  UserError(entity) << "Cannot convert parameter " << tag << " to an integer value from " << param.stringValue();
1017  continue;
1018  }
1019  descriptor.value<int>(entity) = param.getImmutableValue<int>();
1020  if (descriptor.hasOriginalValueStored())
1021  {
1022  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), static_cast<double> (descriptor.value<int>(entity)));
1023  }
1024  }
1025  else if (descriptor.isType<long>())
1026  {
1027  if (!param.isInteger())
1028  {
1029  UserError(entity) << "Cannot convert parameter " << tag << " to an integer value from " << param.stringValue();
1030  continue;
1031  }
1032  descriptor.value<long>(entity) = param.getImmutableValue<long>();
1033  if (descriptor.hasOriginalValueStored())
1034  {
1035  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), static_cast<double> (descriptor.value<long>(entity)));
1036  }
1037  }
1038  else if (descriptor.isType<bool>())
1039  {
1040  if (!param.isBool())
1041  {
1042  UserError(entity) << "Cannot convert parameter " << tag << " to a logical value from " << param.stringValue();
1043  continue;
1044  }
1045  descriptor.value<bool>(entity) = param.getImmutableValue<bool>();
1046  if (descriptor.hasOriginalValueStored())
1047  {
1048  if (descriptor.value<bool>(entity))
1049  {
1050  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), 1.0);
1051  }
1052  else
1053  {
1054  Xyce::Device::setOriginalValue(entity, descriptor.getSerialNumber(), 0.0);
1055  }
1056  }
1057  }
1058  else if (descriptor.isType<std::vector<int> >())
1059  {
1060  if (param.getType() == Util::INT_VEC)
1061  {
1062  (descriptor.value<std::vector<int> >(entity)) = param.getValue<std::vector<int> >();
1063  }
1064  else if (param.getType() == Util::INT)
1065  {
1066  (descriptor.value<std::vector<int> >(entity)).push_back(param.getImmutableValue<int>());
1067  }
1068  }
1069  else if (descriptor.isType<std::vector<double> >())
1070  {
1071  if (param.getType() == Util::DBLE_VEC)
1072  {
1073  (descriptor.value<std::vector<double> >(entity)) = param.getValue<std::vector<double> >();
1074  }
1075  else if (param.getType() == Util::DBLE)
1076  {
1077  (descriptor.value<std::vector<double> >(entity)).push_back(param.getImmutableValue<double>());
1078  }
1079  }
1080  else if (descriptor.isType<std::vector<std::string> >())
1081  {
1082  if (param.getType() == Util::STR_VEC)
1083  {
1084  (descriptor.value<std::vector<std::string> >(entity)) = param.getValue<std::vector<std::string> >();
1085  }
1086  else if (param.getType() == Util::STR)
1087  {
1088  (descriptor.value<std::vector<std::string> >(entity)).push_back(param.stringValue());
1089  }
1090  }
1091  else if (descriptor.hasCompositeData())
1092  {
1093  composite_parameter_map[tag].clear();
1094  composite_name_list.push_back(tag);
1095 
1096  // Note: ERK. This push-back is done to process the base-param tag of a vector composite.
1097  // For example, if the composite parameters are things like REGION0.XWIDTH, where REGION
1098  // is the base parameter tag, 0 is the index, and XWIDTH is the subcomponent, the
1099  // tag that should be pushed back is tagES=REGION.
1100  //
1101  // Note: ERK: This function seems to implicitly rely on the base parameter always preceeding
1102  // subcomponent parameters. So REGION (alone) should preceed REGION0.XWIDTH in the
1103  // STL vector params that is passed into this function. If it doesn't then vc_stat will
1104  // stay false and a fatal error will get thrown.
1105  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
1106  {
1107  Xyce::dout() << "pushing back composite " << tag << std::endl;
1108  }
1109  }
1110  else
1111  {
1112  DevelFatal(entity).in("DeviceEntity::setParams") << "Unknown type";
1113  }
1114  }
1115  }
1116  }
1117 
1118  // Is it a vector (why do nothing?)
1119  else if (param.stringValue() == "VECTOR")
1120  {
1121  }
1122 
1123  // Must be a composite
1124  else
1125  {
1126  bool vc_stat = false;
1127 
1128  std::string::size_type dot = tag.find_first_of('.');
1129  if (dot != std::string::npos)
1130  {
1131  for (std::vector<std::string>::const_iterator it = composite_name_list.begin(); it != composite_name_list.end(); ++it)
1132  {
1133  const std::string &composite_name = *it;
1134 
1135  if (tag.find(composite_name) == 0) // Tag starts with the composite parameter name
1136  {
1137  std::string param_name(tag.begin() + dot + 1, tag.end());
1138 
1139  vc_stat = true;
1140 
1141  int n = 0;
1142  {
1143  std::istringstream is(std::string(tag.begin() + composite_name.size(), tag.begin() + dot));
1144  is >> n;
1145  }
1146 
1147  if (param_name == "NAME")
1148  {
1149  if (n != composite_parameter_map[composite_name].size())
1150  {
1151  DevelFatal(entity).in("DeviceEntity::setParams") << "Error filling 'NAME' vector param " << composite_name;
1152  }
1153 
1154  std::string name = param.stringValue();
1155  CompositeParam *composite = entity.constructComposite(composite_name, name);
1156  composite_parameter_map[composite_name].push_back(composite);
1157  setDefaultParameters(*composite, composite->getParameterMap().begin(), composite->getParameterMap().end(), device_options);
1158  }
1159  else
1160  {
1161  if (n >= composite_parameter_map[composite_name].size())
1162  {
1163  DevelFatal(entity).in("DeviceEntity::setParams") << "Internal error in vector-composite, 'NAME' must come first " << composite_name;
1164  }
1165  }
1166  Xyce::Device::setParameters(*composite_parameter_map[composite_name][n], param_name, param);
1167  }
1168  }
1169  }
1170  if (!vc_stat)
1171  {
1172  DevelFatal(entity) << "Undefined parameter " << tag << ", this parameter is in metadata, but not recognized in constructor";
1173  }
1174  }
1175  }
1176 
1177  if (!composite_name_list.empty())
1178  {
1179  for (std::vector<std::string>::const_iterator name_it = composite_name_list.begin(); name_it != composite_name_list.end(); ++name_it)
1180  {
1181  const std::string &vcs = *name_it;
1182 
1183  for (std::vector<CompositeParam *>::iterator it = composite_parameter_map[vcs].begin(); it != composite_parameter_map[vcs].end(); ++it)
1184  {
1185  (*it)->processParams();
1186  }
1187  }
1188  }
1189 }
1190 
1191 
1192 //-----------------------------------------------------------------------------
1193 // Function : setParameters
1194 // Purpose : Set parameter according to input Param. Used to
1195 // set instance or model parameter sets to netlist values
1196 // Special Notes :
1197 // Scope : public
1198 // Creator : Dave Shirley, PSSI
1199 // Creation Date : 05/06/05
1200 //-----------------------------------------------------------------------------
1201 
1202 void setParameters(CompositeParam &composite_param, const std::string & pName, const Param & ndParam )
1203 {
1204  ParameterMap::const_iterator p_i = composite_param.getParameterMap().find(pName);
1205  if (p_i != composite_param.getParameterMap().end())
1206  {
1207  const Descriptor &p = *(*p_i).second;
1208  if (p.hasGivenMember())
1209  {
1210  if (ndParam.given())
1211  p.setGiven(composite_param, true);
1212  else if (p.getGiven(composite_param))
1213  return;
1214  }
1215  Xyce::Device::setValueGiven(composite_param, p.getSerialNumber(), ndParam.given());
1216  if (ndParam.given() || ndParam.default_val())
1217  {
1218  if (p.isType<double>())
1219  {
1220  p.value<double>(composite_param) = ndParam.getImmutableValue<double>();
1221  if (isTempParam(pName))
1222  p.value<double>(composite_param) += CONSTCtoK;
1223  if (p.hasOriginalValueStored())
1224  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), p.value<double>(composite_param));
1225  }
1226  else if (p.isType<std::string>())
1227  {
1228  p.value<std::string>(composite_param) = ndParam.stringValue();
1229  }
1230  else if (p.isType<int>())
1231  {
1232  p.value<int>(composite_param) = ndParam.getImmutableValue<int>();
1233  if (p.hasOriginalValueStored())
1234  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), static_cast<double>(p.value<int>(composite_param)));
1235  }
1236  else if (p.isType<long>())
1237  {
1238  p.value<long>(composite_param) = ndParam.getImmutableValue<long>();
1239  if (p.hasOriginalValueStored())
1240  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), static_cast<double>(p.value<long>(composite_param)));
1241  }
1242  else if (p.isType<bool>())
1243  {
1244  p.value<bool>(composite_param) = (ndParam.getImmutableValue<double>() != 0.0);
1245  if (p.hasOriginalValueStored())
1246  {
1247  if (p.value<bool>(composite_param))
1248  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), 1.0);
1249  else
1250  Xyce::Device::setOriginalValue(composite_param, p.getSerialNumber(), 0.0);
1251  }
1252  }
1253  else if (p.isType<std::vector<double> >())
1254  {
1255  (p.value<std::vector<double> >(composite_param)).push_back(ndParam.getImmutableValue<double>());
1256  }
1257  else if (p.isType<std::vector<std::string> >())
1258  {
1259  p.value<std::vector<std::string> >(composite_param).push_back(ndParam.stringValue());
1260  }
1261  else
1262  {
1263  Report::DevelFatal().in("CompositeParam::setParams") << "Unknown parameter type for " << pName;
1264  }
1265  }
1266  }
1267  else
1268  {
1269  Report::DevelFatal().in("CompositeParam::setParams") << "Undefined parameter " << pName << std::endl
1270  << "This parameter is in metadata, but not recognized in constructor";
1271  }
1272 }
1273 
1274 
1275 void populateParams(const ParameterMap &parameter_map, std::vector<Param> &param_list, CompositeParamMap &composite_param_map)
1276 {
1277  for (ParameterMap::const_iterator it = parameter_map.begin(); it != parameter_map.end(); ++it)
1278  {
1279  const Descriptor &param = *(*it).second;
1280 
1281  if (param.isType<double>())
1282  {
1283  if (param.getVec() == 0)
1284  {
1285  double val;
1286  if (isTempParam((*it).first))
1287  val = getDefaultValue<double>(param) - CONSTCtoK;
1288  else
1289  val = getDefaultValue<double>(param);
1290  param_list.push_back(Param((*it).first, val));
1291  }
1292  else if (param.getVec() > 0)
1293  {
1294  if (param.getVec() == 1)
1295  {
1296  // This converts parameters link IC1, IC2 to just IC and type vector
1297  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1298  param_list.push_back(Param(vPar, "VECTOR"));
1299  }
1300  // We will also output IC1, IC2 as type double so they can
1301  // be specified as individual elements
1302  // This allows TC=a, b to also be specified as TC1=a TC2=b
1303  double val = getDefaultValue<double>(param);
1304  param_list.push_back(Param((*it).first, val));
1305  }
1306  }
1307  else if (param.isType<bool>())
1308  {
1309  if (param.getVec() == 0)
1310  param_list.push_back(Param((*it).first, getDefaultValue<bool>(param)));
1311  else if (param.getVec() > 0)
1312  {
1313  if (param.getVec() == 1)
1314  {
1315  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1316  param_list.push_back(Param(vPar, "VECTOR"));
1317  }
1318  // We will also output IC1, IC2 as type double so they can
1319  // be specified as individual elements
1320  // This allows TC=a, b to also be specified as TC1=a TC2=b
1321  bool val = getDefaultValue<bool>(param);
1322  param_list.push_back(Param((*it).first, val));
1323  }
1324  }
1325  else if (param.isType<int>())
1326  {
1327  if (param.getVec() == 0)
1328  param_list.push_back(Param((*it).first, getDefaultValue<int>(param)));
1329  else if (param.getVec() > 0)
1330  {
1331  if (param.getVec() == 1)
1332  {
1333  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1334  param_list.push_back(Param(vPar, "VECTOR"));
1335  }
1336  int val = getDefaultValue<int>(param);
1337  param_list.push_back(Param((*it).first, val));
1338  }
1339  }
1340  else if (param.isType<std::string>())
1341  {
1342  if (param.getVec() == 0)
1343  param_list.push_back(Param((*it).first, getDefaultValue<std::string>(param)));
1344  else if (param.getVec() > 0)
1345  {
1346  if (param.getVec() == 1)
1347  {
1348  std::string vPar((*it).first.substr(0, (*it).first.size()-1));
1349  param_list.push_back(Param(vPar, "VECTOR"));
1350  }
1351  std::string val = getDefaultValue<std::string>(param);
1352  param_list.push_back(Param((*it).first, val));
1353  }
1354  }
1355  else if (param.isType<std::vector<std::string> >())
1356  {
1357  Param vc((*it).first, std::vector<std::string>()); // param.value<std::vector<std::string> >(entity));
1358  param_list.push_back(vc);
1359  }
1360  else if (param.isType<std::vector<double> >())
1361  {
1362  Param vc((*it).first, std::vector<double>()); // param.value<std::vector<double> >(entity));
1363  param_list.push_back(vc);
1364  }
1365  else if (param.hasCompositeData())
1366  {
1367  Param vc2((*it).first, "VECTOR-COMPOSITE");
1368  vc2.setDefault(true);
1369  param_list.push_back(vc2);
1370 
1371  std::vector<Param> compositeParams;
1373 
1374  if (c == 0)
1375  {
1376  Report::DevelFatal().in("populateParams") << "Vector-composite map for device type entity empty.";
1377  }
1378 
1379  // TODO: [DGB] I think when the Descriptor is refactored this will be clearer. But this basically adds the
1380  // type to the composite list with 'NAME' first.
1381  const ParametricData<CompositeParam> &d = *c;
1382  const ParameterMap &e = d.getMap();
1383 
1384  for (ParameterMap::const_iterator it4 = e.find("NAME"); it4 != e.end();) {
1385  const Descriptor &p = *(*it4).second;
1386  if (p.isType<double>())
1387  compositeParams.push_back(Param((*it4).first, getDefaultValue<double>(p)));
1388  else if (p.isType<bool>())
1389  compositeParams.push_back(Param((*it4).first, getDefaultValue<bool>(p)));
1390  else if (p.isType<int>())
1391  compositeParams.push_back(Param((*it4).first, getDefaultValue<int>(p)));
1392  else if (p.isType<std::string>())
1393  compositeParams.push_back(Param((*it4).first, getDefaultValue<std::string>(p)));
1394  if ((*it4).first == "NAME")
1395  it4 = e.begin();
1396  else
1397  it4++;
1398  if (it4 != e.end() && (*it4).first == "NAME")
1399  it4++;
1400  }
1401 
1402  composite_param_map[(*it).first] = compositeParams;
1403  }
1404  else
1405  {
1406  // Just skip these, like list of coupled inductors because not needed for metadata
1407  Xyce::dout() << "In final else clause of DeviceEntity::getParams().";
1408  if( param.isType<std::vector<std::string> >() )
1409  Xyce::dout() << " type is STR_VEC ";
1410  if( param.isType<std::vector<double> >() )
1411  Xyce::dout() << " type is DBLE_VEC ";
1412  Xyce::dout() << it->first << " this item is NOT being added to default parameter list." << std::endl;
1413  }
1414  }
1415 }
1416 
1417 } // namespace Device
1418 } // 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:167
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:109
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 findParam(const std::string &param_name) const
bool given() const
Definition: N_DEV_Param.h:114
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
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
virtual std::ostream & printName(std::ostream &os) const =0
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:169
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 getAnalyticSensitivityDefaultParam(std::vector< double > &dfdpVec, std::vector< double > &dqdpVec, std::vector< double > &dbdpVec, std::vector< int > &FindicesVec, std::vector< int > &QindicesVec, std::vector< int > &BindicesVec)
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:119
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.