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 "currentsource.h" 00012 #include "elementset.h" 00013 00014 CurrentSource::CurrentSource( const double current ) 00015 : Element::Element() 00016 { 00017 m_i = current; 00018 m_numCNodes = 2; 00019 } 00020 00021 00022 CurrentSource::~CurrentSource() 00023 { 00024 } 00025 00026 00027 void CurrentSource::setCurrent( const double i ) 00028 { 00029 if ( i == m_i ) return; 00030 00031 if (p_eSet) 00032 p_eSet->setCacheInvalidated(); 00033 00034 // Remove the old current 00035 m_i = -m_i; 00036 add_initial_dc(); 00037 00038 m_i = i; 00039 add_initial_dc(); 00040 } 00041 00042 00043 void CurrentSource::add_map() 00044 { 00045 // We don't need a map for current source :-) 00046 } 00047 00048 00049 void CurrentSource::add_initial_dc() 00050 { 00051 if (!b_status) 00052 return; 00053 00054 b_i( 0 ) -= m_i; 00055 b_i( 1 ) += m_i; 00056 } 00057 00058 00059 void CurrentSource::updateCurrents() 00060 { 00061 m_cnodeI[0] = -m_i; 00062 m_cnodeI[1] = m_i; 00063 }
1.5.1