Translational Hydro-Mechanical Converter with variable area.

1 次查看(过去 30 天)
I would like to create a custom component, similar to the Translational Hydro-Mechanical Converter, however, I'd like it to accept an external area value to be used as the parameter that converts the hydraulic pressure to a force. The intent is to be able to vary the area throughout the simulation.
I have tried modifying the source code for the component to achieve this but do not have enough of a fundamental understanding of the language to do so. How can I define an input and communicate that input to the internal component "chosen_converter"?
Something like this:
% component translational_converter_area
inputs
AR = {1e-3, 'in^2'}; % AR:left
end
nodes
C = foundation.mechanical.translational.translational; % C:left
A = foundation.hydraulic.hydraulic; % A:left
R = foundation.mechanical.translational.translational; % R:right
end
parameters
area = AR;
or = { 1, '1' };
compressibility = { 0, '1' };
init_pos = { 0, 'm' };
V_dead = { 1e-4, 'm^3' };
k_sh = { 1.4, '1' };
initial_pressure = { 0, 'Pa' };
end
if ~compressibility
equations
% Assertions
assert(area > 0);
end
components
chosen_converter = foundation.hydraulic.elements.translational_converter_incompressible...
(area=area, or=or);
end
else
equations
assert(area > 0)
assert(V_dead > 0)
assert(k_sh >= 1)
assert(k_sh < 2)
assert(init_pos >= 0)
assert(initial_pressure >= {-1, 'atm'})
end
components
chosen_converter = foundation.hydraulic.elements.translational_converter_compressible...
(area=area, or=or, init_pos=init_pos, V_dead=V_dead, k_sh=k_sh,...
initial_pressure=initial_pressure);
end
end
connections
connect(chosen_converter.A,A);
connect(chosen_converter.C,C);
connect(chosen_converter.R,R);
end
end
In the original code the input is not invoked and the parameter 'area' has a constant value. The modified version does not work (AR faults out as 'undefined') but I lack the understanding of the way the code communicates information to make it work.
Are there any suggestions or similar exercises I can use as reference?

采纳的回答

Martin
Martin 2018-6-11
Parameters are fixed during compilation, therefore the definition area = AR is not valid. In the Foundation Library block, it picks one file or the other for its internal component based on the compressibility setting. These files contain the math. You will need to modify these as well, as your system has different math (area as input instead of parameter). You can then use a connect statement to connect the input from your outer block to the input of your inner block.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Upgrading Hydraulic Models to Use Isothermal Liquid Blocks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by