how to calculate the half-mass radius and tidal radius of a (simulated) globular cluster
Your first question is about computing, not astronomy. You find a cumulative histogram of distance from the centre of mass and where that reaches 50% of the stars.
As to your second point, there is no tidal radius; you need two bodies in order to have a defined tidal radius. The tidal radius of a cluster is directly related to the gravitational potential external to it.
Stars can escape from a cluster because sometimes they can accumulate enough kinetic energy in weak interactions with each other, that their speed exceeds the escape speed of the cluster. It is a classic result that the &quot;evaporation&quot; timescale is of order 100 times the cluster relaxation timescale, even in the absence of an external gravitational field (e.g. Gerhard 2000).