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