Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Simscape - Convective Heat Transfer - Variable coefficient?

361 views
Skip to first unread message

Horace Lai

unread,
Dec 8, 2010, 4:03:04 AM12/8/10
to
Hello,

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

Arnaud_Miege

unread,
Dec 8, 2010, 9:47:47 AM12/8/10
to

"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

Horace Lai

unread,
Dec 8, 2010, 12:22:05 PM12/8/10
to
Sorry if this is a stupid question, but I could not find it in the help files.

How do I create a custom block? Or even better, how do I view the source code for any simscape/simulink block?

Arnaud Miege

unread,
Dec 9, 2010, 9:43:05 AM12/9/10
to
"Horace Lai" <hora...@gmail.com> wrote in message <idoert$ovb$1...@fred.mathworks.com>...

> Sorry if this is a stupid question, but I could not find it in the help files.
>
> 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

Horace Lai

unread,
Dec 9, 2010, 10:12:06 AM12/9/10
to
Thank you very much, Arnaud. That answers all of my questions and my future questions :)

Horace Lai

unread,
Dec 9, 2010, 5:14:05 PM12/9/10
to
And already I have another question. Couldn't find anything on it in the help files again.

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!

Horace Lai

unread,
Dec 10, 2010, 5:18:04 AM12/10/10
to
I made a little progress with no success, just want to add an update on what I've tried.....

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.

Arnaud Miege

unread,
Dec 10, 2010, 8:48:04 AM12/10/10
to
"Horace Lai" <hora...@gmail.com> wrote in message <idsuos$ou4$1...@fred.mathworks.com>...

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

Horace Lai

unread,
Dec 10, 2010, 9:44:05 AM12/10/10
to
Ah Okay, I think it's getting closer. It's giving me a slightly different error message now.

------------------------------------
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

Arnaud Miege

unread,
Dec 10, 2010, 10:30:08 AM12/10/10
to
"Horace Lai" <hora...@gmail.com> wrote in message <idtebl$m2n$1...@fred.mathworks.com>...

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

Horace Lai

unread,
Dec 10, 2010, 1:25:26 PM12/10/10
to
Reinstalled - it all works now. Thank you for your help!

Ricardo Pereira

unread,
Sep 5, 2012, 8:10:08 PM9/5/12
to
"Horace Lai" wrote in message <idnhk8$80j$1...@fred.mathworks.com>...
It seems that this thread is already out of date, but I have the same problem and I need URGENT help.

I need to do the same thing. Transform the convective heat transfer as variable.

I did everything as Mr Arnaud told to do, but I have a error:

-------------------------------------------------------------------------------------------------------------------------
>> ssc_build
Generating Simulink library 'foundation_lib' in the MATLAB package parent directory '/Applications/MATLAB_R2012a.app/toolbox/physmod/simscape/library/m' ...
Failed to generate 'foundation_lib'

Caused by:
'foundation' is a MathWorks' provided MATLAB package. Building MathWorks' provided
libraries is not supported.
-------------------------------------------------------------------------------------------------------------------------
And:

>>pwd


/Applications/MATLAB_R2012a.app/toolbox/physmod/simscape/library/m/+foundation/+thermal/+elements
-------------------------------------------------------------------------------------------------------------------------
I work with Matlab_2012a for Mac. I have already reinstalled it.

I need URGENT HELP.

Thanks
0 new messages