How to change the initial condition of a customized block on Simscape?
3 次查看(过去 30 天)
显示 更早的评论
Dear all,
The default "Thermal Mass" block on SIMSCAPE presents Mass and Specific Heat as parameters. Since I would like The Specific Heat changes with the temperature (i.e., it changes each substep) I had created a custom block on SIMSCAPE called "OnlyMass" according to the code below. I'd built it using "ssc_build OnlyMass" and then I had solved my problem.
However, now I would like to assume a different initial temperature for such mass. However, when I try to do it an error occurs according to the image below.
Then, all bodies I have using such custom block starts with the same temperature :/.
How to fix this problem?
![Fig01_Try1.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224772/Fig01_Try1.png)
![Fig02_Error.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/224773/Fig02_Error.png)
component OnlyMass
% 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; % M:top
end
inputs
sp_heat = {447, 'J/(kg*K)'}; % c:bottom
end
parameters
mass = {1, 'kg' }; % Mass
end
variables
% Differential variables
T = {value = {295.15, 'K'}, priority = priority.high}; % Temperature
Q = {0, 'W'}; % Heat flow rate
end
branches
Q : M.Q -> *;
end
equations
assert(mass > 0)
assert(sp_heat > 0)
T == M.T;
Q == mass * sp_heat * T.der;
assert(T > 0, 'Temperature must be greater than absolute zero')
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating Custom Components and Libraries 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!