PDE toolbox and non-constant coefficients
Mostra commenti meno recenti
Hi Matlab experts.
I am playing with the C coefficient, and would like to set it as a state dependent coefficient. While I am more and more understanding the nature of function handle as stated in the matlab help for the c coefficient ( Here ), I am a left with few questions:
- I am solving only 1 equation ( model = createpde(1) ). if the c coefficient is constant the program works well. As long as I try to make it state.u dependent, it either doesn't work, or gives me Warning about integration tolerances. I am therefore unsure about the structure of state . The help says that the state.u field represents the current value of the solution u, and that starts to confuse me a bit. As I am trying to solve for pressure diffusion, I would have assume that state.u was a value of pressure in whichever unit I am using, but I am slowly starting to doubt it.
- again in the help, the cmatrix vector is built depending on the N variable. As my N=1, I would have assumed that I needed to fill in cmatrix(1,:) with my calculations around state.u. I guess here again I am wrong, and I don't really get what to do anymore in order to ouput the right vector format.
I join pieces of my code. The idea is to use state.u (assuming to is a pressure) to recalculate the permeability of my 2D field.
function cmatrix = DiffusivityV4(location,state,ki, depth,density, T)
N = 1;
nr = length(location.x);
confiningStress = density*9.81*depth*1e-6;
Cp = 0.000000001;
T = T+273.15;
A=2.414*10^-5;
B=247.8;
C=140;
u = A*10^(B/(T-C));
gamma = (0.012+0.013)/2;
cmatrix = zeros(N,nr);
try
cmatrix(1,:) = (ki-(0.04343*gamma*(confiningStress-state.u(1,:))))/(u*Cp);
if isnan(cmatrix)
cmatrix(N,nr)=0;
end
catch
cmatrix(N,nr)=0;
end
end
This function is called this way:
Dcore= @(location, state) DiffusivityV4(location,state,1e-17,4000, 2700, 200);
specifyCoefficients(model,'m',0,'d',d,'c',Dcore,'a',a,'f',f, 'face',1);
Please let me know if you need any other information about my code. I am really new to function handle and the PDE toolbox, so sorry by advance if I did misunderstand the way it works.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Structural Mechanics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!