Warning, file /sdk/ktechlab/src/electronics/simulation/cccs.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /*************************************************************************** 0002 * Copyright (C) 2003-2004 by David Saxton * 0003 * david@bluehaze.org * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 ***************************************************************************/ 0010 0011 #include "cccs.h" 0012 #include "elementset.h" 0013 0014 CCCS::CCCS(const double gain) 0015 : Element::Element() 0016 { 0017 m_g = gain; 0018 m_numCBranches = 2; 0019 m_numCNodes = 4; 0020 } 0021 0022 CCCS::~CCCS() 0023 { 0024 } 0025 0026 void CCCS::setGain(const double g) 0027 { 0028 if (m_g == g) 0029 return; 0030 0031 if (p_eSet) 0032 p_eSet->setCacheInvalidated(); 0033 0034 m_g = g; 0035 add_initial_dc(); 0036 } 0037 0038 void CCCS::add_initial_dc() 0039 { 0040 if (!b_status) 0041 return; 0042 0043 A_b(0, 0) = 1; 0044 A_c(0, 0) = 1; 0045 A_b(1, 0) = -1; 0046 A_c(0, 1) = -1; 0047 A_b(2, 1) = 1; 0048 A_b(3, 1) = -1; 0049 A_d(1, 0) = -m_g; 0050 A_d(1, 1) = 1; 0051 } 0052 0053 void CCCS::updateCurrents() 0054 { 0055 if (!b_status) 0056 return; 0057 m_cnodeI[1] = p_cbranch[0]->i; 0058 m_cnodeI[0] = -m_cnodeI[1]; 0059 m_cnodeI[3] = p_cbranch[1]->i; 0060 m_cnodeI[2] = -m_cnodeI[3]; 0061 }