File indexing completed on 2024-05-05 05:46:12

0001 /***************************************************************************
0002  *   Copyright (C) 2005 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 "opamp.h"
0012 #include "elementset.h"
0013 
0014 OpAmp::OpAmp()
0015     : Element::Element()
0016 {
0017     m_numCBranches = 1;
0018     m_numCNodes = 3;
0019 }
0020 
0021 OpAmp::~OpAmp()
0022 {
0023 }
0024 
0025 void OpAmp::add_initial_dc()
0026 {
0027     if (!b_status)
0028         return;
0029 
0030     // Non-inverting input
0031     A_c(0, 0) = 1;
0032 
0033     // Inverting input
0034     A_c(0, 2) = -1;
0035 
0036     // Output
0037     A_b(1, 0) = 1;
0038 }
0039 
0040 void OpAmp::updateCurrents()
0041 {
0042     if (!b_status)
0043         return;
0044     m_cnodeI[0] = m_cnodeI[2] = 0.0;
0045     m_cnodeI[1] = p_cbranch[0]->i;
0046 }