Skeeter D Posted September 6, 2019 Share Posted September 6, 2019 I've used the original Spotfire DCA workflow and added a few more bounds to the TC variables (b, IP, and De). Code looks to be flowing through correctly. My only qualm is being able to add a few if statements based on a ramp-up period when the well is originally flowing back. Some wells don't start IP until the second month, while others start at 0. The wells that IP immediately fit perfectly while the wells that IP either on Month 1 or Month 2 have a rather weird fit to the data. I'm trying to add a ramp-up or days flat period. Any help on this would be greatlyappreciated. Code below Hyp.q.forward.fun = function( time, Hyp.qi, Hyp.b, Hyp.Di ){ 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) 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, lower=c(0,0,0), upper=c(Inf, 1.6,Inf), method="L-BFGS-B" ) 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 ) } DCA Decline Curve Analysis Oil and Gas Sector Oil and Gas Analytics TERR R Link to comment Share on other sites More sharing options...
Jason Alley Posted September 21, 2019 Share Posted September 21, 2019 Thearps.with.buildup function in the arpsDCA library should help to give you some direction. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now