15 std::vector<double>
const& Y,
21 std::ostringstream ss;
22 ss <<
"Failed to get species timescales: " << result.error();
25 const std::unordered_map<fourdst::atomic::Species, double>& timescales = result.value();
28 std::size_t maxNameLen = std::string_view(
"Species").size();
29 for (
const auto &key: timescales | std::views::keys) {
30 std::string_view name = key.name();
31 maxNameLen = std::max(maxNameLen, name.size());
35 constexpr int timescaleWidth = 12;
37 std::ostringstream ss;
38 ss <<
"== Timescales (s) ==\n";
41 ss << std::left << std::setw(static_cast<int>(maxNameLen) + 2) <<
"Species"
42 << std::right << std::setw(timescaleWidth) <<
"Timescale (s)" <<
"\n";
45 ss << std::string(static_cast<int>(maxNameLen) + 2 + timescaleWidth,
'=') <<
"\n";
47 ss << std::scientific;
50 for (
auto const& [species, timescale] : timescales) {
51 const std::string_view name = species.name();
52 ss << std::left << std::setw(static_cast<int>(maxNameLen) + 2) << name;
54 if (std::isinf(timescale)) {
55 ss << std::right << std::setw(timescaleWidth) <<
"inf" <<
"\n";
57 ss << std::right << std::setw(timescaleWidth)
58 << std::scientific << std::setprecision(3) << timescale <<
"\n";
63 ss << std::string(static_cast<int>(maxNameLen) + 2 + timescaleWidth,
'=') <<
"\n";
virtual std::expected< std::unordered_map< fourdst::atomic::Species, double >, expectations::StaleEngineError > getSpeciesTimescales(const std::vector< double > &Y, double T9, double rho) const =0
Compute timescales for all species in the network.
std::string formatNuclearTimescaleLogString(const DynamicEngine &engine, const std::vector< double > &Y, const double T9, const double rho)
Formats a map of nuclear species timescales into a human-readable string.