MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
RC Class Reference

#include <RC.h>

+ Collaboration diagram for RC:

Public Member Functions

double getCapacitance () const
 
double getInject () const
 
double getResistance () const
 
double getState () const
 
double getV0 () const
 
void process (const Eref &e, ProcPtr proc)
 
 RC ()
 
void reinit (const Eref &e, ProcPtr proc)
 
void setCapacitance (double capacitance)
 
void setInject (double inject)
 
void setInjectMsg (double inject)
 
void setResistance (double resistance)
 
void setV0 (double voltage)
 

Static Public Member Functions

static const CinfoinitCinfo ()
 

Private Attributes

double capacitance_
 
double dt_tau_
 
double expTau_
 
double inject_
 
double msg_inject_
 
double resistance_
 
double state_
 
double v0_
 

Detailed Description

Definition at line 46 of file RC.h.

Constructor & Destructor Documentation

RC::RC ( )

Definition at line 125 of file RC.cpp.

125  :
126  v0_(0),
127  resistance_(1.0),
128  capacitance_(1.0),
129  state_(0),
130  inject_(0),
131  msg_inject_(0.0),
132  expTau_(0.0),
133  dt_tau_(0.0)
134 {
135  ; // Do nothing
136 }
double inject_
Definition: RC.h:67
double resistance_
Definition: RC.h:64
double capacitance_
Definition: RC.h:65
double state_
Definition: RC.h:66
double expTau_
Definition: RC.h:69
double v0_
Definition: RC.h:63
double msg_inject_
Definition: RC.h:68
double dt_tau_
Definition: RC.h:70

Member Function Documentation

double RC::getCapacitance ( ) const

Definition at line 168 of file RC.cpp.

References capacitance_.

Referenced by initCinfo().

169 {
170 
171  return capacitance_;
172 }
double capacitance_
Definition: RC.h:65

+ Here is the caller graph for this function:

double RC::getInject ( ) const

Definition at line 186 of file RC.cpp.

References inject_.

Referenced by initCinfo().

187 {
188 
189  return inject_;
190 }
double inject_
Definition: RC.h:67

+ Here is the caller graph for this function:

double RC::getResistance ( ) const

Definition at line 156 of file RC.cpp.

References resistance_.

Referenced by initCinfo().

157 {
158 
159  return resistance_;
160 }
double resistance_
Definition: RC.h:64

+ Here is the caller graph for this function:

double RC::getState ( ) const

Definition at line 174 of file RC.cpp.

References state_.

Referenced by initCinfo().

175 {
176 
177  return state_;
178 }
double state_
Definition: RC.h:66

+ Here is the caller graph for this function:

double RC::getV0 ( ) const

Definition at line 144 of file RC.cpp.

References v0_.

Referenced by initCinfo().

145 {
146 
147  return v0_;
148 }
double v0_
Definition: RC.h:63

+ Here is the caller graph for this function:

const Cinfo * RC::initCinfo ( )
static

Definition at line 50 of file RC.cpp.

References getCapacitance(), getInject(), getResistance(), getState(), getV0(), Neutral::initCinfo(), outputOut(), process(), rcCinfo, reinit(), setCapacitance(), setInject(), setInjectMsg(), setResistance(), and setV0().

