Permalink
Browse files

Reformat such that assignments are alligned

  • Loading branch information...
mfherbst committed Jul 7, 2017
1 parent e3759fe commit fc1268b678b391d40b3ebd8918ba19b8f6b63a99
@@ -27,7 +27,7 @@
Language: Cpp
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlinesLeft: true
AlignOperands: true
@@ -135,10 +135,10 @@ bool parse_nlm_basis(const std::string& str, NlmBasis& basis) {
// Tuple format
for (size_t pos = 0; pos < str.size(); ++pos) {
if (str[pos] != '(') continue;
const size_t start = pos;
const size_t sep1 = str.find(',', start);
const size_t sep2 = str.find(',', sep1);
const size_t end = str.find(')', sep2);
const size_t start = pos;
const size_t sep1 = str.find(',', start);
const size_t sep2 = str.find(',', sep1);
const size_t end = str.find(')', sep2);
const size_t nextopen = str.find('(', sep1);

// Errors
@@ -185,36 +185,36 @@ bool parse_nlm_basis(const std::string& str, NlmBasis& basis) {

bool parse_args(int argc, char** argv, args_type& parsed) {
// System
bool had_Z_charge = false;
bool had_xyz = false;
bool had_alpha = false;
bool had_beta = false;
bool had_charge = false;
bool had_Z_charge = false;
bool had_xyz = false;
bool had_alpha = false;
bool had_beta = false;
bool had_charge = false;
bool had_multiplicity = false;
bool had_atomic_xyz = false;
bool had_restricted = false;
bool had_atomic_xyz = false;
bool had_restricted = false;

// Basis
bool had_basis_type = false;
bool had_basis_set = false;
bool had_k_exp = false;
bool had_n_max = false;
bool had_l_max = false;
bool had_m_max = false;
bool had_nlm_basis = false;
bool had_basis_set = false;
bool had_k_exp = false;
bool had_n_max = false;
bool had_l_max = false;
bool had_m_max = false;
bool had_nlm_basis = false;

// Convergence
bool had_error = false;
bool had_max_iter = false;
bool had_diis_size = false;
bool had_error = false;
bool had_max_iter = false;
bool had_diis_size = false;
bool had_n_eigenpairs = false;

// Temporary
gint::Structure structure;
size_t n_alpha = 0;
size_t n_beta = 0;
size_t n_alpha = 0;
size_t n_beta = 0;
size_t multiplicity = 0;
size_t charge = 0;
size_t charge = 0;

// Parsing
for (int i = 1; i < argc; ++i) {
@@ -368,7 +368,7 @@ bool parse_args(int argc, char** argv, args_type& parsed) {
return false;
}
} else if (flag == std::string("--basis_set")) {
had_basis_set = true;
had_basis_set = true;
parsed.basis_set = argument;
} else if (flag == std::string("--basis_type")) {
had_basis_type = true;
@@ -382,12 +382,12 @@ bool parse_args(int argc, char** argv, args_type& parsed) {
std::end(valid_gaussian_basis), argument);

if (res_atomic != std::end(valid_atomic_basis)) {
parsed.sturmian = true;
parsed.gaussian = false;
parsed.sturmian = true;
parsed.gaussian = false;
parsed.basis_type = "sturmian/atomic/" + argument;
} else if (res_gaussian != std::end(valid_gaussian_basis)) {
parsed.gaussian = true;
parsed.sturmian = false;
parsed.gaussian = true;
parsed.sturmian = false;
parsed.basis_type = "gaussian/" + argument;
} else {
std::cerr << "Invalid argument provided to --basis_type: " << argument
@@ -37,24 +37,24 @@ struct args_type {

// Sturmians
bool sturmian = false;
double k_exp = 1.0;
int n_max = 0;
int l_max = 0;
int m_max = 0;
double k_exp = 1.0;
int n_max = 0;
int l_max = 0;
int m_max = 0;
NlmBasis nlm_basis;

// Gaussians
bool gaussian = false;
bool gaussian = false;
std::string basis_set = "<not avail>";

// Convergence
size_t max_iter = 25;
double error = 5e-7;
size_t diis_size = 4;
size_t n_eigenpairs = 0;
std::string eigensolver = "auto";
size_t max_iter = 25;
double error = 5e-7;
size_t diis_size = 4;
size_t n_eigenpairs = 0;
std::string eigensolver = "auto";
std::string guess_esolver = "auto";
std::string guess_method = "hcore";
std::string guess_method = "hcore";
};

/** Write the content of args_type to a stream */
@@ -34,10 +34,10 @@ IntegralTermContainer<StoredMatrix> build_hf_terms(
std::vector<gint::Integral<StoredMatrix>> extra_1e_terms) {
using gint::IntegralTypeKeys;

auto T_bb = integrals.lookup_integral(IntegralTypeKeys::kinetic);
auto T_bb = integrals.lookup_integral(IntegralTypeKeys::kinetic);
auto V0_bb = integrals.lookup_integral(IntegralTypeKeys::nuclear_attraction);
auto J_bb = integrals.lookup_integral(IntegralTypeKeys::coulomb);
auto K_bb = integrals.lookup_integral(IntegralTypeKeys::exchange);
auto J_bb = integrals.lookup_integral(IntegralTypeKeys::coulomb);
auto K_bb = integrals.lookup_integral(IntegralTypeKeys::exchange);

std::vector<gint::Integral<StoredMatrix>> terms_1e = {
{std::move(T_bb), std::move(V0_bb)}};
@@ -49,9 +49,9 @@ template <typename Solution>
Solution replicate_block(Solution solution) {
typedef typename Solution::evector_type evector_type;

auto& evecs = solution.evectors();
auto& evecs = solution.evectors();
const size_t n_orbs_alpha = evecs.n_vectors();
const size_t n_bas = evecs.n_elem();
const size_t n_bas = evecs.n_elem();

linalgwrap::MultiVector<evector_type> guess(2 * n_bas, 2 * n_orbs_alpha);
for (size_t f = 0; f < n_orbs_alpha; ++f) {
@@ -66,14 +66,14 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_external(
GuessExternalKeys::eigensolution);

auto& evectors = esolution.evectors();
auto& evalues = esolution.evalues();
auto& evalues = esolution.evalues();
assert_throw(evectors.n_vectors() == evalues.size(),
ExcInvalidScfGuessParametersEncountered(
"Number of eigenvectors and number of eigenvalues in provided "
"eigensolution does not agree."));

const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const size_t n_vectors = std::max(occa.length(), occb.length());

// Restricted open-shell is not yet implemented
@@ -68,8 +68,8 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_hcore(
}
}

const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const size_t n_vectors = std::max(occa.length(), occb.length());

// Get alpha-alpha block of the overlap matrix.
@@ -53,8 +53,8 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_loewdin(
krims::GenMap eigensolver_params = params.submap(GuessLoewdinKeys::eigensolver_params);
eigensolver_params.insert_default(EigensystemSolverKeys::which, "LR");

const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const size_t n_vectors = std::max(occa.size(), occb.size());

// Get alpha-alpha block of the overlap matrix.
@@ -68,7 +68,7 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_loewdin(

// Eigenvectors and eigenvalues.
auto& evectors = sol.evectors();
auto& evalues = sol.evalues();
auto& evalues = sol.evalues();

assert_internal(evectors.n_vectors() == n_vectors);
assert_internal(evectors.n_elem() == Sa_bb.n_cols());
@@ -48,8 +48,8 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_random(

// TODO Make alpha and beta block both truely random for unrestricted and not one
// identical to the other
const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const auto occa = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_ALPHA);
const auto occb = fock_bb.indices_orbspace(gscf::OrbitalSpace::OCC_BETA);
const size_t n_vectors = std::max(occa.size(), occb.size());
assert_implemented(occa == occb);

@@ -68,7 +68,7 @@ linalgwrap::EigensolutionTypeFor<true, IntegralOperator> guess_random(

linalgwrap::EigensolutionTypeFor<true, IntegralOperator> sol;
sol.evectors() = ortho(guess, Sa_bb);
sol.evalues() = std::vector<scalar_type>(n_vectors, 1);
sol.evalues() = std::vector<scalar_type>(n_vectors, 1);
return fock_bb.restricted() ? sol : replicate_block(sol);
}

@@ -283,7 +283,7 @@ IntegralOperatorBase<StoredMatrix>::terms_1e() const {
using linalgwrap::LazyMatrixProduct;
std::map<gint::IntegralIdentifier, LazyMatrixProduct<StoredMatrix>> ret;

auto itterm = std::begin(m_terms_1e);
auto itterm = std::begin(m_terms_1e);
auto itcoeff = std::begin(m_coeff_1e);
for (; itterm != std::end(m_terms_1e); ++itterm, ++itcoeff) {
ret.insert(std::make_pair(itterm->id(), (*itcoeff) * (*itterm)));
@@ -66,18 +66,18 @@ struct IopScfState final : public gscf::ScfStateBase<ProblemMatrix, OverlapMatri
// TODO This is all but good. The DiagMat template argument really has to
// disappear (or we need yet a layer ... a common base independent of
// DiagMat.
base_type::last_error_norm = other_state.last_error_norm;
base_type::last_error_norm = other_state.last_error_norm;
base_type::problem_matrix_ptr = other_state.problem_matrix_ptr;
base_type::push_new_eigensolution(other_state.previous_eigensolution(),
other_state.eigenproblem_stats());
base_type::push_new_eigensolution(other_state.eigensolution(),
other_state.eigenproblem_stats());

last_tot_energy_change = other_state.last_tot_energy_change;
last_1e_energy_change = other_state.last_1e_energy_change;
last_1e_energy_change = other_state.last_1e_energy_change;

last_step_tot_energy = other_state.last_step_tot_energy;
last_step_1e_energy = other_state.last_step_1e_energy;
last_step_1e_energy = other_state.last_step_1e_energy;

// The following is correct, since we pass the current state number on to the
// IopScfStateWrapper as well, such that it accumulates to give the correct
@@ -152,7 +152,7 @@ class IopScf final : public gscf::ScfBase<IopScfState<IntegralOperator, OverlapM
max_tot_energy_change =
map.at(IopScfKeys::max_tot_energy_change, max_tot_energy_change);
max_1e_energy_change = map.at(IopScfKeys::max_1e_energy_change, max_1e_energy_change);
verbosity = map.at(IopScfKeys::verbosity, verbosity);
verbosity = map.at(IopScfKeys::verbosity, verbosity);

// Copy the map to the internal storage such that we
// can pass it on to the actual eigensolvers.
@@ -258,10 +258,10 @@ void IopScf<IntegralOperator, OverlapMatrix>::solve_up_to(state_type& state,
size_t run_until_iter) const {
// Setup inner solver (max => User settings of accuracy take preference)
WrappedSolver inner_solver{m_inner_params};
inner_solver.max_error_norm = std::max(base_type::max_error_norm, error);
inner_solver.max_1e_energy_change = std::max(100. * error, max_1e_energy_change);
inner_solver.max_error_norm = std::max(base_type::max_error_norm, error);
inner_solver.max_1e_energy_change = std::max(100. * error, max_1e_energy_change);
inner_solver.max_tot_energy_change = std::max(error, max_tot_energy_change);
inner_solver.run_until_iter = run_until_iter;
inner_solver.run_until_iter = run_until_iter;

// Setup inner state
typename WrappedSolver::state_type inner_state{state.problem_matrix(),
@@ -305,7 +305,7 @@ void IopScf<IntegralOperator, OverlapMatrix>::solve_state(state_type& state) con

// TODO make this configurable
const real_type diis_startup_error_norm = 0.25;
const size_t diis_startup_iter = 12;
const size_t diis_startup_iter = 12;

{ // truncated ODA
solve_up_to<TruncODASolver>(state, diis_startup_error_norm, diis_startup_iter);
@@ -386,7 +386,7 @@ void IopScf<IntegralOperator, OverlapMatrix>::on_converged(state_type& s) const
<< "with energies" << std::endl;

// For the virial ratio we need accumulated kinetic and potential energies.
real_type kinetic_energy = 0;
real_type kinetic_energy = 0;
real_type potential_energy = fock_bb.energy_nuclear_repulsion();

size_t friendly_label_size = nuc_rep_label.size();
@@ -22,7 +22,7 @@
namespace molsturm {

const std::string IopScfKeys::max_tot_energy_change = "max_tot_energy_change";
const std::string IopScfKeys::max_1e_energy_change = "max_1e_energy_change";
const std::string IopScfKeys::verbosity = "verbosity";
const std::string IopScfKeys::max_1e_energy_change = "max_1e_energy_change";
const std::string IopScfKeys::verbosity = "verbosity";

} // namespace molsturm
@@ -28,7 +28,7 @@ MolecularSystem::MolecularSystem(gint::Structure structure_, double charge_,
n_beta(0),
charge(std::move(charge_)) {
// Compute number of electrons to distribute to alpha and beta spin:
const double n_elec = structure.total_charge() - charge;
const double n_elec = structure.total_charge() - charge;
const size_t n_elec_count = static_cast<size_t>(n_elec);
assert_throw(n_elec - n_elec_count < 1e-12, ExcNonIntegerElectronCount(n_elec));

@@ -54,7 +54,7 @@ MolecularSystem::MolecularSystem(gint::Structure structure_, double charge_,
"The multiplicity should be larger or equal to the electron count (" +
std::to_string(n_elec_count) + ") plus 1"));

const bool even_elec = n_elec_count % 2 == 0;
const bool even_elec = n_elec_count % 2 == 0;
const bool even_2spin = spin_twice % 2 == 0;

// Odd spin_twice values imply a half-integer total spin
@@ -72,7 +72,7 @@ MolecularSystem::MolecularSystem(gint::Structure structure_, double charge_,

// Compute number of alpha and beta electrons
n_alpha = (n_elec_count - spin_twice) / 2 + spin_twice;
n_beta = n_elec_count - n_alpha;
n_beta = n_elec_count - n_alpha;

// Check that this makes sense
if (multiplicity_ == linalgwrap::Constants<size_t>::invalid) {
@@ -27,8 +27,8 @@ DefException2(ExcInvalidMultiplicity, size_t, std::string,
<< "The multiplicity \"" << arg1
<< " is invalid for this molecular system: " << arg2);

DefException1(ExcNonIntegerElectronCount, double, << "The determined electron count "
<< arg1 << " is not an integer value.");
DefException1(ExcNonIntegerElectronCount, double,
<< "The determined electron count " << arg1 << " is not an integer value.");

// TODO Allow to construct from GenMap!
/** Class which describes the physical system to model
Oops, something went wrong.

0 comments on commit fc1268b

Please sign in to comment.