Xyce  6.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2014 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.127.2.1 $
40 //
41 // Revision Date : $Date: 2014/08/13 20:36:35 $
42 //
43 // Current Owner : $Author: dgbaur $
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_UTL_fwd.h>
58 
59 #include <N_UTL_NetlistLocation.h>
60 #include <N_DEV_Pars.h>
61 #include <N_DEV_InstanceName.h>
62 
63 class N_LAS_Vector;
64 
65 namespace Xyce {
66 namespace Device {
67 
68 typedef std::map<std::string, std::vector<Param>, LessNoCase> CompositeParamMap;
69 
70 void populateParams(const ParameterMap &parameter_map, std::vector<Param> &param_list, CompositeParamMap &composite_param_map);
71 void setParameters(CompositeParam &composite_param, const std::string &pName, const Param &ndParam );
72 void setParameters(DeviceEntity &entity, std::vector<Param>::const_iterator begin, std::vector<Param>::const_iterator end, const DeviceOptions &device_options);
73 
74 struct Depend
75 {
76  std::string name;
77  Util::Expression * expr;
78  union resUnion
79  {
80  double * result;
81  std::vector<double> * resVec;
82  } resultU;
84  std::vector<double> vals;
85  std::vector<std::string> global_params;
86  int n_vars, lo_var;
87 };
88 
89 //-----------------------------------------------------------------------------
90 // Class : DeviceEntity
91 // Purpose :
92 // Special Notes :
93 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
94 // Creation Date : 6/11/02
95 //-----------------------------------------------------------------------------
97 {
98 public:
100  ParametricData<void> & parametric_data,
101  const SolverState & solver_state,
102  const DeviceOptions & device_options,
103  const std::string & netlist_path,
104  int netlist_line);
105 
106 private:
107  DeviceEntity(const DeviceEntity &); ///< No copying
108  DeviceEntity &operator=(const DeviceEntity &); ///< No assignment
109 
110 public:
111  virtual ~DeviceEntity();
112 
113  virtual bool processParams() = 0;
114 
115  virtual bool processInstanceParams() = 0;
116 
117  virtual CompositeParam *constructComposite(const std::string &composite_name, const std::string &param_name)
118  {
119  return NULL;
120  }
121 
122  bool setDefaultParam(double val);
123  double getDefaultParam() const;
124 
125  bool scaleParam(const std::string & paramName, double val, double val0);
126  bool scaleParam(const std::string & paramName, double val);
127  bool scaleDefaultParam(double val);
128 
129  bool analyticSensitivityAvailable (const std::string & paramName);
130  bool getAnalyticSensitivity ( const std::string & paramName,
131  std::vector<double> & dfdpVec,
132  std::vector<double> & dqdpVec,
133  std::vector<double> & dbdpVec,
134  std::vector<int> & FindicesVec,
135  std::vector<int> & QindicesVec,
136  std::vector<int> & BindicesVec );
137 
138  bool setParam(const std::string & paramName, double val);
139  bool getParam(const std::string & paramName, double & result) const;
140  bool getParamBreakpoints( std::vector<Util::BreakPoint> & );
141 
142  bool updateDependentParameters(N_LAS_Vector & vars);
143  bool updateDependentParameters(double temp_tmp);
146 
147  double setDependentParameter(Util::Param &, double *, ParameterType::ExprAccess);
148  double setDependentParameter(Util::Param &, std::vector<double> *, int , ParameterType::ExprAccess);
149  void setDependentParameter(Util::Param & par, Depend & dependentParam, ParameterType::ExprAccess depend);
150 
152  {
154  }
155 
156  void setParams(const std::vector<Param> & params)
157  {
158  setParameters(*this, params.begin(), params.end(), devOptions_);
159  }
160 
161 public:
162  bool given(const std::string & parameter_name) const;
163 
164  virtual std::ostream &printName(std::ostream &os) const = 0;
165 
166  void setDefaultParamName(const std::string &default_param_name)
167  {
168  defaultParamName_ = default_param_name;
169  }
170 
171  const std::vector<Depend> &getDependentParams()
172  {
173  return dependentParams_;
174  }
175 
176  void addDependentParameter(const Depend &param) {
177  dependentParams_.push_back(param);
178  }
179 
181  {
182  return devOptions_;
183  }
184 
185  const SolverState &getSolverState() const
186  {
187  return solState_;
188  }
189 
190  const NetlistLocation &netlistLocation() const
191  {
192  return netlistLocation_;
193  }
194 
196  {
197  return parametricData_.getMap();
198  }
199 
200 private:
201  void escape(std::string &) const;
203 
204 private:
205  std::string defaultParamName_;
207  NetlistLocation netlistLocation_;
208 
211 
213  std::vector<Depend> dependentParams_;
214 
215 protected:
216  std::vector<int> expVarGIDs;
217  std::vector<int> expVarLIDs;
218  std::vector<std::string> expVarNames;
219  std::vector<double> expVarVals;
220  std::vector<double> eVarVals;
221 };
222 
223 } // namespace Device
224 } // namespace Xyce
225 
227 
228 #endif // Xyce_N_DEV_DeviceEntity_h