51 {
52  static DestFinfo process("process",
53  "Handles process call.",
55  static DestFinfo reinit( "reinit",
56  "Handle reinitialization",
57  new ProcOpFunc<RC>( &RC::reinit ));
58  static Finfo* processShared[] = {
59  &process, &reinit
60  };
61  static SharedFinfo proc("proc",
62  "This is a shared message to receive Process messages "
63  "from the scheduler objects."
64  "The first entry in the shared msg is a MsgDest "
65  "for the Process operation. It has a single argument, "
66  "ProcInfo, which holds lots of information about current "
67  "time, thread, dt and so on. The second entry is a MsgDest "
68  "for the Reinit operation. It also uses ProcInfo. ",
69  processShared,
70  sizeof( processShared ) / sizeof( Finfo* ));
71  static ValueFinfo<RC, double> V0( "V0",
72  "Initial value of 'state'",
73  &RC::setV0,
74  &RC::getV0 );
75  static ValueFinfo<RC, double> R( "R",
76  "Series resistance of the RC circuit.",
79  static ValueFinfo<RC, double> C( "C",
80  "Parallel capacitance of the RC circuit.",
83  static ReadOnlyValueFinfo<RC, double> state("state",
84  "Output value of the RC circuit. This is the voltage across the"
85  " capacitor.",
86  &RC::getState);
87  static ValueFinfo<RC, double> inject( "inject",
88  "Input value to the RC circuit.This is handled as an input current to"
89  " the circuit.",
91  &RC::getInject );
92  static DestFinfo injectIn( "injectIn",
93  "Receives input to the RC circuit. All incoming messages are summed up"
94  " to give the total input current." ,
96  static Finfo* rcFinfos[] = {
97  &V0,
98  &R,
99  &C,
100  &state,
101  &inject,
102  outputOut(),
103  &injectIn,
104  &proc,
105  };
106  static string doc[] = {
107  "Name", "RC",
108  "Author", "Subhasis Ray, 2008, NCBS",
109  "Description", "RC circuit: a series resistance R shunted by a capacitance C." };
110  static Dinfo<RC> dinfo;
111  static Cinfo rcCinfo("RC",
113  rcFinfos,
114  sizeof( rcFinfos ) / sizeof( Finfo* ),
115  &dinfo,
116  doc,
117  sizeof(doc)/sizeof(string)
118  );
119  return &rcCinfo;
120 }
void process(const Eref &e, ProcPtr proc)
Definition: RC.cpp:204
double getInject() const
Definition: RC.cpp:186
void setResistance(double resistance)
Definition: RC.cpp:150
void reinit(const Eref &e, ProcPtr proc)
Definition: RC.cpp:234
double getState() const
Definition: RC.cpp:174
Definition: Dinfo.h:60
void setInjectMsg(double inject)
Definition: RC.cpp:192
double getV0() const
Definition: RC.cpp:144
double getResistance() const
Definition: RC.cpp:156
Definition: OpFunc.h:27
void setCapacitance(double capacitance)
Definition: RC.cpp:162
static const Cinfo * rcCinfo
Definition: RC.cpp:122
static SrcFinfo1< double > * outputOut()
Definition: RC.cpp:43
void setInject(double inject)
Definition: RC.cpp:180
static const Cinfo * initCinfo()
Definition: Neutral.cpp:16
void setV0(double voltage)
Definition: RC.cpp:138
double getCapacitance() const
Definition: RC.cpp:168
Definition: Cinfo.h:18
Definition: Finfo.h:12

+ Here is the call graph for this function:

void RC::process ( const Eref e,
ProcPtr  proc 
)

calculates the new voltage across the capacitor. this is the exact solution as described in Electronic Circuit and System Simulation Methods by Lawrance Pillage, McGraw-Hill Professional, 1999. pp 87-100. Eqn: 4.7.21

OR, if we use simple Euler: ///

Definition at line 204 of file RC.cpp.

References expTau_, inject_, msg_inject_, outputOut(), resistance_, and state_.

Referenced by initCinfo().

205 {
206  /*
207  double sum_inject_prev = inject_ + msg_inject_;
208  double sum_inject = inject_ + msg_inject_;
209  double dVin = (sum_inject - sum_inject_prev) * resistance_;
210  double Vin = sum_inject * resistance_;
211  state_ = Vin + dVin - dVin / dt_tau_ +
212  (state_ - Vin + dVin / dt_tau_) * expTau_;
213  sum_inject_prev = sum_inject;
214  msg_inject_ = 0.0;
215  outputOut()->send(e, state_);
216  */
217 
219  // double A = inject + msgInject_;
220  // double B = 1.0/resistance_;
221  // double x = exp( -B * proc->dt / capacitance_ );
222  // state_ = state_ * x + (A/B) * (1.0-x);
223  // double x = exp( -dt_tau_ );
224  state_ = state_ * expTau_ +
226 
228  // state_ += (inject_ + msgInject_ - state_/resistance_ ) * proc->dt / capacitance_;
229 
230  msg_inject_ = 0.0;
231  outputOut()->send(e, state_);
232 }
double inject_
Definition: RC.h:67
double resistance_
Definition: RC.h:64
double state_
Definition: RC.h:66
double expTau_
Definition: RC.h:69
static SrcFinfo1< double > * outputOut()
Definition: RC.cpp:43
double msg_inject_
Definition: RC.h:68

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RC::reinit ( const Eref e,
ProcPtr  proc 
)

Definition at line 234 of file RC.cpp.

References capacitance_, ProcInfo::dt, dt_tau_, expTau_, msg_inject_, outputOut(), resistance_, state_, and v0_.

Referenced by initCinfo().

235 {
236 
237  dt_tau_ = proc->dt / (resistance_ * capacitance_);
238  state_ = v0_;
239  if (dt_tau_ > 1e-15){
240  expTau_ = exp(-dt_tau_);
241  } else {// use approximation
242  expTau_ = 1 - dt_tau_;
243  }
244  msg_inject_ = 0.0;
245  outputOut()->send(e, state_);
246 }
double resistance_
Definition: RC.h:64
double capacitance_
Definition: RC.h:65
double state_
Definition: RC.h:66
double dt
Definition: ProcInfo.h:18
double expTau_
Definition: RC.h:69
static SrcFinfo1< double > * outputOut()
Definition: RC.cpp:43
double v0_
Definition: RC.h:63
double msg_inject_
Definition: RC.h:68
double dt_tau_
Definition: RC.h:70

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RC::setCapacitance ( double  capacitance)

Definition at line 162 of file RC.cpp.

References capacitance_.

Referenced by initCinfo().

163 {
164 
165  capacitance_ = capacitance;
166 }
double capacitance_
Definition: RC.h:65

+ Here is the caller graph for this function:

void RC::setInject ( double  inject)

Definition at line 180 of file RC.cpp.

References inject_.

Referenced by initCinfo().

181 {
182 
183  inject_ = inject;
184 }
double inject_
Definition: RC.h:67

+ Here is the caller graph for this function:

void RC::setInjectMsg ( double  inject)

Definition at line 192 of file RC.cpp.

References msg_inject_.

Referenced by initCinfo().

193 {
194 
195  msg_inject_ += inject;
196 }
double msg_inject_
Definition: RC.h:68

+ Here is the caller graph for this function:

void RC::setResistance ( double  resistance)

Definition at line 150 of file RC.cpp.

References resistance_.

Referenced by initCinfo().

151 {
152 
153  resistance_ = resistance;
154 }
double resistance_
Definition: RC.h:64

+ Here is the caller graph for this function:

void RC::setV0 ( double  voltage)

Definition at line 138 of file RC.cpp.

References v0_.

Referenced by initCinfo().

139 {
140 
141  v0_ = v0;
142 }
double v0_
Definition: RC.h:63

+ Here is the caller graph for this function:

Member Data Documentation

double RC::capacitance_
private

Definition at line 65 of file RC.h.

Referenced by getCapacitance(), reinit(), and setCapacitance().

double RC::dt_tau_
private

Definition at line 70 of file RC.h.

Referenced by reinit().

double RC::expTau_
private

Definition at line 69 of file RC.h.

Referenced by process(), and reinit().

double RC::inject_
private

Definition at line 67 of file RC.h.

Referenced by getInject(), process(), and setInject().

double RC::msg_inject_
private

Definition at line 68 of file RC.h.

Referenced by process(), reinit(), and setInjectMsg().

double RC::resistance_
private

Definition at line 64 of file RC.h.

Referenced by getResistance(), process(), reinit(), and setResistance().

double RC::state_
private

Definition at line 66 of file RC.h.

Referenced by getState(), process(), and reinit().

double RC::v0_
private

Definition at line 63 of file RC.h.

Referenced by getV0(), reinit(), and setV0().


The documentation for this class was generated from the following files: