00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "elementset.h"
00012 #include "vccs.h"
00013
00014 VCCS::VCCS( const double gain )
00015 : Element::Element()
00016 {
00017 m_g = gain;
00018 m_numCBranches = 1;
00019 m_numCNodes = 4;
00020 }
00021
00022 VCCS::~VCCS()
00023 {
00024 }
00025
00026 void VCCS::setGain( const double g )
00027 {
00028 if( g == m_g ) return;
00029
00030 if(p_eSet)
00031 p_eSet->setCacheInvalidated();
00032
00033
00034 m_g = -m_g;
00035 add_initial_dc();
00036
00037
00038 m_g = g;
00039 add_initial_dc();
00040 }
00041
00042
00043 void VCCS::add_map()
00044 {
00045 if(!b_status) return;
00046
00047 if( !p_cnode[0]->isGround )
00048 {
00049 p_A->setUse_c( p_cbranch[0]->n(), p_cnode[0]->n(), Map::et_stable, false );
00050 }
00051 if( !p_cnode[1]->isGround )
00052 {
00053 p_A->setUse_c( p_cbranch[0]->n(), p_cnode[1]->n(), Map::et_stable, false );
00054 }
00055 if( !p_cnode[2]->isGround )
00056 {
00057 p_A->setUse_b( p_cnode[2]->n(), p_cbranch[0]->n(), Map::et_constant, true );
00058 p_A->setUse_c( p_cbranch[0]->n(), p_cnode[2]->n(), Map::et_constant, true );
00059 }
00060 if( !p_cnode[3]->isGround )
00061 {
00062 p_A->setUse_b( p_cnode[3]->n(), p_cbranch[0]->n(), Map::et_constant, true );
00063 p_A->setUse_c( p_cbranch[0]->n(), p_cnode[3]->n(), Map::et_constant, true );
00064 }
00065 }
00066
00067
00068 void VCCS::add_initial_dc()
00069 {
00070 if(!b_status)
00071 return;
00072
00073 A_g( 2, 0 ) += m_g;
00074 A_g( 3, 0 ) -= m_g;
00075 A_g( 2, 1 ) -= m_g;
00076 A_g( 3, 1 ) += m_g;
00077 }
00078
00079
00080 void VCCS::updateCurrents()
00081 {
00082 if(!b_status) return;
00083
00084 m_cnodeI[0] = m_cnodeI[1] = 0.;
00085 m_cnodeI[3] = (p_cnode[0]->v-p_cnode[1]->v)*m_g;
00086 m_cnodeI[2] = -m_cnodeI[3];
00087 }
00088
00089