I want to ask a question about calculating temperatures based on physical locations. I am doing heat transfer case of water confined between solid walls. In order to plot temperature profile in the water system, I need to calculate the temperature of water in certain regions. I could not use the “compute temp” command which calculates temperature based on groups. LAMMPS has a command “compute temp/region”. But this command does not subtract out degrees of freedom due to the constraint applied by “fix shake”.

The reason for this is that it's somewhat an ambiguous calculation
(what about waters that are both inside and outside the region),
and that's it's complicated to do (since waters leave/enter the region).

You could estimate it yourself by simply counting the atoms in the
region (variable region function) and dividing by 3 to get molecules,
then adjust the degrees-of-freedom yourself.

Thanks a lot. Each water molecule has two rigid bonds and rigid angle, so if I have N water molecules in a certain region, I should subtract 3*N degrees-of-freedom to calculate the temperature of water. Am I right?

A fully rigid water molecule has 6 dof, 3 translation, 3 rotation.
Which is 3x3 = 9 for the atoms minus 3 for the constraints.

So if you count the number of water molecules in your region
a good estimate of the temperature is simply 6/9 = 2/3 of
the atomic temperature you would get with compute temp.