summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-07-16 09:34:57 +0200
committer couriersud <couriersud@gmx.org>2020-07-16 09:34:57 +0200
commit0dfa500a4a4a72805d3ea42eb24c6e2922cffa72 (patch)
tree62df29c9fdd27c6dc9140cc1d8b6bd3fa9e63fdd /src
parent6be87b69a1563a2d5e326030e8a4a331377cb1a9 (diff)
netlist: Fix Inductor state saving.
Diffstat (limited to 'src')
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.cpp5
-rw-r--r--src/lib/netlist/analog/nlid_twoterm.h14
2 files changed, 13 insertions, 6 deletions
diff --git a/src/lib/netlist/analog/nlid_twoterm.cpp b/src/lib/netlist/analog/nlid_twoterm.cpp
index 0fc84c06d43..97b3f5e55ac 100644
--- a/src/lib/netlist/analog/nlid_twoterm.cpp
+++ b/src/lib/netlist/analog/nlid_twoterm.cpp
@@ -43,6 +43,7 @@ namespace analog
NETLIB_RESET(R_base)
{
+ // FIXME: this reset is causing issues. Remove.
NETLIB_NAME(twoterm)::reset();
set_R(plib::reciprocal(exec().gmin()));
}
@@ -135,6 +136,7 @@ namespace analog
if (ts_type == timestep_type::FORWARD)
{
m_last_I = m_I;
+ m_last_G = m_G;
// Gpar should support convergence
m_I += m_G * deltaV();
m_G = step / m_L() + m_gmin;
@@ -142,7 +144,10 @@ namespace analog
-m_G, m_G, m_I);
}
else
+ {
m_I = m_last_I;
+ m_G = m_last_G;
+ }
}
// ----------------------------------------------------------------------------------------
diff --git a/src/lib/netlist/analog/nlid_twoterm.h b/src/lib/netlist/analog/nlid_twoterm.h
index 8a970ac16ac..d7574a1cb35 100644
--- a/src/lib/netlist/analog/nlid_twoterm.h
+++ b/src/lib/netlist/analog/nlid_twoterm.h
@@ -415,9 +415,10 @@ namespace analog
NETLIB_CONSTRUCTOR(L)
, m_L(*this, "L", nlconst::magic(1e-6))
, m_gmin(nlconst::zero())
- , m_G(nlconst::zero())
- , m_I(nlconst::zero())
- , m_last_I(nlconst::zero())
+ , m_G(*this, "m_G", nlconst::zero())
+ , m_I(*this, "m_I", nlconst::zero())
+ , m_last_I(*this, "m_last_I", nlconst::zero())
+ , m_last_G(*this, "m_last_G", nlconst::zero())
{
//register_term("1", m_P);
//register_term("2", m_N);
@@ -435,9 +436,10 @@ namespace analog
param_fp_t m_L;
nl_fptype m_gmin;
- nl_fptype m_G;
- nl_fptype m_I;
- nl_fptype m_last_I;
+ state_var<nl_fptype> m_G;
+ state_var<nl_fptype> m_I;
+ state_var<nl_fptype> m_last_I;
+ state_var<nl_fptype> m_last_G;
};
/// \brief Class representing the diode model paramers.