Dear Tazkera,
You got this error that dd['Gas', 'PhysicalMass'] doesn't exist because while defining new field you didn't add it to yt available field. To do so you have to add one more line after
return M in derived field
PhysicalMass...
ds.add_field(("gas", "PhysicalMass"), function = _PhysicalMass, units="g")
Now why you are getting the wrong output: Actually now Yt itself do the conversion between the units. For doing so you can do one thing:
1) if you want to use ["Gas","Mass"] as a field while plotting or deriving new field you can you this:
data["Gas", "Mass"].in_units('g')
2) if you want to see it in output on terminal then do this:
PhysicalMass = dd["Gas","Mass"]; then PhysicalMass.in_units('g') will give you the correct output.
Actually, the problem is with your code for getting mass wrong (in the gram of order 74) is that while giving output Yt itself first converting ["Gas","Mass"] in units of "g" and then it multiplied with your conversion formula.
Please ask if you didn't understand any point in this reply. Hope this will help you.
-Prateek