필터 지우기
필터 지우기

Can you help me find the mistake in my Matlab code?

조회 수: 2 (최근 30일)
Tien Tran
Tien Tran 2016년 1월 9일
답변: Geoff Hayes 2016년 1월 10일
I use Matlab to find the optimal number of wells, however when I run the file of Optimization.m, it seems not work. I don't know where it is wrong. I have checked my functions, they are correctly, but when I set direct number to NPV.m, it run too slow. So, can you help me find my mistake in Optimization.m as the attached file and how to improve speed of process
  댓글 수: 6
Geoff Hayes
Geoff Hayes 2016년 1월 10일
Tien - are you sure that the data you are reading from each column corresponds to the variable that you are reading it into to? And that the units are the same? For example, your RFpl (recovery factor at end of plateau) has values between 30 and 70 (from the VariableSet.xlsx file, but your example from Tfigure43.m assigns 0.5 to this same variable. Does this mean that the wrong column from the Excel file is being assigned to this variable or has it not been converted correctly? Please verify that the data in the file is correct and that you are reading each column correctly.
As for performance, look at the following lines from Optimization.m
if NPV(j, OGIP, PGi, C, n, Pwh, ID, depth, cost, price, rate, RFpl) <= 0
wellCountOpt = 0;
npvOpt = 0;
wellCountNPV(i,:) = [wellCountOpt,npvOpt];
else
delta = 10;
npvOld = NPV(j, OGIP, PGi, C, n, Pwh, ID, depth, cost, price, rate, RFpl);
npvNew = NPV(j+delta, OGIP, PGi, C, n, Pwh, ID, depth, cost, price, rate, RFpl);
diff = npvNew - npvOld;
% etc.
Note that in the if condition you call
NPV(j, OGIP, PGi, C, n, Pwh, ID, depth, cost, price, rate, RFpl)
and if this isn't zero, then we calculate this again for npvOld in the else block. Rather than doing this twice, just do it the once as
npvResult = NPV(j, OGIP, PGi, C, n, Pwh, ID, depth, cost, price, rate, RFpl);
if nvpResult <= 0
% do something
else
delta = 10;
nvpOld = nvpResult;
% etc.
end
The same can be applied to your Tfigure43.m file which duplicates calls to this function.
Tien Tran
Tien Tran 2016년 1월 10일
Thank you very much. You have found my mistake, RFpl in VariableSet.xlsx lies in interval (30% -> 70%), so data in Excel file is wrong and the result is incorrect. Best regards.

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2016년 1월 10일
Requested that Tien verify that the data being read from each column was correct with respect to units and variable descriptions. Pointer out that the RFpl (recovery factor at end of plateau) has values between 30 and 70 (from the VariableSet.xlsx file), but that the example from Tfigure43.m assigned 0.5 to this same variable.
Tien verified that the data in the column was incorrect (percentages rather than the decimal equivalent).

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by