diff --git a/include/openmc/material.h b/include/openmc/material.h index 107f436c9..2454de071 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -65,6 +65,14 @@ public: //! \param[in] density Density of the nuclide in [atom/b-cm] void add_nuclide(const std::string& nuclide, double density); + //! Get density in [atom/b-cm] + //! \return Density in [atom/b-cm] + double density() const { return density_; } + + //! Get density in [g/cm^3] + //! \return Density in [g/cm^3] + double density_gpcc() const { return density_gpcc_; } + //! Set total density of the material int set_density(double density, std::string units); diff --git a/src/material.cpp b/src/material.cpp index 9e6240560..45d000d4a 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1216,7 +1216,7 @@ openmc_material_get_density(int32_t index, double* density) { if (index >= 0 && index < model::materials.size()) { auto& mat = model::materials[index]; - *density = mat->density_gpcc_; + *density = mat->density_gpcc(); return 0; } else { set_errmsg("Index in materials array is out of bounds.");