diff options
Diffstat (limited to 'src/lib/netlist/solver/nld_matrix_solver.h')
-rw-r--r-- | src/lib/netlist/solver/nld_matrix_solver.h | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/src/lib/netlist/solver/nld_matrix_solver.h b/src/lib/netlist/solver/nld_matrix_solver.h index 90c13e6a974..a538775bcc5 100644 --- a/src/lib/netlist/solver/nld_matrix_solver.h +++ b/src/lib/netlist/solver/nld_matrix_solver.h @@ -1,13 +1,13 @@ // license:GPL-2.0+ // copyright-holders:Couriersud -/* - * nld_matrix_solver.h - * - */ #ifndef NLD_MATRIX_SOLVER_H_ #define NLD_MATRIX_SOLVER_H_ +/// +/// \file nld_matrix_solver.h +/// + #include "netlist/nl_base.h" #include "netlist/nl_errstr.h" #include "plib/mat_cr.h" @@ -58,7 +58,7 @@ namespace solver solver_parameters_t(device_t &parent) : m_freq(parent, "FREQ", nlconst::magic(48000.0)) - /* iteration parameters */ + // iteration parameters , m_gs_sor(parent, "SOR_FACTOR", nlconst::magic(1.059)) , m_method(parent, "METHOD", matrix_type_e::MAT_CR) , m_fp_type(parent, "FPTYPE", matrix_fp_type_e::DOUBLE) @@ -68,22 +68,22 @@ namespace solver , m_nr_loops(parent, "NR_LOOPS", 250) ///< Maximum number of Newton-Raphson loops , m_gs_loops(parent, "GS_LOOPS", 9) ///< Maximum number of Gauss-Seidel loops - /* general parameters */ + // general parameters , m_gmin(parent, "GMIN", nlconst::magic(1e-9)) , m_pivot(parent, "PIVOT", false) ///< use pivoting on supported solvers , m_nr_recalc_delay(parent, "NR_RECALC_DELAY", netlist_time::quantum().as_fp<nl_fptype>()) ///< Delay to next solve attempt if nr loops exceeded , m_parallel(parent, "PARALLEL", 0) - /* automatic time step */ + // automatic time step , m_dynamic_ts(parent, "DYNAMIC_TS", false) ///< Use dynamic time stepping , m_dynamic_lte(parent, "DYNAMIC_LTE", nlconst::magic(1e-5)) ///< dynamic time stepping slope , m_dynamic_min_ts(parent, "DYNAMIC_MIN_TIMESTEP", nlconst::magic(1e-6)) ///< smallest time step allowed - /* matrix sorting */ + // matrix sorting , m_sort_type(parent, "SORT_TYPE", matrix_sort_type_e::PREFER_IDENTITY_TOP_LEFT) - /* special */ + // special , m_use_gabs(parent, "USE_GABS", true) , m_use_linear_prediction(parent, "USE_LINEAR_PREDICTION", false) // // savings are eaten up by effort @@ -154,9 +154,9 @@ namespace solver PALIGNAS_VECTOROPT() - plib::aligned_vector<unsigned> m_nz; /* all non zero for multiplication */ - plib::aligned_vector<unsigned> m_nzrd; /* non zero right of the diagonal for elimination, may include RHS element */ - plib::aligned_vector<unsigned> m_nzbd; /* non zero below of the diagonal for elimination */ + plib::aligned_vector<unsigned> m_nz; //!< all non zero for multiplication + plib::aligned_vector<unsigned> m_nzrd; //!< non zero right of the diagonal for elimination, may include RHS element + plib::aligned_vector<unsigned> m_nzbd; //!< non zero below of the diagonal for elimination plib::aligned_vector<int> m_connected_net_idx; private: @@ -184,9 +184,9 @@ namespace solver public: using list_t = std::vector<matrix_solver_t *>; - /* after every call to solve, update inputs must be called. - * this can be done as well as a batch to ease parallel processing. - */ + // after every call to solve, update inputs must be called. + // this can be done as well as a batch to ease parallel processing. + const netlist_time solve(netlist_time now); void update_inputs(); @@ -199,7 +199,7 @@ namespace solver m_Q_sync.net().toggle_and_push_to_queue(after); } - /* netdevice functions */ + // netdevice functions NETLIB_UPDATEI(); NETLIB_RESETI(); @@ -215,7 +215,7 @@ namespace solver return std::pair<pstring, pstring>("", plib::pfmt("/* solver doesn't support static compile */\n\n")); } - /* return number of floating point operations for solve */ + // return number of floating point operations for solve std::size_t ops() { return m_ops; } protected: @@ -355,10 +355,10 @@ namespace solver logic_input_t m_fb_sync; logic_output_t m_Q_sync; - /* base setup - called from constructor */ + // base setup - called from constructor void setup_base(const analog_net_t::list_t &nets); - /* calculate matrix */ + // calculate matrix void setup_matrix(); void step(const netlist_time &delta); @@ -386,9 +386,9 @@ namespace solver , m_DD_n_m_1(size, nlconst::zero()) , m_h_n_m_1(size, nlconst::zero()) { - /* - * save states - */ + // + // save states + // state().save(*this, m_last_V.as_base(), this->name(), "m_last_V"); state().save(*this, m_DD_n_m_1.as_base(), this->name(), "m_DD_n_m_1"); state().save(*this, m_h_n_m_1.as_base(), this->name(), "m_h_n_m_1"); @@ -411,7 +411,7 @@ namespace solver plib::parray2D<float_type *, SIZE, 0> m_mat_ptr; // FIXME: below should be private - /* state - variable time_stepping */ + // state - variable time_stepping PALIGNAS_VECTOROPT() plib::parray<nl_fptype, SIZE> m_last_V; PALIGNAS_VECTOROPT() @@ -433,10 +433,9 @@ namespace solver bool check_err() { - /* NOTE: Ideally we should also include currents (RHS) here. This would - * need a reevaluation of the right hand side after voltages have been updated - * and thus belong into a different calculation. This applies to all solvers. - */ + // NOTE: Ideally we should also include currents (RHS) here. This would + // need a reevaluation of the right hand side after voltages have been updated + // and thus belong into a different calculation. This applies to all solvers. const std::size_t iN = size(); const auto reltol(static_cast<FT>(m_params.m_reltol)); @@ -491,9 +490,9 @@ namespace solver } //if (new_solver_timestep > 10.0 * hn) // new_solver_timestep = 10.0 * hn; - /* - * FIXME: Factor 2 below is important. Without, we get timing issues. This must be a bug elsewhere. - */ + // + // FIXME: Factor 2 below is important. Without, we get timing issues. This must be a bug elsewhere. + return std::max(netlist_time::from_fp(new_solver_timestep), netlist_time::quantum() * 2); } @@ -506,7 +505,7 @@ namespace solver for (std::size_t k=0; k<iN; k++) { std::size_t cnt(0); - /* build pointers into the compressed row format matrix for each terminal */ + // build pointers into the compressed row format matrix for each terminal for (std::size_t j=0; j< this->m_terms[k].railstart();j++) { int other = this->m_terms[k].m_connected_net_idx[j]; @@ -555,7 +554,7 @@ namespace solver for (std::size_t i = 0; i < railstart; i++) *tcr_r[i] += static_cast<FT>(go[i]); - /* use native floattype for now */ + // use native floattype for now auto gtot_t(nlconst::zero()); auto RHS_t (nlconst::zero()); @@ -572,7 +571,7 @@ namespace solver for (std::size_t i = railstart; i < term_count; i++) { - RHS_t += (/*m_Idr[i]*/ (- go[i]) * *cnV[i]); + RHS_t += (- go[i]) * *cnV[i]; } m_RHS[k] = static_cast<FT>(RHS_t); @@ -587,4 +586,4 @@ namespace solver } // namespace solver } // namespace netlist -#endif /* NLD_MS_DIRECT_H_ */ +#endif // NLD_MS_DIRECT_H_ |