PDE Toolbox - Temperature Dependant Properties from array of values
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I am trying to impliment temperature dependant thermal properties in the PDE toolbox. I have thermal conductivity and specific heat capacity data for at specific points. I have linearly interpolated to create an array that contains values for each temperature. However I can not work out how to impliment this array - all the examples I have seen express the material property in terms of the state.u variable. I have tried to use a loop to go through the state.u vector and create a vector that assigns the correct material property based on the value of state.u - however I constistently recieve the following error.
My code is:
function cp = cp_func(location,state)
T_q = 20:1200; % Specify Query Points
g_cp_norm_mean = [1 1.01 1.07 1.2 1.21 1.33 1.32 1.38 1.55]; % Normalised Property Data
g_cp_T = [20 50 100 200 300 400 500 600 800]; % Corresponding temperatures.
g_cp = 790; % base value, J/kgC.
g_cp_mean = g_cp*g_cp_norm_mean;
g_cp_int = interp1(g_cp_T, g_cp_mean, T_q, "linear", g_cp_mean(end)); % Interpolated array.
n = length(state.u); % Find length of state.u;
a = ones(1, n); % Create empty row vector to contain values.
for i = 1:n
a(1,i) = g_cp_int(round(state.u(i) - 19)); % Index no 1 of g_cp_int containts the value for T = 20.
end
cp = a;
end
I would be really grateful if someone could help me with this problem. The nature of state.u is very opaque to me, which makes the problem difficult. From what I know it is a row vector containing the temperature (float value?) at every node.
Best
Victor
0 Kommentare
Antworten (1)
Piyush Dubey
am 8 Sep. 2023
Hi Victor,
I understand that you are facing issues while trying to implement the ‘thermal properties’ of the “PDE toolbox”. While performing this operation you are getting an error signifying, “Function specifying material property must accept 2 input arguments and return 1 output argument.”
The code snippet attached with your question seems to work fine without any errors and there exists a possibility that the scope of any variable has been violated inside or outside the function. Kindly recheck for the scopes of the variables used inside and outside the function.
Please refer to the following MATLAB Answers threads where a similar issue has been addressed:
Hope this helps.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!