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

Fixes for Hubbard U+V non magnetic case #788

Merged
merged 6 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add mixing factor 2 in Hubbard U one-electron contribution
  • Loading branch information
mtaillefumier committed Nov 25, 2022
commit 4693d18fc03042870347feb7047338e99a84efcd
9 changes: 4 additions & 5 deletions src/dft/energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,15 @@ total_energy(Simulation_context const& ctx, K_point_set const& kset, Density con

case electronic_structure_method_t::pseudopotential: {
tot_en = (kset.valence_eval_sum() - energy_vxc(density, potential) - energy_bxc(density, potential) -
potential.PAW_one_elec_energy(density)) -
potential.PAW_one_elec_energy(density) - one_electron_energy_hubbard(density, potential)) -
0.5 * energy_vha(potential) + energy_exc(density, potential) + potential.PAW_total_energy() +
ewald_energy + kset.entropy_sum();
break;
}
}

if (ctx.hubbard_correction()) {
tot_en += ::sirius::energy(density.occupation_matrix());
tot_en -= ::sirius::one_electron_energy_hubbard(density, potential);
tot_en += ::sirius::hubbard_energy(density);
}

return tot_en;
Expand All @@ -194,7 +193,7 @@ double
one_electron_energy(Density const& density, Potential const& potential)
{
return energy_vha(potential) + energy_vxc(density, potential) + energy_bxc(density, potential) +
potential.PAW_one_elec_energy(density) + one_electron_energy_hubbard(density, potential);
potential.PAW_one_elec_energy(density) + one_electron_energy_hubbard(density, potential);
}

double
Expand All @@ -213,7 +212,7 @@ energy_potential(Density const& density, Potential const& potential)
double e =
energy_veff(density, potential) + energy_bxc(density, potential) + potential.PAW_one_elec_energy(density);
if (potential.ctx().hubbard_correction()) {
e += ::sirius::energy(density.occupation_matrix());
e += ::sirius::hubbard_energy(density);
}
return e;
}
Expand Down
7 changes: 7 additions & 0 deletions src/hubbard/hubbard_potential_energy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ calculate_energy_collinear_nonlocal(Simulation_context const& ctx__, const int i
}
}

if (ctx__.num_spins() == 1) {
hubbard_energy *= 2.0;
}
return -0.5 * hubbard_energy;
}

Expand Down Expand Up @@ -631,6 +634,10 @@ one_electron_energy_hubbard(Hubbard_matrix const& om__, Hubbard_matrix const& pm
}
}
}

if (ctx.num_spins() == 1) {
tmp *= 2.0;
}
return std::real(tmp);
}
return 0.0;
Expand Down