fix error

This commit is contained in:
kk
2026-03-23 22:50:00 +08:00
parent 03c7a1ab40
commit b92444ef57
10 changed files with 2621 additions and 10 deletions
@@ -130,6 +130,7 @@ while t < tend
if dt >= dtmax(k) if dt >= dtmax(k)
dt = dtmax(k); dt = dtmax(k);
end end
emit_progress(w, sprintf('Progress: %.4f / %.4f day', t, sum(time)), count, t, dt);
if i ~= Nmax if i ~= Nmax
% waitbar(t / tend); % waitbar(t / tend);
% disp(t); % disp(t);
@@ -147,7 +148,21 @@ trun.leqs_solve_time=leqs_solve_time;
trun.total_simulation_time = etime(clock,t_start); trun.total_simulation_time = etime(clock,t_start);
trun.Newton_step=Newton_step; trun.Newton_step=Newton_step;
trun.Newtons_vs_time=Newtons_vs_time; trun.Newtons_vs_time=Newtons_vs_time;
emit_progress(w, 'Calculation completed', count, t, dt);
fprintf(''); fprintf('');
% close(h0); % close(h0);
end
function emit_progress(w, message, step, time_value, dt_value)
if ~isfield(w, 'progress_callback') || isempty(w.progress_callback)
return;
end
meta = struct( ...
'step', step, ...
'time', time_value, ...
'dt', dt_value, ...
'status', 'Running...');
feval(w.progress_callback, message, meta);
end
@@ -130,6 +130,7 @@ while t < tend
if dt >= dtmax(k) if dt >= dtmax(k)
dt = dtmax(k); dt = dtmax(k);
end end
emit_progress(w, sprintf('Progress: %.4f / %.4f day', t, sum(time)), count, t, dt);
if i ~= Nmax if i ~= Nmax
% waitbar(t / tend); % waitbar(t / tend);
% disp(t); % disp(t);
@@ -147,7 +148,21 @@ trun.leqs_solve_time=leqs_solve_time;
trun.total_simulation_time = etime(clock,t_start); trun.total_simulation_time = etime(clock,t_start);
trun.Newton_step=Newton_step; trun.Newton_step=Newton_step;
trun.Newtons_vs_time=Newtons_vs_time; trun.Newtons_vs_time=Newtons_vs_time;
emit_progress(w, 'Calculation completed', count, t, dt);
fprintf(''); fprintf('');
% close(h0); % close(h0);
end
function emit_progress(w, message, step, time_value, dt_value)
if ~isfield(w, 'progress_callback') || isempty(w.progress_callback)
return;
end
meta = struct( ...
'step', step, ...
'time', time_value, ...
'dt', dt_value, ...
'status', 'Running...');
feval(w.progress_callback, message, meta);
end
@@ -142,6 +142,7 @@ for k = 1:size(well_schedules,1)
if dt >= dtmax(k) if dt >= dtmax(k)
dt = dtmax(k); dt = dtmax(k);
end end
emit_progress(w, sprintf('Progress: %.4f / %.4f day', t, sum(time)), count, t, dt);
if i ~= Nmax if i ~= Nmax
% waitbar(t / tend); % waitbar(t / tend);
% disp(t); % disp(t);
@@ -159,7 +160,21 @@ trun.leqs_solve_time=leqs_solve_time;
trun.total_simulation_time = etime(clock,t_start); trun.total_simulation_time = etime(clock,t_start);
trun.Newton_step=Newton_step; trun.Newton_step=Newton_step;
trun.Newtons_vs_time=Newtons_vs_time; trun.Newtons_vs_time=Newtons_vs_time;
emit_progress(w, 'Calculation completed', count, t, dt);
fprintf(''); fprintf('');
% close(h0); % close(h0);
end
function emit_progress(w, message, step, time_value, dt_value)
if ~isfield(w, 'progress_callback') || isempty(w.progress_callback)
return;
end
meta = struct( ...
'step', step, ...
'time', time_value, ...
'dt', dt_value, ...
'status', 'Running...');
feval(w.progress_callback, message, meta);
end
@@ -1,4 +1,8 @@
function [Times, OutputRs, Wellpara, trun] = solver_NR(r, flow_model, f, os, state0, yitap,yitas,omega,Nmax,epsave,epsmax,dtmin,dtmax,Wellc,time,well_schedules) function [Times, OutputRs, Wellpara, trun] = solver_NR(r, flow_model, f, os, state0, yitap,yitas,omega,Nmax,epsave,epsmax,dtmin,dtmax,Wellc,time,well_schedules, progress_callback)
if nargin < 17
progress_callback = [];
end
w.yitap = yitap; w.yitap = yitap;
w.yitas = yitas; w.yitas = yitas;
w.omega = omega; w.omega = omega;
@@ -12,6 +16,7 @@ w.dtmax = dtmax;
w.Wellc = Wellc; w.Wellc = Wellc;
w.time = time; w.time = time;
w.well_schedules = well_schedules; w.well_schedules = well_schedules;
w.progress_callback = progress_callback;
%% %%
if r.modelflag==1 || r.modelflag==4 || r.modelflag==5 if r.modelflag==1 || r.modelflag==4 || r.modelflag==5
if flow_model == 1 if flow_model == 1
@@ -25,4 +30,4 @@ if r.modelflag==1 || r.modelflag==4 || r.modelflag==5
end end
% [Times, OutputRs, Wellpara, trun] = mainRS_MB_2014(r, f, os, w, state0); % [Times, OutputRs, Wellpara, trun] = mainRS_MB_2014(r, f, os, w, state0);
end end
end end
BIN
View File
Binary file not shown.
+33 -5
View File
@@ -88,21 +88,20 @@ classdef EDFMAppController < handle
drawnow; drawnow;
try try
logText = evalc('[r, Times, OutputRs, Wellpara, trun] = run_case(obj.Config);'); progress_callback = @(message, meta) obj.onRunProgress(message, meta);
[r, Times, OutputRs, Wellpara, trun] = run_case(obj.Config, progress_callback);
obj.Results = struct( ... obj.Results = struct( ...
'r', r, ... 'r', r, ...
'Times', Times, ... 'Times', Times, ...
'OutputRs', {OutputRs}, ... 'OutputRs', {OutputRs}, ...
'Wellpara', {Wellpara}, ... 'Wellpara', {Wellpara}, ...
'trun', trun, ... 'trun', trun, ...
'captured_log', logText); 'captured_log', '');
if ~isempty(strtrim(logText))
obj.appendLog(logText);
end
obj.refreshResults(); obj.refreshResults();
if strlength(obj.CurrentPlotAction) ~= 0 if strlength(obj.CurrentPlotAction) ~= 0
obj.refreshCasePlotControls(obj.CurrentPlotAction); obj.refreshCasePlotControls(obj.CurrentPlotAction);
end end
obj.appendLog('Run completed.');
obj.setRunProgress('Completed'); obj.setRunProgress('Completed');
obj.setStatus('Run completed'); obj.setStatus('Run completed');
catch ME catch ME
@@ -690,6 +689,35 @@ classdef EDFMAppController < handle
drawnow limitrate; drawnow limitrate;
end end
function onRunProgress(obj, message, meta)
if nargin < 3 || ~isstruct(meta)
meta = struct();
end
if nargin >= 2 && strlength(strtrim(string(message))) ~= 0
obj.appendLog(message);
end
if isfield(meta, 'status') && ~isempty(meta.status)
obj.setRunProgress(meta.status);
end
if isfield(meta, 'step') || isfield(meta, 'time') || isfield(meta, 'dt')
stageText = obj.getMetaText(meta, 'step', '-');
timeText = obj.getMetaText(meta, 'time', '-');
dtText = obj.getMetaText(meta, 'dt', '-');
obj.setRunHeader(stageText, timeText, dtText);
end
end
function textValue = getMetaText(obj, meta, fieldName, fallback)
if isfield(meta, fieldName) && ~isempty(meta.(fieldName))
textValue = obj.valueToShortText(meta.(fieldName));
else
textValue = fallback;
end
end
function setRunProgress(obj, textValue) function setRunProgress(obj, textValue)
if isprop(obj.App, 'RunProgressLabel') if isprop(obj.App, 'RunProgressLabel')
obj.App.RunProgressLabel.Text = ['RunProgress: ', char(string(textValue))]; obj.App.RunProgressLabel.Text = ['RunProgress: ', char(string(textValue))];
Binary file not shown.
File diff suppressed because it is too large Load Diff
+27 -1
View File
@@ -10,7 +10,7 @@ arguments
end end
action_id = lower(string(action_id)); action_id = lower(string(action_id));
cla(ax); reset_plot_axes(ax);
switch action_id switch action_id
case "plot_well_response" case "plot_well_response"
@@ -35,6 +35,7 @@ wellpara = results.Wellpara;
well_index = get_option(options, 'well_index', 1); well_index = get_option(options, 'well_index', 1);
metric = upper(string(get_option(options, 'metric', "BHP"))); metric = upper(string(get_option(options, 'metric', "BHP")));
view(ax, 2);
set(ax, 'XScale', 'linear', 'YScale', 'linear'); set(ax, 'XScale', 'linear', 'YScale', 'linear');
if isempty(wellpara) if isempty(wellpara)
@@ -122,6 +123,7 @@ for i = 1:nx * ny
end end
fill(ax, x, y, dis, 'EdgeColor', 'interp'); fill(ax, x, y, dis, 'EdgeColor', 'interp');
view(ax, 2);
axis(ax, 'equal'); axis(ax, 'equal');
axis(ax, 'tight'); axis(ax, 'tight');
colormap(ax, jet); colormap(ax, jet);
@@ -201,6 +203,7 @@ for i = 1:nx * ny
end end
fill(ax, x, y, dis, 'EdgeColor', 'interp'); fill(ax, x, y, dis, 'EdgeColor', 'interp');
view(ax, 2);
axis(ax, 'equal'); axis(ax, 'equal');
axis(ax, 'tight'); axis(ax, 'tight');
colormap(ax, jet); colormap(ax, jet);
@@ -259,3 +262,26 @@ else
value = fallback; value = fallback;
end end
end end
function reset_plot_axes(ax)
cla(ax);
hold(ax, 'off');
grid(ax, 'off');
view(ax, 2);
colorbar(ax, 'off');
set(ax, ...
'XScale', 'linear', ...
'YScale', 'linear', ...
'ZScale', 'linear', ...
'XLimMode', 'auto', ...
'YLimMode', 'auto', ...
'ZLimMode', 'auto', ...
'CLimMode', 'auto', ...
'DataAspectRatioMode', 'auto', ...
'PlotBoxAspectRatioMode', 'auto', ...
'CameraPositionMode', 'auto', ...
'CameraTargetMode', 'auto', ...
'CameraUpVectorMode', 'auto', ...
'CameraViewAngleMode', 'auto');
end
+4 -2
View File
@@ -1,4 +1,4 @@
function [r, Times, OutputRs, Wellpara, trun] = run_case(config) function [r, Times, OutputRs, Wellpara, trun] = run_case(config, progress_callback)
%RUN_CASE Execute a simulation from unified config. %RUN_CASE Execute a simulation from unified config.
% %
% This is the first migration step from hard-coded main1.m scripts toward a % This is the first migration step from hard-coded main1.m scripts toward a
@@ -8,6 +8,7 @@ function [r, Times, OutputRs, Wellpara, trun] = run_case(config)
arguments arguments
config (1,1) struct config (1,1) struct
progress_callback = []
end end
project_root = fileparts(fileparts(fileparts(mfilename('fullpath')))); project_root = fileparts(fileparts(fileparts(mfilename('fullpath'))));
@@ -81,7 +82,8 @@ Wellc = handle_well1_well2(well1, well2, welloc, r);
config.schedule.dtmax, ... config.schedule.dtmax, ...
Wellc, ... Wellc, ...
config.schedule.time, ... config.schedule.time, ...
config.schedule.well_schedules); config.schedule.well_schedules, ...
progress_callback);
trun.run_time = toc(overall_tic); trun.run_time = toc(overall_tic);
end end