Xyce  6.1
N_DEV_Pars.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // Copyright Notice
3 //
4 // Copyright 2002 Sandia Corporation. Under the terms
5 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
6 // Government retains certain rights in this software.
7 //
8 // Xyce(TM) Parallel Electrical Simulator
9 // Copyright(C) 2002-2015 Sandia Corporation
10 //
11 // This program is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, see <http://www.gnu.org/licenses/>.
23 //-----------------------------------------------------------------------------
24 
25 //-------------------------------------------------------------------------
26 // Filename : $RCSfile: N_DEV_Pars.h,v $
27 //
28 // Purpose :
29 //
30 // Special Notes :
31 //
32 // Creator : Netlist device and model parameter management
33 //
34 // Creation Date : 2013/04/18 18:01:27
35 //
36 // Revision Information:
37 // ---------------------
38 //
39 // Revision Number: $Revision: 1.29.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:29:36 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-------------------------------------------------------------------------
45 
46 #ifndef Xyce_N_DEV_Pars_h
47 #define Xyce_N_DEV_Pars_h
48 
49 #include <Sacado.hpp>
50 #include <algorithm>
51 #include <map>
52 #include <set>
53 #include <sstream>
54 #include <string>
55 #include <vector>
56 
57 #include <N_DEV_fwd.h>
58 #include <N_DEV_Units.h>
59 
60 ///
61 /// ParameterType::ExprAccess is enumeration of parameter usage types and masks
62 ///
63 namespace ParameterType {
65  {
66  NO_DEP = 0x0, ///< Parameter can only be set to a constant from netlist
67  TIME_DEP = 0x1, ///< Parameter may be specified as time dependent expression from netlist
68  SOLN_DEP = 0x2, ///< Parameter may be specified as a solution dependent expression from netlist
69  LOG_T_DEP = 0x8, ///< Parameter uses temperature interpolation based on log of value
70  MIN_RES = 0x10, ///< Parameter is subject to being set to minimum lead resistance
71  MIN_CAP = 0x20, ///< Parameter is subject to being set to minimum junction capacitance
72  NO_DOC = 0x40 ///< Parameter is not to be documented
73  };
74 };
75 
76 using namespace ParameterType;
77 
78 
79 namespace Xyce {
80 namespace Device {
81 
82 ///
83 /// @addtogroup xyce_device_parameters_detail
84 ///
85 /// @brief
86 ///
87 /// Device models, device instances and composite parameters are
88 /// collectively called an <b>entity</b>, which are all derived from
89 /// the ParameterBase tag class, and manage the mapping from a
90 /// parameter's string name to a member variable in each created
91 /// entity object. The mapping is refered to as parameter binding and
92 /// the object's bound member variable is refered to as the parameter
93 /// member variable. The object may have an additional member
94 /// variable for each binding that indicates if the value was
95 /// specified in the netlist device and is known as the given member
96 /// variable.
97 ///
98 /// Each class of entity has a ParametricData<T> class, where T is the
99 /// entity class, and a singleton object of that class. This
100 /// singleton manages the parameter binding. A parameter descriptor,
101 /// Descriptor, has the parameter member variable pointer for entity
102 /// object of type T that sets and retrieves the current value of an
103 /// entity's member variable using the parameters string name.
104 ///
105 /// The Descriptor maintains other information about the parameter.
106 /// It has a serial number for each parameter and a boolean member
107 /// variable pointer that determines if the parameter has been given
108 /// in the netlist. The given value map, GivenValueMap, is a mapping
109 /// from entity object pointer and serial number to a boolean given
110 /// member varaible indicating if the parameter was provided by the
111 /// netlist.
112 ///
113 /// Any entity may also wish to restore a parameter member variable
114 /// value to the value originally set during initialization. The
115 /// Descriptor maintains an index into an original value map to store
116 /// and retrieve the parameters original value. The original value
117 /// map, OriginalValueMap, is a mapping from entity object pointer and
118 /// original value index to the parameter's origin value. If the
119 /// original value index is -1, then no original value information is
120 /// maintained.
121 ///
122 /// A parameter may also be vectorized, allowing it to maintain a
123 /// vector values. The Descriptor maintains that vector length.
124 ///
125 /// A parameter has specific usages as described by the
126 /// ParameterType::ExprAccess enumeration.
127 ///
128 /// A parameter may also serves as an aggregation of parametric values
129 /// which is stored as a composite parameter, CompositeParam, entity.
130 ///
131 /// And a parameter has units, a documentation category and a
132 /// documentation description.
133 ///
134 /// Entity - DeviceModel, DeviceInstance or CompositeParam
135 ///
136 /// Given - flag and possibly and entity member variable that
137 /// indicates if a parameter was given in the netlist.
138 ///
139 /// OriginalValue - parameters value after initialization
140 ///
141 
142 typedef std::map<int, double> OriginalValueMap;
143 typedef std::set<int> GivenValueSet;
144 
145 ///
146 /// Base sensitivity functor
147 ///
149 {
150 public:
152  virtual ~baseSensitivity() {}
153 
154  virtual void operator()(
155  const ParameterBase &entity,
156  const std::string &param,
157  std::vector<double> & dfdp,
158  std::vector<double> & dqdp,
159  std::vector<double> & dbdp,
160  std::vector<int> & Findices,
161  std::vector<int> & Qindices,
162  std::vector<int> & Bindices
163  ) const =0;
164 };
165 
166 ///
167 /// Base class for all parameters
168 ///
170 {
171 public:
173  : originalValueMap_(),
174  givenValueSet_()
175  {}
176 
177  virtual ~ParameterBase()
178  {}
179 
180 private:
181  ParameterBase(const ParameterBase &);
182  ParameterBase &operator=(const ParameterBase &);
183 
184 public:
185  double getOriginalValue(int serial_number)
186  {
187  return originalValueMap_[serial_number];
188  }
189 
190  void setOriginalValue(int serial_number, double value)
191  {
192  originalValueMap_[serial_number] = value;
193  }
194 
195  bool wasValueGiven(int serial_number) const
196  {
197  return givenValueSet_.find(serial_number) != givenValueSet_.end();
198  }
199 
200  void setValueGiven(int serial_number, bool value)
201  {
202  if (value)
203  givenValueSet_.insert(serial_number);
204  else
205  givenValueSet_.erase(serial_number);
206  }
207 
208 private:
209  OriginalValueMap originalValueMap_; ///< Map from device entity and original value index to original value
210  GivenValueSet givenValueSet_; ///< Map from device entity and serial number to value given flag
211 };
212 
213 template<class C>
215 
216 template<class T>
217 class Entry;
218 
219 template <class T>
220 inline std::ostream &printEntry(std::ostream &os, const Entry<T> &entry);
221 
222 template <class T>
223 inline std::ostream &printEntry(std::ostream &os, const Entry<std::vector<T> > &entry);
224 
225 template <>
226 inline std::ostream &printEntry(std::ostream &os, const Entry<std::string> &entry);
227 
228 template <>
229 inline std::ostream &printEntry(std::ostream &os, const Entry<bool> &entry);
230 
231 inline std::ostream &printEntry(std::ostream &os, const Entry<CompositeMap> &entry);
232 
233 void typeMismatch(const std::type_info &from_type, const std::type_info &to_type);
234 void nonexistentParameter(const std::string &name, const std::type_info &entity_type);
235 
236 ///
237 /// Class Entry<void> defines the parameter binding value entry interface.
238 ///
239 /// This defines the interface to check the data type of an Entry<T>
240 /// object and to print the value. Type specific Entry classes
241 /// inherit from this class. The entry_cast<T>() function is used to
242 /// cast an object of this type to the derived Entry<T> class safely.
243 ///
244 template<>
245 class Entry<void>
246 {
247 protected:
248  ///
249  /// Constructs the Entry base class
250  ///
251  /// @note The construct is protected so it may only be constructed by Entry<T> classes.
252  ///
253  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
254  /// @date Fri Aug 9 08:32:36 2013
255  ///
257  {}
258 
259 public:
260  ///
261  /// Destroys Entry
262  ///
263  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
264  /// @date Fri Aug 9 08:34:16 2013
265  virtual ~Entry()
266  {}
267 
268 private:
269  Entry(const Entry &);
270  Entry &operator=(const Entry &);
271 
272 public:
273  ///
274  /// Returns the type_info of the data type being stored in the entry.
275  ///
276  /// @return const reference to the type_info of the data type being stored in the entry.
277  ///
278  virtual const std::type_info &type() const = 0;
279 
280  ///
281  /// Prints the value of the entry to the output stream
282  ///
283  /// @param os output stream to write to
284  ///
285  /// @return reference to the output stream
286  ///
287  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
288  /// @date Wed Aug 7 11:28:02 2013
289  std::ostream &print(std::ostream &os) const
290  {
291  doPrint(os);
292 
293  return os;
294  }
295 
296 private:
297  ///
298  /// Prints the value of the entry to the output stream
299  ///
300  /// @param os output stream to write to
301  ///
302  /// @return reference to the output stream
303  ///
304  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
305  /// @date Wed Aug 7 11:29:29 2013
306  virtual std::ostream &doPrint(std::ostream &os) const = 0;
307 };
308 
309 ///
310 /// Class Entry<T> defines the parameter member variable access for
311 /// parameter member variable of type T
312 ///
313 /// The pointer to the parameter member variable and the default value
314 /// to set are contained in this class.
315 ///
316 template<class T>
317 class Entry : public Entry<void>
318 {
319 public:
320  ///
321  /// Constructs an Entry.
322  ///
323  /// Initializes the parameter member variable pointer of type T.
324  /// Note the member variable pointer are actually offsets into an
325  /// object where the data for the member exists. So, by storing
326  /// this pointer the value of any object of type can be retrieved.
327  ///
328  /// The default value ot type T is also contained here.
329  ///
330  /// @param member_value_ptr parameter member variable pointer
331  /// @param default_value Default value of parameter
332  ///
333  Entry(T ParameterBase::*member_value_ptr, const T &default_value = T())
334  : defaultValue_(default_value),
335  memberValuePtr_(member_value_ptr)
336  {}
337 
338  ///
339  /// Destroys the entry
340  ///
341  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
342  /// @date Wed Aug 7 11:30:29 2013
343  ///
344  virtual ~Entry()
345  {}
346 
347 private:
348  Entry(const Entry &); ///< No copying
349  Entry &operator=(const Entry &); ///< No assignment
350 
351 public:
352  ///
353  /// Returns type_info of this entry.
354  ///
355  /// @return const reference to type_info of this entry
356  ///
357  virtual const std::type_info &type() const
358  {
359  return typeid(T);
360  }
361 
362 private:
363  ///
364  /// Prints the value of the entry to the output stream
365  ///
366  /// @param os output stream to write to
367  ///
368  /// @return reference to the output stream
369  ///
370  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
371  /// @date Wed Aug 7 11:29:29 2013
372  ///
373  virtual std::ostream &doPrint(std::ostream &os) const
374  {
375  return printEntry(os, *this);
376  }
377 
378 public:
379  ///
380  /// Return the member pointer to the data member variable that holds
381  /// the value associated with this parameter
382  ///
383  /// @return member pointer to the data member variable
384  ///
385  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
386  /// @date Wed Aug 7 11:31:21 2013
387  ///
389  {
390  return memberValuePtr_;
391  }
392 
393  ///
394  /// Return the value of the entity's parameter
395  ///
396  /// @param entity device class or device instance
397  ///
398  /// @return const reference to the value of the entity's parameter
399  ///
400  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
401  /// @date Wed Aug 7 11:32:58 2013
402  ///
403  const T &getValue(const ParameterBase &entity) const
404  {
405  return entity.*memberValuePtr_;
406  }
407 
408  ///
409  /// Return the value of the entity's parameter
410  ///
411  /// @param entity device class or device instance
412  ///
413  /// @return reference to the value of the entity's parameter
414  ///
415  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
416  /// @date Wed Aug 7 11:32:58 2013
417  ///
418  T &getValue(ParameterBase &entity) const
419  {
420  return entity.*memberValuePtr_;
421  }
422 
423  ///
424  /// Sets the value of the entity's parameter
425  ///
426  /// @param entity device class or device instance
427  /// @param value value to set the entity's parameter to
428  ///
429  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
430  /// @date Wed Aug 7 11:32:58 2013
431  ///
432  void setValue(ParameterBase &entity, const T &value) const
433  {
434  entity.*memberValuePtr_ = value;
435  }
436 
437  ///
438  /// Return the default value of the parameter
439  ///
440  /// All parameters provide a default value when created. The
441  /// parameter is set to this value and the given flag is cleared on
442  /// construction. If the value is provided by the net list, the
443  /// parameter's value is set accordingly and given flag is set to
444  /// true.
445  ///
446  /// @return const reference to the parameter's default value
447  ///
448  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
449  /// @date Wed Aug 7 11:35:18 2013
450  ///
451  const T &getDefaultValue() const
452  {
453  return defaultValue_;
454  }
455 
456  ///
457  /// Sets the parameter's default value
458  ///
459  /// All parameters provide a default value when created. The
460  /// parameter is set to this value and the given flag is cleared on
461  /// construction. If the value is provided by the net list, the
462  /// parameter's value is set accordingly and given flag is set to
463  /// true.
464  ///
465  /// @param value default value of the parameter
466  ///
467  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
468  /// @date Wed Aug 7 11:37:50 2013
469  ///
470  void setDefaultValue(const T &value)
471  {
472  defaultValue_ = value;
473  }
474 
475 private:
476  T defaultValue_; ///< Default value of parameter
477  T ParameterBase::* memberValuePtr_; ///< Member pointer containing value
478 };
479 
480 ///
481 /// Casts the entry to type T
482 ///
483 /// If the entry if not of the specified type, typeMismatch() is
484 /// called to emit a fatal error.
485 ///
486 /// @tparam T type to cast to
487 /// @param entry entry to cast
488 ///
489 /// @return const reference to Entry<T>
490 ///
491 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
492 /// @date Thu Jul 25 13:21:09 2013
493 ///
494 template<class T>
495 const Entry<T> &entry_cast(const Entry<void> &entry)
496 {
497  if (entry.type() != typeid(T))
498  typeMismatch(entry.type(), typeid(T));
499 
500  return static_cast<const Entry<T> &>(entry);
501 }
502 
503 ///
504 /// Casts the entry to type T
505 ///
506 /// If the entry if not of the specified type, typeMismatch() is called to emit a fatal error.
507 ///
508 /// @tparam T type to cast to
509 /// @param entry entry to cast
510 ///
511 /// @return reference to Entry<T>
512 ///
513 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
514 /// @date Thu Jul 25 13:21:09 2013
515 ///
516 template<class T>
518 {
519  if (entry.type() != typeid(T))
520  typeMismatch(entry.type(), typeid(T));
521 
522  return static_cast<Entry<T> &>(entry);
523 }
524 
525 ///
526 /// Class Descriptor describes the parameters stored in the
527 /// ParametricData parameter map.
528 ///
529 /// The descriptor contains the Entry for the parameter member
530 /// variable. Each parameter is assigned a serialNumber_ when it is
531 /// created and is used by manage the given value map. The parameter
532 /// may have a given member variable as well. The parameter can be
533 /// marked to store its original initialized value and the
534 /// serialNumber_ is used to store this value in the originalValueMap.
535 ///
536 /// If the parameter is vectorized, the index to this parameter is in
537 /// vec_.
538 ///
539 /// The expressionAccess_ is used to indicate the parameter's usage.
540 ///
541 /// The Descriptor also contains the units, catagory and description
542 /// for documentation generation. serial number, its original value
543 /// index if the initiazes value needs to be restored, its usage
544 /// (ExprAccess), units,
545 ///
547 {
548 public:
549  ///
550  /// Constructs Descriptor
551  ///
552  /// @param entry the parameter member variable pointer, type and default value
553  ///
554  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
555  /// @date Wed Aug 7 11:38:43 2013
556  ///
557  Descriptor(Entry<void> *const entry)
558  : serialNumber_(0),
559  originalValueFlag_(false),
560  vec_(0),
561  expressionAccess_(ParameterType::NO_DEP),
562  entry_(entry),
563  unit_(U_NONE),
564  category_(CAT_NONE),
565  description_(""),
566  compositeParametricData_(0),
567  given_(static_cast<bool ParameterBase::*>(0)),
568  sensitivityAvailable_(false),
569  sensPtr_(0)
570  {}
571 
572  ///
573  /// Destroy Descriptor
574  ///
575  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
576  /// @date Wed Aug 7 15:42:55 2013
577  ///
578  virtual ~Descriptor()
579  {
580  delete entry_;
581  }
582 
583 private:
584  Descriptor(const Descriptor &descriptor);
585  Descriptor &operator=(const Descriptor &descriptor);
586 
587 public:
588  ///
589  /// Tests entry data type
590  ///
591  /// @return true if entry is of type T
592  ///
593  /// @date Wed Aug 7 10:31:04 2013
594  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
595  ///
596  template <class T>
597  bool isType() const
598  {
599  if (entry_)
600  return entry_->type() == typeid(T);
601 
602  return typeid(T) == typeid(int);
603  }
604 
605  bool hasCompositeData() const
606  {
607  return compositeParametricData_ != 0;
608  }
609 
610  ///
611  /// Sets a boolean marking an original value having been stored.
612  ///
613  /// @param original_value_flag
614  ///
615  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
616  /// @date Fri Aug 9 14:37:03 2013
617  ///
618  Descriptor &setOriginalValueStored(bool original_value_flag)
619  {
620  originalValueFlag_ = original_value_flag;
621  return *this;
622  }
623 
624  ///
625  /// Returns whether an original value has been stored
626  ///
627  /// @return True if original value has been stored. False otherwise.
628  ///
629  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
630  /// @date Fri Aug 9 14:19:59 2013
631  ///
633  {
634  return originalValueFlag_;
635  }
636 
637  ///
638  /// Sets the expression access which describe the usage of the parameter
639  ///
640  /// @param expression_access usage of the paraemeter
641  ///
642  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
643  /// @date Fri Aug 9 14:41:56 2013
644  ///
646  {
647  expressionAccess_ = expression_access;
648  return *this;
649  }
650 
651  ///
652  /// Gets the expression access which describes the usage of the paramter
653  ///
654  /// @return usage of the parameter
655  ///
656  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
657  /// @date Fri Aug 9 14:41:26 2013
658  ///
660  {
661  return expressionAccess_;
662  }
663 
664  ///
665  /// Sets the units of the parameter, only used to document the parameter
666  ///
667  /// @param unit units of the parameter
668  ///
669  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
670  /// @date Fri Aug 9 14:43:32 2013
671  ///
673  {
674  unit_ = unit;
675  return *this;
676  }
677 
678  ///
679  /// Gets the units of the parameter, only used to document the parameter
680  ///
681  /// @return units of the parameter
682  ///
683  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
684  /// @date Fri Aug 9 14:44:16 2013
685  ///
687  {
688  return unit_;
689  }
690 
691  ///
692  /// Sets the category of the parameter, only used to document the parameter
693  ///
694  /// @param category category of the parameter
695  ///
696  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
697  /// @date Fri Aug 9 14:45:09 2013
699  {
700  category_ = category;
701  return *this;
702  }
703 
704  ///
705  /// Gets the category of the parameter, only used to document the parameter
706  ///
707  /// @return categort of the parameter
708  ///
709  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
710  /// @date Fri Aug 9 14:45:40 2013
711  ///
713  {
714  return category_;
715  }
716 
717  ///
718  /// Sets the description of the parameter, only used to document the parameter
719  ///
720  /// @param description description of the parameter
721  ///
722  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
723  /// @date Fri Aug 9 14:46:21 2013
724  ///
725  Descriptor &setDescription(const std::string &description)
726  {
727  description_ = description;
728  return *this;
729  }
730 
731  ///
732  /// Gets the description of the parameter, only used to document the parameter
733  ///
734  /// @return description of the parameter
735  ///
736  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
737  /// @date Fri Aug 9 14:46:46 2013
738  ///
739  const std::string &getDescription() const
740  {
741  return description_;
742  }
743 
744  ///
745  /// Sets the composite parametric
746  ///
747  /// A composite parameter is a named aggregation of parameters
748  ///
749  /// @param composite_parametric_data composite parameter
750  ///
751  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
752  /// @date Fri Aug 9 14:47:19 2013
753  ///
754  Descriptor &setCompositeParametricData(const ParametricData<void> *composite_parametric_data)
755  {
756  compositeParametricData_ = composite_parametric_data;
757  return *this;
758  }
759 
760  ///
761  /// Return the composite parameter
762  ///
763  /// A composite parameter is a named aggregation of parameters
764  ///
765  /// @return const pointer to the composite parameter
766  ///
767  /// @note I think the template parameter is really only ever CompositeParam, though sometimes its
768  /// currently void.
769  ///
770  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
771  /// @date Fri Aug 9 14:09:01 2013
772  ///
773  template <class U>
775  {
776  return static_cast<const ParametricData<U> *>(compositeParametricData_);
777  }
778 
779  ///
780  /// sets the vector length of an vectorized parameter
781  ///
782  /// @param index
783  ///
784  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
785  /// @date Fri Aug 9 14:50:05 2013
786  ///
787  Descriptor &setVec(int index)
788  {
789  vec_ = index;
790  return *this;
791  }
792 
793  ///
794  /// Gets the vector length of a vectorized parameter
795  ///
796  /// @return length of the vectorized parameter
797  ///
798  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
799  /// @date Fri Aug 9 14:51:10 2013
800  ///
801  int getVec() const
802  {
803  return vec_;
804  }
805 
806  ///
807  /// Gets the entry object of the parameter
808  ///
809  /// @return const reference to the Entry<void>
810  ///
811  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
812  /// @date Fri Aug 9 15:29:16 2013
813  ///
814  const Entry<void> &getEntry() const
815  {
816  return *entry_;
817  }
818 
819  ///
820  /// Gets the entry object of the parameter
821  ///
822  /// @return reference to the Entry<void>
823  ///
824  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
825  /// @date Fri Aug 9 15:29:16 2013
826  ///
828  {
829  return *entry_;
830  }
831 
832  ///
833  /// Sets the serial number used to store and retrieve given boolean from the GivenValueMap
834  ///
835  /// @param serial_number serial number of the parameter in the GivenValueMap
836  ///
837  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
838  /// @date Fri Aug 9 14:38:18 2013
839  ///
840  Descriptor &setSerialNumber(int serial_number)
841  {
842  serialNumber_ = serial_number;
843  return *this;
844  }
845 
846  ///
847  /// Gets the serial number used to store and retireve given boolean fromt he GivenValueMap
848  ///
849  /// @return parameter serial number
850  ///
851  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
852  /// @date Fri Aug 9 14:40:30 2013
853  ///
854  int getSerialNumber() const
855  {
856  return serialNumber_;
857  }
858 
859 public:
860  ///
861  /// Returns the value of the parameter for the entity
862  ///
863  /// @param entity device class or device instance
864  ///
865  /// @return reference to the value of the parameter for the entity
866  ///
867  /// @date Wed Aug 7 10:36:10 2013
868  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
869  ///
870  template <class T>
871  const T &value(const ParameterBase &entity) const
872  {
873  const Entry<T> &entry = entry_cast<T>(*entry_);
874 
875  return entry.getValue(entity);
876  }
877 
878  ///
879  /// Returns the value of the parameter for the entity
880  ///
881  /// @param entity device class or device instance
882  ///
883  /// @return reference to the value of the parameter for the entity
884  ///
885  /// @date Wed Aug 7 10:36:10 2013
886  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
887  ///
888  template <class T>
889  T &value(ParameterBase &entity) const
890  {
891  const Entry<T> &entry = entry_cast<T>(*entry_);
892 
893  return entry.getValue(entity);
894  }
895 
896  ///
897  /// Returns the parameter member variable pointer of the enrtry
898  ///
899  /// @return parameter member pointer of type T
900  ///
901  /// @date Wed Aug 7 10:54:58 2013
902  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
903  ///
904  template <class T>
906  {
907  const Entry<T> &entry = entry_cast<T>(*entry_);
908 
909  return entry.getMemberPtr();
910  }
911 
912  ///
913  /// Tests if parameter has a given data member
914  ///
915  /// Parameters may provide a boolean member variable that is set true if the netlist provides
916  /// the value.
917  ///
918  /// @return true if the parameter has a boolean member variable to set if it is provided by the netlist
919  ///
920  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
921  /// @date Wed Aug 7 11:03:55 2013
922  ///
923  bool hasGivenMember() const
924  {
925  return given_ != static_cast<bool ParameterBase::*>(0);
926  }
927 
928  ///
929  /// Sets the boolean member variable to set if the netlist provides the value.
930  ///
931  /// Parameters may provide a boolean member variable that is set true if the netlist provides
932  /// the value.
933  ///
934  /// @param given boolean member variable to be set
935  ///
936  /// @date Wed Aug 7 11:02:38 2013
937  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
938  ///
939  template<class U>
940  Descriptor &setGivenMember(bool U::*given)
941  {
942  given_ = static_cast<bool ParameterBase::*>(given);
943  return *this;
944  }
945 
946  ///
947  /// Tests if the parameter has been given by the netlist.
948  ///
949  /// @return true if the parameter was given by the netline
950  ///
951  /// @date Wed Aug 7 11:01:42 2013
952  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
953  ///
954  bool getGiven(ParameterBase &entity) const
955  {
956  if (hasGivenMember())
957  {
958  return entity.*given_;
959  }
960 
961  return false;
962  }
963 
964  ///
965  /// Sets the given state of the parameter to value
966  ///
967  /// The parameter's boolean member variable that is set true if exists and the netlist provides
968  /// the value.
969  ///
970  /// @param entity device class or device instance
971  /// @param value true if provided by netlist
972  ///
973  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
974  /// @date Wed Aug 7 11:09:00 2013
975  ///
976  void setGiven(ParameterBase &entity, bool value) const
977  {
978  if (hasGivenMember())
979  {
980  entity.*given_ = value;
981  }
982  }
983 
984  ///
985  /// Sets a boolean to indicate if analytic sensitivities are available w.r.t. this parameter.
986  //
987  /// @param entity device class or device instance
988  /// @param value true if provided by netlist
989  ///
990  /// @author Eric R. Keiter, Sandia National Laboratories 1355
991  /// @date Wed Aug 7 11:09:00 2013
992  ///
994  {
995  sensitivityAvailable_ = value;
996  return *this;
997  }
998 
1000  {
1001  sensPtr_ = sensPtr;
1002  return *this;
1003  }
1004 
1005  ///
1006  /// returns a boolean to indicate if analytic sensitivities are available w.r.t. this parameter.
1007  //
1008  /// @param entity device class or device instance
1009  /// @param value true if provided by netlist
1010  ///
1011  /// @author Eric R. Keiter, Sandia National Laboratories 1355
1012  /// @date Wed Aug 7 11:09:00 2013
1013  ///
1015  {
1016  return sensitivityAvailable_;
1017  }
1018 
1019  ///
1020  /// returns analytic sensitivity, evaluated at the most recent solve point.
1021  //
1022  /// @param entity device class or device instance
1023  /// @param value true if provided by netlist
1024  ///
1025  /// @author Eric R. Keiter, Sandia National Laboratories 1355
1026  /// @date Wed Aug 7 11:09:00 2013
1027  ///
1029  const ParameterBase &entity1,
1030  const std::string & name,
1031  std::vector<double> & dfdp, std::vector<double> & dqdp, std::vector<double> & dbdp,
1032  std::vector<int> & Findices, std::vector<int> & Qindices, std::vector<int> & Bindices) const
1033  {
1034  if (sensPtr_)
1035  {
1036  sensPtr_->operator()(entity1, name, dfdp, dqdp, dbdp, Findices, Qindices, Bindices);
1037  return true;
1038  }
1039  else
1040  {
1041  return false;
1042  }
1043  }
1044 
1045 private:
1046  int serialNumber_; ///< Unique identifier of descriptor
1047  bool originalValueFlag_; ///< Flag indicating original value was stored
1048  int vec_; ///< If > 0 specifies a vector of params.(eg: if = 3 then IC becomes IC1, IC2, IC3)
1049  ExprAccess expressionAccess_; ///< Flags for parameter attributes, such as whether can be input by user, may depend on time, etc.
1050  Entry<void> * const entry_; ///< Pointer to entry which contains the value
1051  ParameterUnit unit_; ///< Unit designator for documentation
1052  ParameterCategory category_; ///< Category designator for documentation
1053  std::string description_; ///< Description of parameter for documentation
1054  const ParametricData<void> * compositeParametricData_; ///< If a composite, then this points to the ParameterData of the composite
1055  bool ParameterBase::* given_; ///< Pointer to given bool, usually 0
1056  bool sensitivityAvailable_; ///< Flag indicating that analytic sensitivity is available for this param.
1057  const baseSensitivity * sensPtr_; ///< pointer to the sensitivity functor
1058 };
1059 
1060 
1061 ///
1062 /// Prints the entry default value to the output stream
1063 ///
1064 /// @param os output stream
1065 /// @param entry entry to print
1066 ///
1067 /// @return reference to the output stream
1068 ///
1069 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1070 /// @date Fri Aug 9 15:32:26 2013
1071 ///
1072 template <class T>
1073 inline std::ostream &printEntry(std::ostream &os, const Entry<T> &entry)
1074 {
1075  os << entry.getDefaultValue();
1076 
1077  return os;
1078 }
1079 
1080 ///
1081 /// Prints the entry default values of a vectorized parameter
1082 ///
1083 /// @param os output stream
1084 /// @param entry entry to print
1085 ///
1086 /// @return reference to the output stream
1087 ///
1088 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1089 /// @date Fri Aug 9 15:33:24 2013
1090 ///
1091 template <class T>
1092 inline std::ostream &printEntry(std::ostream &os, const Entry<std::vector<T> > &entry)
1093 {
1094  for (typename std::vector<T>::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
1095  os << (*it) << std::endl;
1096 
1097  return os;
1098 }
1099 
1100 ///
1101 /// Prints the entry default values of a map parameter
1102 ///
1103 /// @param os output stream
1104 /// @param entry entry to print
1105 ///
1106 /// @return reference to the output stream
1107 ///
1108 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1109 /// @date Thu Feb 6 16:37:16 2014
1110 ///
1111 template <class T>
1112 inline std::ostream &printEntry(std::ostream &os, const Entry<std::map<std::string, T> > &entry)
1113 {
1114  for (typename std::map<std::string, T>::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
1115  os << (*it).first << std::endl;
1116 
1117  return os;
1118 }
1119 
1120 ///
1121 /// Prints the entry default string value, within single quotes
1122 ///
1123 /// @param os output stream
1124 /// @param entry entry to print
1125 ///
1126 /// @return reference to the output stream
1127 ///
1128 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1129 /// @date Fri Aug 9 15:34:18 2013
1130 ///
1131 template <>
1132 inline std::ostream &printEntry(std::ostream &os, const Entry<std::string> &entry)
1133 {
1134  os << "'" << entry.getDefaultValue() << "'";
1135 
1136  return os;
1137 }
1138 
1139 ///
1140 /// Prints the entry default boolean value, printed as true or false
1141 ///
1142 /// @param os output stream
1143 /// @param entry entry to print
1144 ///
1145 /// @return reference to the output stream
1146 ///
1147 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1148 /// @date Fri Aug 9 15:34:18 2013
1149 ///
1150 template <>
1151 inline std::ostream &printEntry(std::ostream &os, const Entry<bool> &entry)
1152 {
1153  os << (entry.getDefaultValue() ? "true" : "false");
1154 
1155  return os;
1156 }
1157 
1158 ///
1159 /// Prints the entry composite value as newline terminated list of colon separated name, value pairs
1160 ///
1161 /// @param os output stream
1162 /// @param entry entry to print
1163 ///
1164 /// @return reference to the output stream
1165 ///
1166 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1167 /// @date Fri Aug 9 15:34:18 2013
1168 ///
1169 inline std::ostream &printEntry(std::ostream &os, const Entry<CompositeMap> &entry)
1170 {
1171  for (CompositeMap::const_iterator it = entry.getDefaultValue().begin(); it != entry.getDefaultValue().end(); ++it)
1172  os << (*it).first << ": " << (*it).second << std::endl;
1173 
1174  return os;
1175 }
1176 
1177 ///
1178 /// Gets the default value of the parameter
1179 ///
1180 /// @param descriptor descriptor of the parameter
1181 ///
1182 /// @return const reference to the default value of the entry of the descriptor
1183 ///
1184 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1185 /// @date Fri Aug 9 15:37:33 2013
1186 ///
1187 template <class T>
1188 inline const T &getDefaultValue(const Descriptor &descriptor)
1189 {
1190  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1191 
1192  return entry.getDefaultValue();
1193 }
1194 
1195 ///
1196 /// Sets the default value of the parameter
1197 ///
1198 /// @param descriptor descriptor of the parameter
1199 /// @param t default value
1200 ///
1201 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1202 /// @date Fri Aug 9 15:38:49 2013
1203 ///
1204 template <class T>
1205 inline void setDefaultValue(Descriptor &descriptor, const T &t)
1206 {
1207  Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1208 
1209  entry.setDefaultValue(t);
1210 }
1211 
1212 ///
1213 /// Returns the value of the parameter for the entity
1214 ///
1215 /// @param entity device class or device instance
1216 /// @param descriptor descriptor of the parameter
1217 ///
1218 /// @return const reference to the value of the entry of the descriptor
1219 ///
1220 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1221 /// @date Fri Aug 9 15:39:40 2013
1222 ///
1223 template <class T>
1224 inline const T &value(const ParameterBase &entity, const Descriptor &descriptor)
1225 {
1226  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1227 
1228  return entry.getValue(entity);
1229 }
1230 
1231 ///
1232 /// Returns the value of the parameter for the entity
1233 ///
1234 /// @param entity device class or device instance
1235 /// @param descriptor descriptor of the parameter
1236 ///
1237 /// @return reference to the value of the entry of the descriptor
1238 ///
1239 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1240 /// @date Fri Aug 9 15:39:40 2013
1241 ///
1242 template <class T>
1243 inline T &value(ParameterBase &entity, const Descriptor &descriptor)
1244 {
1245  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1246 
1247  return entry.getValue(entity);
1248 }
1249 
1250 
1251 ///
1252 /// Gets the value of the parameter for the entity
1253 ///
1254 /// @param entity device class or device instance
1255 /// @param descriptor descriptor of the parameter
1256 ///
1257 /// @return const reference to the value of the entry of the descriptor
1258 ///
1259 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1260 /// @date Fri Aug 9 15:39:40 2013
1261 ///
1262 template <class T, class U>
1263 inline const T &getValue(const ParameterBase &entity, const Descriptor &descriptor)
1264 {
1265  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1266 
1267  return entry.getValue(entity);
1268 }
1269 
1270 ///
1271 /// Sets the value of the parameter
1272 ///
1273 /// @param entity device class or device instance
1274 /// @param descriptor descriptor of the parameter
1275 /// @param value value
1276 ///
1277 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1278 /// @date Fri Aug 9 15:42:13 2013
1279 ///
1280 template <class T, class U>
1281 inline void setValue(ParameterBase &entity, const Descriptor &descriptor, const T &value)
1282 {
1283  const Entry<T> &entry = entry_cast<T>(descriptor.getEntry());
1284 
1285  entry.setValue(entity, value);
1286 }
1287 
1288 ///
1289 /// Class ParametricData<void> manages the configuration information and the parameter binding map
1290 ///
1291 /// Parametric data associated with a device instance, device model or composite parameter
1292 ///
1293 /// The Parametric data class manages the mapping of parameter string names to descriptors and the
1294 /// general configuration information associated with a device model.
1295 ///
1296 /// To restore original values during perturbation, the originalValueCount_ and serialNumber_ members
1297 /// maintain counts of original values to be stored and of parameters declared.
1298 ///
1299 /// @date Tue Aug 6 13:10:21 2013
1300 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1301 ///
1302 template<>
1303 class ParametricData<void>
1304 {
1305 public:
1306  ///
1307  /// Constructs a ParametricData object
1308  ///
1309  /// @date Tue Aug 6 13:10:21 2013
1310  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1311  ///
1313  : map_()
1314  {}
1315 
1316  ///
1317  /// Destroys a ParametricData object
1318  ///
1319  /// @date Tue Aug 6 13:13:47 2013
1320  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1321  ///
1323  {
1324  for (ParameterMap::iterator it = map_.begin(); it != map_.end(); ++it)
1325  delete (*it).second;
1326  }
1327 
1328 private:
1329  ParametricData(const ParametricData &parametric_data); ///< No copying
1330  ParametricData &operator=(const ParametricData &parametric_data); ///< No assignment
1331 
1332 public:
1333  ///
1334  /// Gets the parameter binding map map
1335  ///
1336  /// @return reference to the parameter binding map
1337  ///
1338  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1339  /// @date Fri Aug 9 15:50:06 2013
1340  ///
1342  {
1343  return map_;
1344  }
1345 
1346  ///
1347  /// Returns the parameter binding map
1348  ///
1349  /// @return const reference to the parameter binding map
1350  ///
1351  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1352  /// @date Fri Aug 9 15:50:06 2013
1353  ///
1354  const ParameterMap &getMap() const
1355  {
1356  return map_;
1357  }
1358 
1359 protected:
1360  ///
1361  /// Adds the parameter to the parameter binding map
1362  ///
1363  /// @param name parameter name
1364  /// @param descriptor descriptor created for the parameter
1365  /// @param parameter_data_class typeinfo to get the class name for diagnostics
1366  ///
1367  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1368  /// @date Fri Aug 9 16:23:45 2013
1369  ///
1370  void addDescriptor(const std::string &name, Descriptor *descriptor, const std::type_info &parameter_data_class);
1371 
1372 protected:
1373  ParameterMap map_; ///< Mapping from parameter name to descriptor
1374 };
1375 
1376 void checkExprAccess(const std::string &name, ParameterType::ExprAccess &expr_access, const std::type_info &parameter_data_class);
1377 
1378 ///
1379 /// Manages parameter binding for class C.
1380 ///
1381 ///
1382 template<class C>
1383 class ParametricData : public ParametricData<void>
1384 {
1385 public:
1386  ///
1387  /// Constructs the parameter data map
1388  ///
1389  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1390  /// @date Thu Feb 6 16:39:06 2014
1391  ///
1393  : ParametricData<void>()
1394  {}
1395 
1396  ///
1397  /// Destroys the parameter data map
1398  ///
1399  ///
1400  ///
1401  /// @return
1402  ///
1403  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1404  /// @date Thu Feb 6 16:39:34 2014
1405  ///
1407  {}
1408 
1409 private:
1410  ParametricData(const ParametricData &parametric_data); ///< No copying
1411  ParametricData &operator=(const ParametricData &parametric_data); ///< No assignment
1412 
1413 public:
1414  ///
1415  /// Adds the parameter description to the parameter map
1416  ///
1417  /// @tparam T data type of the parameter
1418  /// @tparam U class containing the member data storing the parameter's value
1419  /// @param parName const pointer to the parameter name
1420  /// @param default_value default value
1421  /// @param varPtr member pointer to the parameter's value
1422  ///
1423  /// @return
1424  ///
1425  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1426  /// @date Thu Feb 6 16:33:48 2014
1427  ///
1428  template<class T, class U>
1429  Descriptor &addPar(const char *parName, T default_value, T U::*varPtr)
1430  {
1431  Descriptor *descriptor = new Descriptor(new Entry<T>(static_cast<T ParameterBase::*>(varPtr), default_value));
1432 
1433  addDescriptor(parName, descriptor, typeid(C));
1434 
1435  return *descriptor;
1436  }
1437 
1438  ///
1439  /// Adds the parameter description to the parameter map
1440  ///
1441  /// This is specialization to allow const char * (quoted strings) to create a std::string type parameter.
1442  ///
1443  /// @tparam U class containing the member data storing the parameter's value
1444  /// @param parName const pointer to the parameter name
1445  /// @param default_value default value
1446  /// @param varPtr member pointer to the parameter's value
1447  ///
1448  /// @return
1449  ///
1450  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1451  /// @date Thu Feb 6 16:33:48 2014
1452  ///
1453  template<class U>
1454  Descriptor &addPar(const char *parName, const char *default_value, std::string U::*varPtr)
1455  {
1456  Descriptor *descriptor = new Descriptor(new Entry<std::string>(static_cast<std::string ParameterBase::*>(varPtr), default_value));
1457 
1458  addDescriptor(parName, descriptor, typeid(C));
1459 
1460  return *descriptor;
1461  }
1462 
1463 
1464  ///
1465  /// Adds the parameter description to the parameter map
1466  ///
1467  /// TODO: [DGB] This function should be eliminated and the addPar(const char *parName, T default_value, T U::*varPtr) used exclusively
1468  ///
1469  /// @tparam T data type of the parameter
1470  /// @tparam U class containing the member data storing the parameter's value
1471  /// @param parName const pointer to the parameter name
1472  /// @param def default value
1473  /// @param orig true if the original value is no be stored
1474  /// @param depend the dependency type of this parameter
1475  /// @param varPtr member pointer to the parameter's value
1476  /// @param givenPtr member pointer to the parameter's given boolean
1477  /// @param unit parameter's measurement units
1478  /// @param category parameter documentation category
1479  /// @param description documentation description
1480  ///
1481  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1482  /// @date Thu Feb 6 16:43:30 2014
1483  ///
1484  template<class T, class U>
1485  void addPar(const char *parName, T def, bool orig, ParameterType::ExprAccess depend, T U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
1486  {
1487  Descriptor *descriptor = new Descriptor(new Entry<T>(static_cast<T ParameterBase::*>(varPtr), def));
1488 
1489  checkExprAccess(parName, depend, typeid(C));
1490 
1491  descriptor->setExpressionAccess(depend);
1492  descriptor->setOriginalValueStored(orig);
1493  descriptor->setGivenMember(givenPtr);
1494  descriptor->setUnit(unit);
1495  descriptor->setCategory(category);
1496  descriptor->setDescription(description);
1497 
1498  addDescriptor(parName, descriptor, typeid(C));
1499  }
1500 
1501  ///
1502  /// Adds the parameter description to the parameter map
1503  ///
1504  /// This is specialization to allow const char * (quoted strings) to create a std::string type parameter.
1505  ///
1506  /// TODO: [DGB] This function should be eliminated and the addPar(const char *parName, T default_value, T U::*varPtr) used exclusively
1507  ///
1508  /// @tparam T data type of the parameter
1509  /// @tparam U class containing the member data storing the parameter's value
1510  /// @param parName const pointer to the parameter name
1511  /// @param def default value
1512  /// @param orig true if the original value is no be stored
1513  /// @param depend the dependency type of this parameter
1514  /// @param varPtr member pointer to the parameter's value
1515  /// @param givenPtr member pointer to the parameter's given boolean
1516  /// @param unit parameter's measurement units
1517  /// @param category parameter documentation category
1518  /// @param description documentation description
1519  ///
1520  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1521  /// @date Thu Feb 6 16:43:30 2014
1522  ///
1523  template<class U>
1524  void addPar(const char *parName, const char *def, bool orig, ParameterType::ExprAccess depend, std::string U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
1525  {
1526  Descriptor *descriptor = new Descriptor(new Entry<std::string>(static_cast<std::string ParameterBase::*>(varPtr), def));
1527 
1528  checkExprAccess(parName, depend, typeid(C));
1529 
1530  descriptor->setExpressionAccess(depend);
1531  descriptor->setOriginalValueStored(orig);
1532  descriptor->setGivenMember(givenPtr);
1533  descriptor->setUnit(unit);
1534  descriptor->setCategory(category);
1535  descriptor->setDescription(description);
1536 
1537  addDescriptor(parName, descriptor, typeid(C));
1538  }
1539 
1540  ///
1541  /// Adds a composite parameter to the parameter map
1542  ///
1543  /// THIS IS SUPER DANGEROUS U * MAY NOT ACTUALLY POINT TO CompositeParam *. IT COULD BE SLICED
1544  ///
1545  /// @param comp_name
1546  /// @param composite_pars
1547  /// @param composite_map
1548  ///
1549  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1550  /// @date Thu Feb 6 16:47:59 2014
1551  ///
1552  template<class U, class V>
1553  void addComposite(const char *comp_name, const ParametricData<U> &composite_pars, std::map<std::string, U *> V::*composite_map)
1554  {
1555  Descriptor *descriptor = new Descriptor(new Entry<CompositeMap>(reinterpret_cast<CompositeMap ParameterBase::*>(composite_map)));
1556 
1557  descriptor->setUnit(U_INVALID);
1558  descriptor->setCategory(CAT_INVALID);
1559  descriptor->setCompositeParametricData(&composite_pars);
1560 
1561  addDescriptor(comp_name, descriptor, typeid(C));
1562  }
1563 
1564  ///
1565  /// Adds a composite vector parameter to the parameter map
1566  ///
1567  /// THIS IS SUPER DANGEROUS U * MAY NOT ACTUALLY POINT TO CompositeParam *. IT COULD BE SLICED
1568  ///
1569  /// @param comp_name
1570  /// @param composite_pars
1571  /// @param composite_vector
1572  ///
1573  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1574  /// @date Thu Feb 6 16:47:59 2014
1575  ///
1576  template<class U, class V>
1577  void addComposite(const char *comp_name, const ParametricData<U> &composite_pars, std::vector<U *> V::*composite_vector)
1578  {
1579  Descriptor *descriptor = new Descriptor(new Entry<CompositeVector>(reinterpret_cast<CompositeVector ParameterBase::*>(composite_vector)));
1580 
1581  descriptor->setUnit(U_INVALID);
1582  descriptor->setCategory(CAT_INVALID);
1583  descriptor->setCompositeParametricData(&composite_pars);
1584  addDescriptor(comp_name, descriptor, typeid(C));
1585  }
1586 
1587  ///
1588  /// Allows the parameter to be specified as a vector
1589  ///
1590  ///
1591  /// @param cname
1592  /// @param len
1593  ///
1594  /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1595  /// @date Thu Feb 6 16:50:29 2014
1596  ///
1597  void makeVector(const std::string &cname, int len)
1598  {
1599  for (int i = 1; i <= len; ++i)
1600  {
1601  std::ostringstream oss;
1602  oss << cname << i;
1603  std::string param = oss.str();
1604 
1605  ParameterMap::iterator it = map_.find(param);
1606  if (it == map_.end())
1607  nonexistentParameter(param, typeid(C));
1608 
1609  Descriptor &descriptor = *(*it).second;
1610  descriptor.setVec(i);
1611  }
1612  }
1613 };
1614 
1615 ///
1616 /// Set the default values for the parameter.
1617 ///
1618 /// Note that any values provided in the objects constructor that are defined as parameters have their initialized value
1619 /// replaced with the default value given in the addPar() call
1620 ///
1621 /// @param parameter_base
1622 /// @param begin
1623 /// @param end
1624 /// @param device_options
1625 ///
1626 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1627 /// @date Thu Feb 6 16:51:00 2014
1628 ///
1629 void setDefaultParameters(ParameterBase &parameter_base, ParameterMap::const_iterator begin, ParameterMap::const_iterator end, const DeviceOptions &device_options);
1630 
1631 ///
1632 /// Retrieve a parameter's original value
1633 ///
1634 /// @param parameter_base device entity holding parameter
1635 /// @param serial_number entity's serial number
1636 ///
1637 /// @return original value of the parameter
1638 ///
1639 /// @date Tue Aug 6 13:51:16 2013
1640 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1641 ///
1642 inline double getOriginalValue(ParameterBase &parameter_base, int serial_number)
1643 {
1644  return parameter_base.getOriginalValue(serial_number);
1645 }
1646 
1647 ///
1648 /// Set a parameter's original value
1649 ///
1650 /// @param parameter_base device entity or composite holding parameter
1651 /// @param serial_number entity's serial number
1652 /// @param value value to be stored
1653 ///
1654 /// @date Tue Aug 6 13:53:29 2013
1655 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1656 ///
1657 inline void setOriginalValue(ParameterBase &parameter_base, int serial_number, double value)
1658 {
1659  parameter_base.setOriginalValue(serial_number, value);
1660 }
1661 
1662 
1663 ///
1664 /// Return true if a value was provided for the device
1665 ///
1666 /// @param parameter_base device entity or composite holding parameter
1667 /// @param serial_number serial number of parameter
1668 ///
1669 /// @return true if a value was provided for the device
1670 ///
1671 /// @date Tue Aug 6 13:54:25 2013
1672 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1673 ///
1674 inline bool wasValueGiven(const ParameterBase &parameter_base, int serial_number)
1675 {
1676  return parameter_base.wasValueGiven(serial_number);
1677 }
1678 
1679 
1680 ///
1681 /// Set the given value state of a parameter
1682 ///
1683 /// @param parameter_base device entity or composite holding parameter
1684 /// @param serial_number serial number of parameter
1685 /// @param value true if the value was given
1686 ///
1687 /// @date Tue Aug 6 13:55:34 2013
1688 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1689 ///
1690 inline void setValueGiven(ParameterBase &parameter_base, int serial_number, bool value)
1691 {
1692  parameter_base.setValueGiven(serial_number, value);
1693 }
1694 
1695 ///
1696 /// Returns true if the name is TNOM or TEMP
1697 ///
1698 /// @param name parameter name
1699 ///
1700 /// @return true if the name is TNOM or TEMP
1701 ///
1702 /// @author David G. Baur Raytheon Sandia National Laboratories 1355
1703 /// @date Thu Feb 6 16:52:26 2014
1704 ///
1705 inline bool isTempParam(const std::string &name)
1706 {
1707  return equal_nocase(name, "TNOM") || equal_nocase(name, "TEMP");
1708 }
1709 
1710 } // namespace Device
1711 } // namespace Xyce
1712 
1713 #endif // Xyce_N_DEV_Pars_h
const Entry< void > & getEntry() const
Gets the entry object of the parameter.
Definition: N_DEV_Pars.h:814
bool ParameterBase::* given_
Pointer to given bool, usually 0.
Definition: N_DEV_Pars.h:1055
int getVec() const
Gets the vector length of a vectorized parameter.
Definition: N_DEV_Pars.h:801
virtual const std::type_info & type() const
Returns type_info of this entry.
Definition: N_DEV_Pars.h:357
Descriptor & setSensitivityFunctor(const baseSensitivity *sensPtr)
Definition: N_DEV_Pars.h:999
virtual ~Entry()
Destroys the entry.
Definition: N_DEV_Pars.h:344
Descriptor & setVec(int index)
sets the vector length of an vectorized parameter
Definition: N_DEV_Pars.h:787
void setOriginalValue(ParameterBase &parameter_base, int serial_number, double value)
Set a parameter's original value.
Definition: N_DEV_Pars.h:1657
Descriptor & addPar(const char *parName, T default_value, T U::*varPtr)
Adds the parameter description to the parameter map.
Definition: N_DEV_Pars.h:1429
Descriptor & setCompositeParametricData(const ParametricData< void > *composite_parametric_data)
Sets the composite parametric.
Definition: N_DEV_Pars.h:754
void nonexistentParameter(const std::string &name, const std::type_info &entity_type)
Report casting error when attempting to cast from from_type to to_type.
Definition: N_DEV_Pars.C:130
int vec_
If > 0 specifies a vector of params.(eg: if = 3 then IC becomes IC1, IC2, IC3)
Definition: N_DEV_Pars.h:1048
double getOriginalValue(int serial_number)
Definition: N_DEV_Pars.h:185
Descriptor & setExpressionAccess(ExprAccess expression_access)
Sets the expression access which describe the usage of the parameter.
Definition: N_DEV_Pars.h:645
Pure virtual class to augment a linear system.
void typeMismatch(const std::type_info &from_type, const std::type_info &to_type)
Report casting error when attempting to cast from from_type to to_type.
Definition: N_DEV_Pars.C:149
OriginalValueMap originalValueMap_
Map from device entity and original value index to original value.
Definition: N_DEV_Pars.h:209
Parameter may be specified as time dependent expression from netlist.
Definition: N_DEV_Pars.h:67
void setDefaultValue(const T &value)
Sets the parameter's default value.
Definition: N_DEV_Pars.h:470
ParameterUnit unit_
Unit designator for documentation.
Definition: N_DEV_Pars.h:1051
bool originalValueFlag_
Flag indicating original value was stored.
Definition: N_DEV_Pars.h:1047
std::map< int, double > OriginalValueMap
Definition: N_DEV_Pars.h:142
virtual ~ParametricData()
Destroys the parameter data map.
Definition: N_DEV_Pars.h:1406
unordered_map< std::string, Descriptor *, HashNoCase, EqualNoCase > ParameterMap
Definition: N_DEV_fwd.h:159
void makeVector(const std::string &cname, int len)
Allows the parameter to be specified as a vector.
Definition: N_DEV_Pars.h:1597
Base class for all parameters.
Definition: N_DEV_Pars.h:169
Descriptor & setAnalyticSensitivityAvailable(bool value)
Sets a boolean to indicate if analytic sensitivities are available w.r.t. this parameter.
Definition: N_DEV_Pars.h:993
Parameter can only be set to a constant from netlist.
Definition: N_DEV_Pars.h:66
Parameter is subject to being set to minimum junction capacitance.
Definition: N_DEV_Pars.h:71
bool wasValueGiven(int serial_number) const
Definition: N_DEV_Pars.h:195
ParametricData()
Constructs a ParametricData object.
Definition: N_DEV_Pars.h:1312
std::string description_
Description of parameter for documentation.
Definition: N_DEV_Pars.h:1053
bool getAnalyticSensitivityAvailable() const
returns a boolean to indicate if analytic sensitivities are available w.r.t. this parameter...
Definition: N_DEV_Pars.h:1014
Parameter is subject to being set to minimum lead resistance.
Definition: N_DEV_Pars.h:70
Descriptor & setSerialNumber(int serial_number)
Sets the serial number used to store and retrieve given boolean from the GivenValueMap.
Definition: N_DEV_Pars.h:840
void setValue(ParameterBase &entity, const Descriptor &descriptor, const T &value)
Sets the value of the parameter.
Definition: N_DEV_Pars.h:1281
bool getGiven(ParameterBase &entity) const
Tests if the parameter has been given by the netlist.
Definition: N_DEV_Pars.h:954
int serialNumber_
Unique identifier of descriptor.
Definition: N_DEV_Pars.h:1046
T & value(ParameterBase &entity, const Descriptor &descriptor)
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1243
bool isTempParam(const std::string &name)
Returns true if the name is TNOM or TEMP.
Definition: N_DEV_Pars.h:1705
const ParametricData< void > * compositeParametricData_
If a composite, then this points to the ParameterData of the composite.
Definition: N_DEV_Pars.h:1054
virtual ~ParametricData()
Destroys a ParametricData object.
Definition: N_DEV_Pars.h:1322
std::ostream & printEntry(std::ostream &os, const Entry< std::map< std::string, T > > &entry)
Prints the entry default values of a map parameter.
Definition: N_DEV_Pars.h:1112
const std::string & getDescription() const
Gets the description of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:739
double getOriginalValue(ParameterBase &parameter_base, int serial_number)
Retrieve a parameter's original value.
Definition: N_DEV_Pars.h:1642
std::ostream & print(std::ostream &os) const
Prints the value of the entry to the output stream.
Definition: N_DEV_Pars.h:289
bool hasGivenMember() const
Tests if parameter has a given data member.
Definition: N_DEV_Pars.h:923
ExprAccess expressionAccess_
Flags for parameter attributes, such as whether can be input by user, may depend on time...
Definition: N_DEV_Pars.h:1049
void addComposite(const char *comp_name, const ParametricData< U > &composite_pars, std::map< std::string, U * > V::*composite_map)
Adds a composite parameter to the parameter map.
Definition: N_DEV_Pars.h:1553
Parameter is not to be documented.
Definition: N_DEV_Pars.h:72
const T & getDefaultValue(const Descriptor &descriptor)
Gets the default value of the parameter.
Definition: N_DEV_Pars.h:1188
Entry< T > & entry_cast(Entry< void > &entry)
Casts the entry to type T.
Definition: N_DEV_Pars.h:517
const T & getValue(const ParameterBase &entity) const
Return the value of the entity's parameter.
Definition: N_DEV_Pars.h:403
const T & value(const ParameterBase &entity) const
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:871
const baseSensitivity * sensPtr_
pointer to the sensitivity functor
Definition: N_DEV_Pars.h:1057
const T & getDefaultValue() const
Return the default value of the parameter.
Definition: N_DEV_Pars.h:451
std::set< int > GivenValueSet
Definition: N_DEV_Pars.h:143
Class ParametricData manages the configuration information and the parameter binding map...
Definition: N_DEV_Pars.h:1303
Entry< void > *const entry_
Pointer to entry which contains the value.
Definition: N_DEV_Pars.h:1050
ExprAccess getExpressionAccess() const
Gets the expression access which describes the usage of the paramter.
Definition: N_DEV_Pars.h:659
Entry()
Constructs the Entry base class.
Definition: N_DEV_Pars.h:256
Descriptor & setOriginalValueStored(bool original_value_flag)
Sets a boolean marking an original value having been stored.
Definition: N_DEV_Pars.h:618
Parameter uses temperature interpolation based on log of value.
Definition: N_DEV_Pars.h:69
Descriptor(Entry< void > *const entry)
Constructs Descriptor.
Definition: N_DEV_Pars.h:557
void setValueGiven(ParameterBase &parameter_base, int serial_number, bool value)
Set the given value state of a parameter.
Definition: N_DEV_Pars.h:1690
const ParametricData< U > * getCompositeParametricData() const
Return the composite parameter.
Definition: N_DEV_Pars.h:774
Descriptor & setCategory(ParameterCategory category)
Sets the category of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:698
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
GivenValueSet givenValueSet_
Map from device entity and serial number to value given flag.
Definition: N_DEV_Pars.h:210
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
const ParameterMap & getMap() const
Returns the parameter binding map.
Definition: N_DEV_Pars.h:1354
bool hasCompositeData() const
Definition: N_DEV_Pars.h:605
virtual ~Entry()
Destroys Entry.
Definition: N_DEV_Pars.h:265
T ParameterBase::* getMemberPtr() const
Return the member pointer to the data member variable that holds the value associated with this param...
Definition: N_DEV_Pars.h:388
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 hasOriginalValueStored() const
Returns whether an original value has been stored.
Definition: N_DEV_Pars.h:632
T ParameterBase::* memberValuePtr_
Member pointer containing value.
Definition: N_DEV_Pars.h:477
int getSerialNumber() const
Gets the serial number used to store and retireve given boolean fromt he GivenValueMap.
Definition: N_DEV_Pars.h:854
bool sensitivityAvailable_
Flag indicating that analytic sensitivity is available for this param.
Definition: N_DEV_Pars.h:1056
ParameterCategory category_
Category designator for documentation.
Definition: N_DEV_Pars.h:1052
void setGiven(ParameterBase &entity, bool value) const
Sets the given state of the parameter to value.
Definition: N_DEV_Pars.h:976
Descriptor & setDescription(const std::string &description)
Sets the description of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:725
Descriptor & setGivenMember(bool U::*given)
Sets the boolean member variable to set if the netlist provides the value.
Definition: N_DEV_Pars.h:940
ParameterUnit getUnit() const
Gets the units of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:686
T & getValue(ParameterBase &entity) const
Return the value of the entity's parameter.
Definition: N_DEV_Pars.h:418
ParametricData()
Constructs the parameter data map.
Definition: N_DEV_Pars.h:1392
virtual ~Descriptor()
Destroy Descriptor.
Definition: N_DEV_Pars.h:578
void setValue(ParameterBase &entity, const T &value) const
Sets the value of the entity's parameter.
Definition: N_DEV_Pars.h:432
ParameterMap map_
Mapping from parameter name to descriptor.
Definition: N_DEV_Pars.h:1373
void addPar(const char *parName, const char *def, bool orig, ParameterType::ExprAccess depend, std::string U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
Adds the parameter description to the parameter map.
Definition: N_DEV_Pars.h:1524
T & value(ParameterBase &entity) const
Returns the value of the parameter for the entity.
Definition: N_DEV_Pars.h:889
Descriptor & addPar(const char *parName, const char *default_value, std::string U::*varPtr)
Adds the parameter description to the parameter map.
Definition: N_DEV_Pars.h:1454
bool isType() const
Tests entry data type.
Definition: N_DEV_Pars.h:597
T defaultValue_
Default value of parameter.
Definition: N_DEV_Pars.h:476
void addPar(const char *parName, T def, bool orig, ParameterType::ExprAccess depend, T U::*varPtr, bool U::*givenPtr, ParameterUnit unit, ParameterCategory category, const char *description)
Adds the parameter description to the parameter map.
Definition: N_DEV_Pars.h:1485
Base sensitivity functor.
Definition: N_DEV_Pars.h:148
virtual std::ostream & doPrint(std::ostream &os) const
Prints the value of the entry to the output stream.
Definition: N_DEV_Pars.h:373
Descriptor & setUnit(ParameterUnit unit)
Sets the units of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:672
ParameterType::ExprAccess is enumeration of parameter usage types and masks.
Definition: N_DEV_Pars.h:63
void setOriginalValue(int serial_number, double value)
Definition: N_DEV_Pars.h:190
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
Class Entry defines the parameter binding value entry interface.
Definition: N_DEV_Pars.h:245
void checkExprAccess(const std::string &name, ParameterType::ExprAccess &expr_access, const std::type_info &parameter_data_class)
Report error if both MIN_CAP and MIN_RES have been specified.
Definition: N_DEV_Pars.C:169
Class Entry defines the parameter member variable access for parameter member variable of type T...
Definition: N_DEV_Pars.h:217
ParameterCategory getCategory() const
Gets the category of the parameter, only used to document the parameter.
Definition: N_DEV_Pars.h:712
ParameterMap & getMap()
Gets the parameter binding map map.
Definition: N_DEV_Pars.h:1341
virtual const std::type_info & type() const =0
Returns the type_info of the data type being stored in the entry.
void addComposite(const char *comp_name, const ParametricData< U > &composite_pars, std::vector< U * > V::*composite_vector)
Adds a composite vector parameter to the parameter map.
Definition: N_DEV_Pars.h:1577
T ParameterBase::* getMemberPtr() const
Returns the parameter member variable pointer of the enrtry.
Definition: N_DEV_Pars.h:905
Entry< void > & getEntry()
Gets the entry object of the parameter.
Definition: N_DEV_Pars.h:827
const T & getValue(const ParameterBase &entity, const Descriptor &descriptor)
Gets the value of the parameter for the entity.
Definition: N_DEV_Pars.h:1263
void setValueGiven(int serial_number, bool value)
Definition: N_DEV_Pars.h:200
void setDefaultValue(Descriptor &descriptor, const T &t)
Sets the default value of the parameter.
Definition: N_DEV_Pars.h:1205
Entry(T ParameterBase::*member_value_ptr, const T &default_value=T())
Constructs an Entry.
Definition: N_DEV_Pars.h:333