Dear Lammps Users,
I am conducting a project using lammps involving evaporation of water inside nanopores. One of the measurements I’m trying to take is the temperature of the water molecules (tip4p). To do this I have written a Matlab code but the answers have been off and running a test simulation of only 1000 water molecules shows answers are exactly 2/3 of the actual temperature.
Some assumptions I’ve made:

Temperature is set using ‘fix fx tip4p nvt temp 300.0 300.0 200.0’ command

Lammps temperature is given by ‘thermo_style custom step temp’ command

Matlab temperature is given by: 1/2 m v^2 = 3/2 N k T

Kinetic energy is evaluated from both hydrogen and oxygen atom velocities

N is the total number of hydrogen and oxygen atoms
Questions I have: 
Is the temperature equation I’m using correct?

Should KE be derived from just oxygen atom velocity and water molecule mass or by current method?

What am I misunderstanding that leads to matlab producing 2/3 lammps result?
Attached are the results I’m obtaining and the matlab script I used along with the lammps run file (although the simulations appear to run without any issues).
Any advice you can offer is greatly appreciated.
Best regards,
Sam Shilliday
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
run.int.nvt (1.45 KB)
water_temp.m (4.5 KB)