Phase Change Material in Simscape
Dear Sir or Madam,
I would like to model a Phase Change Material in Simscape by editing a normal thermal mass block. I already found this question <https://de.mathworks.com/matlabcentral/answers/300839-simscape-model-of-latent-heat-storage-in-a-pcm> but it’s not working when I put the mentioned code to the thermal mass block. Do you have any idea why it’s not working? I’ll attach the code which is the normal thermal mass block modified with the code I found on that link. But if I want to introduce a Simcape component block it always says "Line: 37 Column: 25 Unexpected MATLAB operator."
Many greetings,
Ralf
if true
component mass
% Thermal Mass
% This block models internal energy storage in a thermal network. The rate
% of temperature increase is proportional to the heat flow rate into the
% material and inversely proportioanl to the mass and specific heat of the
% material.
% Copyright 2005-2016 The MathWorks, Inc.
nodes
M = foundation.thermal.thermal; % :top
end
parameters
m = {1, ‘kg’ }; % Mass
Cps = {200, ‘J/(kg*K)’}; % Specific heat solid
Cpl = {1000, ‘J/(kg*K)’}; % Specific heat liquid
Tmelt = {310, ‘K’}; % Melting Temperature
L = {100, ‘J/(kg)’}; % Specific Latent Heat
end
variables
% Differential variables
T = {value = {300, ‘K’}, priority = priority.high}; % Temperature
Q = {0, ‘W’}; % Heat flow rate
end
branches
Q : M.Q -> *;
end
equations
T == M.T;
if T < Tmelt
Q == m * integral(Cps dT,0,Tmelt)
else if T > Tmelt
Q == m * integral(Cpl dT, Tmelt, Inf)
else
Q == m*L;
end
end
endDear Sir or Madam,
I would like to model a Phase Change Material in Simscape by editing a normal thermal mass block. I already found this question <https://de.mathworks.com/matlabcentral/answers/300839-simscape-model-of-latent-heat-storage-in-a-pcm> but it’s not working when I put the mentioned code to the thermal mass block. Do you have any idea why it’s not working? I’ll attach the code which is the normal thermal mass block modified with the code I found on that link. But if I want to introduce a Simcape component block it always says "Line: 37 Column: 25 Unexpected MATLAB operator."
Many greetings,
Ralf
if true
component mass
% Thermal Mass
% This block models internal energy storage in a thermal network. The rate
% of temperature increase is proportional to the heat flow rate into the
% material and inversely proportioanl to the mass and specific heat of the
% material.
% Copyright 2005-2016 The MathWorks, Inc.
nodes
M = foundation.thermal.thermal; % :top
end
parameters
m = {1, ‘kg’ }; % Mass
Cps = {200, ‘J/(kg*K)’}; % Specific heat solid
Cpl = {1000, ‘J/(kg*K)’}; % Specific heat liquid
Tmelt = {310, ‘K’}; % Melting Temperature
L = {100, ‘J/(kg)’}; % Specific Latent Heat
end
variables
% Differential variables
T = {value = {300, ‘K’}, priority = priority.high}; % Temperature
Q = {0, ‘W’}; % Heat flow rate
end
branches
Q : M.Q -> *;
end
equations
T == M.T;
if T < Tmelt
Q == m * integral(Cps dT,0,Tmelt)
else if T > Tmelt
Q == m * integral(Cpl dT, Tmelt, Inf)
else
Q == m*L;
end
end
end Dear Sir or Madam,
I would like to model a Phase Change Material in Simscape by editing a normal thermal mass block. I already found this question <https://de.mathworks.com/matlabcentral/answers/300839-simscape-model-of-latent-heat-storage-in-a-pcm> but it’s not working when I put the mentioned code to the thermal mass block. Do you have any idea why it’s not working? I’ll attach the code which is the normal thermal mass block modified with the code I found on that link. But if I want to introduce a Simcape component block it always says "Line: 37 Column: 25 Unexpected MATLAB operator."
Many greetings,
Ralf
if true
component mass
% Thermal Mass
% This block models internal energy storage in a thermal network. The rate
% of temperature increase is proportional to the heat flow rate into the
% material and inversely proportioanl to the mass and specific heat of the
% material.
% Copyright 2005-2016 The MathWorks, Inc.
nodes
M = foundation.thermal.thermal; % :top
end
parameters
m = {1, ‘kg’ }; % Mass
Cps = {200, ‘J/(kg*K)’}; % Specific heat solid
Cpl = {1000, ‘J/(kg*K)’}; % Specific heat liquid
Tmelt = {310, ‘K’}; % Melting Temperature
L = {100, ‘J/(kg)’}; % Specific Latent Heat
end
variables
% Differential variables
T = {value = {300, ‘K’}, priority = priority.high}; % Temperature
Q = {0, ‘W’}; % Heat flow rate
end
branches
Q : M.Q -> *;
end
equations
T == M.T;
if T < Tmelt
Q == m * integral(Cps dT,0,Tmelt)
else if T > Tmelt
Q == m * integral(Cpl dT, Tmelt, Inf)
else
Q == m*L;
end
end
end phase change material, simscape MATLAB Answers — New Questions