Warning, file /sdk/ktechlab/src/electronics/simulation/vccs.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 "vccs.h" 0012 #include "elementset.h" 0013 0014 VCCS::VCCS(const double gain) 0015 : Element::Element() 0016 { 0017 m_g = gain; 0018 m_numCBranches = 1; 0019 m_numCNodes = 4; 0020 } 0021 0022 VCCS::~VCCS() 0023 { 0024 } 0025 0026 void VCCS::setGain(const double g) 0027 { 0028 if (g == m_g) 0029 return; 0030 0031 if (p_eSet) 0032 p_eSet->setCacheInvalidated(); 0033 0034 // Remove old values 0035 m_g = -m_g; 0036 add_initial_dc(); 0037 0038 // Add new values 0039 m_g = g; 0040 add_initial_dc(); 0041 } 0042 0043 void VCCS::add_initial_dc() 0044 { 0045 if (!b_status) 0046 return; 0047 0048 A_c(0, 0) = +1.0; 0049 A_c(0, 1) = -1.0; 0050 A_b(3, 0) = +1.0; 0051 A_b(2, 0) = -1.0; 0052 A_d(0, 0) = -1.0 / m_g; 0053 0054 #if 0 0055 A_g( 2, 0 ) += m_g; 0056 A_g( 3, 0 ) -= m_g; 0057 A_g( 2, 1 ) -= m_g; 0058 A_g( 3, 1 ) += m_g; 0059 #endif 0060 } 0061 0062 void VCCS::updateCurrents() 0063 { 0064 if (!b_status) 0065 return; 0066 0067 m_cnodeI[0] = m_cnodeI[1] = 0.; 0068 m_cnodeI[3] = (p_cnode[0]->v - p_cnode[1]->v) * m_g; 0069 m_cnodeI[2] = -m_cnodeI[3]; 0070 }