P# Lesson 3: Calculate KPIs

Exercise 3

Create a script that calculates some KPIs (e.g. WC, WOR, cumulative oil production) for all wells and the entire production history in a monthly time increment. Apply a gap filling method to all gaps in the oil production rate. Make sure to save the results back into the database.

Exercise 3 Solution

  • When running the script, remember nothing is saved back into the database.
  • Only when the Saving statement is available and the Run with Saving option was clicked, results like the KPIs will be written back into the database.
  • If the script is being executed during workflow execution, Saving statements will of course be executed (just like the run with saving option).
Context "All Wells FromStartToEnd Monthly"

   Entity Set "All Wells"

   Scope "FromStartToEnd Monthly"

End Context

Entity Set "All Wells"

   EntitiesByType("Well")

End Set

Scope "FromStartToEnd Monthly"

   Between StartOf()

   And EndOf()

   Step Monthly

End Scope

Table "KPIs"

   Column "Oil Rate" in "m3/d"

   FillGaps("oil production rate" in "m3/d")

End Column

Column "Water Rate" in "m3/d"

   "water production rate" in "m3/d"

End Column

Column "WOR" in " " Saving "water oil ratio"

   If Column "Oil Rate" in "m3/d" > 0 Then

   Column "Water Rate" in "m3/d" / Column "Oil Rate" in "m3/d"

   Else

   Null()

   End If

End Column

Column "WC" in " " Saving "water cut"

   If Column "Oil Rate" in "m3/d" > 0 Then

   Column "Water Rate" in "m3/d" / (Column "Water Rate" in "m3/d" + Column "Oil Rate" in "m3/d")

   Else

   Null()

   End If

End Column

Column "Cum Oil" in "m3" Saving "cumulative oil production"

   Cumulative(Column "Oil Rate" in "m3/d" * DaysInMonth())

End Column

End Table