From 5a644b0e5de4bdeece9835f4fa18709393e05a48 Mon Sep 17 00:00:00 2001 From: athomps Date: Mon, 19 Dec 2011 16:39:40 +0000 Subject: [PATCH] Added protection for zero atoms case git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@7380 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/fix_nh.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index 2bf3df8a89..1aa2ad87fb 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -1596,7 +1596,9 @@ void FixNH::nhc_temp_integrate() eta_mass[ich] = boltz * t_target / (t_freq*t_freq); } - eta_dotdot[0] = (kecurrent - ke_target)/eta_mass[0]; + if (eta_mass[0] > 0.0) + eta_dotdot[0] = (kecurrent - ke_target)/eta_mass[0]; + else eta_dotdot[0] = 0.0; double ncfac = 1.0/nc_tchain; for (int iloop = 0; iloop < nc_tchain; iloop++) { @@ -1623,8 +1625,11 @@ void FixNH::nhc_temp_integrate() t_current *= factor_eta*factor_eta; kecurrent = tdof * boltz * t_current; - eta_dotdot[0] = (kecurrent - ke_target)/eta_mass[0]; - + + if (eta_mass[0] > 0.0) + eta_dotdot[0] = (kecurrent - ke_target)/eta_mass[0]; + else eta_dotdot[0] = 0.0; + for (ich = 0; ich < mtchain; ich++) eta[ich] += ncfac*dthalf*eta_dot[ich];