CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PadeTableODE Class Reference

#include <PadeTableODE.h>

Public Member Functions

void calculate (double tau, double inputCurrent, double dIdt, double d2Id2t, const double *x, unsigned lenX, unsigned firstNode, double *derivative) const
 
unsigned getPadeColumn () const
 
unsigned getPadeRow () const
 
unsigned nParameters () const
 
 PadeTableODE (unsigned padeRow, unsigned padeColumn)
 
void setParameters (const double *pars, unsigned nPars)
 

Private Attributes

unsigned col_
 
unsigned row_
 

Detailed Description

Definition at line 11 of file PadeTableODE.h.

Constructor & Destructor Documentation

PadeTableODE::PadeTableODE ( unsigned  padeRow,
unsigned  padeColumn 
)

Definition at line 6 of file PadeTableODE.cc.

References col_, Exception, row_, and mitigatedMETSequence_cff::U.

7  : row_(padeRow),
8  col_(padeColumn)
9 {
10  if (row_ > 2U) throw cms::Exception(
11  "In PadeTableODE constructor: Pade table row number out of range");
12  if (col_ > 3U) throw cms::Exception(
13  "In PadeTableODE constructor: Pade table column number out of range");
14 }
unsigned col_
Definition: PadeTableODE.h:28
unsigned row_
Definition: PadeTableODE.h:27

Member Function Documentation

void PadeTableODE::calculate ( double  tau,
double  inputCurrent,
double  dIdt,
double  d2Id2t,
const double *  x,
unsigned  lenX,
unsigned  firstNode,
double *  derivative 
) const

Definition at line 16 of file PadeTableODE.cc.

References col_, Exception, row_, metsig::tau, and mitigatedMETSequence_cff::U.

20 {
21  // Check input sanity
22  if (lenX < firstNode + col_) throw cms::Exception(
23  "In PadeTableODE::calculate: insufficient number of variables");
24  if (tau <= 0.0) throw cms::Exception(
25  "In PadeTableODE::calculate: delay time is not positive");
26  if (col_) assert(x);
27  assert(derivative);
28 
29  switch (col_)
30  {
31  case 0U:
32  // Special case: no ODE to solve
33  derivative[firstNode] = 0.0;
34  switch (row_)
35  {
36  case 2U:
37  derivative[firstNode] += 0.5*tau*tau*d2Id2t;
38  case 1U:
39  derivative[firstNode] -= tau*dIdt;
40  case 0U:
41  derivative[firstNode] += currentIn;
42  break;
43 
44  default:
45  assert(0);
46  }
47  break;
48 
49  case 1U:
50  // First order ODE to solve
51  switch (row_)
52  {
53  case 0U:
54  derivative[firstNode] = (currentIn - x[firstNode])/tau;
55  break;
56 
57  case 1U:
58  derivative[firstNode] = 2.0*(currentIn - x[firstNode])/tau - dIdt;
59  break;
60 
61  case 2U:
62  derivative[firstNode] = 3.0*(currentIn - x[firstNode])/tau -
63  2.0*dIdt + 0.5*tau*d2Id2t;
64  break;
65 
66  default:
67  assert(0);
68  }
69  break;
70 
71  case 2U:
72  // Second order ODE to solve
73  derivative[firstNode] = x[firstNode+1];
74  switch (row_)
75  {
76  case 0U:
77  derivative[firstNode+1] =
78  2.0*(currentIn-x[firstNode]-tau*x[firstNode+1])/tau/tau;
79  break;
80 
81  case 1U:
82  derivative[firstNode+1] = (6.0*(currentIn - x[firstNode]) -
83  2.0*tau*dIdt -
84  4.0*tau*x[firstNode+1])/tau/tau;
85  break;
86 
87  case 2U:
88  derivative[firstNode+1] =
89  12.0*(currentIn - x[firstNode])/tau/tau -
90  6.0*(x[firstNode+1] + dIdt)/tau + d2Id2t;
91  break;
92 
93  default:
94  assert(0);
95  }
96  break;
97 
98  case 3U:
99  // Third order ODE to solve
100  derivative[firstNode] = x[firstNode+1];
101  derivative[firstNode+1] = x[firstNode+2];
102  switch (row_)
103  {
104  case 0U:
105  derivative[firstNode+2] =
106  6.0*(currentIn - x[firstNode] - tau*x[firstNode+1] -
107  0.5*tau*tau*x[firstNode+2])/tau/tau/tau;
108  break;
109 
110  case 1U:
111  derivative[firstNode+2] = 24.0/tau/tau/tau*(
112  currentIn - x[firstNode] - 0.25*tau*dIdt -
113  0.75*tau*x[firstNode+1] - 0.25*tau*tau*x[firstNode+2]);
114  break;
115 
116  case 2U:
117  derivative[firstNode+2] = 60.0/tau/tau/tau*(
118  currentIn - x[firstNode] - 0.4*tau*dIdt +
119  0.05*tau*tau*d2Id2t - 0.6*tau*x[firstNode+1] -
120  0.15*tau*tau*x[firstNode+2]);
121  break;
122 
123  default:
124  assert(0);
125  }
126  break;
127 
128  default:
129  //
130  // In principle, it is possible to proceed a bit further, but
131  // we will soon encounter difficulties. For example, row 0 and
132  // column 4 is going to generate a 4th order differential
133  // equation for which all roots of the characteristic equation
134  // still have negative real parts. The most "inconvenient" pair
135  // of roots there is (-0.270556 +- 2.50478 I) which leads
136  // to oscillations with damping. The characteristic equation
137  // of 5th and higher order ODEs are going to have roots with
138  // positive real parts. Unless additional damping is
139  // purposefully introduced into the system, numerical
140  // solutions of such equations will just blow up.
141  //
142  assert(0);
143  }
144 }
Derivative< X, A >::type derivative(const A &_)
Definition: Derivative.h:18
unsigned col_
Definition: PadeTableODE.h:28
unsigned row_
Definition: PadeTableODE.h:27
unsigned PadeTableODE::getPadeColumn ( ) const
inline

Definition at line 22 of file PadeTableODE.h.

References col_.

22 {return col_;}
unsigned col_
Definition: PadeTableODE.h:28
unsigned PadeTableODE::getPadeRow ( ) const
inline

Definition at line 21 of file PadeTableODE.h.

References row_.

21 {return row_;}
unsigned row_
Definition: PadeTableODE.h:27
unsigned PadeTableODE::nParameters ( ) const
inline

Definition at line 23 of file PadeTableODE.h.

References setParameters(), and mitigatedMETSequence_cff::U.

void PadeTableODE::setParameters ( const double *  pars,
unsigned  nPars 
)

Definition at line 146 of file PadeTableODE.cc.

References mitigatedMETSequence_cff::U.

Referenced by nParameters().

147 {
148  assert(nPars == 0U);
149 }

Member Data Documentation

unsigned PadeTableODE::col_
private

Definition at line 28 of file PadeTableODE.h.

Referenced by calculate(), getPadeColumn(), and PadeTableODE().

unsigned PadeTableODE::row_
private

Definition at line 27 of file PadeTableODE.h.

Referenced by calculate(), getPadeRow(), and PadeTableODE().