Xyce  6.1
N_DEV_SourceData.C
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.C,v $
27 //
28 // Purpose : This file contains the member functions of the
29 // N_DEV_SourceData class, which is used by the Vsrc
30 // and ISRC devices.
31 //
32 // Special Notes :
33 //
34 // Creator : Eric R. Keiter, SNL, Parallel Computational Sciences
35 //
36 // Creation Date : 02/28/00
37 //
38 // Revision Information:
39 // ---------------------
40 //
41 // Revision Number: $Revision: 1.135.2.1 $
42 //
43 // Revision Date : $Date: 2015/04/02 18:20:09 $
44 //
45 // Current Owner : $Author: tvrusso $
46 //-------------------------------------------------------------------------
47 
48 #include <Xyce_config.h>
49 
50 #include <N_DEV_DeviceInstance.h>
51 #include <N_DEV_DeviceOptions.h>
52 #include <N_DEV_Message.h>
53 #include <N_DEV_SolverState.h>
54 #include <N_DEV_SourceData.h>
55 #include <N_UTL_BreakPoint.h>
56 #include <N_UTL_FeatureTest.h>
57 #include <N_UTL_Math.h>
58 
59 namespace Xyce {
60 namespace Device {
61 
63 {
64  std::vector<Param> sourceFcnParamList;
65  // Source function metadata.
66  sourceFcnParamList.resize(7);
67  sourceFcnParamList[0].set("V1", 0.0);
68  sourceFcnParamList[1].set("V2", 0.0);
69  sourceFcnParamList[2].set("TD", 0.0);
70  sourceFcnParamList[3].set("TR", 0.0);
71  sourceFcnParamList[4].set("TF", 0.0);
72  sourceFcnParamList[5].set("PW", 0.0);
73  sourceFcnParamList[6].set("PER", 0.0);
74  sourceFcnMap[ "PULSE" ] = sourceFcnParamList;
75 
76  sourceFcnParamList.resize(6);
77  sourceFcnParamList[0].set("V0", 0.0);
78  sourceFcnParamList[1].set("VA", 0.0);
79  sourceFcnParamList[2].set("FREQ", 0.0);
80  sourceFcnParamList[3].set("TD", 0.0);
81  sourceFcnParamList[4].set("THETA", 0.0);
82  sourceFcnParamList[5].set("PHASE", 0.0);
83  sourceFcnMap[ "SIN" ] = sourceFcnParamList;
84 
85  sourceFcnParamList.resize(6);
86  sourceFcnParamList[0].set("V1", 0.0);
87  sourceFcnParamList[1].set("V2", 0.0);
88  sourceFcnParamList[2].set("TD1", 0.0);
89  sourceFcnParamList[3].set("TAU1", 0.0);
90  sourceFcnParamList[4].set("TD2", 0.0);
91  sourceFcnParamList[5].set("TAU2", 0.0);
92  sourceFcnMap[ "EXP" ] = sourceFcnParamList;
93  sourceFcnParamList.resize(5);
94  sourceFcnParamList[0].set("V0", 0.0);
95  sourceFcnParamList[1].set("VA", 0.0);
96  sourceFcnParamList[2].set("FC", 0.0);
97  sourceFcnParamList[3].set("MDI", 0.0);
98  sourceFcnParamList[4].set("FS", 0.0);
99  sourceFcnMap[ "SFFM" ] = sourceFcnParamList;
100 
101 // sourceFcnParamList is empty for source function "PWL" indicating
102  // that it needs special handling in NetlistHandler.C
103  sourceFcnParamList.clear();
104  sourceFcnMap[ "PWL" ] = sourceFcnParamList;
105 
106  sourceFcnParamList.resize(8);
107  sourceFcnParamList[0].set("V1", 0.0);
108  sourceFcnParamList[1].set("V2", 0.0);
109  sourceFcnParamList[2].set("TD", 0.0);
110  sourceFcnParamList[3].set("TR", 0.0);
111  sourceFcnParamList[4].set("TF", 0.0);
112  sourceFcnParamList[5].set("PW", 0.0);
113  sourceFcnParamList[6].set("PER", 0.0);
114  sourceFcnParamList[7].set("SF", 0.0);
115  sourceFcnMap[ "SMOOTHPULSE" ] = sourceFcnParamList;
116 }
117 
118 
119 //-----------------------------------------------------------------------------
120 // Function : SourceData::SourceData
121 // Purpose : constructor
122 // Special Notes :
123 // Scope : public
124 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
125 // Creation Date : 4/24/00
126 //-----------------------------------------------------------------------------
128  const DeviceOptions & do1)
129  : SourceValue(0.0),
130  initializeFlag_(false),
131  resetFlag_(true),
132  solState_(ss1),
133  time(0.0),
134  devOptions_(do1),
135  typeName_(""),
136  sourceName_(""),
137  defaultParamName_("") ,
138  fastTimeScaleFlag_(false),
139  realFlag_(true)
140 {}
141 
142 //-----------------------------------------------------------------------------
143 // Function : SourceData::~SourceData
144 // Purpose : destructor
145 // Special Notes :
146 // Scope : public
147 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
148 // Creation Date : 4/24/00
149 //-----------------------------------------------------------------------------
151 {}
152 
153 //-----------------------------------------------------------------------------
154 // Function : SourceData::initializeSource
155 // Purpose : Base class initialization function.
156 // Special Notes :
157 // Scope : public
158 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
159 // Creation Date : 9/04/01
160 //-----------------------------------------------------------------------------
162 {
163  initializeFlag_ = true;
164  return true;
165 }
166 
167 //-----------------------------------------------------------------------------
168 // Function : SourceData::returnSource
169 // Purpose :
170 // Special Notes :
171 // Scope : public
172 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
173 // Creation Date : 4/24/00
174 //-----------------------------------------------------------------------------
176 {
177  return SourceValue;
178 }
179 
180 //-----------------------------------------------------------------------------
181 // Function : SourceData::returnSource
182 // Purpose :
183 // Special Notes :
184 // Scope : public
185 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
186 // Creation Date : 4/24/00
187 //-----------------------------------------------------------------------------
189 {
190  return typeName_;
191 }
192 
193 //-----------------------------------------------------------------------------
194 // Function : SourceData::printOutParams
195 // Purpose :
196 // Special Notes :
197 // Scope : public
198 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
199 // Creation Date : 6/21/00
200 //-----------------------------------------------------------------------------
202 {}
203 
204 //-----------------------------------------------------------------------------
205 // Function : SourceData::getMaxTimeStepSize
206 // Purpose :
207 // Special Notes :
208 // Scope : public
209 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
210 // Creation Date : 4/01/02
211 //-----------------------------------------------------------------------------
213 {
215 }
216 
217 //-----------------------------------------------------------------------------
218 // Function : SourceData::getTime_
219 // Purpose :
220 // Special Notes :
221 // Scope : protected
222 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
223 // Creation Date : 3/25/04
224 //-----------------------------------------------------------------------------
226 {
227  double tmpTime = 0.0;
228 
229  if (fastTimeScaleFlag_)
230  tmpTime = solState_.currFastTime;
231  else
232  tmpTime = solState_.currTime;
233 
234  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
235  {
236  Xyce::dout() << "SourceData::getTime. time = ";
237  Xyce::dout() << tmpTime << std::endl;
238  Xyce::dout() << "SourceData::getTime. currFastTime = ";
239  Xyce::dout() << solState_.currFastTime<< std::endl;
240  Xyce::dout() << "SourceData::getTime. currTime = ";
241  Xyce::dout() << solState_.currTime << std::endl;
242  }
243 
244  return tmpTime;
245 }
246 
247 // Class SinData
248 
249 //-----------------------------------------------------------------------------
250 // Function : SinData::SinData
251 // Purpose : constructor
252 // Special Notes :
253 // Scope : public
254 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
255 // Creation Date : 3/16/00
256 //
257 // From 3f5: remember to incorporate this later:
258 //
259 //-----------------------------------------------------------------------------
260 #if 0
261  // this is from 3f5:
262  #define FREQ (((here->VSRCfunctionOrder >=3) && (*(here->VSRCcoeffs+2)))? \
263  (*(here->VSRCcoeffs+2)):(1/ckt->CKTfinalTime))
264 #endif
265 
267  const DeviceEntity & device,
268  const std::vector<Param> & paramRef,
269  const SolverState & ss1,
270  const DeviceOptions & do1)
271  : SourceData(ss1,do1),
272  V0(0.0),
273  VA(0.0),
274  FREQ(0.0),
275  TD(0.0),
276  THETA(0.0),
277  PHASE(0.0),
278  V0given(false),
279  VAgiven(false),
280  FREQgiven(false),
281  TDgiven(false),
282  THETAgiven(false),
283  PHASEgiven(false)
284 {
285  std::vector<Param>::const_iterator iter = paramRef.begin();
286  std::vector<Param>::const_iterator last = paramRef.end();
287 
288  for ( ; iter != last; ++iter)
289  {
290  const std::string & tmpname = iter->tag();
291 
292  if (tmpname == "V0") { V0 = iter->getImmutableValue<double>(); V0given = iter->given();}
293  if (tmpname == "VA") { VA = iter->getImmutableValue<double>(); VAgiven = iter->given();}
294  if (tmpname == "FREQ") { FREQ = iter->getImmutableValue<double>(); FREQgiven = iter->given();}
295  if (tmpname == "TD") { TD = iter->getImmutableValue<double>(); TDgiven = iter->given();}
296  if (tmpname == "THETA") { THETA = iter->getImmutableValue<double>(); THETAgiven = iter->given();}
297  if (tmpname == "PHASE") { PHASE = iter->getImmutableValue<double>(); PHASEgiven = iter->given();}
298  }
299 
300  if (!(V0given && VAgiven && FREQgiven))
301  UserError(device) << "V0, VA and FREQ are required for the SIN source function";
302 
303  typeName_ = "SIN";
304  defaultParamName_ = "V0";
305 }
306 
307 //-----------------------------------------------------------------------------
308 // Function : SinData::initializeSource
309 // Purpose :
310 // Special Notes :
311 // Scope : public
312 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
313 // Creation Date : 9/04/01
314 //-----------------------------------------------------------------------------
316 {
317 
318  // If neccessary, set defaults:
319  double tstop = solState_.finalTime;
320 
321  if (!FREQgiven) FREQ = 1.0/tstop;
322  if (!TDgiven) TD = 0.0;
323  if (!THETAgiven) THETA = 0.0;
324 
325  initializeFlag_ = true;
326 
327  return true;
328 }
329 
330 //-----------------------------------------------------------------------------
331 // Function : SinData::~SinData
332 // Purpose : destructor
333 // Special Notes :
334 // Scope : public
335 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
336 // Creation Date : 3/16/00
337 //-----------------------------------------------------------------------------
339 {}
340 
341 //-----------------------------------------------------------------------------
342 // Function : SinData::printOutParams
343 // Purpose :
344 // Special Notes :
345 // Scope : public
346 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
347 // Creation Date : 6/21/00
348 //-----------------------------------------------------------------------------
349 
351 
352 {
353  Xyce::dout() << "SinData:\n";
354  Xyce::dout() << "V0 = " << V0 << std::endl;
355  Xyce::dout() << "VA = " << VA << std::endl;
356  Xyce::dout() << "FREQ = " << FREQ << std::endl;
357  Xyce::dout() << "TD = " << TD << std::endl;
358  Xyce::dout() << "THETA = " << THETA << std::endl;
359  Xyce::dout() << "PHASE = " << PHASE << std::endl;
360 }
361 
362 // Additional Declarations
363 
364 //-----------------------------------------------------------------------------
365 // Function : SinData::updateSource
366 // Purpose : Update the sinwave source.
367 // Special Notes :
368 //
369 // V0 - offset (V or A)
370 // VA - Amplitude (V or A)
371 // FREQ - frequency in Hz
372 // TD - delay in seconds
373 // THETA - damping factor (Hz).
374 // PHASE - phase (degrees)
375 //
376 // Scope : public
377 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
378 // Creation Date : 4/24/00
379 //-----------------------------------------------------------------------------
381 {
382  bool bsuccess = true;
383 
384  if (!initializeFlag_) bsuccess = initializeSource ();
385 
386 //#ifdef Xyce_MPDE
387  time = getTime_();
388 //#else
389 // time = solState_.currTime;
390 //#endif // Xyce_MPDE
391 
392  time -= TD;
393  double mpi = M_PI;
394  if (time <= 0)
395  {
396  //SourceValue = V0;
397  SourceValue = V0 + VA * sin (2.0*mpi*(PHASE/360)) ;
398  }
399  else
400  {
401  // 2PI to convert from hz to radians/sec
402  SourceValue = V0 + VA * sin (2.0*mpi*(FREQ*time + PHASE/360)) *
403  exp( -(time*THETA));
404  }
405 
406  resetFlag_ = false;
407  return bsuccess;
408 }
409 
410 //-----------------------------------------------------------------------------
411 // Function : SinData::getParams
412 // Purpose : Pass back the sine source params.
413 // Special Notes : TD and FREQ are interchanged from their normal order
414 // to accomodate the storage layout in the device classes
415 //
416 // Scope : public
417 // Creator : Dave Shirley, PSSI
418 // Creation Date : 4/14/05
419 //-----------------------------------------------------------------------------
420 void SinData::getParams(double *params)
421 {
422  params[0] = V0;
423  params[1] = VA;
424  params[2] = TD;
425  params[3] = FREQ;
426  params[4] = THETA;
427  params[5] = PHASE;
428 }
429 
430 //-----------------------------------------------------------------------------
431 // Function : SinData::setParams
432 // Purpose : Update the sine source params.
433 // Special Notes : TD and FREQ are interchanged from their normal order
434 // to accomodate the storage layout in the device classes
435 //
436 // Scope : public
437 // Creator : Dave Shirley, PSSI
438 // Creation Date : 4/14/05
439 //-----------------------------------------------------------------------------
440 void SinData::setParams(double *params)
441 {
442  bool reset=false;
443  if (V0 != params[0])
444  {
445  V0 = params[0];
446  reset = true;
447  }
448  if (VA != params[1])
449  {
450  VA = params[1];
451  reset = true;
452  }
453  if (TD != params[2])
454  {
455  TD = params[2];
456  reset = true;
457  }
458  if (FREQ != params[3])
459  {
460  FREQ = params[3];
461  reset = true;
462  }
463  if (THETA != params[4])
464  {
465  THETA = params[4];
466  reset = true;
467  }
468  if (PHASE != params[5])
469  {
470  PHASE = params[5];
471  reset = true;
472  }
473  if (reset)
474  {
475  updateSource();
476  }
477 }
478 
479 // Class ExpData
480 
481 //-----------------------------------------------------------------------------
482 // Function : ExpData::ExpData
483 // Purpose : constructor
484 // Special Notes :
485 // Scope : public
486 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
487 // Creation Date : 3/16/00
488 //-----------------------------------------------------------------------------
490  const DeviceEntity & device,
491  const std::vector<Param> & paramRef,
492  const SolverState & ss1,
493  const DeviceOptions & do1)
494  : SourceData(ss1,do1),
495  V1 (0.0),
496  V2 (0.0),
497  TD1 (0.0),
498  TAU1 (0.0),
499  TD2 (0.0),
500  TAU2 (0.0),
501  V1given (false),
502  V2given (false),
503  TD1given (false),
504  TAU1given (false),
505  TD2given (false),
506  TAU2given (false)
507 {
508  // Set the user-defined params:
509  std::vector<Param>::const_iterator iter = paramRef.begin();
510  std::vector<Param>::const_iterator last = paramRef.end();
511 
512  for ( ; iter != last; ++iter)
513  {
514  const std::string & tmpname = iter->tag();
515 
516  if (tmpname == "V1") { V1 = iter->getImmutableValue<double>(); V1given = iter->given();}
517  if (tmpname == "V2") { V2 = iter->getImmutableValue<double>(); V2given = iter->given();}
518  if (tmpname == "TD1") { TD1 = iter->getImmutableValue<double>(); TD1given = iter->given();}
519  if (tmpname == "TAU1") { TAU1 = iter->getImmutableValue<double>(); TAU1given = iter->given();}
520  if (tmpname == "TD2") { TD2 = iter->getImmutableValue<double>(); TD2given = iter->given();}
521  if (tmpname == "TAU2") { TAU2 = iter->getImmutableValue<double>(); TAU2given = iter->given();}
522  }
523 
524  if (!(V1given && V2given))
525  UserError(device) << "V1 and V2 are required for the EXP source function";
526 
527  typeName_ = "EXP";
528  defaultParamName_ = "V1";
529 }
530 
531 //-----------------------------------------------------------------------------
532 // Function : ExpData::~ExpData
533 // Purpose : destructor
534 // Special Notes :
535 // Scope : public
536 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
537 // Creation Date : 3/16/00
538 //-----------------------------------------------------------------------------
540 {}
541 
542 // Additional Declarations
543 
544 //-----------------------------------------------------------------------------
545 // Function : ExpData::printOutParams
546 // Purpose :
547 // Special Notes :
548 // Scope : public
549 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
550 // Creation Date : 6/21/00
551 //-----------------------------------------------------------------------------
553 {
554  Xyce::dout() << "ExpData:\n";
555 
556  Xyce::dout() << "V1 = " << V1 << std::endl;
557  Xyce::dout() << "V2 = " << V2 << std::endl;
558 
559  Xyce::dout() << "TD1 = " << TD1 << std::endl;
560  Xyce::dout() << "TAU1 = " << TAU1 << std::endl;
561 
562  Xyce::dout() << "TD2 = " << TD2 << std::endl;
563  Xyce::dout() << "TAU2 = " << TAU2 << std::endl;
564 
565 }
566 
567 //-----------------------------------------------------------------------------
568 // Function : ExpData::initializeSource
569 // Purpose :
570 // Special Notes :
571 // Scope : public
572 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
573 // Creation Date : 9/04/01
574 //-----------------------------------------------------------------------------
576 {
577  // If neccessary, set defaults:
578  double tstep = solState_.startingTimeStep;
579 
580  if (!TD1given) TD1 = 0.0;
581  if (!TAU1given) TAU1 = tstep;
582  if (!TD2given) TD2 = TD1 + tstep;
583  if (!TAU2given) TAU2 = tstep;
584 
585  initializeFlag_ = true;
586 
587  return true;
588 }
589 
590 //-----------------------------------------------------------------------------
591 // Function : ExpData::updateSource
592 // Purpose : Updates an exponential source:
593 // Special Notes :
594 //
595 // V1 - Initial value (V or A)
596 // V2 - Pulsed value (V or A).
597 // TD1 - Rise delay time (seconds).
598 // TAU1 - Rise time constant (seconds)
599 // TD2 - Fall delay time (seconds).
600 // TAU2 - Fall time constant (seconds)
601 //
602 // Scope : public
603 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
604 // Creation Date : 4/24/00
605 //-----------------------------------------------------------------------------
606 
608 
609 {
610  bool bsuccess = true;
611 
612  if (!initializeFlag_) bsuccess = initializeSource ();
613 
614 //#ifdef Xyce_MPDE
615  time = getTime_();
616 //#else
617 // time = solState_.currTime;
618 //#endif // Xyce_MPDE
619 
620  if (time <= TD1)
621  {
622  SourceValue = V1;
623  }
624  else if (time <= TD2)
625  {
626  SourceValue = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1));
627  }
628  else
629  {
630  SourceValue = V1 + (V2-V1)*(1-exp(-(time-TD1)/TAU1)) +
631  (V1-V2)*(1-exp(-(time-TD2)/TAU2)) ;
632  }
633 
634  resetFlag_ = false;
635 
636  return bsuccess;
637 
638 }
639 
640 //-----------------------------------------------------------------------------
641 // Function : ExpData::getParams
642 // Purpose : Pass back the exponential source params.
643 // Special Notes :
644 //
645 // Scope : public
646 // Creator : Dave Shirley, PSSI
647 // Creation Date : 4/14/05
648 //-----------------------------------------------------------------------------
649 void ExpData::getParams(double *params)
650 {
651  params[0] = V1;
652  params[1] = V2;
653  params[2] = TD1;
654  params[3] = TAU1;
655  params[4] = TD2;
656  params[5] = TAU2;
657 }
658 
659 //-----------------------------------------------------------------------------
660 // Function : ExpData::setParams
661 // Purpose : Update the exponential source params.
662 // Special Notes :
663 //
664 // Scope : public
665 // Creator : Dave Shirley, PSSI
666 // Creation Date : 4/14/05
667 //-----------------------------------------------------------------------------
668 void ExpData::setParams(double *params)
669 {
670  bool reset=false;
671  if (V1 != params[0])
672  {
673  V1 = params[0];
674  reset = true;
675  }
676  if (V2 != params[1])
677  {
678  V2 = params[1];
679  reset = true;
680  }
681  if (TD1 != params[2])
682  {
683  TD1 = params[2];
684  reset = true;
685  }
686  if (TAU1 != params[3])
687  {
688  TAU1 = params[3];
689  reset = true;
690  }
691  if (TD2 != params[4])
692  {
693  TD2 = params[4];
694  reset = true;
695  }
696  if (TAU2 != params[5])
697  {
698  TAU2 = params[5];
699  reset = true;
700  }
701  if (reset)
702  {
703  updateSource();
704  }
705 }
706 
707 // Class PulseData
708 
709 //-----------------------------------------------------------------------------
710 // Function : PulseData::PulseData
711 // Purpose : constructor
712 // Special Notes :
713 // Scope : public
714 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
715 // Creation Date : 3/16/00
716 //-----------------------------------------------------------------------------
718  const DeviceEntity & device,
719  const std::vector<Param> & paramRef,
720  const SolverState & ss1,
721  const DeviceOptions & do1)
722  : SourceData (ss1,do1),
723  V1 (0.0),
724  V2 (0.0),
725  TD (0.0),
726  TR (0.0),
727  TF (0.0),
728  PW (0.0),
729  PER (0.0),
730  V1given (false),
731  V2given (false),
732  TDgiven (false),
733  TRgiven (false),
734  TFgiven (false),
735  PWgiven (false),
736  PERgiven (false)
737 {
738 
739  // Get the user-defined values:
740  std::vector<Param>::const_iterator iter = paramRef.begin();
741  std::vector<Param>::const_iterator last = paramRef.end();
742 
743  for ( ; iter != last; ++iter)
744  {
745  const std::string & tmpname = iter->tag();
746 
747  if (tmpname == "V1") { V1 = iter->getImmutableValue<double>(); V1given = iter->given();}
748  if (tmpname == "V2") { V2 = iter->getImmutableValue<double>(); V2given = iter->given();}
749  if (tmpname == "TD") { TD = iter->getImmutableValue<double>(); TDgiven = iter->given();}
750  if (tmpname == "TR") { TR = iter->getImmutableValue<double>(); TRgiven = iter->given();}
751  if (tmpname == "TF") { TF = iter->getImmutableValue<double>(); TFgiven = iter->given();}
752  if (tmpname == "PW") { PW = iter->getImmutableValue<double>(); PWgiven = iter->given();}
753  if (tmpname == "PER") { PER = iter->getImmutableValue<double>(); PERgiven = iter->given();}
754  }
755 
756  typeName_ = "PULSE";
757  defaultParamName_ = "V2";
758 }
759 
760 //-----------------------------------------------------------------------------
761 // Function : PulseData::~PulseData
762 // Purpose : destructor
763 // Special Notes :
764 // Scope : public
765 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
766 // Creation Date : 3/16/00
767 //-----------------------------------------------------------------------------
769 {}
770 
771 // Additional Declarations
772 
773 //-----------------------------------------------------------------------------
774 // Function : PulseData::printOutParams
775 // Purpose :
776 // Special Notes :
777 // Scope : public
778 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
779 // Creation Date : 6/21/00
780 //-----------------------------------------------------------------------------
782 {
783  Xyce::dout() << std::endl;
784  Xyce::dout() << " PulseData::printOutParams\n";
785  Xyce::dout() << " V1 = " << V1 << std::endl;
786  Xyce::dout() << " V2 = " << V2 << std::endl;
787 
788  Xyce::dout() << " TD = " << TD << std::endl;
789  Xyce::dout() << " TR = " << TR << std::endl;
790  Xyce::dout() << " TF = " << TF << std::endl;
791  Xyce::dout() << " PW = " << PW << std::endl;
792  Xyce::dout() << " PER = " << PER << std::endl;
793  Xyce::dout() << std::endl;
794 
795 }
796 
797 //-----------------------------------------------------------------------------
798 // Function : PulseData::initializeSource
799 // Purpose :
800 // Special Notes :
801 // Scope : public
802 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
803 // Creation Date : 9/04/01
804 //-----------------------------------------------------------------------------
806 {
807  // If neccessary, set the defaults:
808 
809  double tstep = solState_.startingTimeStep;
810  double tstop = solState_.finalTime;
811 
812  if (!TDgiven) TD = 0.0;
813  if (!TRgiven) TR = tstep;
814  if (!TFgiven) TF = tstep;
815  if (!PWgiven) PW = tstop;
816  if (!PERgiven) PER = tstop;
817 
818  initializeFlag_ = true;
819 
820  return true;
821 }
822 
823 //-----------------------------------------------------------------------------
824 // Function : PulseData::updateSource
825 // Purpose :
826 // Special Notes :
827 // Scope : public
828 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
829 // Creation Date : 4/24/00
830 //-----------------------------------------------------------------------------
832 
833 {
834 //notused: double tstep = solState_.startingTimeStep;
835 //notused: double tstop = solState_.finalTime;
836  bool bsuccess = true;
837 
838  if (!initializeFlag_) bsuccess = initializeSource ();
839 
840  double basetime = 0;
841  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
842  {
843  Xyce::dout() << " PulseData::updateSources\n";
844  printOutParams();
845  }
846 
847 //#ifdef Xyce_MPDE
848  time = getTime_();
849 //#else
850 // time = solState_.currTime;
851 //#endif // Xyce_MPDE
852 
853  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
854  {
855  Xyce::dout() << " Time = " << time << std::endl;
856  }
857 
858  time -= TD;
859 
860  if (time > PER && PER != 0.0)
861  {
862  // repeating signal - figure out where we are in period
863  basetime = PER * floor(time/PER);
864  time -= basetime;
865  }
866 
867  // This section got ugly because of a nasty roundoff bug.
868  // Instead of doing "time > X" you need also check that time
869  // is not within bptol of X.
870  // So the following translation is used:
871  // Instead of: we do:
872  // time > X time>X && fabs(time-x)>bptol
873  // time <= X time<X || fabs(time-x)<bptol
874 
875  if (time <= 0 || (time > (TR + PW + TF) &&
876  (fabs (time - (TR+PW+TF)) > solState_.bpTol) ) )
877  {
878  SourceValue = V1;
879  }
880  else if ((time > TR && fabs(time-TR) > solState_.bpTol)
881  && (time < (TR + PW) || fabs (time-(TR+PW))<solState_.bpTol) )
882  {
883  SourceValue = V2;
884  }
885  else if (time > 0 &&
886  (time < TR || fabs(time-TR) < solState_.bpTol))
887  {
888  if (TR != 0.0)
889  {
890  SourceValue = V1 + (V2 - V1) * (time) / TR;
891  }
892  else
893  {
894  SourceValue = V1;
895  }
896  }
897  else
898  { // time > (TR + PW) && <= (TR + PW + TF)
899  if (TF != 0.0)
900  {
901  SourceValue = V2 + (V1 - V2) * (time - (TR + PW)) / TF;
902  }
903  else
904  {
905  SourceValue = V2; // SourceValue = 0.5 * (V1 + V2);
906  }
907  }
908 
909  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
910  {
911  Xyce::dout() << " SourceValue = " << SourceValue << std::endl;
912  }
913 
914  resetFlag_ = false;
915 
916  return bsuccess;
917 }
918 
919 //-----------------------------------------------------------------------------
920 // Function : PulseData::getParams
921 // Purpose : Pass back the pulse source params.
922 // Special Notes :
923 //
924 // Scope : public
925 // Creator : Dave Shirley, PSSI
926 // Creation Date : 4/14/05
927 //-----------------------------------------------------------------------------
928 void PulseData::getParams(double *params)
929 {
930  params[0] = V1;
931  params[1] = V2;
932  params[2] = TD;
933  params[3] = TR;
934  params[4] = TF;
935  params[5] = PW;
936  params[6] = PER;
937 }
938 
939 //-----------------------------------------------------------------------------
940 // Function : PulseData::setParams
941 // Purpose : Update the pulse source params.
942 // Special Notes :
943 //
944 // Scope : public
945 // Creator : Dave Shirley, PSSI
946 // Creation Date : 4/14/05
947 //-----------------------------------------------------------------------------
948 void PulseData::setParams(double *params)
949 {
950  bool reset=false;
951  if (V1 != params[0])
952  {
953  V1 = params[0];
954  reset = true;
955  }
956  if (V2 != params[1])
957  {
958  V2 = params[1];
959  reset = true;
960  }
961  if (TD != params[2])
962  {
963  TD = params[2];
964  reset = true;
965  }
966  if (TR != params[3])
967  {
968  TR = params[3];
969  reset = true;
970  }
971  if (TF != params[4])
972  {
973  TF = params[4];
974  reset = true;
975  }
976  if (PW != params[5])
977  {
978  PW = params[5];
979  reset = true;
980  }
981  if (PER != params[6])
982  {
983  PER = params[6];
984  reset = true;
985  }
986  if (reset)
987  {
988  updateSource();
989  }
990 }
991 
992 //-----------------------------------------------------------------------------
993 // Function : PulseData::getBreakPoints
994 // Purpose : This function adds break points to a vector of breakpoints.
995 //
996 // It does not bother to check them in any way, or put them
997 // in order. It only adds them in.
998 //
999 // Special Notes : Like much of this file, this is adapted from spice 3f5.
1000 // Some of the stuff in it is a little hokey, and may get
1001 // removed or modified later.
1002 //
1003 // Scope : public
1004 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1005 // Creation Date : 06/08/01
1006 //-----------------------------------------------------------------------------
1008  (std::vector<Util::BreakPoint> & breakPointTimes )
1009 {
1010  bool bsuccess = true;
1011 
1012  if (!initializeFlag_) bsuccess = initializeSource ();
1013 
1014  // currPeriodIndex is the integer index representing the period of
1015  // the current circuit time.
1016  int currPeriodIndex = 0;
1017 
1018  // subtract out the delay.
1019  double basetime = 0.0;
1020 
1021 //#ifdef Xyce_MPDE
1022  time = getTime_() - TD;
1023 //#else
1024 // time = solState_.currTime - TD;
1025 //#endif // Xyce_MPDE
1026 
1027  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1028  {
1029  Xyce::dout() << std::endl;
1030  Xyce::dout() << " In PulseData::getBreakPoints\n";
1031  Xyce::dout() << " time = " << time << std::endl;
1032  Xyce::dout() << " TD = " << TD << std::endl;
1033  Xyce::dout() << " PER = " << PER << std::endl;
1034  }
1035 
1036  // repeating signal - figure out where we are in period
1037  if(time >= PER)
1038  {
1039  if (PER != 0.0)
1040  {
1041  currPeriodIndex = (static_cast<int> (floor(time/PER)));
1042  basetime = PER * (static_cast<double> (currPeriodIndex));
1043  time -= basetime;
1044  }
1045  }
1046 
1047  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1048  {
1049  Xyce::dout() << " time = " << time << std::endl;
1050  Xyce::dout() << " basetime = " << basetime << std::endl;
1051  Xyce::dout() << " currPeriodIndex = " << currPeriodIndex << std::endl;
1052  Xyce::dout() << std::endl;
1053  }
1054 
1055  // now that we know which period this is, push_back all breakpoints
1056  // in this period and the next. If we are still in the delay, then
1057  // just use first two periods.
1058 
1059  // current period:
1060  breakPointTimes.push_back(basetime+TD);
1061  breakPointTimes.push_back(basetime+TD+TR);
1062  breakPointTimes.push_back(basetime+TD+TR+PW);
1063  breakPointTimes.push_back(basetime+TD+TR+PW+TF);
1064 
1065  if (PER != 0.0)
1066  {
1067  breakPointTimes.push_back(basetime+TD+PER);
1068 
1069  // next period:
1070  breakPointTimes.push_back(basetime+TD+PER+TR);
1071  breakPointTimes.push_back(basetime+TD+PER+TR+PW);
1072  breakPointTimes.push_back(basetime+TD+PER+TR+PW+TF);
1073  breakPointTimes.push_back(basetime+TD+PER+PER);
1074  }
1075 
1076  return bsuccess;
1077 }
1078 
1079 //-----------------------------------------------------------------------------
1080 // Function : PulseData::getMaxTimeStepSize
1081 // Purpose :
1082 // Special Notes :
1083 // Scope : public
1084 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1085 // Creation Date : 9/25/01
1086 //-----------------------------------------------------------------------------
1088 {
1089  double maxTimeStep = devOptions_.defaultMaxTimeStep;
1090 
1091  // check if we are still in the delay or not.
1092 //#ifdef Xyce_MPDE
1093  time = getTime_();
1094 //#else
1095 // time = solState_.currTime;
1096 //#endif // Xyce_MPDE
1097 
1098  if (time < TD) maxTimeStep = (0.1*TD );
1099  else maxTimeStep = (0.1*PER);
1100 
1101  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1102  {
1103  Xyce::dout() << "\nIn PulseData::getMaxTimeStepSize. ";
1104  Xyce::dout() << " maxTimeStep = "<< maxTimeStep;
1105  Xyce::dout() << " TD = " << TD << " PER = " <<PER;
1106  Xyce::dout() << " time = "<< time << std::endl;
1107  }
1108 
1109  return maxTimeStep;
1110 }
1111 
1112 // Class PWLinData
1113 
1114 //-----------------------------------------------------------------------------
1115 // Function : PWLinData::PWLinData
1116 // Purpose : constructor
1117 // Special Notes :
1118 // Scope : public
1119 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1120 // Creation Date : 3/16/00
1121 //-----------------------------------------------------------------------------
1123  const DeviceEntity & device,
1124  const std::vector<Param> & paramRef,
1125  const SolverState & ss1,
1126  const DeviceOptions & do1)
1127  : SourceData(ss1,do1),
1128  NUM(0),
1129  REPEAT(false),
1130  REPEATTIME(0.0),
1131  TD(0.0),
1132  loc_(0),
1133  starttime_(0.0)
1134 {
1135  std::vector<Param>::const_iterator iter = paramRef.begin();
1136  std::vector<Param>::const_iterator last = paramRef.end();
1137 
1138  for ( ; iter != last; ++iter)
1139  {
1140  const std::string & tmpname = iter->tag();
1141  const bool & tmpgiven = iter->given();
1142 
1143  if (tmpname == "NUM") NUM = iter->getImmutableValue<int>();
1144  if (tmpname == "R" && tmpgiven == true)
1145  {
1146  REPEAT = true;
1147  REPEATTIME = iter->getImmutableValue<double>();
1148  }
1149  if (tmpname == "TD") TD = iter->getImmutableValue<double>();
1150 
1151  if ( tmpname == "T" && iter->given() )
1152  {
1153  time = iter->getImmutableValue<double>();
1154  ++iter;
1155 
1156  TVVEC.push_back(std::pair<double,double>(time, iter->getImmutableValue<double>()));
1157  }
1158  }
1159 
1160  if (NUM == 0)
1161  UserError(device) << "At least one voltage/time pair must be specified for the PWL source function";
1162 
1163  if (REPEATTIME < 0 || REPEATTIME >=TVVEC[NUM-1].first)
1164  UserError(device) << "PWL source's repeat value (R) must be >= 0 and < last value in Time-Voltage list";
1165 
1166  typeName_ = "PWL";
1167 }
1168 
1169 //-----------------------------------------------------------------------------
1170 // Function : PWLinData::PWLinData
1171 // Purpose : destructor
1172 // Special Notes :
1173 // Scope : public
1174 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1175 // Creation Date : 3/16/00
1176 //-----------------------------------------------------------------------------
1178 {}
1179 
1180 //-----------------------------------------------------------------------------
1181 // Function : PWLinData::printOutParams
1182 // Purpose :
1183 // Special Notes :
1184 // Scope : public
1185 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1186 // Creation Date : 6/21/00
1187 //-----------------------------------------------------------------------------
1189 {
1190  Xyce::dout() << std::endl;
1191  Xyce::dout() << " NUM = " << NUM << std::endl;
1192  Xyce::dout() << " REPEAT = " << REPEAT << std::endl;
1193  Xyce::dout() << " REPEATTIME = " << REPEATTIME << std::endl;
1194  Xyce::dout() << " TD = " << TD << std::endl;
1195  Xyce::dout() << " loc_ = " << loc_ << std::endl;
1196  Xyce::dout() << " starttime_ = " << starttime_ << std::endl;
1197 
1198  Xyce::dout() << " Time Voltage" << std::endl;
1199  for( int i = 0; i < NUM; ++i )
1200  Xyce::dout() << " " << TVVEC[i].first << " " << TVVEC[i].second << std::endl;
1201 
1202  Xyce::dout() << std::endl;
1203 }
1204 
1205 // Additional Declarations
1206 
1207 //-----------------------------------------------------------------------------
1208 // Function : PWLinData::updateSource
1209 // Purpose :
1210 // Special Notes :
1211 // Scope : public
1212 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1213 // Creation Date : 4/24/00
1214 //-----------------------------------------------------------------------------
1216 {
1217 
1218  bool bsuccess = true;
1219 
1220  if (!initializeFlag_) bsuccess = initializeSource ();
1221 
1222  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1223  {
1224  Xyce::dout() << std::endl;
1225  Xyce::dout() << " PWLinData::updateSource\n";
1226  printOutParams();
1227  }
1228 
1229  time = getTime_();
1230 
1231  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1232  {
1233  Xyce::dout() << Xyce::section_divider << std::endl;
1234  Xyce::dout() << " Time = " << time << std::endl;
1235  }
1236 
1237  double time1, time2, voltage1, voltage2;
1238  double simtime = time;
1239 
1240  if( time >= TD )
1241  {
1242  time -= TD;
1243 
1244  if( time <= TVVEC[NUM-1].first )
1245  {
1246  for( int i = 0; i < NUM; ++i )
1247  if( time < TVVEC[i].first ) {loc_ = i;break;}
1248 
1249  if( loc_ == 0 )
1250  {
1251  time1 = 0.0;
1252  voltage1 = 0.0;
1253  }
1254  else
1255  {
1256  time1 = TVVEC[loc_-1].first;
1257  voltage1 = TVVEC[loc_-1].second;
1258  }
1259  time2 = TVVEC[loc_].first;
1260  voltage2 = TVVEC[loc_].second;
1261 
1262  }
1263  else if( !REPEAT )
1264  {
1265  // this has the net-effect of setting SourceValue = voltage2
1266  // when combined with the next if-else block
1267  time1 = 0.0;
1268  time2 = 1.0;
1269  voltage1 = voltage2 = TVVEC[NUM-1].second;
1270  }
1271  else
1272  {
1273  double looptime = TVVEC[NUM-1].first - REPEATTIME;
1274  time -= TVVEC[NUM-1].first;
1275  time -= looptime * floor(time / looptime);
1276  time += REPEATTIME;
1277 
1278  for( int i = 0; i < NUM; ++i )
1279  {
1280  if( time < TVVEC[i].first ) {loc_ = i;break;}
1281  }
1282  if (time == REPEATTIME)
1283  {
1284  time1 = 0.0;
1285  time2 = 1.0;
1286  voltage1 = voltage2 = TVVEC[NUM-1].second;
1287  }
1288  else
1289  {
1290  if( loc_ == 0 )
1291  {
1292  time1 = REPEATTIME;
1293  voltage1 = TVVEC[NUM-1].second;
1294  }
1295  else
1296  {
1297  time1 = TVVEC[loc_-1].first;
1298  voltage1 = TVVEC[loc_-1].second;
1299  }
1300  time2 = TVVEC[loc_].first;
1301  voltage2 = TVVEC[loc_].second;
1302  }
1303 
1304  }
1305 
1306  if( time1 == time2 )
1307  SourceValue = voltage2;
1308  else
1309  {
1310  double length = time2 - time1;
1311  SourceValue = ( time2 - time ) * voltage1 / length;
1312  SourceValue += ( -time1 + time ) * voltage2 / length;
1313  }
1314 
1315  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1316  {
1317  Xyce::dout() << "time: " << time << std::endl;
1318  Xyce::dout() << "time1: " << time1 << std::endl;
1319  Xyce::dout() << "time2: " << time2 << std::endl;
1320  Xyce::dout() << "voltage1: " << voltage1 << std::endl;
1321  Xyce::dout() << "voltage2: " << voltage2 << std::endl;
1322  Xyce::dout() << "Src: " << SourceValue << std::endl;
1323  Xyce::dout() << Xyce::section_divider << std::endl;
1324  }
1325  }
1326  else
1327  {
1328  SourceValue = 0.0;
1329  }
1330 
1331 
1332  resetFlag_ = false;
1333 
1334  return bsuccess;
1335 }
1336 
1337 //-----------------------------------------------------------------------------
1338 // Function : PWLinData::getBreakPoints
1339 // Purpose :
1340 // Special Notes :
1341 // Scope : public
1342 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1343 // Creation Date : 06/08/01
1344 //-----------------------------------------------------------------------------
1346  (std::vector<Util::BreakPoint> & breakPointTimes )
1347 {
1348  bool bsuccess = true;
1349 
1350  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1351  {
1352  Xyce::dout() << " In PWLinData::getBreakPoints\n";
1353  }
1354 
1355  if (!initializeFlag_) bsuccess = initializeSource ();
1356 
1357  time = solState_.currTime;
1358 
1359  time -= TD;
1360 
1361  // if it's a repeating signal, figure out what period we are in
1362  if (REPEAT && time >= TVVEC[NUM - 1].first)
1363  {
1364  double loopBaseTime = 0.0;
1365  double bp_time;
1366 
1367  double looptime = TVVEC[NUM-1].first - REPEATTIME;
1368  loopBaseTime = looptime * (1.0 + floor((time - TVVEC[NUM - 1].first) / looptime));
1369  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1370  {
1371  Xyce::dout() << "loopBaseTime: " << loopBaseTime << std::endl;
1372  Xyce::dout() << "floor function: " << floor((time - TVVEC[NUM - 1].first) / (TVVEC[NUM - 1].first - REPEATTIME)) << std::endl;
1373  }
1374 
1375  for (int i = 0; i < NUM; ++i)
1376  {
1377  bp_time = TVVEC[i].first;
1378  if (bp_time >= REPEATTIME)
1379  {
1380  breakPointTimes.push_back(bp_time + loopBaseTime + TD);
1381  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1382  {
1383  Xyce::dout() << "bp_time + loopBaseTime + TD: " << bp_time + loopBaseTime + TD << std::endl;
1384  }
1385  }
1386  }
1387  }
1388  else
1389  {
1390  for (int i = 0; i < NUM; ++i)
1391  {
1392  double bp_time = TVVEC[i].first;
1393  breakPointTimes.push_back(bp_time+TD);
1394  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
1395  {
1396  Xyce::dout() << "bp_time + TD: " << bp_time + TD << std::endl;
1397  }
1398  }
1399  }
1400  // now that we know which period this is, push_back all breakpoints
1401  // in this period and the next.
1402 
1403  return bsuccess;
1404 }
1405 
1406 // Class SFFMData
1407 
1408 //-----------------------------------------------------------------------------
1409 // Function : SFFMData::SFFMData
1410 // Purpose : constructor
1411 // Special Notes :
1412 // Scope : public
1413 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1414 // Creation Date : 3/16/00
1415 //-----------------------------------------------------------------------------
1416 
1418  const DeviceEntity & device,
1419  const std::vector<Param> & paramRef,
1420  const SolverState & ss1,
1421  const DeviceOptions & do1)
1422  : SourceData(ss1,do1),
1423  V0 (0.0),
1424  VA (0.0),
1425  FC (0.0),
1426  MDI (0.0),
1427  FS (0.0),
1428  V0given (false),
1429  VAgiven (false),
1430  FCgiven (false),
1431  MDIgiven (false),
1432  FSgiven (false)
1433 
1434 {
1435  std::vector<Param>::const_iterator iter = paramRef.begin();
1436  std::vector<Param>::const_iterator last = paramRef.end();
1437 
1438  for ( ; iter != last; ++iter)
1439  {
1440  const std::string & tmpname = iter->tag();
1441 
1442  if (tmpname == "V0") { V0 = iter->getImmutableValue<double>(); V0given = iter->given(); }
1443  if (tmpname == "VA") { VA = iter->getImmutableValue<double>(); VAgiven = iter->given(); }
1444  if (tmpname == "FC") { FC = iter->getImmutableValue<double>(); FCgiven = iter->given(); }
1445  if (tmpname == "MDI") { MDI = iter->getImmutableValue<double>(); MDIgiven = iter->given(); }
1446  if (tmpname == "FS") { FS = iter->getImmutableValue<double>(); FSgiven = iter->given(); }
1447  }
1448 
1449  if (!(V0given && VAgiven))
1450  UserError(device) << "V0 and VA are required for the SFFM source function";
1451 
1452  typeName_ = "SFFM";
1453 }
1454 
1455 //-----------------------------------------------------------------------------
1456 // Function : SFFMData::~SFFMData
1457 // Purpose : destructor
1458 // Special Notes :
1459 // Scope : public
1460 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1461 // Creation Date : 3/16/00
1462 //-----------------------------------------------------------------------------
1464 {}
1465 
1466 // Additional Declarations
1467 
1468 //-----------------------------------------------------------------------------
1469 // Function : SFFMData::printOutParams
1470 // Purpose :
1471 // Special Notes :
1472 // Scope : public
1473 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1474 // Creation Date : 5/01/00
1475 //-----------------------------------------------------------------------------
1476 
1478 {
1479  Xyce::dout() << "SFFMData:\n";
1480  Xyce::dout() << "V0 = " << V0 << std::endl;
1481  Xyce::dout() << "VA = " << VA << std::endl;
1482  Xyce::dout() << "FC = " << FC << std::endl;
1483  Xyce::dout() << "MDI = " << MDI << std::endl;
1484  Xyce::dout() << "FS = " << FS << std::endl;
1485 }
1486 
1487 //-----------------------------------------------------------------------------
1488 // Function : SFFMData::initializeSource
1489 // Purpose :
1490 // Special Notes :
1491 // Scope : public
1492 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1493 // Creation Date : 9/04/01
1494 //-----------------------------------------------------------------------------
1495 
1497 {
1498  // If neccessary, set the defaults:
1499  double tstop = solState_.finalTime;
1500 
1501  if (!FCgiven) FC = 1.0/tstop;
1502  if (!FSgiven) FS = 1.0/tstop;
1503 
1504  initializeFlag_ = true;
1505 
1506  return true;
1507 }
1508 
1509 //-----------------------------------------------------------------------------
1510 // Function : SFFMData::updateSource
1511 // Purpose :
1512 // Special Notes :
1513 //
1514 // V0 - offset (V or A)
1515 // VA - Amplitude (V or A)
1516 // FC - carrier frequency
1517 // MDI - modulation index
1518 // FS - signal frequency
1519 //
1520 // Scope : public
1521 // Creator : Eric Keiter, SNL, Parallel Computational Sciences
1522 // Creation Date : 4/24/00
1523 //-----------------------------------------------------------------------------
1524 
1526 {
1527  bool bsuccess = true;
1528 
1529  if (!initializeFlag_) bsuccess = initializeSource ();
1530 
1531 //#ifdef Xyce_MPDE
1532  time = getTime_();
1533 //#else
1534 // time = solState_.currTime;
1535 //#endif // Xyce_MPDE
1536 
1537  double mpi = M_PI;
1538  SourceValue = V0 + VA * sin((2 * mpi * FC * time) +
1539  MDI * sin (2 * mpi * FS * time));
1540 
1541  resetFlag_ = false;
1542 
1543  return bsuccess;
1544 }
1545 
1546 //-----------------------------------------------------------------------------
1547 // Function : SFFMData::getParams
1548 // Purpose : Pass back the SFFM source params.
1549 // Special Notes :
1550 //
1551 // Scope : public
1552 // Creator : Dave Shirley, PSSI
1553 // Creation Date : 4/14/05
1554 //-----------------------------------------------------------------------------
1555 void SFFMData::getParams(double *params)
1556 {
1557  params[0] = V0;
1558  params[1] = VA;
1559  params[2] = FC;
1560  params[3] = MDI;
1561  params[4] = FS;
1562 }
1563 
1564 //-----------------------------------------------------------------------------
1565 // Function : SFFMData::setParams
1566 // Purpose : Update the SFFM source params.
1567 // Special Notes :
1568 //
1569 // Scope : public
1570 // Creator : Dave Shirley, PSSI
1571 // Creation Date : 4/14/05
1572 //-----------------------------------------------------------------------------
1573 void SFFMData::setParams(double *params)
1574 {
1575  bool reset=false;
1576  if (V0 != params[0])
1577  {
1578  V0 = params[0];
1579  reset = true;
1580  }
1581  if (VA != params[1])
1582  {
1583  VA = params[1];
1584  reset = true;
1585  }
1586  if (FC != params[2])
1587  {
1588  FC = params[2];
1589  reset = true;
1590  }
1591  if (MDI != params[3])
1592  {
1593  MDI = params[3];
1594  reset = true;
1595  }
1596  if (FS != params[4])
1597  {
1598  FS = params[4];
1599  reset = true;
1600  }
1601  if (reset)
1602  updateSource();
1603 }
1604 
1605 // Class ACData
1606 
1607 //-----------------------------------------------------------------------------
1608 // Function : ACData::ACData
1609 // Purpose : constructor
1610 // Special Notes :
1611 // Scope : public
1612 // Creator : Ting Mei, SNL
1613 // Creation Date :
1614 //-----------------------------------------------------------------------------
1615 
1617  const DeviceEntity & device,
1618  const std::vector<Param> & paramRef,
1619  const SolverState & ss1,
1620  const DeviceOptions & do1)
1621  : SourceData(ss1,do1),
1622  ACMAG(1.0),
1623  ACPHASE(0.0),
1624  ACMAGgiven(false),
1625  ACPHASEgiven(false)
1626 {
1627  std::vector<Param>::const_iterator iter = paramRef.begin();
1628  std::vector<Param>::const_iterator last = paramRef.end();
1629 
1630  for ( ; iter != last; ++iter)
1631  {
1632  const std::string & tmpname = iter->tag();
1633 
1634  if (tmpname == "ACMAG") { ACMAG = iter->getImmutableValue<double>(); ACMAGgiven = iter->given();}
1635  if (tmpname == "ACPHASE") { ACPHASE = iter->getImmutableValue<double>(); ACPHASEgiven = iter->given();}
1636  }
1637 
1638  typeName_ = "AC";
1639  defaultParamName_ = "ACMAG";
1640 }
1641 
1642 //-----------------------------------------------------------------------------
1643 // Function : ACData::~ACData
1644 // Purpose : destructor
1645 // Special Notes :
1646 // Scope : public
1647 // Creator : Ting Mei, SNL
1648 // Creation Date : 3/16/00
1649 //-----------------------------------------------------------------------------
1651 {}
1652 
1653 //-----------------------------------------------------------------------------
1654 // Function : ACData::printOutParams
1655 // Purpose :
1656 // Special Notes :
1657 // Scope : public
1658 // Creator : Ting Mei, SNL
1659 // Creation Date : 6/21/00
1660 //-----------------------------------------------------------------------------
1661 
1663 
1664 {
1665  Xyce::dout() << "ACData:\n";
1666  Xyce::dout() << "ACMAG = " << ACMAG << std::endl;
1667  Xyce::dout() << "ACPHASE = " << ACPHASE << std::endl;
1668 }
1669 
1670 //-----------------------------------------------------------------------------
1671 // Function : ACData::updateSource
1672 // Purpose : Update the sinwave source.
1673 // Special Notes :
1674 //
1675 // Scope : public
1676 // Creator : Ting Mei, SNL
1677 // Creation Date :
1678 //-----------------------------------------------------------------------------
1679 
1681 {
1682  bool bsuccess = true;
1683 
1684  double mpi = M_PI;
1685 
1686  if (!initializeFlag_) bsuccess = initializeSource ();
1687 
1688  if (realFlag_)
1689  {
1690  SourceValue = ACMAG * cos(2.0*mpi*ACPHASE/360);
1691  }
1692  else
1693  {
1694  SourceValue = ACMAG * sin(2.0*mpi*ACPHASE/360);
1695  }
1696 
1697  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS))
1698  {
1699  Xyce::dout() << " SourceValue = " << SourceValue << std::endl;
1700  }
1701 
1702  resetFlag_ = false;
1703 
1704  return bsuccess;
1705 }
1706 
1707 //-----------------------------------------------------------------------------
1708 // Function : ACData::getParams
1709 // Purpose : Pass back the AC source params.
1710 // Special Notes :
1711 // Scope : public
1712 // Creator : Ting Mei
1713 // Creation Date :
1714 //-----------------------------------------------------------------------------
1715 void ACData::getParams(double *params)
1716 {
1717  params[0] = ACMAG;
1718  params[1] = ACPHASE;
1719 }
1720 
1721 //-----------------------------------------------------------------------------
1722 // Function : ACData::setParams
1723 // Purpose : Update the AC source params.
1724 // Special Notes :
1725 //
1726 // Scope : public
1727 // Creator : Ting Mei
1728 // Creation Date :
1729 //-----------------------------------------------------------------------------
1730 void ACData::setParams(double *params)
1731 {
1732  bool reset=false;
1733  if (ACMAG!= params[0])
1734  {
1735  ACMAG = params[0];
1736  reset = true;
1737  }
1738  if ( ACPHASE != params[1])
1739  {
1740  ACPHASE = params[1];
1741  reset = true;
1742  }
1743  if (reset)
1744  updateSource();
1745 }
1746 
1747 
1748 // Class ConstData
1749 
1750 //-----------------------------------------------------------------------------
1751 // Function : ConstData::ConstData
1752 // Purpose : constructor
1753 // Special Notes :
1754 // Scope : public
1755 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
1756 // Creation Date : 10/5/00
1757 //-----------------------------------------------------------------------------
1758 
1760  const DeviceEntity & device,
1761  const std::vector<Param> & paramRef,
1762  const SolverState & ss1,
1763  const DeviceOptions & do1)
1764  : SourceData(ss1,do1),
1765  V0(0.0)
1766 {
1767  std::vector<Param>::const_iterator iter = paramRef.begin();
1768  std::vector<Param>::const_iterator last = paramRef.end();
1769 
1770  for ( ; iter != last; ++iter)
1771  {
1772  const std::string & tmpname = iter->tag();
1773  if (tmpname == "DCV0")
1774  {
1775  V0 = iter->getImmutableValue<double>();
1776  }
1777  }
1778 
1779  typeName_ = "CONST";
1780  defaultParamName_ = "DCV0";
1781 // SourceValue = V0; // updateSource function is a no-op, essentially.
1782 }
1783 
1784 //-----------------------------------------------------------------------------
1785 // Function : ConstData::~ConstData
1786 // Purpose : destructor
1787 // Special Notes :
1788 // Scope : public
1789 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
1790 // Creation Date : 10/5/00
1791 //-----------------------------------------------------------------------------
1793 {}
1794 
1795 //-----------------------------------------------------------------------------
1796 // Function : ConstData::printOutParams
1797 // Purpose :
1798 // Special Notes :
1799 // Scope : public
1800 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
1801 // Creation Date : 10/5/00
1802 //-----------------------------------------------------------------------------
1803 
1805 
1806 {
1807  Xyce::dout() << "ConstData:\n";
1808  Xyce::dout() << "V0: " << V0 << std::endl;
1809 }
1810 
1811 // Additional Declarations
1812 
1813 //-----------------------------------------------------------------------------
1814 // Function : ConstData::updateSource
1815 // Purpose : Update the const source.
1816 // Special Notes : ERK: this is now a no-op, as the source value is set in
1817 // the constructor. The value for this source never changes,
1818 // so there isn't any point is re-setting the same value
1819 // over and over.
1820 //
1821 // Scope : public
1822 // Creator : Robert Hoekstra, SNL, Parallel Computational Sciences
1823 // Creation Date : 10/5/00
1824 //-----------------------------------------------------------------------------
1826 {
1827 
1828  bool bsuccess = true;
1829 
1830  if (!initializeFlag_) bsuccess = initializeSource ();
1831 
1832  SourceValue = V0;
1833 
1834  resetFlag_ = false;
1835 
1836  return bsuccess;
1837 
1838 }
1839 
1840 //-----------------------------------------------------------------------------
1841 // Function : ConstData::getParams
1842 // Purpose : Pass back the const source params.
1843 // Special Notes :
1844 //
1845 // Scope : public
1846 // Creator : Dave Shirley, PSSI
1847 // Creation Date : 4/13/05
1848 //-----------------------------------------------------------------------------
1849 void ConstData::getParams(double *params)
1850 {
1851  params[0] = V0;
1852 }
1853 
1854 //-----------------------------------------------------------------------------
1855 // Function : ConstData::setParams
1856 // Purpose : Update the const source params.
1857 // Special Notes :
1858 //
1859 // Scope : public
1860 // Creator : Dave Shirley, PSSI
1861 // Creation Date : 4/13/05
1862 //-----------------------------------------------------------------------------
1863 void ConstData::setParams(double *params)
1864 {
1865  if (V0 != params[0])
1866  {
1867  V0 = params[0];
1868  updateSource();
1869  }
1870 }
1871 
1872 
1873 // Class SmoothPulseData
1874 
1875 //-----------------------------------------------------------------------------
1876 // Function : SmoothPulseData::SmoothPulseData
1877 // Purpose : constructor
1878 // Special Notes :
1879 // Scope : public
1880 // Creator : Richard Schiek, Electrical Systems Modeling
1881 // Creation Date : 04/13/11
1882 //-----------------------------------------------------------------------------
1883 
1885  const DeviceEntity & device,
1886  const std::vector<Param> & paramRef,
1887  const SolverState & ss1,
1888  const DeviceOptions & do1)
1889  : SourceData (ss1,do1),
1890  V1 (0.0),
1891  V2 (0.0),
1892  TD (0.0),
1893  TR (0.0),
1894  TF (0.0),
1895  PW (0.0),
1896  PER (0.0),
1897  riseScaleFactor_(0.0),
1898  fallScaleFactor_(0.0),
1899  functionScaleFactor_(20.0),
1900  V1given (false),
1901  V2given (false),
1902  TDgiven (false),
1903  TRgiven (false),
1904  TFgiven (false),
1905  PWgiven (false),
1906  PERgiven (false),
1907  functionScaleFactorGiven_(false)
1908 {
1909 
1910  // Get the user-defined values:
1911  std::vector<Param>::const_iterator iter = paramRef.begin();
1912  std::vector<Param>::const_iterator last = paramRef.end();
1913 
1914  for ( ; iter != last; ++iter)
1915  {
1916  const std::string & tmpname = iter->tag();
1917 
1918  if (tmpname == "V1") { V1 = iter->getImmutableValue<double>(); V1given = iter->given();}
1919  if (tmpname == "V2") { V2 = iter->getImmutableValue<double>(); V2given = iter->given();}
1920  if (tmpname == "TD") { TD = iter->getImmutableValue<double>(); TDgiven = iter->given();}
1921  if (tmpname == "TR") { TR = iter->getImmutableValue<double>(); TRgiven = iter->given();}
1922  if (tmpname == "TF") { TF = iter->getImmutableValue<double>(); TFgiven = iter->given();}
1923  if (tmpname == "PW") { PW = iter->getImmutableValue<double>(); PWgiven = iter->given();}
1924  if (tmpname == "PER") { PER = iter->getImmutableValue<double>(); PERgiven = iter->given();}
1925  if (tmpname == "SF") { functionScaleFactor_ = iter->getImmutableValue<double>(); functionScaleFactorGiven_ = iter->given();}
1926  }
1927 
1928  typeName_ = "SMOOTHPULSE";
1929  defaultParamName_ = "V2";
1930 }
1931 
1932 //-----------------------------------------------------------------------------
1933 // Function : SmoothPulseData::~SmoothPulseData
1934 // Purpose : destructor
1935 // Special Notes :
1936 // Scope : public
1937 // Creator : Richard Schiek, Electrical Systems Modeling
1938 // Creation Date : 04/13/11
1939 //-----------------------------------------------------------------------------
1941 {}
1942 
1943 // Additional Declarations
1944 
1945 //-----------------------------------------------------------------------------
1946 // Function : SmoothPulseData::printOutParams
1947 // Purpose :
1948 // Special Notes :
1949 // Scope : public
1950 // Creator : Richard Schiek, Electrical Systems Modeling
1951 // Creation Date : 04/13/11
1952 //-----------------------------------------------------------------------------
1953 
1955 {
1956 
1957  Xyce::dout() << std::endl;
1958  Xyce::dout() << " SmoothPulseData::printOutParams\n";
1959  Xyce::dout() << " V1 = " << V1 << std::endl;
1960  Xyce::dout() << " V2 = " << V2 << std::endl;
1961 
1962  Xyce::dout() << " TD = " << TD << std::endl;
1963  Xyce::dout() << " TR = " << TR << std::endl;
1964  Xyce::dout() << " TF = " << TF << std::endl;
1965  Xyce::dout() << " PW = " << PW << std::endl;
1966  Xyce::dout() << " PER = " << PER << std::endl;
1967  Xyce::dout() << " SF = " << functionScaleFactor_ << std::endl;
1968  Xyce::dout() << std::endl;
1969 
1970 }
1971 
1972 //-----------------------------------------------------------------------------
1973 // Function : SmoothPulseData::initializeSource
1974 // Purpose :
1975 // Special Notes :
1976 // Scope : public
1977 // Creator : Richard Schiek, Electrical Systems Modeling
1978 // Creation Date : 04/13/11
1979 //-----------------------------------------------------------------------------
1980 
1982 {
1983 
1984  // If neccessary, set the defaults:
1985 
1986  double tstep = solState_.startingTimeStep;
1987  double tstop = solState_.finalTime;
1988 
1989  if (!TDgiven) TD = 0.0;
1990  if (!TRgiven) TR = tstep;
1991  if (!TFgiven) TF = tstep;
1992  if (!PWgiven) PW = tstop;
1993  if (!PERgiven) PER = tstop;
1994  // scale the amplitude of the response so it better joins the low and hi value
1995  // riseFallScaleFactor_ = M_PI;
1996  riseScaleFactor_ = 2.0*fabs( atan(M_PI * functionScaleFactor_ * (0.5*TR) / TR) );
1997  fallScaleFactor_ = 2.0*fabs( atan(M_PI * functionScaleFactor_ * (0.5*TF) / TF) );
1998  initializeFlag_ = true;
1999 
2000  return true;
2001 }
2002 
2003 //-----------------------------------------------------------------------------
2004 // Function : SmoothPulseData::updateSource
2005 // Purpose :
2006 // Special Notes :
2007 // Scope : public
2008 // Creator : Richard Schiek, Electrical Systems Modeling
2009 // Creation Date : 04/13/11
2010 //-----------------------------------------------------------------------------
2011 
2013 
2014 {
2015  bool bsuccess = true;
2016 
2017  if (!initializeFlag_) bsuccess = initializeSource ();
2018 
2019  double basetime = 0;
2020 
2021  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
2022  {
2023  Xyce::dout() << " SmoothPulseData::updateSources\n";
2024  printOutParams();
2025  }
2026 
2027  time = getTime_();
2028 
2029  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
2030  {
2031  Xyce::dout() << " Time = " << time << std::endl;
2032  }
2033 
2034  time -= TD;
2035 
2036  if (time > PER && PER != 0.0)
2037  {
2038  // repeating signal - figure out where we are in period
2039  basetime = PER * floor(time/PER);
2040  time -= basetime;
2041  }
2042 
2043  // This section got ugly because of a nasty roundoff bug.
2044  // Instead of doing "time > X" you need also check that time
2045  // is not within bptol of X.
2046  // So the following translation is used:
2047  // Instead of: we do:
2048  // time > X time>X && fabs(time-x)>bptol
2049  // time <= X time<X || fabs(time-x)<bptol
2050 
2051  if (time <= 0 || (time > (TR + PW + TF) &&
2052  (fabs (time - (TR+PW+TF)) > solState_.bpTol) ) )
2053  {
2054  SourceValue = V1;
2055  }
2056  else if ((time > TR && fabs(time-TR) > solState_.bpTol)
2057  && (time < (TR + PW) || fabs (time-(TR+PW))<solState_.bpTol) )
2058  {
2059  SourceValue = V2;
2060  }
2061  else if (time > 0 &&
2062  (time < TR || fabs(time-TR) < solState_.bpTol))
2063  {
2064  if (TR != 0.0)
2065  SourceValue = V1 + (V2 - V1) *
2066  (((atan(M_PI * functionScaleFactor_ * (time-0.5*TR) / TR))/riseScaleFactor_) + 0.5);
2067  else
2068  SourceValue = V1;
2069  }
2070  else
2071  { // time > (TR + PW) && <= (TR + PW + TF)
2072  if (TF != 0.0)
2073  SourceValue = V2 + (V1 - V2) *
2074  (((atan(M_PI * functionScaleFactor_ * (time - (TR + PW + 0.5*TF)) / TF))/fallScaleFactor_) + 0.5);
2075  else
2076  SourceValue = V2;
2077  }
2078 
2079  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
2080  {
2081  Xyce::dout() << " SourceValue = " << SourceValue << std::endl;
2082  }
2083 
2084  resetFlag_ = false;
2085 
2086  return bsuccess;
2087 }
2088 
2089 //-----------------------------------------------------------------------------
2090 // Function : SmoothPulseData::getParams
2091 // Purpose : Pass back the pulse source params.
2092 // Special Notes :
2093 //
2094 // Scope : public
2095 // Creator : Richard Schiek, Electrical Systems Modeling
2096 // Creation Date : 04/13/11
2097 //-----------------------------------------------------------------------------
2098 void SmoothPulseData::getParams(double *params)
2099 {
2100  params[0] = V1;
2101  params[1] = V2;
2102  params[2] = TD;
2103  params[3] = TR;
2104  params[4] = TF;
2105  params[5] = PW;
2106  params[6] = PER;
2107 }
2108 
2109 //-----------------------------------------------------------------------------
2110 // Function : SmoothPulseData::setParams
2111 // Purpose : Update the pulse source params.
2112 // Special Notes :
2113 //
2114 // Scope : public
2115 // Creator : Richard Schiek, Electrical Systems Modeling
2116 // Creation Date : 04/13/11
2117 //-----------------------------------------------------------------------------
2118 void SmoothPulseData::setParams(double *params)
2119 {
2120  bool reset=false;
2121  if (V1 != params[0])
2122  {
2123  V1 = params[0];
2124  reset = true;
2125  }
2126  if (V2 != params[1])
2127  {
2128  V2 = params[1];
2129  reset = true;
2130  }
2131  if (TD != params[2])
2132  {
2133  TD = params[2];
2134  reset = true;
2135  }
2136  if (TR != params[3])
2137  {
2138  TR = params[3];
2139  reset = true;
2140  }
2141  if (TF != params[4])
2142  {
2143  TF = params[4];
2144  reset = true;
2145  }
2146  if (PW != params[5])
2147  {
2148  PW = params[5];
2149  reset = true;
2150  }
2151  if (PER != params[6])
2152  {
2153  PER = params[6];
2154  reset = true;
2155  }
2156  if (reset)
2157  updateSource();
2158 }
2159 
2160 //-----------------------------------------------------------------------------
2161 // Function : SmoothPulseData::getBreakPoints
2162 // Purpose : This function adds break points to a vector of breakpoints.
2163 //
2164 // It does not bother to check them in any way, or put them
2165 // in order. It only adds them in.
2166 //
2167 // Special Notes : Like much of this file, this is adapted from spice 3f5.
2168 // Some of the stuff in it is a little hokey, and may get
2169 // removed or modified later.
2170 //
2171 // Scope : public
2172 // Creator : Richard Schiek, Electrical Systems Modeling
2173 // Creation Date : 04/13/11
2174 //-----------------------------------------------------------------------------
2176  (std::vector<Util::BreakPoint> & breakPointTimes )
2177 {
2178  bool bsuccess = true;
2179 
2180  if (!initializeFlag_) bsuccess = initializeSource ();
2181 
2182  return bsuccess;
2183 }
2184 
2185 //-----------------------------------------------------------------------------
2186 // Function : SmoothPulseData::getMaxTimeStepSize
2187 // Purpose :
2188 // Special Notes :
2189 // Scope : public
2190 // Creator : Richard Schiek, Electrical Systems Modeling
2191 // Creation Date : 04/13/11
2192 //-----------------------------------------------------------------------------
2194 {
2195  double maxTimeStep = devOptions_.defaultMaxTimeStep;
2196 
2197  // check if we are still in the delay or not.
2198  time = getTime_();
2199 
2200  if (time < TD) maxTimeStep = (0.1*TD );
2201  else maxTimeStep = (0.1*PER);
2202 
2203  if (DEBUG_DEVICE && isActive(Diag::DEVICE_PARAMETERS) && solState_.debugTimeFlag)
2204  {
2205  Xyce::dout() << "\nIn SmoothPulseData::getMaxTimeStepSize. ";
2206  Xyce::dout() << " maxTimeStep = "<< maxTimeStep;
2207  Xyce::dout() << " TD = " << TD << " PER = " <<PER;
2208  Xyce::dout() << " time = "<< time << std::endl;
2209  }
2210 
2211  return maxTimeStep;
2212 }
2213 
2214 } // namespace Device
2215 } // namespace Xyce
void setParams(double *)
virtual bool updateSource()
void setParams(double *)
Pure virtual class to augment a linear system.
std::vector< std::pair< double, double > > TVVEC
void getParams(double *)
#define THETA
const DeviceOptions & devOptions_
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)
void getParams(double *)
void setParams(double *)
ExpData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
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)
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()
ConstData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
virtual bool updateSource()
#define M_PI
const SolverState & solState_
void getParams(double *)
PulseData(const DeviceEntity &device, const std::vector< Param > &paramRef, const SolverState &ss1, const DeviceOptions &do1)
void sourceFunctionMetadata(DeviceParamMap &map)