Error: Unable to perform assignment because the left and right sides have a different number of elements.

5 次查看(过去 30 天)
I am attempting to develop transfer function class for the dual porosity model. I have written the scripts and vetted to ascertain correct syntax and formulation. In my dual porosity model - (code #1 below), I have to define a transfer function class already developed. But when I run the model, I keep getting this error: Unable to perform assignment because the left and right sides have a different number of elements - with details in code #2 below
I will really appreciate any advice and tips to rectify this bug.
Thanks,
Emeka.
Code #1 - Dual Porosity Model
%% Two-phase water injection in an oil-saturated dual-porosity reservoir.
% Water flows quickly in the fracture system, while transfer to the matrix
% happens via spontaneous imbibition.
clear;
clc;
close all;
mrstModule add ad-blackoil ad-core ad-props dual-porosity
%% Set up grid
G = cartGrid([60, 1, 1], [60, 1, 1]*meter);
G = computeGeometry(G);
%% Set up rock properties
rock_matrix = makeRock(G, 10*milli*darcy, .1);
rock_fracture = makeRock(G, 100*milli*darcy, .01);
%% Set up fluid
fluid_matrix = initSimpleADIFluid('phases', 'WO', ...
'rho', [1000, 800]*kilogram/meter^3,...
'c', [1e-20, 1e-20]/barsa);
fluid_fracture = initSimpleADIFluid('phases', 'WO', ...
'rho', [1000, 800]*kilogram/meter^3,...
'c', [1e-20, 1e-20]/barsa);
Pe = 0.15*psia;
fluid_matrix.pcOWm = @(swm)Pe.*swm.^0.5;
fluid_matrix.krWm = @(swm)swm.^2;
fluid_matrix.krOm = @(swm) (1-swm).^2;
fluid_matrix.krWm_h = @(swm_av)swm_av.^2;
fluid_matrix.krOm_h = @(swm_av) (1-swm_av).^2;
%% Set the DP model. Here, a two-phase model is used. Rock and fluid
% are sent in the constructor as a cell array {fracture,matrix}
model = TwoPhaseOilWaterModelDP(G, {rock_fracture,rock_matrix},...
{fluid_fracture,fluid_matrix});
%% Initializing state
eps = 0.01;
state = initResSol(G, 2.5*psia, [eps, (1-eps)]);
state.wellSol = initWellSolAD([], model, state);
state.pressure_matrix = state.pressure;
state.sm = state.s;
%% Setting transfer function. This step is important to ensure that fluids
% will be transferred from fracture to matrix (and vice-versa). The second argument is the matrix block size. Another
% possible transfer function to be used in this model would be:
model.transfer_model_object = G_TF2_QC('G_SF',[5,5,5]);
%% Boundary conditions
bc = pside([], G, 'xmin', 500*psia, 'sat', [1,0]);
bc = pside(bc, G, 'xmax', 2.5*psia, 'sat', [0,1]);
%% Solver
solver = NonLinearSolver();
%% Validating model
model = model.validateModel();
%% Figure
fig1 = figure('Position',[100,100,1200,600]);
fig1.Color = 'w';
colormap('jet');
%% Time loop
dt = 1*day;
tmax = 1000*day;
t = 0;
while t<=tmax
disp(['Time = ',num2str(t/day), ' days'])
state = solver.solveTimestep(state, dt, model, 'bc', bc);
figure(fig1)
subplot(2,2,1);
p = plotCellData(G,state.s(:,1));
p.EdgeAlpha = 0;
colorbar;
% caxis([0,1]);
set(gca,'FontSize',16);
xlabel('x')
ylabel('y')
subplot(2,2,3);
p = plotCellData(G,state.sm(:,1));
p.EdgeAlpha = 0;
colorbar;
caxis([0,1]);
set(gca,'FontSize',16);
xlabel('x')
ylabel('y')
figure(fig1)
subplot(2,2,2);
plot(G.cells.centroids(:,1),state.s(:,1),'LineWidth',1.5,'Color','r');
set(gca,'FontSize',16);
xlabel('x')
ylim([0,1])
ylabel('Swf [-]')
subplot(2,2,4);
plot(G.cells.centroids(:,1),state.sm(:,1),'LineWidth',1.5);
set(gca,'FontSize',16);
xlabel('x')
ylim([0,1])
ylabel('Swm [-]')
drawnow;
t = t+dt;
end
Code #2 - Error messgage
Time = 0 days
264 end
Unable to perform assignment because the left and right sides have a different number of elements.
Error in getConvergenceValuesCNV (line 101)
CNV(ph) = B_avg*dt*mv;
Error in DualPorosityReservoirModel/getConvergenceValues (line 388)
[v_cnv, names_cnv, tol_cnv, is_cnv] = getConvergenceValuesCNV(model, problem);
Error in PhysicalModel/checkConvergence (line 604)
[values, tolerances, names] = getConvergenceValues(model, problem, varargin{:});
Error in PhysicalModel/stepFunction (line 676)
[convergence, values, resnames] = model.checkConvergence(problem);
Error in NonLinearSolver/solveMinistep (line 352)
model.stepFunction(state, state0, dt, drivingForces, ...
Error in NonLinearSolver/solveTimestep (line 203)
solveMinistep(solver, model, state, state0_inner, dt, drivingForces);
Error in example_2ph_drainage (line 68)
state = solver.solveTimestep(state, dt, model, 'bc', bc);

回答(2 个)

David Hill
David Hill 2021-3-25
Put a stop in on this line of code:
CNV(ph) = B_avg*dt*mv;
Then inspect each variable size (ph, B_avg, ... ). You can also perform the calculation (B_avg*dt*mv) in the command window. The sizes are different on the left vs. right side.

Chukwuemeka Enemanna
Thank you David, I think I rectified that bug. I skipped the 'dot' notation in calculating one of my variables so I had a 60x60 matrix rather than a 60x1 matrix in discomformity with the rest of the variables. Thanks for your feedback, much appreiated.
Emeka.

类别

Help CenterFile Exchange 中查找有关 Upgrading Hydraulic Models to Use Isothermal Liquid Blocks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by