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