Xyce  6.1
N_DEV_DeviceEntity.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_DeviceEntity.h,v $
27 //
28 // Purpose : This file contains the device entity base class.
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.131.2.1 $
40 //
41 // Revision Date : $Date: 2015/04/02 18:20:09 $
42 //
43 // Current Owner : $Author: tvrusso $
44 //-----------------------------------------------------------------------------
45 
46 
47 #ifndef Xyce_N_DEV_DeviceEntity_h
48 #define Xyce_N_DEV_DeviceEntity_h
49 
50 #include <iosfwd>
51 #include <map>
52 #include <string>
53 #include <vector>
54 
55 #include <N_DEV_fwd.h>
56 #include <N_IO_fwd.h>
57 #include <N_LAS_fwd.h>
58 #include <N_UTL_fwd.h>
59 
60 #include <N_UTL_NetlistLocation.h>
61 #include <N_DEV_Pars.h>
62 #include <N_DEV_InstanceName.h>
63 
64 namespace Xyce {
65 namespace Device {
66 
67 typedef std::map<std::string, std::vector<Param>, LessNoCase> CompositeParamMap;
68 
69 void populateParams(const ParameterMap &parameter_map, std::vector<Param> &param_list, CompositeParamMap &composite_param_map);
70 void setParameters(CompositeParam &composite_param, const std::string &pName, const Param &ndParam );
71 void setParameters(DeviceEntity &entity, std::vector<Param>::const_iterator begin, std::vector<Param>::const_iterator end, const DeviceOptions &device_options);
72 
73 struct Depend
74 {
75  std::string name;
76  Util::Expression * expr;
77  union resUnion
78  {
79  double * result;
80  std::vector<double> * resVec;
81  } resultU;
83  std::vector<double> vals;
84  std::vector<std::string> global_params;
85  int n_vars, lo_var;
86 };
87 
88 //-----------------------------------------------------------------------------
89 // Class : DeviceEntity
90 // Purpose :
91 // Special Notes :
92 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
93 // Creation Date : 6/11/02
94 //-----------------------------------------------------------------------------
96 {
97 public:
99  ParametricData<void> & parametric_data,
100  const SolverState & solver_state,
101  const DeviceOptions & device_options,
102  const std::string & netlist_filename,
103  int netlist_line);
104 
105 private:
106  DeviceEntity(const DeviceEntity &); ///< No copying
107  DeviceEntity &operator=(const DeviceEntity &); ///< No assignment
108 
109 public:
110  virtual ~DeviceEntity();
111 
112  virtual bool processParams() = 0;
113 
114  virtual bool processInstanceParams() = 0;
115 
116  virtual CompositeParam *constructComposite(const std::string &composite_name, const std::string &param_name)
117  {
118  return NULL;
119  }
120 
121  bool setDefaultParam(double val, bool overrideOriginal=false);
122  double getDefaultParam() const;
123 
124  bool scaleParam(const std::string & paramName, double val, double val0);
125  bool scaleParam(const std::string & paramName, double val);
126  bool scaleDefaultParam(double val);
127 
128  bool analyticSensitivityAvailable (const std::string & paramName);
129  bool getAnalyticSensitivity ( const std::string & paramName,
130  std::vector<double> & dfdpVec,
131  std::vector<double> & dqdpVec,
132  std::vector<double> & dbdpVec,
133  std::vector<int> & FindicesVec,
134  std::vector<int> & QindicesVec,
135  std::vector<int> & BindicesVec );
136 
137  bool setParam(const std::string & paramName, double val, bool overrideOriginal=false);
138  bool getParam(const std::string & paramName, double & result) const;
139  bool getParamBreakpoints( std::vector<Util::BreakPoint> & );
140 
141  bool updateDependentParameters(Linear::Vector & vars);
142  bool updateDependentParameters(double temp_tmp);
145 
146  double setDependentParameter(Util::Param &, double *, ParameterType::ExprAccess);
147  double setDependentParameter(Util::Param &, std::vector<double> *, int , ParameterType::ExprAccess);
148  void setDependentParameter(Util::Param & par, Depend & dependentParam, ParameterType::ExprAccess depend);
149 
151  {
153  }
154 
155  void setParams(const std::vector<Param> & params)
156  {
157  setParameters(*this, params.begin(), params.end(), devOptions_);
158  }
159 
160 public:
161  bool given(const std::string & parameter_name) const;
162 
163  virtual std::ostream &printName(std::ostream &os) const = 0;
164 
165  void setDefaultParamName(const std::string &default_param_name)
166  {
167  defaultParamName_ = default_param_name;
168  }
169 
170  const std::vector<Depend> &getDependentParams()
171  {
172  return dependentParams_;
173  }
174 
175  void addDependentParameter(const Depend &param) {
176  dependentParams_.push_back(param);
177  }
178 
180  {
181  return devOptions_;
182  }
183 
184  const SolverState &getSolverState() const
185  {
186  return solState_;
187  }
188 
189  const NetlistLocation &netlistLocation() const
190  {
191  return netlistLocation_;
192  }
193 
195  {
196  return parametricData_.getMap();
197  }
198 
199 private:
200  void escape(std::string &) const;
202 
203 private:
204  std::string defaultParamName_;
206  NetlistLocation netlistLocation_;
207 
210 
212  std::vector<Depend> dependentParams_;
213 
214 protected:
215  std::vector<int> expVarGIDs;
216  std::vector<int> expVarLIDs;
217  std::vector<std::string> expVarNames;
218  std::vector<double> expVarVals;
219  std::vector<double> eVarVals;
220 };
221 
222 } // namespace Device
223 } // namespace Xyce
224 
226 
227 #endif // Xyce_N_DEV_DeviceEntity_h
ParametricData< void > & parametricData_
bool getParam(const std::string &paramName, double &result) const
void escape(std::string &) const
bool given(const std::string &parameter_name) const
DeviceEntity & operator=(const DeviceEntity &)
No assignment.
Pure virtual class to augment a linear system.
unordered_map< std::string, Descriptor *, HashNoCase, EqualNoCase > ParameterMap
Definition: N_DEV_fwd.h:159
virtual CompositeParam * constructComposite(const std::string &composite_name, const std::string &param_name)
Base class for all parameters.
Definition: N_DEV_Pars.h:169
const std::vector< Depend > & getDependentParams()
DeviceEntity(ParametricData< void > &parametric_data, const SolverState &solver_state, const DeviceOptions &device_options, const std::string &netlist_filename, int netlist_line)
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 scaleDefaultParam(double val)
double setDependentParameter(Util::Param &, double *, ParameterType::ExprAccess)
const DeviceOptions & devOptions_
void setParams(const std::vector< Param > &params)
const ParameterMap & getParameterMap() const
std::vector< double > vals
void setParameters(CompositeParam &composite_param, const std::string &pName, const Param &ndParam)
const DeviceOptions & getDeviceOptions() const
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
void checkDepend(ParameterType::ExprAccess &)
bool setDefaultParam(double val, bool overrideOriginal=false)
std::vector< Depend > dependentParams_
void setDefaultParameters(ParameterBase &parameter_base, ParameterMap::const_iterator begin, ParameterMap::const_iterator end, const DeviceOptions &device_options)
Set the default values for the parameter.
Definition: N_DEV_Pars.C:77
virtual std::ostream & printName(std::ostream &os) const =0
bool getParamBreakpoints(std::vector< Util::BreakPoint > &)
bool analyticSensitivityAvailable(const std::string &paramName)
std::vector< double > eVarVals
const SolverState & getSolverState() const
const NetlistLocation & netlistLocation() const
void populateParams(const ParameterMap &parameter_map, std::vector< Param > &param_list, CompositeParamMap &composite_param_map)
void addDependentParameter(const Depend &param)
std::map< std::string, std::vector< Param >, LessNoCase > CompositeParamMap
unordered_map< std::string, double, HashNoCase, EqualNoCase > GlobalParameterMap
Definition: N_DEV_fwd.h:161
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)
Xyce::Device::Depend Depend
void setDefaultParamName(const std::string &default_param_name)
Util::Expression * expr
virtual bool processInstanceParams()=0
bool updateGlobalParameters(GlobalParameterMap &)
ParameterMap & getMap()
Gets the parameter binding map map.
Definition: N_DEV_Pars.h:1341
virtual bool processParams()=0
std::vector< std::string > expVarNames
CompositeParam is the base class for classes that wish to only manage the processing of parameter dat...
const SolverState & solState_