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