Cell Contents Assignment To A Non-Cell Array Object Methods

Cette erreur survient lors d'une opération de concaténation.

Pour déterminer, si l'erreur provient lors d'une concaténation horizontale entre vecteurs supposés « lignes », ou lors d'une concaténation verticale entre vecteurs supposés « colonnes », il faut regarder le message d'erreur dans son ensemble.

Concaténation horizontale :

Concaténation verticale :

Solution :

Pour une concaténation verticale, le nombre de colonnes de toutes les tableaux à concaténer doit être identique.

Pour une concaténation horizontale, le nombre de lignes de toutes les tableaux à concaténer doit être identique.

Cas particulier :

L'erreur ci-dessus apparait également lorsque l'on souhaite concaténer à toutes les lignes d'une matrice, le même élément (ou vecteur).

Par exemple, pour ajouter le caractère virgule (',') à toutes les lignes d'un tableau de chaine de caractères. Si l'on essaie avec une simple concaténation :

La solution consiste à utiliser la fonction strcatDocumentation fonction strcat :

 

Sélectionnez

 

Sélectionnez

 

Sélectionnez

 

Sélectionnez

Créé le 5 novembre 2007  par Jérôme Briot


Lien : Concatenating Matrices
Lien : Comment exploiter les messages d'erreurs ?

Harmonic Upscaling of Realistic Field Model¶

Generated from cpGridHarmonic.m

Load the required modules

Load and process data¶

We assume that the data has been downloaded and placed in the appropriate data directory under the MRST root directory.

saigupPath=fullfile(getDatasetPath('SAIGUP'),'SAIGUP.GRDECL');grdecl=readGRDECL(saigupPath);grdecl=convertInputUnits(grdecl,getUnitSystem('METRIC'));G=processGRDECL(grdecl);G=computeGeometry(G);rock=grdecl2Rock(grdecl,G.cells.indexMap);

Upscale model¶

Upscale the model by a factor 5x5x5 using a simple harmonic average for the permeability and arithmetic average for the porosity. (This demonstrates the power of the accumarray call..)

w=G.cells.volumes;p=partitionUI(G,G.cartDims./[555]);fori=1:size(rock.perm,2)K=accumarray(p,w./rock.perm(:,i))./accumarray(p,w);crock.perm(:,i)=1./K;endcrock.poro=accumarray(p,rock.poro.*w)./accumarray(p,w);

Visualize result¶

As expected, using such a naive upscaling will move the permeability values towards the centre of their fine-scale spectre.

clfpargs={'EdgeColor','none'};subplot(2,2,1)plotCellData(G,log10(rock.perm(:,1)),pargs{:});view(-95,40);axistightoff;cx=caxis;title('original');subplot(2,2,2)plotCellData(G,log10(crock.perm(p,1)),pargs{:});set(gca,'zdir','reverse');view(-95,40);axistightoff;caxis(cx);title('upscaled');subplot(2,2,3:4)hist(log10(convertTo(rock.perm(:,1),milli*darcy)),100);holdonhist(log10(convertTo(crock.perm(p,1),milli*darcy)),100);holdoffh=get(gca,'Children');set(h(1),'FaceColor',[000.4])set(h(2),'FaceColor',[0.700],'FaceAlpha',.4)legend('original','upscaled');title('permeability histogram');xlabel('mD')

Copyright notice¶

<html>% <p><font size="-1
mrstModuleaddupscalingcoarsegrid

Steady-state permeability upscaling¶

Generated from periodicUpscaleExample.m

This example demonstrates upscaling of relative permeability on periodic grids. To this end, we upscale a single block sampled from SPE10 using first a standard flow-based method to determine the effective permeability and then finds relative permeability curves based on steady-state upscaling for the capillary and the viscous limits, as well as based on a dynamic simulation.

Set up a simple grid with periodic boundaries¶

Make a grid in which the right boundary wraps around with left boundary, the front with the back, and the bottom with the top. We retain the regular grid for plotting, as plotGrid uses the boundary faces to plot grids: A fully periodic grid has, per definition, no boundary faces.

G=cartGrid([552]);G=computeGeometry(G);% Set faces for wrap-aroundbcr{1}=pside([],G,'RIGHT',0);bcl{1}=pside([],G,'LEFT',0);bcr{2}=pside([],G,'FRONT',0);bcl{2}=pside([],G,'BACK',0);bcr{3}=pside([],G,'BOTTOM',0);bcl{3}=pside([],G,'TOP',0);% Make periodic grid.[Gp,bcp]=makePeriodicGridMulti3d(G,bcl,bcr,{0,0,0});
Cell contents assignment to a non-cell array object. Error in periodicUpscaleExample (line 22) bcr{1}=pside([],G,'RIGHT',0); bcl{1}=pside([],G,'LEFT',0);

