Skip to content

Commit

Permalink
Add } to close if else block
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabrielgerez committed Oct 2, 2023
1 parent c4f2d07 commit bf6f088
Showing 1 changed file with 110 additions and 119 deletions.
229 changes: 110 additions & 119 deletions src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1086,143 +1086,134 @@ void driver::build_fock_operator(const json &json_fock, Molecule &mol, FockBuild
// 4 different parametrizations, not all implemented yet.
dhscreening.printParameters();
if (solver_type == "Poisson-Boltzmann") {

scrf_p = std::make_unique<PBESolver>(dielectric_func, dhscreening, nuclei, P_p, D_p, poisson_prec, kain, max_iter, accelerate_pot, dynamic_thrs, density_type);
} else if (solver_type == "Linearized_Poisson-Boltzmann") {
auto radii_0 = cavity_p->getOriginalRadii();
auto radii_ion = std::vector<double>(radii_0.size());

for (int i = 0; i < radii_0.size(); i++) { radii_ion[i] = radii_0[i] + ion_radius; }
auto cavity_centers = cavity_p->getCoordinates();
auto cavity_ion = std::make_shared<Cavity>(cavity_centers, radii_ion, width_ion);
DHScreening dhscreening(*cavity_ion, kappa_o, kformulation); // this is now deciding the pb formulation, but it really shouldn't, the formulation here is for the DHScreening where we
// have 4 different parametrizations, not all implemented yet.
dhscreening.printParameters();
scrf_p = std::make_unique<LPBESolver>(dielectric_func, dhscreening, nuclei, P_p, D_p, poisson_prec, kain, max_iter, accelerate_pot, dynamic_thrs, density_type);
} else {
MSG_ERROR("Solver type not implemented");
}

auto V_R = std::make_shared<ReactionOperator>(std::move(scrf_p), Phi_p);
F.getReactionOperator() = V_R;
}
///////////////////////////////////////////////////////////
//////////////////// XC Operator //////////////////////
///////////////////////////////////////////////////////////
double exx = 1.0;
if (json_fock.contains("xc_operator")) {
auto shared_memory = json_fock["xc_operator"]["shared_memory"];
auto json_xcfunc = json_fock["xc_operator"]["xc_functional"];
auto xc_spin = json_xcfunc["spin"];
auto xc_cutoff = json_xcfunc["cutoff"];
auto xc_funcs = json_xcfunc["functionals"];
auto xc_order = order + 1;

mrdft::Factory xc_factory(*MRA);
xc_factory.setSpin(xc_spin);
xc_factory.setOrder(xc_order);
xc_factory.setDensityCutoff(xc_cutoff);
for (const auto &f : xc_funcs) {
auto name = f["name"];
auto coef = f["coef"];
xc_factory.setFunctional(name, coef);
}
auto mrdft_p = xc_factory.build();
exx = mrdft_p->functional().amountEXX();

if (order == 0) {
auto XC_p = std::make_shared<XCOperator>(mrdft_p, Phi_p, shared_memory);
F.getXCOperator() = XC_p;
} else if (order == 1) {
auto XC_p = std::make_shared<XCOperator>(mrdft_p, Phi_p, X_p, Y_p, shared_memory);
F.getXCOperator() = XC_p;
} else {
MSG_ABORT("Invalid perturbation order");
}
}
///////////////////////////////////////////////////////////
///////////////// Exchange Operator ///////////////////
///////////////////////////////////////////////////////////
if (json_fock.contains("exchange_operator") and exx > mrcpp::MachineZero) {
auto exchange_prec = json_fock["exchange_operator"]["exchange_prec"];
auto poisson_prec = json_fock["exchange_operator"]["poisson_prec"];
auto P_p = std::make_shared<PoissonOperator>(*MRA, poisson_prec);
if (order == 0) {
auto K_p = std::make_shared<ExchangeOperator>(P_p, Phi_p, exchange_prec);
F.getExchangeOperator() = K_p;
} else {
auto K_p = std::make_shared<ExchangeOperator>(P_p, Phi_p, X_p, Y_p, exchange_prec);
F.getExchangeOperator() = K_p;
}
}
///////////////////////////////////////////////////////////
///////////////// External Operator ///////////////////
///////////////////////////////////////////////////////////
if (json_fock.contains("external_operator")) {
auto field = json_fock["external_operator"]["electric_field"].get<std::array<double, 3>>();
auto r_O = json_fock["external_operator"]["r_O"];
auto V_ext = std::make_shared<ElectricFieldOperator>(field, r_O);
F.getExtOperator() = V_ext;
}
F.build(exx);

