Xyce  6.1
N_DEV_SourceData.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_SourceData.h,v $
27 //
28 // Purpose : Source data containers. Used by the vsrc and isrc
29 // devices.
30 //
31 // Special Notes :
32 //
33 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
34 //
35 // Creation Date : 02/28/00
36 //
37 // Revision Information:
38 // ---------------------
39 //
40 // Revision Number: $Revision: 1.60 $
41 //
42 // Revision Date : $Date: 2015/07/02 21:41:48 $
43 //
44 // Current Owner : $Author: hkthorn $
45 //-----------------------------------------------------------------------------
46 
47 #ifndef Xyce_N_DEV_SourceData_h
48 #define Xyce_N_DEV_SourceData_h
49 
50 // ---------- Standard Includes ----------
51 #include <vector>
52 #include <list>
53 
54 // ---------- Xyce Includes ----------
55 #include <N_IO_fwd.h>
56 #include <N_UTL_fwd.h>
57 
58 #include <N_DEV_Device.h>
59 #include <N_DEV_DeviceBlock.h>
60 #include <N_DEV_Param.h>
61 
62 enum Src_index {
69 
73 };
74 
75 
76 namespace Xyce {
77 namespace Device {
78 
79 typedef std::map<std::string, std::vector<Param>, LessNoCase> DeviceParamMap;
80 
81 void sourceFunctionMetadata(DeviceParamMap &map);
82 int getSourceFunctionID(const std::string & sourceFcn);
83 const std::vector<Param> &getSourceFunctionParameters(const std::string &sourceFcn);
84 
85 //-----------------------------------------------------------------------------
86 // Class : SourceData
87 // Purpose :
88 // Special Notes :
89 // Creator : Eric Keiter
90 // Creation Date : 4/24/00
91 //-----------------------------------------------------------------------------
92 
94 {
95  friend class VsrcModel;
96  friend class VsrcInstance;
97  friend class ISRCModel;
98  friend class ISRCInstance;
99  friend class SourceInstance;
100 
101 public:
102  SourceData(const SolverState & ss1, const DeviceOptions & do1);
103 
104 private:
105  SourceData(const SourceData &right);
106  SourceData &operator=(const SourceData &right);
107 
108 public:
109  virtual ~SourceData();
110 
111  virtual bool initializeSource ();
112 
113  virtual bool updateSource() = 0;
114 
115  virtual bool getBreakPoints (std::vector<Util::BreakPoint> & breakPointTimes)
116  { return true; }
117 
118  virtual double getMaxTimeStepSize ();
119 
120  virtual void setRealFlag(bool flag) { realFlag_ = true;}
121 
122  virtual double period() { return 0.0; }
123 
124  double returnSource ();
125 
126  bool getResetFlag ()
127  {
128  return resetFlag_;
129  }
130 
131  std::string getSourceTypeName ();
132 
133  virtual void getParams (double *) {}
134  virtual void setParams (double *) {}
135  virtual void printOutParams();
136 
137  bool getFastTimeScaleFlag() const
138  {
139  return fastTimeScaleFlag_;
140  }
141 
142  void setFastTimeScaleFlag(bool fastTimeScaleFlag)
143  {
144  fastTimeScaleFlag_ = fastTimeScaleFlag;
145  }
146 
147 protected:
148  double getTime_();
149 
150 private:
151  SourceData ();
152 
153 protected:
154  std::string sourceName_;
155  std::string typeName_;
156  std::string defaultParamName_;
157 
158  double time;
159  double SourceValue;
160 
162 
164 
167 
169 
170  bool realFlag_;
171 };
172 
173 //-----------------------------------------------------------------------------
174 // Class : SinData
175 // Purpose : This class contains data and functions associated with
176 // sinusoidal independent sources.
177 // Special Notes :
178 // Creator : Eric Keiter
179 // Creation Date : 3/16/00
180 //-----------------------------------------------------------------------------
181 
182 class SinData : public SourceData
183 {
184 
185 public:
186  SinData(
187  const DeviceEntity & device,
188  const std::vector<Param> & paramRef,
189  const SolverState & ss1,
190  const DeviceOptions & do1);
191 
192  ~SinData();
193 
194 private:
195  SinData(const SinData &right);
196  SinData &operator=(const SinData &right);
197 
198 public:
199  bool initializeSource ();
200  virtual bool updateSource() /* override */ ;
201  void getParams (double *);
202  void setParams (double *);
203 
204  void printOutParams();
205 
206  double getMaxTimeStepSize () { return (0.1/FREQ); }
207 
208  double period() { return (1.0/FREQ); }
209 
210 private:
211  // Data Members for Class Attributes
212 
213  double V0; // Offset (V or A)
214  double VA; // Amplitude (V or A)
215  double FREQ; // Frequency (Hz)
216  double TD; // Delay (seconds)
217  double THETA; // Damping factor (1/seconds)
218  double PHASE; // Phase (degrees)
219 
220  bool V0given;
221  bool VAgiven;
222  bool FREQgiven;
223  bool TDgiven;
226 
227  friend class VsrcModel;
228  friend class VsrcInstance;
229  friend class ISRCModel;
230  friend class ISRCInstance;
231 };
232 
233 //-----------------------------------------------------------------------------
234 // Class : ExpData
235 // Purpose : This class contains data and functions associated with
236 // exponential independent sources.
237 // Special Notes :
238 // Creator : Eric Keiter
239 // Creation Date : 3/16/00
240 //-----------------------------------------------------------------------------
241 class ExpData : public SourceData
242 {
243  friend class VsrcModel;
244  friend class VsrcInstance;
245  friend class ISRCModel;
246  friend class ISRCInstance;
247 
248 public:
249  ExpData(const DeviceEntity & device, const std::vector<Param> & paramRef,
250  const SolverState & ss1,
251  const DeviceOptions & do1);
252 
253  ~ExpData();
254 
255 private:
256  ExpData(const ExpData & right);
257  ExpData &operator=(const ExpData & right);
258 
259 public:
260  bool initializeSource ();
261  virtual bool updateSource() /* override */ ;
262  void getParams (double *);
263  void setParams (double *);
264 
265  void printOutParams ();
266 
267 private:
268  double V1; // Initial value (V or A)
269  double V2; // Pulsed value (V or A).
270  double TD1; // Rise delay time (seconds).
271  double TAU1; // Rise time constant (seconds)
272  double TD2; // Fall delay time (seconds).
273  double TAU2; // Fall time constant (seconds)
274 
275  bool V1given;
276  bool V2given;
277  bool TD1given;
278  bool TAU1given;
279  bool TD2given;
280  bool TAU2given;
281 };
282 
283 
284 //-----------------------------------------------------------------------------
285 // Class : ACData
286 // Purpose : This class contains data and functions associated with
287 // AC independent sources.
288 // Special Notes :
289 // Creator : Ting Mei
290 // Creation Date :
291 //-----------------------------------------------------------------------------
292 
293 class ACData : public SourceData
294 {
295  friend class VsrcModel;
296  friend class VsrcInstance;
297  friend class ISRCModel;
298  friend class ISRCInstance;
299 
300 public:
301  ACData(const DeviceEntity & device, const std::vector<Param> & paramRef,
302  const SolverState & ss1,
303  const DeviceOptions & do1);
304 
305  ~ACData();
306 
307 private:
308  ACData(const ACData &right);
309  ACData &operator=(const ACData &right);
310 
311 public:
312  virtual bool updateSource() /* override */ ;
313  void getParams (double *);
314  void setParams (double *);
315 
316  void printOutParams();
317 
318  void setRealFlag(bool flag) { realFlag_ = flag; }
319 
320 private:
321  double ACMAG; // Amplitude (V or A)
322  double ACPHASE; // Phase (degrees)
323 
326 };
327 
328 
329 //-----------------------------------------------------------------------------
330 // Class : PulseData
331 // Purpose : This class contains data and functions associated with
332 // pulsed independent sources.
333 // Special Notes :
334 // Creator : Eric Keiter
335 // Creation Date : 3/16/00
336 //-----------------------------------------------------------------------------
337 class PulseData : public SourceData
338 {
339  friend class VsrcModel;
340  friend class VsrcInstance;
341  friend class ISRCModel;
342  friend class ISRCInstance;
343 
344 public:
345  PulseData(const DeviceEntity & device, const std::vector<Param> & paramRef,
346  const SolverState & ss1,
347  const DeviceOptions & do1);
348 
349  ~PulseData();
350 
351 private:
352  PulseData(const PulseData & right);
353  PulseData &operator=(const PulseData & right);
354 
355 public:
356  bool initializeSource();
357  virtual bool updateSource() /* override */ ;
358  void getParams (double *);
359  void setParams (double *);
360  bool getBreakPoints(std::vector<Util::BreakPoint> & breakPointTimes);
361 
362  void printOutParams();
363 
364  double getMaxTimeStepSize ();
365 
366  double period() { return PER; }
367 
368 public:
369  double V1; // Initial value (for a voltage source, units are Volts,
370  // For a current source, units are Amps)
371  double V2; // Pulsed value. (Volts or Amps)
372  double TD; // Delay time (seconds)
373  double TR; // Rise time (seconds)
374  double TF; // Fall Time (seconds)
375  double PW; // Pulse Width (seconds)
376  double PER; // Period (seconds)
377 
378  bool V1given;
379  bool V2given;
380  bool TDgiven;
381  bool TRgiven;
382  bool TFgiven;
383  bool PWgiven;
384  bool PERgiven;
385 };
386 
387 
388 //-----------------------------------------------------------------------------
389 // Class : PWLinData
390 // Purpose : This class contains the data and functions associated
391 // with piece-wise linear independent sources.
392 // Special Notes :
393 // Creator : Eric Keiter
394 // Creation Date : 3/16/00
395 //-----------------------------------------------------------------------------
396 class PWLinData : public SourceData
397 {
398  friend class VsrcModel;
399  friend class VsrcInstance;
400  friend class ISRCModel;
401  friend class ISRCInstance;
402 
403 public:
404  PWLinData(const DeviceEntity & device, const std::vector<Param> & paramRef,
405  const SolverState & ss1,
406  const DeviceOptions & do1);
407 
408  ~PWLinData();
409 
410 private:
411  PWLinData(const PWLinData &right);
412  PWLinData &operator=(const PWLinData &right);
413 
414 public:
415  virtual bool updateSource() /* override */ ;
416  bool getBreakPoints( std::vector<Util::BreakPoint> & breakPointTimes);
417 
418  void printOutParams ();
419 
420 private:
421  // Data Members for Class Attributes
422  int NUM; //number of time,voltage pairs
423  bool REPEAT; //repeat cycle?
424  double REPEATTIME; //start time in cycle for repeat
425  double TD; //time delay
426  std::vector< std::pair<double,double> > TVVEC; // Array (time,voltage)
427 
428  int loc_; //current location in time vector
429  double starttime_; //absolute start time of current cycle
430 };
431 
432 
433 //-----------------------------------------------------------------------------
434 // Class : SFFMData
435 // Purpose : This class contains data and functions associated with
436 // Single-frequency FM independent sources.
437 // Special Notes :
438 // Creator : Eric Keiter
439 // Creation Date : 3/16/00
440 //-----------------------------------------------------------------------------
441 class SFFMData : public SourceData
442 {
443  friend class VsrcModel;
444  friend class VsrcInstance;
445  friend class ISRCModel;
446  friend class ISRCInstance;
447 
448 public:
449  SFFMData(const DeviceEntity & device, const std::vector<Param> & paramRef,
450  const SolverState & ss1,
451  const DeviceOptions & do1);
452 
453  ~SFFMData();
454 
455 private:
456  SFFMData(const SFFMData & right);
457  SFFMData &operator=(const SFFMData & right);
458 
459 public:
460  bool initializeSource ();
461  virtual bool updateSource() /* override */ ;
462  void getParams (double *);
463  void setParams (double *);
464 
465  void printOutParams ();
466 
467 private:
468  double V0; // Offset. (V or A)
469  double VA; // Amplitude (V or A)
470  double FC; // Carrier frequency (Hz)
471  double MDI; // Modulation index
472  double FS; // Signal frequency (Hz)
473 
474  bool V0given;
475  bool VAgiven;
476  bool FCgiven;
477  bool MDIgiven;
478  bool FSgiven;
479 };
480 
481 //-----------------------------------------------------------------------------
482 // Class : ConstData
483 // Purpose : This class contains data and functions associated with
484 // const DC sources. It is not yet implemented.
485 // Special Notes :
486 // Creator : Robert Hoekstra
487 // Creation Date : 10/4/00
488 //-----------------------------------------------------------------------------
489 class ConstData : public SourceData
490 {
491  friend class VsrcModel;
492  friend class VsrcInstance;
493  friend class ISRCModel;
494  friend class ISRCInstance;
495 
496 public:
497  ConstData(const DeviceEntity & device, const std::vector<Param> & paramRef,
498  const SolverState & ss1,
499  const DeviceOptions & do1);
500 
501  ~ConstData();
502 
503 private:
504  ConstData(const ConstData & right);
505  ConstData &operator=(const ConstData & right);
506 
507 public:
508  virtual bool updateSource() /* override */ ;
509  void getParams (double *);
510  void setParams (double *);
511 
512  void printOutParams();
513 
514 private:
515  double V0;
516 };
517 
518 
519 //-----------------------------------------------------------------------------
520 // Class : PulseData
521 // Purpose : This class contains data and functions associated with
522 // a smooth pulsed independent source.
523 // Special Notes :
524 // Creator : Richard Schiek
525 // Creation Date : 4/13/11
526 //-----------------------------------------------------------------------------
528 {
529  friend class VsrcModel;
530  friend class VsrcInstance;
531  friend class ISRCModel;
532  friend class ISRCInstance;
533 
534 public:
535  SmoothPulseData(const DeviceEntity & device, const std::vector<Param> & paramRef,
536  const SolverState & ss1,
537  const DeviceOptions & do1);
538 
540 
541 private:
542  SmoothPulseData(const SmoothPulseData & right);
543  SmoothPulseData &operator=(const SmoothPulseData & right);
544 
545 public:
546  bool initializeSource();
547  virtual bool updateSource() /* override */ ;
548  void getParams (double *);
549  void setParams (double *);
550  bool getBreakPoints(std::vector<Util::BreakPoint> & breakPointTimes);
551 
552  void printOutParams();
553 
554  double getMaxTimeStepSize ();
555 
556  double period() { return PER; }
557 
558 public:
559  double V1; // Initial value (for a voltage source, units are Volts,
560  // For a current source, units are Amps)
561  double V2; // Pulsed value. (Volts or Amps)
562  double TD; // Delay time (seconds)
563  double TR; // Rise time (seconds)
564  double TF; // Fall Time (seconds)
565  double PW; // Pulse Width (seconds)
566  double PER; // Period (seconds)
567  double riseScaleFactor_; // scaling of amplitude of rise smoothing function so that
568  // it joins the low and high signal appropriately.
569  double fallScaleFactor_; // scaling of amplitude of rise smoothing function so that
570  // it joins the low and high signal appropriately.
571  double functionScaleFactor_; // a scale factor for the smooth function used to fill in the
572  // rise and fall segment
573 
574  bool V1given;
575  bool V2given;
576  bool TDgiven;
577  bool TRgiven;
578  bool TFgiven;
579  bool PWgiven;
580  bool PERgiven;
582 };
583 
584 bool extractSourceData(
585  const IO::TokenVector & parsedInputLine,
586  IO::DeviceBlock & device_block,
587  const std::string & primaryDeviceParameter);
588 
590  const IO::TokenVector & parsedInputLine,
591  IO::DeviceBlock & device_block,
592  const std::vector<std::string> & fieldNames,
593  const std::vector<int> & fieldPositions);
594 
595 } // namespace Device
596 } // namespace Xyce
597 
598 #endif
void setParams(double *)
bool extractSourceFields(const IO::TokenVector &parsedInputLine, IO::DeviceBlock &device_block, const std::vector< std::string > &fieldNames, const std::vector< int > &fieldPositions)
virtual bool updateSource()
void setParams(double *)
Pure virtual class to augment a linear system.
SFFMData & operator=(const SFFMData &right)
std::vector< std::pair< double, double > > TVVEC
void setRealFlag(bool flag)
ACData & operator=(const ACData &right)
void getParams(double *)
const DeviceOptions & devOptions_
SinData & operator=(const SinData &right)
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
virtual double getMaxTimeStepSize()
SFFMData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
PWLinData & operator=(const PWLinData &right)
void getParams(double *)
void setParams(double *)
ExpData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
virtual void getParams(double *)
ACData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
std::map< std::string, std::vector< Param >, LessNoCase > DeviceParamMap
bool extractSourceData(const IO::TokenVector &parsedInputLine, IO::DeviceBlock &device_block, const std::string &primaryDeviceParameter)
SinData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
virtual bool getBreakPoints(std::vector< Util::BreakPoint > &breakPointTimes)
PWLinData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
SmoothPulseData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
virtual bool updateSource()
virtual bool initializeSource()
ExpData & operator=(const ExpData &right)
virtual void setRealFlag(bool flag)
ConstData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
void setFastTimeScaleFlag(bool fastTimeScaleFlag)
ConstData & operator=(const ConstData &right)
virtual bool updateSource()
const std::vector< Param > & getSourceFunctionParameters(const std::string &sourceFcn)
bool getFastTimeScaleFlag() const
PulseData & operator=(const PulseData &right)
const SolverState & solState_
virtual bool updateSource()=0
void getParams(double *)
PulseData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
SourceData & operator=(const SourceData &right)
SmoothPulseData & operator=(const SmoothPulseData &right)
Src_index
virtual void setParams(double *)
int getSourceFunctionID(const std::string &sourceFcn)
void sourceFunctionMetadata(DeviceParamMap &map)