Skip to content

Commit

Permalink
core: Use aggregate initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Apr 9, 2021
1 parent b09d3da commit 383da42
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 22 deletions.
9 changes: 2 additions & 7 deletions src/core/electrostatics_magnetostatics/coulomb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,10 @@ void deactivate() {
break;
#endif
case COULOMB_DH:
dh_params.r_cut = 0.0;
dh_params.kappa = 0.0;
dh_params = {};
break;
case COULOMB_RF:
rf_params.kappa = 0.0;
rf_params.epsilon1 = 0.0;
rf_params.epsilon2 = 0.0;
rf_params.r_cut = 0.0;
rf_params.B = 0.0;
rf_params = {};
break;
case COULOMB_MMM1D:
mmm1d_params.maxPWerror = 1e40;
Expand Down
4 changes: 1 addition & 3 deletions src/core/electrostatics_magnetostatics/debye_hueckel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ Debye_hueckel_params dh_params{};
void dh_set_params(double kappa, double r_cut) {
if (kappa < 0.0)
throw std::domain_error("kappa should be a non-negative number");

if (r_cut < 0.0)
throw std::domain_error("r_cut should be a non-negative number");

dh_params.kappa = kappa;
dh_params.r_cut = r_cut;
dh_params = {r_cut, kappa};

mpi_bcast_coulomb_params();
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/electrostatics_magnetostatics/debye_hueckel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
#include <cmath>

/** Structure to hold Debye-Hueckel parameters. */
typedef struct {
struct Debye_hueckel_params {
/** Cutoff for Debye-Hueckel interaction. */
double r_cut;
/** Debye kappa (inverse Debye length) . */
double kappa;
} Debye_hueckel_params;
};

/** Debye-Hueckel parameters. */
extern Debye_hueckel_params dh_params;
Expand Down
13 changes: 5 additions & 8 deletions src/core/electrostatics_magnetostatics/reaction_field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ void rf_set_params(double kappa, double epsilon1, double epsilon2,
if (r_cut < 0.0)
throw std::domain_error("r_cut should be a non-negative number");

rf_params.kappa = kappa;
rf_params.epsilon1 = epsilon1;
rf_params.epsilon2 = epsilon2;
rf_params.r_cut = r_cut;
rf_params.B = (2 * (epsilon1 - epsilon2) * (1 + kappa * r_cut) -
epsilon2 * kappa * kappa * r_cut * r_cut) /
((epsilon1 + 2 * epsilon2) * (1 + kappa * r_cut) +
epsilon2 * kappa * kappa * r_cut * r_cut);
auto const B = (2 * (epsilon1 - epsilon2) * (1 + kappa * r_cut) -
epsilon2 * kappa * kappa * r_cut * r_cut) /
((epsilon1 + 2 * epsilon2) * (1 + kappa * r_cut) +
epsilon2 * kappa * kappa * r_cut * r_cut);
rf_params = {kappa, epsilon1, epsilon2, r_cut, B};

mpi_bcast_coulomb_params();
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/electrostatics_magnetostatics/reaction_field.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <utils/math/int_pow.hpp>

/** Structure to hold Reaction Field Parameters. */
typedef struct {
struct Reaction_field_params {
/** ionic strength. */
double kappa;
/** epsilon1 (continuum dielectric constant inside). */
Expand All @@ -46,7 +46,7 @@ typedef struct {
double r_cut;
/** B important prefactor. */
double B;
} Reaction_field_params;
};

/** Structure containing the Reaction Field parameters. */
extern Reaction_field_params rf_params;
Expand Down

0 comments on commit 383da42

Please sign in to comment.