netlist: more magic number removal. (nw)

This commit is contained in:
couriersud 2020-05-01 16:13:34 +02:00
parent 40f8f99f9a
commit f74ad44550
2 changed files with 23 additions and 7 deletions

View File

@ -211,25 +211,23 @@ namespace analog
{
public:
generic_diode(device_t &dev, const pstring &name)
: m_Vd(dev, name + ".m_Vd", nlconst::magic(0.7))
: m_Vd(dev, name + ".m_Vd", nlconst::diode_start_voltage())
, m_Id(dev, name + ".m_Id", nlconst::zero())
, m_G(dev, name + ".m_G", nlconst::magic(1e-15))
, m_G(dev, name + ".m_G", nlconst::cgminalt())
, m_Vt(nlconst::zero())
, m_Vmin(nlconst::zero()) // not used in MOS model
, m_Is(nlconst::zero())
, m_logIs(nlconst::zero())
, m_gmin(nlconst::magic(1e-15))
, m_gmin(nlconst::cgminalt())
, m_VtInv(nlconst::zero())
, m_Vcrit(nlconst::zero())
{
set_param(
nlconst::np_Is()
, nlconst::one()
, nlconst::magic(1e-15)
, nlconst::cgminalt()
, nlconst::T0());
//m_name = name;
}
//pstring m_name;
// Basic math
//
// I(V) = f(V)
@ -318,7 +316,7 @@ namespace analog
m_VtInv = plib::reciprocal(m_Vt);
#if USE_TEXTBOOK_DIODE
m_Vmin = nlconst::magic(-5.0) * m_Vt;
m_Vmin = nlconst::diode_min_cutoff_mult() * m_Vt;
// Vcrit : f(V) has smallest radius of curvature rho(V) == min(rho(v))
m_Vcrit = m_Vt * plib::log(m_Vt / m_Is / nlconst::sqrt2());
#else

View File

@ -33,8 +33,26 @@ namespace netlist
{
using BC = plib::constants<T>;
/// \brief constant startup gmin
///
/// This should be used during object creation to initialize
/// conductivities with a reasonable value.
/// During reset, the object should than make use of exec().gmin()
/// to use the actual gmin() value.
static inline constexpr T cgmin() noexcept { return BC::magic(1e-9); } // NOLINT
// FIXME: Some objects used 1e-15 for initial gmin. Needs to be
// aligned with cgmin
static inline constexpr T cgminalt() noexcept { return BC::magic(1e-15); } // NOLINT
/// \brief Multiplier applied to VT in np diode models to determine range for constant model
///
static inline constexpr T diode_min_cutoff_mult() noexcept { return BC::magic(-5.0); } // NOLINT
/// \brief Startup voltage used by np diode models
///
static inline constexpr T diode_start_voltage() noexcept { return BC::magic(0.7); } // NOLINT
static inline constexpr T np_VT(T n=BC::one(), T temp=BC::T0()) noexcept
{ return n * temp * BC::k_b() / BC::Q_e(); }