当前位置: 首页>>代码示例>>C++>>正文


C++ TestData::aeqb方法代码示例

本文整理汇总了C++中TestData::aeqb方法的典型用法代码示例。如果您正苦于以下问题:C++ TestData::aeqb方法的具体用法?C++ TestData::aeqb怎么用?C++ TestData::aeqb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestData的用法示例。


在下文中一共展示了TestData::aeqb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: of

void sa_nto_analysis_test::test_1() throw(libtest::test_exception) {

    static const char *testname = "sa_nto_analysis_test::test_1()";

    try {

    std::ofstream of("sa_nto_analysis_test", std::ofstream::app);

    // Prepare input data:

    size_t nao = TestData::k_nao;
    size_t nmo = TestData::k_nmo;
    TestData data;

    mat s(nao, nao);
    read_matrix(data, testname, "s", s);

    ab_matrix c(data.aeqb());
    c.alpha() = mat(nao, nmo);
    if (! data.aeqb()) c.beta() = mat(nao, nmo);
    read_ab_matrix(data, testname, "c", c);

    ab_matrix hdm_av(data.aeqb()), edm_av(data.aeqb());
    hdm_av.alpha() = mat(nao, nao, fill::zeros);
    edm_av.alpha() = mat(nao, nao, fill::zeros);
    if (! data.aeqb()) {
        hdm_av.beta() = mat(nao, nao, fill::zeros);
        edm_av.beta() = mat(nao, nao, fill::zeros);
    }

    // Form state-averaged hole and particle densities
    for (size_t istate = 1; istate <= data.nstates(); istate++) {
        ab_matrix tdm(data.aeqb());
        tdm.alpha() = mat(nao, nao);
        if (! data.aeqb()) tdm.beta() = mat(nao, nao);
        std::ostringstream ssdm; ssdm << "tdm" << istate;
        read_ab_matrix(data, testname, ssdm.str().c_str(), tdm);

        ab_matrix hdm, edm;
        nto_analysis::form_eh(s, tdm.t(), edm, hdm);

        hdm_av += hdm;
        edm_av += edm;
    }

    // Form spin-traced hole and particle densities
    ab_matrix edm_av_s(true), hdm_av_s(true);
    edm_av_s.alpha() = 0.5 * (edm_av.alpha() + edm_av.beta());
    hdm_av_s.alpha() = 0.5 * (hdm_av.alpha() + hdm_av.beta());

    // Construct SA-NTOs

    sa_nto_analysis sa_nto1(s, nto_analysis(s, c, edm_av, hdm_av));
    sa_nto_analysis sa_nto2(s, nto_analysis(s, c, edm_av_s, hdm_av_s));

    const ab_matrix &u1 = sa_nto1.get_transf_l();
    const ab_matrix &v1 = sa_nto1.get_transf_r();
    const ab_matrix &u2 = sa_nto2.get_transf_l();
    const ab_matrix &v2 = sa_nto2.get_transf_r();

    if (accu(abs(u1.alpha().t() * u1.alpha() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "U(1,alpha) not unitary.");
    if (accu(abs(u1.beta().t() * u1.beta() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "U(1,beta) not unitary.");
    if (accu(abs(v1.alpha() * v1.alpha().t() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "V(1,alpha) not unitary.");
    if (accu(abs(v1.beta() * v1.beta().t() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "V(1,beta) not unitary.");
    if (! u2.is_alpha_eq_beta() || ! v2.is_alpha_eq_beta())
        fail_test(testname, __FILE__, __LINE__, "SA-NTO(2): Alpha != beta.");
    if (accu(abs(u2.alpha().t() * u2.alpha() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "U(2,alpha) not unitary.");
    if (accu(abs(u2.beta().t() * u2.beta() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "U(2,beta) not unitary.");
    if (accu(abs(v2.alpha() * v2.alpha().t() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "V(2,alpha) not unitary.");
    if (accu(abs(v2.beta() * v2.beta().t() - s) > 1e-12) != 0)
        fail_test(testname, __FILE__, __LINE__, "V(1,beta) not unitary.");

    // Loop to decompose TDM for each state

    for (size_t istate = 1; istate <= data.nstates(); istate++) {

        ab_matrix tdm(data.aeqb());
        tdm.alpha() = mat(nao, nao);
        if (! data.aeqb()) tdm.beta() = mat(nao, nao);
        std::ostringstream ssdm; ssdm << "tdm" << istate;
        read_ab_matrix(data, testname, ssdm.str().c_str(), tdm);

        tdm = tdm.t();

        sa_nto_analysis sa_nto0(s, nto_analysis(s, c, tdm));

        ab_matrix x0, x1, x2;
        sa_nto0.analyse(of, tdm, x0);
        of << std::endl;
        sa_nto1.analyse(of, tdm, x1);
        of << std::endl;
        sa_nto2.analyse(of, tdm, x2);
        of << std::endl << std::endl;
//.........这里部分代码省略.........
开发者ID:steabert,项目名称:libwfa,代码行数:101,代码来源:sa_nto_analysis_test.C


注:本文中的TestData::aeqb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。