MATLAB: Use of “region” and “state” in PDE models with variable coefficients.

coefficientsheat transferMATLABpde

"state" and "region" sometimes show up in questions about solving PDEs with variable coefficients, but these things are basically undocumented. I am trying to model a 3-region heat-transfer system in which the thermal conductivity of one layer is a function of temperature (see https://www.mathworks.com/matlabcentral/answers/498820-how-to-write-anonymous-function-for-variable-coefficients-in-heat-transfer-problem). What I wrote in the other post does not give an error but also does not assign the proper value to the layer in question.
If anyone has a grasp of how to use state and region to assign variable properties in PDEs, as in the earlier post, please reply.

Best Answer

Hi Allen,
Solver passes two input arguments to the function that you define, "region" and "state" are just place holder names. You can call them anything you want. Just be aware that the first argument, region, contains spatial data which you can use to compute k and second contains solution data to serve you the same purpose.
Now to your specific question on kFunc I think you are using the logical expression state.u<cractT to modify K. The input data, that solver sends to your function, state.u contains solution at several points withiin Face 3. Depending on your initial condition you start out with state.u<cractT yielding logical vector (logical zeros and ones). I am guessing this is not what you want. Also, it is hard to say if the solution actually crosses 900 to change the thermal conductivity. If the condition is never false, then you will always get k +k*(Nu-1) as thermal conductivity. I would suggest writing a full function, instead of anonymous function as:
function kOut = kFunc(region,state)
if any(isnan(state.u))
kOut = nan(size(state.u));
return;
end
kOut = k;
if any(state.u < crackT)
kOut = k+k*(Nu-1)*ones(size(state.u));
end
end
Then specify, this kFunc's handle on to faces 3 as:
thermalProperties(thermalModel,'Face',3,'ThermalConductivity',@kFunc,'MassDensity',2500,'SpecificHeat',1000);
Regards,
Ravi