Mathematical modelling of nanoparticle melting or freezing