Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

void Capacitance::time_step (  )  [virtual]

Called on every time step for the element to update itself

Implements Reactive.

Definition at line 69 of file capacitance.cpp.

References Element::b_status.

{
      if (!b_status) return;
      
      double v = p_cnode[0]->v-p_cnode[1]->v;
      double i_eq_new = 0.0, g_eq_new = 0.0;
      
      if ( m_method == Capacitance::m_euler )
      {
            g_eq_new = m_cap/m_delta;
            i_eq_new = -v*g_eq_new;
      }
      else if ( m_method == Capacitance::m_trap ) {
            // TODO Implement + test trapezoidal method
            g_eq_new = 2.*m_cap/m_delta;
      }
      
      if ( g_eq_old != g_eq_new )
      {
            A_g( 0, 0 ) += g_eq_new-g_eq_old;
            A_g( 1, 1 ) += g_eq_new-g_eq_old;
            A_g( 0, 1 ) -= g_eq_new-g_eq_old;
            A_g( 1, 0 ) -= g_eq_new-g_eq_old;
      }
      
      if ( i_eq_new != i_eq_old )
      {
            b_i( 0 ) -= i_eq_new-i_eq_old;
            b_i( 1 ) += i_eq_new-i_eq_old;
      }
      
      g_eq_old = g_eq_new;
      i_eq_old = i_eq_new;
}


Generated by  Doxygen 1.6.0   Back to index