Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
425 views
in Technique[技术] by (71.8m points)

How to input discrete heat coefficients into the function 'thermalProperties' in MATLAB using PDE Toolbox?

I am solving a 2-D transient heat transfer equation. The thermal conductivity coefficient is dependent on space location and time. Furtherly, I only have discrete data of thermal conductivity coefficient. When I use the function 'thermalProperties' in MATLAB PDE Toolbox to define thermal properties, I write a function

function re = TC_direct(location,state)
    
x = location.x;
y = location.y;
t = state.time;

global TC_true
global P_info
global tau

if isnan(t)
    re = NaN;
else 

    % find the node index
    dist = P_info - [x * ones(1,size(P_info,2)); y * ones(1,size(P_info,2))];
    [~, p_index] = min(sum(dist.^2));

    % find the time index
    t_index = round(t/tau);
    
    re = TC_true(p_index, t_index + 1);
end

end

TC_true is a matrix. Every column gives thermal conductivity coefficient of every node at a time point. P_info is a matrix of all nodes. The first row is x coordinate and the second is y. tau s time step. And call the function like this

thermalProperties(thermalmodel, 'ThermalConductivity', @TC_direct, ...
                                'MassDensity', 1, ...
                                'SpecificHeat', 2);

But I can't use my own function successfully. It seems that location.x is a vector. So if I only have discrete coefficients, how can I use PDE Toolbox?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...