Do a single-phase periodic upscale¶

To find the permeability we use a unitary fluid so that the mobility/relperm is equal to the saturation which is equal to one, removing any fluid specific effects. We upscale the permeability using two-point flux approximation for the pressure solver.

psolver=@(state,Grid,Fluid,BCP,Rock)...incompTPFA(state,Grid,computeTransGp(G,Grid,Rock),...Fluid,'bcp',BCP);L=max(G.faces.centroids)-min(G.faces.centroids);fluid_pure=initSingleFluid('mu',1,'rho',1);warning('off','mrst:periodic_bc')perm2=upscalePermeabilityPeriodic(Gp,bcp,1,psolver,fluid_pure,rock,L);warning('on','mrst:periodic_bc')

Load a two-phase fluid for upscaling¶

The data are synthetic and should not be used for anything but testing. The file ‘rocklist.txt’ contains a list of included property files in a simple format tabulated on water saturation.

current_dir=fileparts(mfilename('fullpath'));fn=fullfile(current_dir,'rocklist.txt');T=readTabulatedJFluidFile(fn);% Print the tabulated values from the first and only filefprintf('\n');fprintf(' Sw | Krw | Kro | J-func\n')fprintf('-------------|-------------|-------------|------------\n')fprintf(' %+1.4e | %+1.4e | %+1.4e | %+1.4e\n',T{1}.')fprintf('\n');fluid=initSWOFFluidJfunc('mu',[10,100].*centi*poise,...'rho',[1000,600].*kilogram/meter^3,...'table',T,...'satnum',1,'jfunc',true,'rock',rock,...'surf_tens',10*dyne/(centi*meter));

Steady-state upscaling (viscous/capillary limits)¶

We assume zero capillary forces and do a steady-state upscale using the viscous and capillary limits, respectively. The viscous limit is equal in all directions, while the capillary is not

[saturations_visc,kr_visc]=...upscaleRelpermLimit(G,rock,fluid,'type','fixed','limit','viscous');[saturations_cap,kr_cap]=...upscaleRelpermLimit(G,rock,fluid,'type','fixed','limit','capillary');% Plot the resultsclf;p=get(gcf,'Position');set(gcf,'Position',[p(1:2)840420]);ph={'water','oil'};fori=1:2subplot(1,2,i)holdonplot(saturations_visc,kr_visc{i});plot(saturations_cap,kr_cap{i},'--.');title(['Relative permeability (Viscous/capillary limit), 'ph{i}' phase']);holdoff;axistightxlabel('Saturation')legend({'x (viscous)','y (viscous)','z (viscous)'...'x (capillary)','y (capillary)','z (capillary)'},'location','Best')end

General steady-state upscaling¶

In the general case, we initialize the model with a certain fraction of water and simulate the dynamic behaviour due to a linear pressure drop in until steady-state is reached. This way, we can tabulate relative permeability versus average water saturation. Here, we use ~20 data points. As the default option is to use a pressure drop in x-direction, the x-values are significantly different from the y/z values which are similar, but not equal.

saturations=0:0.05:1;dp_scale=1e-3;% Ignore warnings from the implicit solver as the solution is driven to% steady state. It is natural that some steps fail during this process.warning('off','implicitTransport:failure')[sat_vec,kr,perm,krK]=upscaleRelperm(G,rock,fluid,dp_scale,saturations,'periodic',false);warning('on','implicitTransport:failure')% Plot the resulting relative permeabilityfor i = 1:2subplot(1,2,i)plot(sat_vec,kr{i});title(['Relative permeability, phase 'num2str(i)]);axistightxlabel('Water saturation')legend({'x','y','z'},'location','Best')end

Copyright notice¶

<html>% <p><font size="-1
unction[kr]=simpleRelpermUpscalingExample2D(perm_case,fluid_case)% This demonstrate the method used for relperm upscaling% The default setup is a quasi 1D casemrstModuleaddmimeticupscalingincompwarning('off','mrst:periodic_bc');figure(3),clfif(nargin==0)perm_case='uniform';fluid_case='periodic_capillary_pressure';end% set up gridLx=10;Ly=10;nx=50;ny=2;G=cartGrid([nxny],[LxLy]);G=computeGeometry(G);sperm=100;%rock=makePerm(perm_case,G);n=[22];%set original exponent of fluidmu=[14];%set viscosity of fluids[fluid_pure,fluid,fluid_nc]=makeFluids(fluid_case,rock,G,Lx,Ly,'n',n,'mu',mu);dp_scale=4*barsa;dpx=dp_scale;dpy=0.0;% set the saturations to be upscaledsat_vec=0.1:0.2:0.9;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Upscale using MRST upscaling%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%end%%%%%%%%%%[sat_mat,kr,perm,krK]=upscaleRelperm(G,rock,fluid,dp_scale,...sat_vec,'periodic',true,'dir',1);%#ok<NASGU,ASGLU>% plot the resultfigure(1),clfplot(sat_mat,[kr{1}(:,[1,4]),kr{2}(:,[1,4])],'*-')legend('krxx_1','kryy_1','krxx_2','kryy_2')xlabel('S')ylabel('kr')axis([0101])title('Upscaled relperm from mrst')%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start example of upscaling%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% define pressure dropbl=pside([],G,'LEFT',0);br=pside([],G,'RIGHT',0);bd=pside([],G,'BACK',0);bu=pside([],G,'FRONT',0);% find boundary cells which are used to calculate fluxescells_r=sum(G.faces.neighbors(br.face,:),2);%cells_u=sum(G.faces.neighbors(bu.face,:),2);% make periodic grid[Gp,bcp]=makePeriodicGridMulti(G,{bl,bd},{br,bu},{dpx,dpy});Trans=computeTrans(G,rock);Transp=Trans(Gp.cells.faces(:,end));phase_fluxkr=nan(numel(sat_vec),2);lambda=@(s)bsxfun(@rdivide,fluid.relperm(s),fluid.properties());% initialize state and calculate trivial upscalingstate=initResSol(Gp,100*barsa,1);state=incompTPFA(state,Gp,Transp,fluid_pure,'bcp',bcp);x_faces=bcp.face(bcp.value==dpx);%y_faces=bcp.face(bcp.value==dpy);sign_x=2*(Gp.faces.neighbors(x_faces,1)==cells_r)-1;%sign_y=2*(Gp.faces.neighbors(y_faces,2)==cells_u)-1;tflux_x=sum(state.flux(x_faces).*sign_x);%tflux_y=sum(state.flux(y_faces).*sign_y);tflux=tflux_x;permkr=(tflux/Ly)/(dpx/Lx);DT=100*day;% set up parmeter used in the uspcaling lopmax_DT=40*year;max_it=40;diff_tol=1e-4;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start loop for finding upcaled relperm%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%state=initResSol(Gp,100*barsa,0.1);pv=poreVolume(G,rock);fori=1:numel(sat_vec);sat=sat_vec(i);% errir ub treatment of boundary conditions %fl_sat=lambda(sat); %fl_sat=fl_sat(:,1)/sum(fl_sat,2);% make initial saturation to for the statoinary state calculationeff_sat=sum(state.s.*pv)/sum(pv);if(eff_sat>0)state.s=state.s*(sat/eff_sat);elsestate.s=ones(size(state.s))*sat;endstate.s=ones(size(state.s))*sat;% search for stationary stateinit_state=state;it=0;stationary=false;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start loop for finding stationary state%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% find a flux assosiated with the pressure dropstate=incompTPFA(state,Gp,Transp,fluid_nc,'bcp',bcp);while~stationary&&it<max_its_pre=state.s;% do one transport step[state,report]=implicitTransport(state,Gp,DT,rock,fluid,'Trans',Transp,...'verbose',false,...'nltol',1.0e-6,...% Non-linear residual tolerance 'lstrials', 10 , ...% Max no of line search trials 'maxnewt' , 20 , ...% Max no. of NR iterations 'tsref' , 4 , ...% Time step refinement 'init_state',init_state);disp(['Iteration ',num2str(it),' DT ',num2str(DT/year),' Error ',num2str(norm(s_pre-state.s))])% check if transport step is successfull if(report.success)init_state=state;% increas timestep if change is small if(norm(s_pre-state.s,inf)<1e-2)DT=min(max_DT,DT*2);end% calculate new pressurestate=incompTPFA(state,Gp,Transp,fluid,'bcp',bcp);if(norm(s_pre-state.s,inf)<diff_tol)stationary=true;endelse% if not success full cut time stepdisp('Cutting time step');init_state.s=0.5*ones(size(state.s));DT=DT/2;endit=it+1;end% Plot the stationary state %figure(3)pv=poreVolume(G,rock);sat_vec(i)=sum(pv.*state.s(:,1))/sum(pv);if(ny>2)clf,plotCellData(G,state.s),colorbarelse%clf,mcells=1:nx;subplot(2,1,1),%claholdonplot(G.cells.centroids(mcells,1),state.s(mcells),'*')axis([min(G.cells.centroids(:,1))max(G.cells.centroids(:,1)),01])ylabel('Saturation')xlabel('x');%title(['The stationary saturation for average saturation', num2str(sat_vec(i))])title
% Load the required modulesmrstModuleaddmimeticupscalingspe10incompdeckformat

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *