diff options
Diffstat (limited to 'src/lib/netlist/solver/nld_ms_direct2.h')
-rw-r--r-- | src/lib/netlist/solver/nld_ms_direct2.h | 58 |
1 files changed, 27 insertions, 31 deletions
diff --git a/src/lib/netlist/solver/nld_ms_direct2.h b/src/lib/netlist/solver/nld_ms_direct2.h index 01f77c3bc3c..0f4702ce84b 100644 --- a/src/lib/netlist/solver/nld_ms_direct2.h +++ b/src/lib/netlist/solver/nld_ms_direct2.h @@ -1,19 +1,18 @@ -// license:GPL-2.0+ +// license:BSD-3-Clause // copyright-holders:Couriersud -/* - * nld_ms_direct1.h - * - */ #ifndef NLD_MS_DIRECT2_H_ #define NLD_MS_DIRECT2_H_ +/// +/// \file nld_ms_direct2.h +/// + +#include "nld_matrix_solver_ext.h" #include "nld_ms_direct.h" #include "nld_solver.h" -namespace netlist -{ -namespace devices +namespace netlist::solver { // ---------------------------------------------------------------------------------------- @@ -27,32 +26,29 @@ namespace devices using float_type = FT; - matrix_solver_direct2_t(netlist_state_t &anetlist, const pstring &name, const solver_parameters_t *params) - : matrix_solver_direct_t<double, 2>(anetlist, name, params, 2) - {} - unsigned vsolve_non_dynamic(const bool newton_raphson) override + matrix_solver_direct2_t(devices::nld_solver &main_solver, const pstring &name, + const matrix_solver_t::net_list_t &nets, + const solver::solver_parameters_t *params) + : matrix_solver_direct_t<FT, 2>(main_solver, name, nets, params, 2) + {} + void upstream_solve_non_dynamic() override { - this->build_LE_A(*this); - this->build_LE_RHS(*this); - - const float_type a = this->A(0,0); - const float_type b = this->A(0,1); - const float_type c = this->A(1,0); - const float_type d = this->A(1,1); - - const float_type v1 = (a * this->RHS(1) - c * this->RHS(0)) / (a * d - b * c); - const float_type v0 = (this->RHS(0) - b * v1) / a; - std::array<float_type, 2> new_V = {v0, v1}; - - this->m_stat_calculations++; - const float_type err = (newton_raphson ? this->delta(new_V) : 0.0); - this->store(new_V); - return (err > this->m_params.m_accuracy) ? 2 : 1; + this->clear_square_mat(this->m_A); + this->fill_matrix_and_rhs(); + + const float_type a = this->m_A[0][0]; + const float_type b = this->m_A[0][1]; + const float_type c = this->m_A[1][0]; + const float_type d = this->m_A[1][1]; + + const float_type v1 = (a * this->m_RHS[1] - c * this->m_RHS[0]) / (a * d - b * c); + const float_type v0 = (this->m_RHS[0] - b * v1) / a; + this->m_new_V[0] = v0; + this->m_new_V[1] = v1; } }; -} //namespace devices -} // namespace netlist +} // namespace netlist::solver -#endif /* NLD_MS_DIRECT2_H_ */ +#endif // NLD_MS_DIRECT2_H_ |