cccs.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2003-2004 by David Saxton                               *
00003  *   david@bluehaze.org                                                    *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 
00011 #include "elementset.h"
00012 #include "cccs.h"
00013 
00014 CCCS::CCCS( const double gain )
00015         : Element::Element()
00016 {
00017         m_g = gain;
00018         m_numCBranches = 2;
00019         m_numCNodes = 4;
00020 }
00021 
00022 CCCS::~CCCS()
00023 {
00024 }
00025 
00026 void CCCS::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 CCCS::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         }
00057         if ( !p_cnode[3]->isGround )
00058         {
00059                 p_A->setUse_b( p_cnode[3]->n(), p_cbranch[1]->n(), Map::et_constant, true );
00060         }
00061         p_A->setUse_d( p_cbranch[1]->n(), p_cbranch[0]->n(), Map::et_stable, true );
00062         p_A->setUse_d( p_cbranch[1]->n(), p_cbranch[1]->n(), Map::et_constant, true );
00063 }
00064 
00065 void CCCS::add_initial_dc()
00066 {
00067         if (!b_status) return;
00068         
00069         A_b( 0, 0 ) = 1;
00070         A_c( 0, 0 ) = 1;
00071         A_b( 1, 0 ) = -1;
00072         A_c( 0, 1 ) = -1;
00073         A_b( 2, 1 ) = 1;
00074         A_b( 3, 1 ) = -1;
00075         A_d( 1, 0 ) = -m_g;
00076         A_d( 1, 1 ) = 1;
00077 }
00078 
00079 void CCCS::updateCurrents()
00080 {
00081         if (!b_status) return;
00082         m_cnodeI[1] = p_cbranch[0]->i;
00083         m_cnodeI[0] = -m_cnodeI[1];
00084         m_cnodeI[3] = p_cbranch[1]->i;
00085         m_cnodeI[2] = -m_cnodeI[3];
00086 }
00087 

Generated on Tue May 8 17:05:28 2007 for KTechLab by  doxygen 1.5.1