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

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