Skip to content

Commit

Permalink
Updated C++ standard to C++23.
Browse files Browse the repository at this point in the history
  • Loading branch information
fevangelista committed Nov 28, 2024
1 parent e9992cb commit 58d5768
Show file tree
Hide file tree
Showing 33 changed files with 11,998 additions and 23,151 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# Forte tests
Expand Down
8 changes: 2 additions & 6 deletions forte/base_classes/mo_space_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
*/

#include <algorithm>
#include <format>
#include <numeric>
#include <unordered_map>
#include <unordered_set>

#define FMT_HEADER_ONLY
#include "lib/fmt/core.h"

#include "psi4/psi4-dec.h"
#include "psi4/libpsi4util/PsiOutStream.h"
#include "psi4/libmints/molecule.h"
Expand Down Expand Up @@ -387,13 +385,11 @@ void MOSpaceInfo::compute_space_info() {
if (unassigned[h] < 0) {
// Throw and exception if there are more orbitals assigned to an irrep than there
// are available
auto msg = fmt::format("There is an error in the definition of the orbital spaces. "
auto msg = std::format("There is an error in the definition of the orbital spaces. "
" Total assigned MOs "
"for irrep {} is {} leaving {} orbitals unassigned.",
h, nmopi_[h], unassigned[h]);
outfile->Printf("\n%s", msg.c_str());

// generate a runtime error and use the fmt library to print the error message
throw std::runtime_error(msg);
}
}
Expand Down
14 changes: 6 additions & 8 deletions forte/genci/ci_occupation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
* @END LICENSE
*/

#include <format>
#include <string>

#define FMT_HEADER_ONLY
#include "lib/fmt/core.h"

#include "psi4/psi4-dec.h"
#include "psi4/libpsi4util/PsiOutStream.h"

Expand Down Expand Up @@ -414,22 +412,22 @@ std::string occupation_table(size_t num_spaces,
std::string s;
s += "\n Config.";
for (size_t i = 0; i < num_spaces; i++) {
s += fmt::format(" Space {:1}", i + 1);
s += std::format(" Space {:1}", i + 1);
}
s += "\n ";
for (size_t i = 0; i < num_spaces; i++) {
s += fmt::format(" α β ");
s += std::format(" α β ");
}
int ndash = 7 + 10 * num_spaces;
std::string dash(ndash, '-');
s += fmt::format("\n {}", dash);
s += std::format("\n {}", dash);
for (size_t num_conf{0}; const auto& [aocc_idx, bocc_idx] : occupation_pairs) {
num_conf += 1;
const auto& aocc = alfa_occupation[aocc_idx];
const auto& bocc = beta_occupation[bocc_idx];
s += fmt::format("\n {:6d} ", num_conf);
s += std::format("\n {:6d} ", num_conf);
for (size_t i = 0; i < num_spaces; i++) {
s += fmt::format(" {:4d} {:4d}", aocc[i], bocc[i]);
s += std::format(" {:4d} {:4d}", aocc[i], bocc[i]);
}
}
return s;
Expand Down
10 changes: 4 additions & 6 deletions forte/helpers/printing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
*/

#include <algorithm>
#include <format>
#include <vector>

#define FMT_HEADER_ONLY
#include "lib/fmt/core.h"

#include "psi4/psi4-dec.h"
#include "psi4/libpsi4util/PsiOutStream.h"
#include "psi4/libmints/matrix.h"
Expand Down Expand Up @@ -142,11 +140,11 @@ std::string matrix_to_string(const psi::Matrix& mat) {
auto nsopi = mat.rowspi();
auto nmopi = mat.colspi();
for (int h = 0; h < nirrep; ++h) {
str += fmt::format(" irrep {}:\n", h);
str += std::format(" irrep {}:\n", h);
for (int mu = 0; mu < nsopi.get(h); ++mu) {
str += fmt::format(" {:>3} ", mu);
str += std::format(" {:>3} ", mu);
for (int nu = 0; nu < nmopi.get(h); ++nu) {
str += fmt::format("{:10.6f} ", mat.get(h, mu, nu));
str += std::format("{:10.6f} ", mat.get(h, mu, nu));
}
str += "\n";
}
Expand Down
34 changes: 16 additions & 18 deletions forte/integrals/integrals.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
*/

#include <algorithm>
#include <format>
#include <cmath>
#include <numeric>

Expand All @@ -45,9 +46,6 @@
#include "integrals.h"
#include "memory.h"

#define FMT_HEADER_ONLY
#include "lib/fmt/core.h"

#ifdef HAVE_GA
#include <ga.h>
#include <macdecls.h>
Expand Down Expand Up @@ -410,68 +408,68 @@ void ForteIntegrals::print_info() {

std::string ForteIntegrals::repr() const {
std::string str = "ForteIntegrals object\n";
str += fmt::format(" Number of molecular orbitals: {:>15d}\n", nmo_);
str += fmt::format(" Nuclear repulsion energy: {:>15.8f}\n", nucrep_);
str += fmt::format(" Scalar energy: {:>15.8f}\n", scalar_energy_);
str += std::format(" Number of molecular orbitals: {:>15d}\n", nmo_);
str += std::format(" Nuclear repulsion energy: {:>15.8f}\n", nucrep_);
str += std::format(" Scalar energy: {:>15.8f}\n", scalar_energy_);
str +=
fmt::format(" Frozen-core energy: {:>15.8f}\n", frozen_core_energy_);
str += fmt::format(" Two-electron integral type: {:>15s}\n",
std::format(" Frozen-core energy: {:>15.8f}\n", frozen_core_energy_);
str += std::format(" Two-electron integral type: {:>15s}\n",
int_type_label.at(integral_type_));

if ((integral_type_ != IntegralType::Conventional) and
(integral_type_ != IntegralType::Custom)) {
return str;
}

str += fmt::format(" Alpha one-electron integrals (T + V_en)\n");
str += std::format(" Alpha one-electron integrals (T + V_en)\n");
for (size_t p = 0; p < nmo_; ++p) {
for (size_t q = 0; q < nmo_; ++q) {
if (std::abs(oei_a(p, q)) >= 1e-14)
str += fmt::format(" h[{:>6d}][{:>6d}] = {:>20.12f}\n", p, q, oei_a(p, q));
str += std::format(" h[{:>6d}][{:>6d}] = {:>20.12f}\n", p, q, oei_a(p, q));
}
}

str += fmt::format(" Beta one-electron integrals (T + V_en)\n");
str += std::format(" Beta one-electron integrals (T + V_en)\n");
for (size_t p = 0; p < nmo_; ++p) {
for (size_t q = 0; q < nmo_; ++q) {
if (std::abs(oei_b(p, q)) >= 1e-14)
str += fmt::format(" h[{:>6d}][{:>6d}] = {:>20.12f}\n", p, q, oei_b(p, q));
str += std::format(" h[{:>6d}][{:>6d}] = {:>20.12f}\n", p, q, oei_b(p, q));
}
}

str += fmt::format(" Alpha-alpha two-electron integrals <pq||rs>\n");
str += std::format(" Alpha-alpha two-electron integrals <pq||rs>\n");
for (size_t p = 0; p < nmo_; ++p) {
for (size_t q = 0; q < nmo_; ++q) {
for (size_t r = 0; r < nmo_; ++r) {
for (size_t s = 0; s < nmo_; ++s) {
if (std::abs(aptei_aa(p, q, r, s)) >= 1e-14)
str += fmt::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
str += std::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
q, r, s, aptei_aa(p, q, r, s));
}
}
}
}

str += fmt::format(" Alpha-beta two-electron integrals <pq||rs>\n");
str += std::format(" Alpha-beta two-electron integrals <pq||rs>\n");
for (size_t p = 0; p < nmo_; ++p) {
for (size_t q = 0; q < nmo_; ++q) {
for (size_t r = 0; r < nmo_; ++r) {
for (size_t s = 0; s < nmo_; ++s) {
if (std::abs(aptei_ab(p, q, r, s)) >= 1e-14)
str += fmt::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
str += std::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
q, r, s, aptei_ab(p, q, r, s));
}
}
}
}

str += fmt::format(" Beta-beta two-electron integrals <pq||rs>\n");
str += std::format(" Beta-beta two-electron integrals <pq||rs>\n");
for (size_t p = 0; p < nmo_; ++p) {
for (size_t q = 0; q < nmo_; ++q) {
for (size_t r = 0; r < nmo_; ++r) {
for (size_t s = 0; s < nmo_; ++s) {
if (std::abs(aptei_bb(p, q, r, s)) >= 1e-14)
str += fmt::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
str += std::format(" v[{:>6d}][{:>6d}][{:>6d}][{:>6d}] = {:>20.12f}\n", p,
q, r, s, aptei_bb(p, q, r, s));
}
}
Expand Down
Loading

0 comments on commit 58d5768

Please sign in to comment.