Modeling the Spring in Chamber with Composite Components in the Position-Based Translational Domain
This example shows how to model the Spring in Chamber block with an equivalent system that contains simple subcomponents. This example is the second in a series that starts with Pressure Relief Valve in the Position-Based Translational Domain and uses the same pressure relief valve. The next example in the series is Equivalent Systems for the Conical Poppet Valve.
The Pressure Relief Valve
The PositionBasedSpringChamber
model compares the pressure relief valve implemented with the Spring in Chamber block to an equivalent system.
% Close model if it is open to reset Subsystem to empty close_system('PositionBasedSpringChamber',0); % Open the model open_system('PositionBasedSpringChamber');
The Spring in Chamber block represents a fluid chamber that contains a spring between two pistons. The spring assembly can move within the casing, but remains inside the casing. The chamber contains fluid and is connected to an orifice that allows fluid to transfer in or out.
Building the Composite Spring in Chamber
Construct the Spring in Chamber equivalent system by adding a Spring block and a Translational Mechanical Converter block connected in parallel. Connect the isothermal liquid port of the converter to the overall system's isothermal liquid port with an orifice block.
% Specify model and block paths. SubSystem = 'PositionBasedSpringChamber/Spring in Chamber1'; Spring = [SubSystem '/Spring']; Orifice = [SubSystem '/Orifice (IL)']; HsLeft = [SubSystem '/Hard Stop Left']; HsRight = [SubSystem '/Hard Stop Right']; Spacer = [SubSystem '/Maximum Distance Between B and F']; % Uncomment composite system blocks set_param(SubSystem, 'Commented', 'off'); set_param('PositionBasedSpringChamber/Translational World (PB)1', 'Commented', 'off') set_param('PositionBasedSpringChamber/Solver Configuration1', 'Commented', 'off') set_param('PositionBasedSpringChamber/Knob1', 'Commented', 'off') set_param('PositionBasedSpringChamber/Conical Poppet Valve1', 'Commented', 'off') set_param('PositionBasedSpringChamber/Reservoir (IL)1', 'Commented', 'off') set_param('PositionBasedSpringChamber/Pressure Source (IL)1', 'Commented', 'off') set_param('PositionBasedSpringChamber/PS Ramp1', 'Commented', 'off') % Open the model open_system(SubSystem) % Add Spring PositionBasedSpringChamberBuildSystem('Spring','Add'); % Add Translational Mechanical Converter PositionBasedSpringChamberBuildSystem('Converter','Add'); % Add Orifice PositionBasedSpringChamberBuildSystem('Orifice','Add'); % Connect Spring PositionBasedSpringChamberBuildSystem('Spring','Connect'); % Connect Orifice PositionBasedSpringChamberBuildSystem('Orifice','Connect'); % Connect Converter PositionBasedSpringChamberBuildSystem('Converter','Connect');
This system's parameterization is equivalent to the Spring in Chamber block. The equivalent system is functional but it will not restrict any motion, and the component you are modeling has both lower and upper length restrictions on the spring. At the low end, the spring cannot be compressed below a length of zero, as the piston heads would collide. At the upper end, the spring cannot exceed the length of the casing containing the spring, piston, and fluid chamber system.
Add a Hard Stop Left block and connect its B and F ports to the overall system's B and F ports. This prevents the spring from being compressed to a length less than zero.
% Add Left Hard Stop PositionBasedSpringChamberBuildSystem('Hardstop Left','Add');
If you want to model both contraction and expansion hardstops instead, add a Spacer block and another Hard Stop block and connect them as shown below. The Length initial target of the Spacer block corresponds to the maximum size allowed by the component casing. The hard stop prevents the Spring block from extending beyond the specified maximum length.
% Delete Hard Stop F Connection HsPortHandles = get_param(HsLeft, 'PortHandles'); line_handle = get_param(HsPortHandles.RConn, 'Line'); delete_line(line_handle); % Add Spacer PositionBasedSpringChamberBuildSystem('Spacer','Add'); % Add Hard Stop for Extension PositionBasedSpringChamberBuildSystem('Hardstop Right','Add');
% Connect Hard Stops PositionBasedSpringChamberBuildSystem('Hard stops','Connect'); % Connect Spacer PositionBasedSpringChamberBuildSystem('Spacer','Connect'); % Connect Hard Stop Assembly to Spring and Chamber PositionBasedSpringChamberBuildSystem('Assembly','Connect');
This model is an equivalent system.
% Return model to top level diagram open_system('PositionBasedSpringChamber');
Set Values
The equivalent system uses these non-default parameter settings based on the Spring in Chamber block.
Spring in Chamber Parameter | Equivalent System Block | Equivalent System Parameter |
Spring stiffness parameter set to | Spring block | Spring stiffness set to |
Cross-sectional area at ports Af and Bf parameter set to | Orifice block | Cross-sectional area at ports Af and Bf set to |
Upper bound distance between F and B parameter set to | Space block, labeled Maximum Distance Between B and F | Length initial target set to |
Set the parameter values manually or by using the code below:
set_param(Spacer, 'length', '80', 'length_unit', 'mm', 'length_specify', 'on', 'length_priority', 'High'); %mm set_param(Spring, 'stiffness', '20000', 'stiffness_unit', 'N/m'); % N/m set_param(Orifice, 'area', '0.01', 'area_unit', 'm^2'); % m^2
Initializing the Model
The system construction and parameter values are insufficient for a successful model because there is not enough information for the simulation to solve. Initialize the Hard Stop Left block Gap length initial target to 45 mm. Initialize the Hard Stop Right block Gap length initial target to 80 mm - 45 mm = 35 mm. Initialize the Spring block Length initial target to 45 mm and the Force initial target to 100 N. This is the spring preload that balances the Conical Poppet Valve initialization force value.
% Initialize Left Hard Stop set_param(HsLeft, 'gap_length_specify', 'on'); set_param(HsLeft, 'gap_length_priority', 'high'); set_param(HsLeft, 'gap_length', '45'); set_param(HsLeft, 'gap_length_unit', 'mm'); % Initialize Right Hard Stop set_param(HsRight, 'gap_length_specify', 'on'); set_param(HsRight, 'gap_length_priority', 'high'); set_param(HsRight, 'gap_length', '35'); % 80 mm - 45 mm set_param(HsRight, 'gap_length_unit', 'mm'); % Initialize Spring set_param(Spring, 'f_specify', 'on'); set_param(Spring, 'f_priority', 'high'); set_param(Spring, 'f', '100'); set_param(Spring, 'f_unit', 'N'); set_param(Spring, 'length_specify', 'on'); set_param(Spring, 'length_priority', 'high'); set_param(Spring, 'length', '45'); set_param(Spring, 'length_unit', 'mm');
The Spring in Chamber block automatically handles some of this variable initialization based upon its block parameters. Review spring_chamber
.ssc in +PositionBasedValve
for more details.
System Comparison
These plots compare the behavior of the Spring in the Spring in Chamber composite block and the created equivalent system. The behavior matches.
PositionBasedSpringChamberPlot
Summary
Complicated blocks can be modeled as composite components.
The initialization specification process may differ depending on the composite component architecture, but the systems will perform similarly if you initialize them correctly.