Dear all,
When I was working on an EDFM model with a 2D matrix grid, I encountered a runtime error.
The required files for running the case are attached below. I would greatly appreciate it if anyone could help clarify this issue. Thank you.
ERROR:
>> sample_of_heterogeneous_2D
Solving timestep 01/12: -> 2 Hours, 2925 Seconds
Error using assert
Expected single index, got 2
Error in indexing (line 279)
assert(numel(s(1).subs) == 1, ...
Error in PhysicalModel/getProp (line 1036)
p = state.(fn)(:, index);
Error in PhysicalModel>@(x)model.getProp(state,x) (line 1189)
varargout = cellfun(@(x) model.getProp(state, x), ...
Error in PhysicalModel/getProps (line 1189)
varargout = cellfun(@(x) model.getProp(state, x), ...
Error in PhasePressures/evaluateOnDomain (line 23)
p = model.getProps(state, 'Pressure');
Error in StateFunctionGrouping/evaluateStateFunction (line 212)
props_struct.(name) = prop.evaluateOnDomain(model, state);
Error in StateFunctionGrouping/evaluateStateFunctionWithDependencies (line 237)
state = props.evaluateStateFunction(model, state, name);
Error in StateFunctionGrouping/evaluateDependencies (line 286)
state = props.evaluateStateFunctionWithDependencies(model, state, name);
Error in StateFunctionGrouping/evaluateStateFunctionWithDependencies (line 235)
state = props.evaluateDependencies(model, state, prop.dependencies);
Error in StateFunctionGrouping/get (line 189)
state = props.evaluateStateFunctionWithDependencies(model, state, name);
Error in PhysicalModel/getProp (line 1022)
[p, state] = c.get(model, state, nms{sub});
Error in PhysicalModel>@(x)model.getProp(state,x) (line 1189)
varargout = cellfun(@(x) model.getProp(state, x), ...
Error in PhysicalModel/getProps (line 1189)
varargout = cellfun(@(x) model.getProp(state, x), ...
Error in equationsBlackOil (line 163)
[b, pv] = model.getProps(state, 'ShrinkageFactors', 'PoreVolume');
Error in ThreePhaseBlackOilModel/getEquations (line 202)
[problem, state] = equationsBlackOil(state0, state, model, dt, drivingForces, varargin{:});
Error in PhysicalModel/stepFunction (line 717)
[problem, state] = model.getEquations(state0, state, dt, drivingForces, ...
Error in ReservoirModel/stepFunction (line 307)
[state, report] = stepFunction@PhysicalModel(model, state, state0, dt, drivingForces, linsolver, nonlinsolver, iteration, varargin{:});
Error in NonLinearSolver/solveMinistep (line 374)
model.stepFunction(state, state0, dt, drivingForces, ...
Error in NonLinearSolver/solveTimestep (line 210)
solveMinistep(solver, model, state, state0_inner, dt, drivingForces);
Error in simulateScheduleAD (line 295)
[state, report] = solver.solveTimestep(state0, dt, model,...
Error in sample_of_heterogeneous_2D (line 171)
[ws, states,reports] = simulateScheduleAD(state0, model, schedule);
Hi Olav,
Thank you very much for your reply.
I am currently using MATLAB R2024a together with MRST 2025b.
Based on your comment, I understand that several similar runtime errors were related to changes in MATLAB behavior and have been fixed in the latest MRST releases.
I would like to clarify one point:
if I intend to use MRST 2025b, does this imply that I should also use a corresponding newer MATLAB version (for example MATLAB 2025b or 2026a) to ensure full compatibility?
Or is MRST 2025b expected to work correctly with MATLAB R2024a as well?
Thank you again for your help and for maintaining MRST.
Best regards,
Calvin
Hi Olav,
Just to add one more piece of information that may be relevant for debugging:
On my machine, I currently have MATLAB R2024a installed.
I tested the same script under different MRST versions, and observed the following behavior:
With MRST 2024b, the script runs without any issues.
With MRST 2025b, the script triggers the runtime error I reported earlier.
Best regards,
Calvin
Hi Olav,
Thank you for your patience. I would like to clarify my previous message, as my earlier wording may have caused some confusion.
After further checks, the situation is actually the following:
On another machine, the same script runs without any issues under both MRST 2024b and MRST 2025b.
On my own machine, the same script fails with a runtime error under both MRST 2024b and MRST 2025b.
On my machine, MATLAB R2024a has been installed for quite a long time and the script used to run correctly before.
The only recent change to my environment is that I installed the MinGW compiler two days ago.
Therefore, I am wondering whether the installation of MinGW (or changes to the compiler / environment variables associated with it) could be related to the runtime error I am seeing now.
Please let me know if you think this is a plausible cause, or if you would recommend any specific checks or tests.
Best regards,
Calvin
Hi Olav,
Thank you very much for your helpful suggestions.
Following your advice, I checked the MATLAB path using pathdef and carefully compared the files being used.
You were absolutely right — the issue was caused by local modifications and shadowed files.
Specifically, in my chemical reaction module folder, I found several files that were originally from MRST but had been locally modified. These modified files were being picked up by MATLAB and led to the runtime error. After cleaning up the path and restoring consistency with the original MRST files, the problem was resolved.
Thank you again for your clear guidance — it was very helpful in pinpointing the root cause.
Best regards,
Calvin