Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

please run this program if any one using MRST MATLAB

1 Ansicht (letzte 30 Tage)
SAEED UR REHMAN
SAEED UR REHMAN am 24 Jan. 2018
Geschlossen: John D'Errico am 24 Jan. 2018
%---------------------------------------------------------------------------------- % SYNOPSIS: % mrstEnKF % % DESCRIPTION: % Main program of the Ensemble Kalman Filter module for the SINTEF reservoir % simulator MRST. % %{ Copyright 2012, 2013, TNO, Petroleum Geosciences.
This file is part of the EnKF module for MRST.
The EnKF module is free software. You can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.
The EnKF module is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this
code. If not, see <http://www.gnu.org/licenses/>.
%}
%
% The code has been tested with Matlab version R2011a.
%
% Please acknowledge TNO in any reports or publications that use the EnKF module.
% TNO welcomes any feedback or improvements to the code.
%
% Written by Olwijn Leeuwenburgh, TNO, 2013.
%----------------------------------------------------------------------------------
cdd = pwd;
addpath(genpath(cdd));
%---------------------------------------------------------------------------------- % input section %---------------------------------------------------------------------------------- inputSettings;
%---------------------------------------------------------------------------------- % loop over experiments %---------------------------------------------------------------------------------- for ir = 1 : nrepeats + 1
rng(ir,'twister');
%---------------------------------------------------------------------------------
% preparation
%---------------------------------------------------------------------------------
if exist(workdir,'dir')
[~, ~, ~] = rmdir(workdir,'s');
end
[status, message, messageid] = mkdir(workdir);
cd(workdir);
%---------------------------------------------------------------------------------
% loop over update times
%---------------------------------------------------------------------------------
t = 0;
time = convertTo(t,day);
tda = union(dtu:dtu:tend,tend);
tdo = union(dto:dto:tend,tend);
tds = union(dts:dts:tend,tend);
tda = union(tda,tsim);
for iu = 1 : length(tda)
tu = tda(iu);
% select observation times for the current update step
if iu > 1
obsTimes = intersect(tdo(tdo > tda(iu-1)),tdo(tdo <= tda(iu)));
else
obsTimes = tdo(tdo <= tda(iu));
end
obsTimes = convertTo(obsTimes,day);
%-------------------------------------------------------------------------------
% loop over iterations
%-------------------------------------------------------------------------------
iter = 1; niter = niterations + 1;
if tu == tsim && tsim > tend
niter = 1;
end
while iter <= niter
if iter > 1
% restart from previous update time
if iu > 1
t = tda(iu-1);
end
% restart from time zero
if restart == 1
t = 0;
clear timeSteps wellData*
end
end
time = convertTo(t,day);
%-----------------------------------------------------------------------------
% read current states from EnKF file or rebuild grid and run model from time 0
%-----------------------------------------------------------------------------
initializeModel;
%-----------------------------------------------------------------------------
% simulate to next update time
%-----------------------------------------------------------------------------
simulateModel;
%-----------------------------------------------------------------------------
% construct ensemble state matrix A
%-----------------------------------------------------------------------------
constructEnsemble;
%-----------------------------------------------------------------------------
% observations
%-----------------------------------------------------------------------------
ai = alpha(min(numel(alpha),iter));
if isempty(find(strncmp('sat',obstype,3),1))
[Y,R,D,loc,io] = makeObservations(wellData,wellDataE,timeSteps,...
obsTimes,obstype,transformobs,sigma,ai);
else
[Y,R,D,loc,io] = makeObservations(wellData,wellDataE,timeSteps,...
obsTimes,obstype,transformobs,sigma,ai,...
sat,sate,tds,imap);
end
clear sat* ai
%-----------------------------------------------------------------------------
% remove obsolete observations
%-----------------------------------------------------------------------------
if size(Y,1) > 0
if iter == 1
ro = setdiff(1:size(Y,1),io); ro0 = ro;
else
ro = ro0;
end
Y(ro,:) = []; D(ro,:) = []; R(ro) = []; loc(ro) = [];
end
nobs = size(Y,1);
if nobs == 0, iter = niter; end
%-----------------------------------------------------------------------------
% evaluate mean normalized squared model-data misfit
%-----------------------------------------------------------------------------
mse = evaluateMSE(Y, D, R);
%-----------------------------------------------------------------------------
% update the models if needed
%-----------------------------------------------------------------------------
if nmembers > 0 && iter < niter
%---------------------------------------------------------------------------
% transformation of states
%---------------------------------------------------------------------------
A = applyTransform(A,nstat,transform);
EnkfFile = ['states_' num2str(time) '_' num2str(iter) '.mat'];
%---------------------------------------------------------------------------
% initialization, stopping criteria and step size adjustment for EnRML
%---------------------------------------------------------------------------
if strcmp(method,'EnRML')
prepareEnRML;
end
%---------------------------------------------------------------------------
% ensemble update
%---------------------------------------------------------------------------
if iter < niter
updateEnsemble;
end
%---------------------------------------------------------------------------
% inflation
%---------------------------------------------------------------------------
if inflation > 0
inflateEnsemble;
end
%---------------------------------------------------------------------------
% back transformation of states
%---------------------------------------------------------------------------
U = applyTransform(U,nstat,itransform);
%---------------------------------------------------------------------------
% fix updated states
%---------------------------------------------------------------------------
U = fixStates(U,nstat);
%---------------------------------------------------------------------------
% store results from udating
%---------------------------------------------------------------------------
if strcmp(method,'EnRML')
save(EnkfFile,'xt','U','A0','Y0','A1','J','beta');
else
save(EnkfFile,'xt','U','mse');
end
else
%---------------------------------------------------------------------------
% store results from simulation with updated models
%---------------------------------------------------------------------------
EnkfFile = ['states_' num2str(time) '_' num2str(iter) '.mat'];
U = A;
if isempty(G)
save(EnkfFile,'xt','U','mse');
else
save(EnkfFile,'xt','U','mse','gridE');
end
end
clear A U xt
%-----------------------------------------------------------------------------
% save experiment input settings and well data
%-----------------------------------------------------------------------------
summary = ['summary_' num2str(time) '_iter' num2str(iter) '.mat'];
if nmembers > 0
save(summary,'wellData','wellDataE','timeSteps','settings');
else
save(summary,'wellData','timeSteps','settings');
end
iter = iter+1;
end
end
cd(cdd);
%---------------------------------------------------------------------------------- end % repeated experiments %----------------------------------------------------------------------------------
  2 Kommentare
Rik
Rik am 24 Jan. 2018
After I quick scan, I get the feeling a lot of functions are missing, as well as some other files containing data. You also didn't describe your problem, only using a tag to tell us you have an error.
Have a read here and here. It will greatly improve your chances of getting an answer.
Rik
Rik am 24 Jan. 2018
Comment by e-mail:
please send me your email i want to share the whole scenario with you please
Your question should be complete here. I'm not sure I can even answer your question for you, so why share relevant details only with me? You can add all files in a zip.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by