Jump to content
We've recently updated our Privacy Statement, available here. ×

How to implement the "aRpsDCA" package into a DXP file


Georgi Koemdzhiev

Recommended Posts

Hello, I am trying to figure out how one can consume the"aRpsDCA" R package to generate a Decline Curve Analysis. Currently, I am trying to replace the code from "Simple Decline Curve Analysis Data Function for TIBCO Spotfire" by simply utilising the"aRpsDCA" package. However, I have no R experience.

 

This is TIBCO's R code:

# Inputs

# col.Date # [Analysis Data].[${well.date}]

# col.Production # [Analysis Data].[${well.production}]

 

# Outputs

# Hyp.qi

# Hyp.b

# Hyp.Di

 

#------------------------------------------------------------------------------

Hyp.q.forward.fun = function( time, Hyp.qi, Hyp.b, Hyp.Di ){ # time in days

# Peter Shaw

# e.g. SPE 98042 (4)

Hyp.q.theo = Hyp.qi*(1 + Hyp.b*Hyp.Di*time)^(-1/Hyp.b)

return(Hyp.q.theo)

}

#------------------------------------------------------------------------------

residfun = function(x,x.days,y.prod){

Hyp.qi = x[1]

Hyp.b = x[2]

Hyp.Di = x[3]

q.theo = (365.25/12)*Hyp.q.forward.fun(

time=x.days,

Hyp.qi=Hyp.qi,

Hyp.b=Hyp.b,

Hyp.Di=Hyp.Di)

#plot(x.days,y.prod); lines(x.days,q.theo)

residual = sqrt(sum((q.theo-y.prod)^2))

return(residual)

}

#------------------------------------------------------------------------------

min.data = 3

 

result = data.frame(

time.days = numeric(0),

time.months = numeric(0),

production = numeric(0),

theo = numeric(0)

)

Hyp.qi =as.numeric(NA)

Hyp.b =as.numeric(NA)

Hyp.Di.daily =as.numeric(NA)

Hyp.Di.annual=as.numeric(NA)

 

ok = length(col.Production)>0

if(ok) ok = length(col.Date) == length(col.Production)

 

if(ok){

u.order = order(col.Date)

 

col.Date = col.Date[u.order]

col.Production = col.Production[u.order]

 

t.days = as.numeric(difftime(col.Date,min(col.Date),units="days"))

t.months = round(t.days*12/365.25)

 

u0 = which.max(col.Production)

u = u0:length(col.Production)

 

x.months = t.months

x.days = t.days

y.prod = col.Production

 

x0 = c(y.prod[1]*12/365.25,1.00,0.005)

 

optim.result = optim(

par = x0,

fn=residfun,

x.days=x.days, y.prod=y.prod

)

 

Hyp.qi = optim.result$par[1]*(365.25/12) # Monthly

Hyp.b = optim.result$par[2]

Hyp.Di.daily = optim.result$par[3]

Hyp.Di.annual = optim.result$par[3]*365.25 # Annualized

 

result = data.frame(

time.days = x.days,

time.months = x.months,

production = y.prod

)

}

And this is what I currently have:

 

require(aRpsDCA)

 

t = col.Date # one year, in days

q nominal conversion and change units

Di = as.nominal(0.75, from.period = "year", to.period = "day"),

b = 1.5,

 

t

)Above, I have simply tried to use the col.Date & col.Production input parameters but I am quite sure that the code is wrong. Can somebody with more R experience help me here

I have followed this article on implementing the"aRpsDCA" package

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...