I was wondering if there's a way to have variable heat transfer coefficient in the convective heat transfer model of Simscape. I would guess I would have to set the coefficient to a variable, but how would I vary that variable?
I'm trying to model transient brake disc heat transfer of a car. Model will be calibrated in a rig after the model is finished.
Horace
"Horace Lai" <hora...@gmail.com> wrote in message
news:idnhk8$80j$1...@fred.mathworks.com...
Look at the source code for the block and create your own version of it
using the Simscape language so that the heat transfer coefficient would be
an input rather than a parameter. It should be something like:
---------------------------------------------
component var_convection < foundation.thermal.branch
% Variable convective Heat Transfer
% The block represents an energy transfer by convection between two
% bodies by means of fluid motion. The transfer is governed by the Newton
% law of cooling and is directly proportional to the convection heat
% transfer coefficient, surface area, and the temperature difference. The
heat
% transfer coefficient is provided as an input to the block.
%
% Connections A and B are thermal conserving ports associated
% with the points between which the energy transport by convection takes
% place. The block positive direction is from port A to port B. This means
% that the heat flow is positive if it flows from A to B.
% Copyright 2005-2010 The MathWorks, Inc.
inputs
heat_tr_coeff = { 20, 'W/(m^2*K)' }; % heat_tr_coeff: left
end
parameters
area = { 1e-4, 'm^2' }; % Area
end
function setup
% Parameter range checking
if area <= 0
pm_error('simscape:GreaterThanZero','Area')
end
end
equations
Q == area * heat_tr_coeff * T;
end
end
------------------------------------------
HTH,
Arnaud
How do I create a custom block? Or even better, how do I view the source code for any simscape/simulink block?
Hi,
The source code of most of the Simscape foundation blocks is viewable as of R2009a:
http://www.mathworks.com/help/toolbox/physmod/simscape/rn/brzaliz-1.html#brzamn0-1
Just drag a block in a model, double-click on the block and click on "view source code for <block name>".
To create a custom block, you need to use the Simscape language, available as of R2008b:
http://www.mathworks.com/access/helpdesk/help/toolbox/physmod/simscape/lang/ug_intropage.html
Have a look at those videos for a short intro to the language:
http://www.mathworks.co.uk/products/demos/simscape/Simscape_Language_Nonlinear_Spring/
http://www.mathworks.co.uk/products/demos/simscape/Simscape_Demo_Language_Hydraulic_Orifice/
There is also a webinar on the same topic:
http://www.mathworks.co.uk/company/events/webinars/wbnr49772.html
HTH,
Arnaud
I made my own version of the convection block and put it in the same folder as the convection block that came with the Simscape installation. When I try to compile it using ssc_build, I get an error.
-------------------------------------------------
ssc_build foundation
Warning: When running 'ssc_build' from within a MATLAB package directory,
there is no need to provide the package name 'foundation' as it is
automatically derived from the MATLAB package directory.
Generating 'foundation_lib.mdl' in the MATLAB package parent directory 'C:\Program Files\MATLAB\R2010a\toolbox\physmod\simscape\simscape' ...
??? Failed to generate 'foundation_lib'
Caused by:
'foundation' is a MathWorks' provided MATLAB package. Building
MathWorks' provided libraries is not supported.
-------------------------------------------------------------
It sounds like I am not allowed to modify the foundation folder. Can you confirm this? I guess if this is true then I need to make a new folder and then also make new domain files too right?
Thanks!
I made a new folder "+custom" on the same directory level as "+foundation" in the simscape folder. Within the "+custom" folder is my new block "var_convection.ssc". I then go into my "+custom" folder and used ssc_build and I got an error message.
--------------------------------------------
>> ssc_build
Generating 'custom_lib.mdl' in the MATLAB package parent directory 'C:\Program Files\MATLAB\R2010a\toolbox\physmod\simscape\simscape' ...
??? Failed to generate 'custom_lib'
Caused by:
Error using ==> ne_buildpackage at 32
Error: File: C:\Program
Files\MATLAB\R2010a\toolbox\physmod\simscape\simscape\+custom\var_convection.ssc
Line: 1 Column: 26
Unexpected MATLAB operator.
-------------------------------------------
I have no idea what that means. I have tried using mex-setup like the help files suggests but it didn't get my anywhere.
Don't (ever) do that. Create your +custom package directory somewhere that isn't in the installation directory, e.g. "My Documents" or anywhere that isn't under <matlabroot> and where you have write permission. It is really bad practice to modify what is in the installation directory, you're very likely to break your MATLAB installation. It builds just fine on my machine.
HTH,
Arnaud
------------------------------------
ssc_build custom
Warning: When running 'ssc_build' from within a MATLAB package directory,
there is no need to provide the package name 'custom' as it is automatically
derived from the MATLAB package directory.
Generating 'custom_lib.mdl' in the MATLAB package parent directory 'C:\Documents and Settings\H. Lai\Desktop\My Dropbox\Master Thesis\Simulink' ...
??? Failed to generate 'custom_lib'
Caused by:
Error using ==> ne_buildpackage at 32
Cannot open C:\Program
Files\MATLAB\R2010a\toolbox\physmod\simscape\simscape\+foundation\+thermal\branch.ssc
for reading. Check file name, location, and permissions.
------------------------------------------
I don't know if this is the reason, but I don't see a branch.ssc in that folder. The only things in the thermal folder are elements, sensors, sources, and lib.m
I've tried doing "component var_convection < foundation.thermal.lib" instead but it isn't working either, and I'm not surprised, since it is not .ssc
The files should be there:
>> pwd
ans =
C:\Program Files\MATLAB\R2010a\toolbox\physmod\simscape\simscape\+foundation\+thermal
>> ls
+elements +sensors +sources . .. branch.ssc lib.m thermal.ssc
I don't know if that's a result of your previous attempts to modify the installation directory, but it sounds like you may need to uninstall and reinstall MATLAB.
Sorry,
Arnaud