计算Eggmodel Data doc
%加载模块
mrstModule add ad-core ad-blackoil spe10 blackoil-sequential mrst-gui
%预设求解器
psolver = BackslashSolverAD()
tsolvrt = GMRES_ILUSolverAD()
%挑选层
layer = 1
mrstModule add ad-core ad-blackoil blackoil-sequential spe10
%读取建立model
[G,rock,fluid,deck,state] = setupEGG()
%G包含地质数据(点线面等参数)
%rock 岩石参数(渗透率,孔隙度,净毛率)
%fluid 流体参数(三相密度、压缩系数、相渗)
%deck 导入模型的关键词
%state 初始状态(压力、流量、饱和度)
model = selectModelFromDeck(G,rock,fluid,deck)
%物理模型的一种,跟simulateScheduleAD配合使用,设置误差、参数的范围、
% 求解类型以及地质、井位数据
schedule = convertDeckScheduleToMRST(model,deck)
%把deck类型的schedule转换为MRST 类型的,跟simulateScheduleAD配合使用
%建立顺序模型(sequential model)
seqModel = getSequentialModelFromFI(model, 'pressureLinearSolver', psolver,....
'transportLinearSolver', tsolver)
%设置时间模型的形式,压力线性求解和运输线性求解,设置(压力、运输求解模式,误差、迭代次数、数值范围...
%流体、岩石属性,重力、地质模型等
%求解模型run
[wsSeq, statesSeq, repSeq] = simulateScheduleAD(state, seqModel, schedule)
%自动求解非线性物理模型 [wellsols,asatate,report] = fun(initstate,model,schedule)
%initstate 初始状态(地层初始压力——差不大,流量——初始是0,饱和度(0.1,0.9)
%model 物理模型决定雅克比矩阵和收敛性
%schedule .control 井的生产状况、边界条件等
%.step 包括(control 和 val)control 控制时间步
%val 控制步长
%wellsols 记录每一个井的生产情况/每一时间步 ‘outputministeps’-》enable
%states 每一个时间步的状态 ‘outputministeps’-》enable
%schedulerport 包含模拟的细节(时间、收敛性、迭代次数等)
%全隐式仿真
solver = NonLinearSolver() %非线性求解、利用牛顿法
solver.LinearSolver = CPRSolverAD('ellipticSolver',psolver); %设置一种椭圆求解器。
[wsFIMP,statesFIMP,repFIMP] = simulateScheduleAD(state,model,schedule,'nonlinearsolver',solver)
%驻地办法差分来求解
%画图部分(比较两种方法)
figure(1); clf; hold on
plot(cumsum(repSeq.SimulationTime)/60, 'b-*')
plot(cumsum(repFIMP.SimulationTime)/60, 'r-o')
ylabel('Simulation time [minutes]')
xlabel('Control step #')
legend('Sequential implicit', 'Fully implicit')
%交互界面画图
G = model.G;
W = schedule.control(1).W;
% Plot the well curves
plotWellSols({wsSeq, wsFIMP}, cumsum(schedule.step.val), ...
'datasetnames', {'Sequential', 'FIMP'}, 'field', 'qOs')
% 油藏动态图
figure;
plotToolbar(G, statesSeq);
axis equal tight
view(90, 90);
plotWell(G, W);
title('Sequential implicit')
figure;
plotToolbar(G, statesFIMP);
axis equal tight
view(90, 90);
plotWell(G, W);
title('Fully-implicit')
caxis([4*10^7 5*10^7])
%Plot time taken
figure;
subplot(1, 2, 1)
bar([sum(repFIMP.SimulationTime), sum(repSeq.SimulationTime)]/60)
set(gca, 'XTickLabel', {'Fully-implicit', 'Sequential'})
ylabel('Simulation time [minutes]')
set(gca, 'FontSize', 12)
axis tight
subplot(1, 2, 2)
plotCellData(model.G, statesSeq{60}.s(:, 1), 'edgecolor', 'none')
title('S_w')
set(gca, 'FontSize', 12)
axis equal tight off