voltagepoint.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 "voltagepoint.h"
00012 #include "elementset.h"
00013 
00014 VoltagePoint::VoltagePoint( const double voltage )
00015         : Element::Element()
00016 {
00017         m_voltage = -voltage;
00018         m_numCBranches = 1;
00019         m_numCNodes = 1;
00020 }
00021 
00022 
00023 VoltagePoint::~VoltagePoint()
00024 {
00025 }
00026 
00027 
00028 void VoltagePoint::setVoltage( const double v )
00029 {
00030         if(-v == m_voltage ) return;
00031 
00032         if(p_eSet) p_eSet->setCacheInvalidated();
00033 
00034         m_voltage = -v;
00035         add_initial_dc();
00036 }
00037 
00038 
00039 void VoltagePoint::add_map()
00040 {
00041         if(!b_status) return;
00042         
00043         if(!p_cnode[0]->isGround) {
00044                 p_A->setUse_b(p_cnode[0]->n(), p_cbranch[0]->n(), Map::et_constant, true);
00045                 p_A->setUse_c(p_cbranch[0]->n(), p_cnode[0]->n(), Map::et_constant, true);
00046         }
00047 }
00048 
00049 
00050 void VoltagePoint::add_initial_dc()
00051 {
00052         if(!b_status) return;
00053         
00054         A_b(0, 0) = -1;
00055         A_c(0, 0) = -1;
00056         
00057         b_v(0) = m_voltage;
00058 }
00059 
00060 
00061 void VoltagePoint::updateCurrents()
00062 {
00063         if(!b_status) return;
00064         m_cnodeI[0] = p_cbranch[0]->i;
00065 }
00066 

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