Function tracks::checkSurfaceAbundances

Function Documentation

void tracks::checkSurfaceAbundances(const std::vector<double> &data, std::size_t nrow, std::size_t ncol, const std::vector<std::size_t> &qtyIdx, const std::string &context)

Check that every tabulated point of a track has physical surface mass fractions.

Tracks2D and Tracks3D call this on every track they read, so that corrupt track data is reported where it is loaded, rather than silently absorbed by renormalizeSurfaceAbundances() – which, by design, corrects any excess above 1 in an interpolated value, since interpolating each surface mass fraction independently legitimately overshoots by up to several percent even when every tabulated point is valid.

Parameters:
  • data – A track’s data, as read by utils::readDataset2D: nrow rows (one per time point) of ncol fields, row-major

  • nrow – Number of rows in data

  • ncol – Number of fields per row in data

  • qtyIdx – Column of data holding each FieldIdx quantity, as built by Tracks2D/Tracks3D (qtyIdx[k] is the column holding quantity k)

  • context – Description of the track being checked (e.g. its file, group, and dataset), for the error message

Throws:

std::runtime_error – if any row’s X, Y, C, N, or O is not finite or is negative (no tabulated value in any track set slug ships is), or their sum exceeds 1 + surfaceAbundanceTol