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 #ifndef DIODE_H 00012 #define DIODE_H 00013 00014 #include "nonlinear.h" 00015 00016 class DiodeSettings 00017 { 00018 public: 00019 DiodeSettings(); 00020 void reset(); 00021 00022 double I_S; 00023 double N; 00024 double V_B; 00025 }; 00026 00041 /* TODO : create bridge rectifier device */ 00042 00043 class Diode : public NonLinear 00044 { 00045 public: 00046 Diode(); 00047 virtual ~Diode(); 00048 00049 virtual void update_dc(); 00050 virtual void add_initial_dc(); 00051 virtual void add_map(); 00052 virtual Element::Type type() const { return Element_Diode; } 00053 DiodeSettings settings() const { return m_diodeSettings; } 00054 void setDiodeSettings( const DiodeSettings & settings ); 00058 double current() const; 00059 00060 protected: 00061 virtual void updateCurrents(); 00062 void calc_eq(); 00063 00064 void calcIg( double V, double * I, double * g ) const; 00065 00066 double g_new, g_old; 00067 double I_new, I_old; 00068 double V_prev; 00069 00070 DiodeSettings m_diodeSettings; 00071 }; 00072 00073 #endif 00074
1.5.1