{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-guides/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Unit handling","description":"Accelerate E&P application development and protect your innovation by consuming our Data and Domain APIs / Platform APIs.","lang":"en-US","meta":[{"name":"robots","content":"noindex"}],"llmstxt":{"hide":false}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"unit-handling","__idx":0},"children":["Unit handling"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In order to better align with Petromod unit handling, units in the Open Simulator (for example, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Overlay.unit"]},") are now ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit"]}," objects, rather than simple strings. When specifying units (for a new overlay, for example) it is still possible to use a string, but it is recommended that ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit"]}," objects are used instead."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For example, instead of assigning: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["my_new_overlay.unit = \"Kelvin\""]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["my_new_overlay.unit = pmpy.Unit(\"Kelvin\", pmpy.UnitGroup.Temperature)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Because Petromod distinguishes units by their context (for example: temperature versus temperature difference, pressure versus capillary pressure, and so on), the second form is safer. This is because there is no chance of unintentionally assigning the Kelvin unit in the TemperatureDifference group, and then having the Petromod viewers display your overlay as if it were a temperature difference."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For a list of unit groups enter ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["help(pmpy.UnitGroup)"]}," in the python interpreter. Similarly, enter ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["help(pmpy.Unit)"]}," to see a list of defined Petromod (PM) and SI units. In this instance, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit.SITemperature"]}," could be used instead of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit(\"Kelvin\", pmpy.UnitGroup.Temperature)"]}," for example."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Note:"]}," A ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit"]}," is not a string, therefore it may be necessary to explicitly convert it to one in some contexts (for example: when your script writes messages to the console)."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If “u” was a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pmpy.Unit"]}," this could be done using:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["str(u)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Or equivalently, by referring to the string:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["u.name"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Parent topic:"]},{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/solutions/petromod-python-toolbox/tutorial/get_started"},"children":["Get started"]}]}]},"headings":[{"value":"Unit handling","id":"unit-handling","depth":1}],"frontmatter":{"seo":{"title":"Unit handling"}},"lastModified":"2026-08-24T13:00:34.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/solutions/petromod-python-toolbox/tutorial/unit_handling","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}