Borrar filtros
Borrar filtros

Temperature Dependent Custom Fluid

4 visualizaciones (últimos 30 días)
Dan
Dan el 26 de Jun. de 2014
Respondida: Tumelo Motlhanka el 19 de Abr. de 2022
I am attempting to use the Custom Hydraulic Fluid code in Simscape (custom_fluid.ssc) to make a variable temperature dependent fluid block (basically I need to run my model with both Skydrol LD-4 and Skydrol 5 so I wanted a switch the user can throw to use one or the other). To the custom_fluid.ssc code I added two inputs (temperature and fluid choice) and commented out the density, viscosity, and bulk modulus parameters. Then I added an equations block in which the curve-fits for the density, viscosity, and bulk modulus are included in an if block for the two fluids.
component(Propagation=source) mycustom_fluid
% Custom Hydraulic Fluid : 1.5 : fixed
% The block assigns fluid properties for all components assembled in
% a particular loop. The loop detection is performed automatically and the
% block is considered as part of the loop if it is hydraulically connected
% to at least one of the loop components. If no Hydraulic Fluid block is
% connected to the loop, the default properties of the Custom Hydraulic
% Fluid block are assigned.
inputs
T = { 20, 'K' }; % T:left
Fluid = { 1, '1' }; % Fld:left
end
parameters
% density = { 850 , 'kg/m^3' }; % Fluid density
% viscosity_kin = { 18e-6 , 'm^2/s' }; % Kinematic viscosity
% bulk = { 0.8e9 , 'Pa' }; % Bulk modulus at atm. pressure and no gas
alpha = { 0.005 , '1' }; % Relative amount of trapped air
range_error = { 2 , '1' }; % Pressure below absolute zero
end
nodes
G = foundation.hydraulic.hydraulic; % :right
end
function setup
% if density <= 0
% pm_error('simscape:GreaterThanZero', 'Fluid density');
% end
% if viscosity_kin <= 0
% pm_error('simscape:GreaterThanZero', 'Kinematic viscosity');
% end
% if bulk <= 0
% pm_error('simscape:GreaterThanZero', 'Bulk modulus at atm. pressure and no gas');
% end
if alpha < 0
pm_error('simscape:GreaterThanOrEqual', 'Relative amount of trapped air','0');
end
if alpha == 0
pm_warning('simscape:GreaterThan', 'In practice, the relative amount of trapped air', '0');
end
% G.density = density;
% G.viscosity_kin = viscosity_kin;
% G.bulk = bulk;
G.alpha = alpha;
G.range_error = range_error;
end
equations
if Fluid == 1 % Skydrol LD-4
G.density == -7.81300e-1*T + 1.00875e3;
G.viscosity_kin == 10^(8.90292e-10*T^4 - 5.41938e-7*T^3 + 1.31259e-4*T^2 - 1.84576e-2*T - 4.41859);
G.bulk == 2.22199e-3*T^5 - 1.47421*T^4 + 3.45233e2*T^3 - 2.04077e4*T^2 - 7.38360e6*T + 1.70081e9;
else % Skydrol 5
G.density == -7.84600e-1*T + 0.99283e3;
G.viscosity_kin == 10^(0.11983e-10*T^4 - 7.12442e-7*T^3 + 1.64085e-4*T^2 - 2.07875e-2*T - 4.46965);
G.bulk == 0.24826e-3*T^5 - 0.13982*T^4 + 0.07082e2*T^3 - 1.77240e4*T^2 - 8.48723e6*T + 1.62466e9;
end
end
end
The curve-fits are taken from the data that Matlab includes for the two fluids in the Hydraulic Fluid block.
When I attempt to build this block (ssc_build) I get the following error...
Failed to generate 'CustomOrificeLib_lib'
Caused by: Error using ne_updatelibraryitem>lBuild (line 35) Source element has failed to resolve all shared data.
I'm fairly new to making my own blocks so I wouldn't be surprised if this was a small/obvious error, but I can't find help through other searches so I hoping my problem can be discussed here.
Thanks for any help you can offer.
Dan

Respuestas (3)

Aljen
Aljen el 18 de Ag. de 2014
Editada: Aljen el 19 de Ag. de 2014
I got this message also when creating a Source for my custom domain. It turns out that it was linked to the domain parameters. It appears you need to define / mention all of them in the setup function. I am not sure how you can make sure that some are not changed w.r.t. the domain value, maybe with hidden parameters?

Thomas LE DIOURON
Thomas LE DIOURON el 1 de Nov. de 2018
A component with variables fluids properties dependent on a variable temperature would be helpfull. I've tried with another way in Matlab R2016b. This code compiles but it fails during execution with the following error: "The following equation doesn't reference any variables or outputs."
component(Propagation=source) variable_fluid
% Variable fluid
%
% This block enables to set variable density, kinematic viscosity and bulk moduluse
% for any kind of fluid.
parameters
alpha = { 0.005 , '1' }; % Relative amount of trapped air
range_error = { 2 , '1' }; % Pressure below absolute zero
end
nodes
A = foundation.hydraulic.hydraulic; % :right
end
inputs
density = { 850 , 'kg/m^3' }; % Fluid density
viscosity_kin = { 18e-6 , 'm^2/s' }; % Kinematic viscosity
bulk = { 0.8e9 , 'Pa' }; % Bulk modulus at atm. pressure and no gas
end
function setup
if alpha < 0
pm_error('simscape:GreaterThanOrEqual', 'Relative amount of trapped air','0');
end
if alpha == 0
pm_warning('simscape:GreaterThan', 'In practice, the relative amount of trapped air', '0');
end
A.alpha = alpha;
A.range_error = range_error;
end
equations
A.density == density;
A.viscosity_kin == viscosity_kin;
A.bulk == bulk;
end
end

Tumelo Motlhanka
Tumelo Motlhanka el 19 de Abr. de 2022
Viscosity is a measure of how easily a fluid flow such as water. Thabo wants to investigate how viscosity of water varies with temperature which can be determined by the following correlation: Using MATLAB, create a table for Thabo that shows the viscosity of water as a function of temperature in the range of 0° C (273.15 K) to 100° C (373.15 K) in increments of 5° C. Also, create a graph showing the value of viscosity as a function of temperature.

Categorías

Más información sobre Foundation and Custom Domains en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by