예제 #1
0
            //NETLIB_UPDATEI();

            //NETLIB_RESETI();
            protected override void reset()
            {
                nl_double v = m_Dial.op();

                if (m_DialIsLog.op())
                {
                    v = (std.exp(v) - 1.0) / (std.exp(1.0) - 1.0);
                }

                m_R1.set_R(std.max(m_R.op() * v, exec().gmin()));
                m_R2.set_R(std.max(m_R.op() * (nl_config_global.NL_FCONST(1.0) - v), exec().gmin()));
            }
예제 #2
0
            //~nld_solver()
            //{
            //    for (auto &s : m_mat_solvers)
            //    {
            //        plib::pfree(s);
            //    }
            //}


            public void post_start()
            {
                const bool use_specific = true;

                m_params.m_pivot    = m_pivot.op() ? 1 : 0;
                m_params.m_accuracy = m_accuracy.op();
                /* FIXME: Throw when negative */
                m_params.m_gs_loops        = (UInt32)m_gs_loops.op();
                m_params.m_nr_loops        = (UInt32)m_nr_loops.op();
                m_params.m_nr_recalc_delay = netlist_time.from_double(m_nr_recalc_delay.op());
                m_params.m_dynamic_lte     = m_dynamic_lte.op();
                m_params.m_gs_sor          = m_gs_sor.op();

                m_params.m_min_timestep = m_dynamic_min_ts.op();
                m_params.m_dynamic_ts   = (m_dynamic_ts.op() == true ? true : false);
                m_params.m_max_timestep = netlist_time.from_double(1.0 / m_freq.op()).as_double();

                if (m_params.m_dynamic_ts)
                {
                    m_params.m_max_timestep *= 1;//NL_FCONST(1000.0);
                }
                else
                {
                    m_params.m_min_timestep = m_params.m_max_timestep;
                }

                //m_params.m_max_timestep = std::max(m_params.m_max_timestep, m_params.m_max_timestep::)

                // Override log statistics
                string p = "";  //plib::util::environment("NL_STATS", "");

                if (p != "")
                {
                    m_params.m_log_stats = plib.pstring_global.pstonum_bool(p);  //plib::pstonum<decltype(m_params.m_log_stats)>(p);
                }
                else
                {
                    m_params.m_log_stats = m_log_stats.op();
                }

                log().verbose.op("Scanning net groups ...");
                // determine net groups

                net_splitter splitter = new net_splitter();

                splitter.run(state());

                // setup the solvers
                log().verbose.op("Found {0} net groups in {1} nets\n", splitter.groups.size(), state().nets().size());
                foreach (var grp in splitter.groups)
                {
                    matrix_solver_t ms;
                    UInt32          net_count = (UInt32)grp.size();
                    string          sname     = new plib.pfmt("Solver_{0}").op(m_mat_solvers.size());

                    switch (net_count)
                    {
#if true
                    case 1:
                        if (use_specific)
                        {
                            ms = new matrix_solver_direct1_t(state(), sname, m_params);      //ms = plib::palloc<matrix_solver_direct1_t<double>>(state(), sname, &m_params);
                        }
                        else
                        {
                            ms = create_solver/*<double, 1>*/ (1, 1, sname);
                        }
                        break;

                    case 2:
                        if (use_specific)
                        {
                            ms = new matrix_solver_direct2_t(state(), sname, m_params);      //ms =  plib::palloc<matrix_solver_direct2_t<double>>(state(), sname, &m_params);
                        }
                        else
                        {
                            ms = create_solver/*<double, 2>*/ (2, 2, sname);
                        }
                        break;

#if false
                    case 3:
                        ms = create_solver <double, 3>(3, sname);
                        break;

                    case 4:
                        ms = create_solver <double, 4>(4, sname);
                        break;

                    case 5:
                        ms = create_solver <double, 5>(5, sname);
                        break;

                    case 6:
                        ms = create_solver <double, 6>(6, sname);
                        break;

                    case 7:
                        ms = create_solver <double, 7>(7, sname);
                        break;

                    case 8:
                        ms = create_solver <double, 8>(8, sname);
                        break;

                    case 9:
                        ms = create_solver <double, 9>(9, sname);
                        break;

                    case 10:
                        ms = create_solver <double, 10>(10, sname);
                        break;

                    case 11:
                        ms = create_solver <double, 11>(11, sname);
                        break;

                    case 12:
                        ms = create_solver <double, 12>(12, sname);
                        break;

                    case 15:
                        ms = create_solver <double, 15>(15, sname);
                        break;

                    case 31:
                        ms = create_solver <double, 31>(31, sname);
                        break;

                    case 35:
                        ms = create_solver <double, 35>(35, sname);
                        break;

                    case 43:
                        ms = create_solver <double, 43>(43, sname);
                        break;

                    case 49:
                        ms = create_solver <double, 49>(49, sname);
                        break;
#endif
#if false
                    case 87:
                        ms = create_solver <87, 87>(87, sname);
                        break;
#endif
#endif
                    default:
                        log().warning.op(nl_errstr_global.MW_1_NO_SPECIFIC_SOLVER, net_count);
                        if (net_count <= 8)
                        {
                            ms = create_solver/*<double, -8>*/ (-8, net_count, sname);
                        }
                        else if (net_count <= 16)
                        {
                            ms = create_solver/*<double, -16>*/ (-16, net_count, sname);
                        }
                        else if (net_count <= 32)
                        {
                            ms = create_solver/*<double, -32>*/ (-32, net_count, sname);
                        }
                        else
                        if (net_count <= 64)
                        {
                            ms = create_solver/*<double, -64>*/ (-64, net_count, sname);
                        }
                        else
                        if (net_count <= 128)
                        {
                            ms = create_solver/*<double, -128>*/ (-128, net_count, sname);
                        }
                        else
                        {
                            log().fatal.op(nl_errstr_global.MF_1_NETGROUP_SIZE_EXCEEDED_1, 128);
                            ms = null;     /* tease compilers */
                        }
                        break;
                    }

                    // FIXME ...
                    ms.setup(grp);

                    log().verbose.op("Solver {0}", ms.name());
                    log().verbose.op("       ==> {0} nets", grp.size());
                    log().verbose.op("       has {0} elements", ms.has_dynamic_devices() ? "dynamic" : "no dynamic");
                    log().verbose.op("       has {0} elements", ms.has_timestep_devices() ? "timestep" : "no timestep");

                    foreach (var n in grp)
                    {
                        log().verbose.op("Net {0}", n.name());
                        foreach (var pcore in n.core_terms)
                        {
                            log().verbose.op("   {0}", pcore.name());
                        }
                    }

                    m_mat_solvers.push_back(ms);
                    if (ms.has_timestep_devices())
                    {
                        m_mat_solvers_timestepping.push_back(ms);
                    }
                }
            }