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;
u = A*10^(B/(T-C));
gamma = (0.012+0.013)/2;
cmatrix = zeros(N,nr);
cmatrix(1,:) = (ki-(0.04343*gamma*(confiningStress-state.u(1,:))))/(u*Cp);
This function is called this way:
Dcore= @(location, state) DiffusivityV4(location,state,1e-17,4000, 2700, 200);
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.