File indexing completed on 2024-04-28 05:43:17
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 "voltagesignal.h" 0012 #include "elementset.h" 0013 0014 VoltageSignal::VoltageSignal(const double delta, const double voltage) 0015 : Reactive::Reactive(delta) 0016 { 0017 m_voltage = voltage; 0018 m_numCNodes = 2; 0019 m_numCBranches = 1; 0020 } 0021 0022 VoltageSignal::~VoltageSignal() 0023 { 0024 } 0025 0026 void VoltageSignal::setVoltage(const double v) 0027 { 0028 m_voltage = v; 0029 } 0030 0031 void VoltageSignal::add_initial_dc() 0032 { 0033 if (!b_status) 0034 return; 0035 0036 A_b(0, 0) = -1; 0037 A_c(0, 0) = -1; 0038 A_b(1, 0) = 1; 0039 A_c(0, 1) = 1; 0040 } 0041 0042 void VoltageSignal::time_step() 0043 { 0044 if (!b_status) 0045 return; 0046 b_v(0) = m_voltage * advance(m_delta); 0047 } 0048 0049 void VoltageSignal::updateCurrents() 0050 { 0051 if (!b_status) 0052 return; 0053 m_cnodeI[1] = p_cbranch[0]->i; 0054 m_cnodeI[0] = -m_cnodeI[1]; 0055 }