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