Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix casscf-1 c1 #372

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions forte/casscf/casscf_orb_grad.cc
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,13 @@ void CASSCF_ORB_GRAD::compute_orbital_grad() {
A_["ru"] = Fc_["rt"] * D1_["tu"];
A_["ru"] += V_["rtvw"] * D2_["tuvw"];

for (const auto& block : A_.block_labels()) {
A_.block(block).iterate([&](const std::vector<size_t>&, double& value) {
if (std::fabs(value) < 1.0e-12)
value = 0.0;
});
}

// build orbital gradients
g_["pq"] = 2.0 * A_["pq"];
g_["pq"] -= 2.0 * A_["qp"];
Expand Down
11 changes: 1 addition & 10 deletions forte/casscf/mcscf_2step.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ double MCSCF_2STEP::compute_energy() {

std::vector<CASSCF_HISTORY> history;

// std::string title = " Energy CI ( Delta E )"
// " Energy Opt. ( Delta E )"
// " E_OPT - E_CI Orbital RMS Micro";
// psi::outfile->Printf("\n %s", title.c_str());

print_h2("MCSCF Iterations");
std::string dash1 = std::string(30, '-');
std::string dash2 = std::string(88, '-');
Expand Down Expand Up @@ -312,13 +307,9 @@ double MCSCF_2STEP::compute_energy() {
title += " DIIS";
psi::outfile->Printf("\n %s", title.c_str());
}
psi::outfile->Printf("\n %4d %20.12f %11.4e%20.12f %11.4e %10.4e %4d/%c", macro + 1,
psi::outfile->Printf("\n %4d %20.12f %11.4e%20.12f %11.4e %10.4e %4d/%c", macro,
e_c, de_c, e_o, de_o, g_rms, n_micro, o_conv);

// psi::outfile->Printf("\n %18.12f (%11.4e) %18.12f (%11.4e) %12.4e %12.4e
// %4d/%c",
// e_c, de_c, e_o, de_o, de, g_rms, n_micro, o_conv);

// test convergence
if (macro == 1 and lbfgs.converged() and std::fabs(de) < e_conv_) {
psi::outfile->Printf("\n\n Initial orbitals are already converged!");
Expand Down
26 changes: 13 additions & 13 deletions tests/methods/casscf-1/input.dat
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ molecule {
Be 0.000000000000 0.000000000000 0.000000000000
H 0.000000000000 1.390000000000 2.500000000000
H 0.000000000000 -1.390000000000 2.500000000000
#symmetry c1
symmetry c1
units bohr
no_reorient
}

set globals {
scf_type out_of_core
scf_type pk
mcscf_e_convergence 8
mcscf_r_convergence 6
basis 3-21g
restricted_docc [2,0,0,0]
active [1,0,0,1]
restricted_docc [2]
active [2]
# restricted_docc [2,0,0,0]
# active [1,0,0,1]
maxiter 20
reference rhf
mcscf_type conv
diag_method rsp
}
refscf = energy('casscf')

set scf_type direct
ecas_psi4 = energy('casscf')
compare_values(refcasscf, ecas_psi4, 6, "PSI4 CASSCF ENERGY")

set forte{
job_type mcscf_two_step
active_space_solver fci
casscf_g_convergence 1e-6
casscf_e_convergence 1e-8
restricted_docc [2,0,0,0]
active [1,0,0,1]
int_type conventional
restricted_docc [2]
active [2]
# restricted_docc [2,0,0,0]
# active [1,0,0,1]
}
e_casscf = energy('forte')

compare_values(refcasscf, e_casscf, 6, "CASSCF ENERGY")

compare_values(refcasscf, e_casscf, 6, "FORTE CASSCF ENERGY")
Loading