auto V_R = std::make_shared<ReactionOperator>(std::move(scrf_p), Phi_p);
F.getReactionOperator() = V_R;
}
///////////////////////////////////////////////////////////
//////////////////// XC Operator //////////////////////
///////////////////////////////////////////////////////////
double exx = 1.0;
if (json_fock.contains("xc_operator")) {
auto shared_memory = json_fock["xc_operator"]["shared_memory"];
auto json_xcfunc = json_fock["xc_operator"]["xc_functional"];
auto xc_spin = json_xcfunc["spin"];
auto xc_cutoff = json_xcfunc["cutoff"];
auto xc_funcs = json_xcfunc["functionals"];
auto xc_order = order + 1;

mrdft::Factory xc_factory(*MRA);
xc_factory.setSpin(xc_spin);
xc_factory.setOrder(xc_order);
xc_factory.setDensityCutoff(xc_cutoff);
for (const auto &f : xc_funcs) {
auto name = f["name"];
auto coef = f["coef"];
xc_factory.setFunctional(name, coef);
}
auto mrdft_p = xc_factory.build();
exx = mrdft_p->functional().amountEXX();

/** @brief Construct perturbation operator based on input keyword */
template <int I> RankOneOperator<I> driver::get_operator(const std::string &name, const json &json_inp) {
RankOneOperator<I> h;
if (name == "h_e_dip") {
h = H_E_dip(json_inp["r_O"]);
} else if (name == "h_b_dip") {
auto D = driver::get_derivative(json_inp["derivative"]);
h = H_B_dip(D, json_inp["r_O"]);
} else if (name == "h_m_pso") {
auto D = driver::get_derivative(json_inp["derivative"]);
h = H_M_pso(D, json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
if (order == 0) {
auto XC_p = std::make_shared<XCOperator>(mrdft_p, Phi_p, shared_memory);
F.getXCOperator() = XC_p;
} else if (order == 1) {
auto XC_p = std::make_shared<XCOperator>(mrdft_p, Phi_p, X_p, Y_p, shared_memory);
F.getXCOperator() = XC_p;
} else {
MSG_ERROR("Invalid operator: " << name);
MSG_ABORT("Invalid perturbation order");
}
return h;
}

template <int I, int J> RankTwoOperator<I, J> driver::get_operator(const std::string &name, const json &json_inp) {
RankTwoOperator<I, J> h;
if (name == "h_e_quad") {
h = H_E_quad(json_inp["r_O"]);
} else if (name == "h_bb_dia") {
h = H_BB_dia(json_inp["r_O"]);
} else if (name == "h_mb_dia") {
h = H_MB_dia(json_inp["r_O"], json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
} else if (name == "h_bm_dia") {
h = H_BM_dia(json_inp["r_O"], json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
///////////////////////////////////////////////////////////
///////////////// Exchange Operator ///////////////////
///////////////////////////////////////////////////////////
if (json_fock.contains("exchange_operator") and exx > mrcpp::MachineZero) {
auto exchange_prec = json_fock["exchange_operator"]["exchange_prec"];
auto poisson_prec = json_fock["exchange_operator"]["poisson_prec"];
auto P_p = std::make_shared<PoissonOperator>(*MRA, poisson_prec);
if (order == 0) {
auto K_p = std::make_shared<ExchangeOperator>(P_p, Phi_p, exchange_prec);
F.getExchangeOperator() = K_p;
} else {
MSG_ERROR("Invalid operator: " << name);
auto K_p = std::make_shared<ExchangeOperator>(P_p, Phi_p, X_p, Y_p, exchange_prec);
F.getExchangeOperator() = K_p;
}
return h;
}
///////////////////////////////////////////////////////////
///////////////// External Operator ///////////////////
///////////////////////////////////////////////////////////
if (json_fock.contains("external_operator")) {
auto field = json_fock["external_operator"]["electric_field"].get<std::array<double, 3>>();
auto r_O = json_fock["external_operator"]["r_O"];
auto V_ext = std::make_shared<ElectricFieldOperator>(field, r_O);
F.getExtOperator() = V_ext;
}
F.build(exx);
}

/** @brief Construct derivative operator based on input keyword */
DerivativeOperator_p driver::get_derivative(const std::string &name) {
DerivativeOperator_p D = nullptr;
if (name == "abgv_00") {
D = std::make_shared<mrcpp::ABGVOperator<3>>(*MRA, 0.0, 0.0);
} else if (name == "abgv_55") {
D = std::make_shared<mrcpp::ABGVOperator<3>>(*MRA, 0.5, 0.5);
} else if (name == "ph") {
D = std::make_shared<mrcpp::PHOperator<3>>(*MRA, 1);
} else if (name == "bspline") {
D = std::make_shared<mrcpp::BSOperator<3>>(*MRA, 1);
} else {
MSG_ERROR("Invalid derivative operator");
}
return D;
/** @brief Construct perturbation operator based on input keyword */
template <int I> RankOneOperator<I> driver::get_operator(const std::string &name, const json &json_inp) {
RankOneOperator<I> h;
if (name == "h_e_dip") {
h = H_E_dip(json_inp["r_O"]);
} else if (name == "h_b_dip") {
auto D = driver::get_derivative(json_inp["derivative"]);
h = H_B_dip(D, json_inp["r_O"]);
} else if (name == "h_m_pso") {
auto D = driver::get_derivative(json_inp["derivative"]);
h = H_M_pso(D, json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
} else {
MSG_ERROR("Invalid operator: " << name);
}
return h;
}

json driver::print_properties(const Molecule &mol) {
print_utils::headline(0, "Printing Molecular Properties");
mol.printGeometry();
mol.printEnergies("final");
mol.printProperties();
return mol.json();
template <int I, int J> RankTwoOperator<I, J> driver::get_operator(const std::string &name, const json &json_inp) {
RankTwoOperator<I, J> h;
if (name == "h_e_quad") {
h = H_E_quad(json_inp["r_O"]);
} else if (name == "h_bb_dia") {
h = H_BB_dia(json_inp["r_O"]);
} else if (name == "h_mb_dia") {
h = H_MB_dia(json_inp["r_O"], json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
} else if (name == "h_bm_dia") {
h = H_BM_dia(json_inp["r_O"], json_inp["r_K"], json_inp["precision"], json_inp["smoothing"]);
} else {
MSG_ERROR("Invalid operator: " << name);
}
return h;
}

/** @brief Construct derivative operator based on input keyword */
DerivativeOperator_p driver::get_derivative(const std::string &name) {
DerivativeOperator_p D = nullptr;
if (name == "abgv_00") {
D = std::make_shared<mrcpp::ABGVOperator<3>>(*MRA, 0.0, 0.0);
} else if (name == "abgv_55") {
D = std::make_shared<mrcpp::ABGVOperator<3>>(*MRA, 0.5, 0.5);
} else if (name == "ph") {
D = std::make_shared<mrcpp::PHOperator<3>>(*MRA, 1);
} else if (name == "bspline") {
D = std::make_shared<mrcpp::BSOperator<3>>(*MRA, 1);
} else {
MSG_ERROR("Invalid derivative operator");
}
return D;
}

json driver::print_properties(const Molecule &mol) {
print_utils::headline(0, "Printing Molecular Properties");
mol.printGeometry();
mol.printEnergies("final");
mol.printProperties();
return mol.json();
}

} // namespace mrchem

0 comments on commit bf6f088

Please sign in to comment.