diff --git a/src/core/npt.cpp b/src/core/npt.cpp
index 1a202777d05..ac9b2d42316 100644
--- a/src/core/npt.cpp
+++ b/src/core/npt.cpp
@@ -16,11 +16,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-#include "npt.hpp"
+#include
+
#include "communication.hpp"
#include "config.hpp"
#include "errorhandling.hpp"
#include "integrate.hpp"
+#include "npt.hpp"
#ifdef NPT
void synchronize_npt_state(int n_steps) {
@@ -28,8 +30,13 @@ void synchronize_npt_state(int n_steps) {
MPI_Bcast(&nptiso.p_inst, 1, MPI_DOUBLE, 0, comm_cart);
MPI_Bcast(&nptiso.p_diff, 1, MPI_DOUBLE, 0, comm_cart);
MPI_Bcast(&nptiso.volume, 1, MPI_DOUBLE, 0, comm_cart);
- if (this_node == 0)
- nptiso.p_inst_av /= 1.0 * n_steps;
+ if (this_node == 0) {
+ if (n_steps == 0) {
+ nptiso.p_inst_av = std::nan("");
+ } else {
+ nptiso.p_inst_av /= 1.0 * n_steps;
+ }
+ }
MPI_Bcast(&nptiso.p_inst_av, 1, MPI_DOUBLE, 0, comm_cart);
}