Main Content

hydraulicToIsothermalLiquid

Upgrade hydraulic block diagram to use isothermal liquid blocks

Description

hydraulicToIsothermalLiquid converts hydraulic blocks to isothermal liquid blocks, appends _converted to the name of the original file, and saves each converted file. Although the conversion tool attempts to preserve the parameter values and connections between the blocks, there is not always a one-to-one correspondence between the Isothermal Liquid and Hydraulic library blocks. The conversion tool lists the issues encountered during the conversion in an HTML report.

For more information, see Upgrading Hydraulic Models to Use Isothermal Liquid Blocks.

hydraulicToIsothermalLiquid(oldfile) replaces blocks from the Foundation > Hydraulic library in the block diagram system, oldfile, with equivalent Isothermal Liquid library blocks and saves each converted file in the same folder as the original file. If you have a Simscape™ Fluids™ license, this tool also replaces blocks from the Fluids > Hydraulics (Isothermal) library with equivalent blocks from the Fluids > Isothermal Liquid and Foundation > Isothermal Liquid libraries.

example

hydraulicToIsothermalLiquid(oldfile,newpath) replaces blocks in the specified block diagram system and saves the converted block diagram system and the conversion report in the location specified by newpath.

hydraulicToIsothermalLiquid(oldfiles) converts a list of files, oldfiles, where each of the files can be a model, subsystem, or library. The conversion tool preserves the links between the converted files. Use this syntax to convert models that contain references or links to other libraries, models, or subsystems.

example

hydraulicToIsothermalLiquid(toppath) converts the models, subsystems, and libraries in the folder toppath and its subfolders. Use this syntax to convert custom libraries and other models that contain references or links to other libraries, models, or subsystems. Both toppath and its subfolders must be on the MATLAB® path.

example

hydraulicToIsothermalLiquid(___,subsystemflag) replaces blocks from the Hydraulic library with equivalent Isothermal Liquid library blocks, and organizes the blocks in the newfile model according to the value of the subsystemflag parameter.

example

hydraulicToIsothermalLiquid(___,oldcustomblocks,newcustomblocks) replaces the custom hydraulic blocks listed in oldcustomblocks with the corresponding isothermal liquid blocks, newcustomblocks. Use this syntax to convert models that contain customized hydraulic blocks, such as masked library blocks or custom blocks written in Simscape language.

To create equivalent isothermal liquid version of the customized blocks:

  • For custom library blocks and subsystems that contain blocks from the Foundation > Hydraulic library or Fluids > Hydraulics (Isothermal) library, run the conversion tool on these custom libraries.

  • For custom hydraulic blocks written in Simscape language, manually create equivalent versions of these blocks that use the isothermal liquid domain.

newfiles = hydraulicToIsothermalLiquid(___) returns the list of converted file names as newfiles. The conversion tool forms each new file name by appending _converted to the name of the original file.

Examples

collapse all

This example shows how to use the conversion tool on a model that contains Hydraulic blocks. The tool generates a converted model and an HTML report.

Open the Hydraulic Actuator with Analog Position Controller example model:

openExample('simscape/HydraulicActuatorWithAnalogControlHExample')

This example model contains blocks from Hydraulic libraries.

Replace the Hydraulic library blocks with the equivalent blocks from the Isothermal Liquid library.

hydraulicToIsothermalLiquid(bdroot)
ans =

  1×1 cell array

    {'HydraulicActuatorWithAnalogControlH_converted'}

The conversion tool creates a new file named HydraulicActuatorWithAnalogControlH_converted and saves it and the conversion report in the current folder.

Review the HTML report and manually fix the remaining issues. In this example, the converted model does not contain broken connections or removed blocks, but the conversion tool generated several parameter warnings that require attention.

In this example, you clean up the model after using the conversion tool. First, complete the example Convert Model to Use Isothermal Liquid Blocks. These images show the converted model and the conversion report.

For a list of the conversion messages and suggested actions to address them, see Conversion Messages After Converting Hydraulic to Isothermal Liquid Models. For each message, clicking a link in the Block column opens the associated subsystem and highlights the block that generated the message.

The first two messages refer to the two chambers of the Hydraulic Actuator subsystem. The original model used a Translational Hydro-Mechanical Converter block for each of these chambers. The conversion tool replaced these blocks with a Translational Mechanical Converter (IL) block.

Translational Hydro-Mechanical Converter blocks have a Specific heat ratio parameter, but in the isothermal liquid domain, all of the fluid properties are defined in the Isothermal Liquid Properties (IL) block. The conversion report lists the original value of the Specific heat ratio parameter in the original block so that you can set the fluid properties in the Isothermal Liquid Properties (IL) block: Original block had Specific heat ratio of 1.4. Set Air polytropic index to this value in an Isothermal Liquid Properties (IL) block.

Open the Isothermal Liquid Properties (IL) block in the converted model and set its Air polytropic index parameter to 1.4.

After addressing the first two conversion messages, click the third link in the Block column.

The Spool Valve subsystem opens. The tool highlights the Orifice PA block.

In the original model, HydraulicActuatorWithAnalogControlH, open the Spool Valve subsystem.

Orifice PA is one of four Variable Area Hydraulic Orifice blocks that comprise the valve. Double-click the Orifice PA block to see its parameters.

The conversion tool replaced each Variable Area Hydraulic Orifice block with a Local Restriction (IL) block. Double-click the Orifice PA block to see its parameters.

The first warning message in the conversion report for the Orifice PA block, Critical Reynolds number set to 150, is because the Laminar transition specification parameter is Pressure ratio in the original Variable Area Hydraulic Orifice block. The replacement Local Restriction (IL) block can specify the transition between the laminar and turbulent regime only by the critical Reynolds number, and the conversion tool sets the Critical Reynolds number parameter to its default value of 150. Because the Variable Area Hydraulic Orifice block in the original model used the default Laminar flow pressure ratio parameter value of 0.999, no action is necessary.

The next warning, Maximum restriction area set to 1e10 m^2, is because the original Variable Area Hydraulic Orifice block assumed an infinitely large maximum opening area, while the replacement Local Restriction (IL) block, with Restriction type set to Variable, requires a Maximum restriction area parameter value less than inf.

The conversion tool sets the Maximum restriction area parameter in the replacement Local Restriction (IL) block to an arbitrary large value, 1e10 m^2. No action is necessary, but you can adjust this value to match the data sheet for your model.

The rest of the conversion messages refer to the other three orifices. You can inspect these three blocks in the original model and verify that no action is necessary.

After you address the conversion messages, you can compare the simulation results of the original and the converted model to ensure they are the same. You can also perform further cosmetic cleanup, if desired. For example, you can manually reroute the connection lines.

To see an example of this model after conversion and cleanup, open the HydraulicActuatorWithAnalogControlExample model.

openExample('simscape/HydraulicActuatorWithAnalogControlExample')

Compare this model with the original model, HydraulicActuatorWithAnalogControlH, and the converted model, HydraulicActuatorWithAnalogControlH_converted.

This example shows how to use subsystems to preserve line routing when converting a model.

Open the Cavitation Cycle example model.

openExample('simscape/CavitationCycleExample')

Convert the model with subsystems to preserve line routing.

hydraulicToIsothermalLiquid('CavitationCycle.slx','addsubsystems')

Open the Custom Cylinder subsystem.

The function places both pistons into subsystems to preserve the line routing.

This example shows how you can convert models together with their referenced models, subsystems, and linked libraries, and preserve the links between the converted files.

Suppose you have a model named modelWithLink that contains hydraulic blocks and a referenced model, referenceModel, which also contains hydraulic blocks. referenceModel is in a separate folder, Reference Systems, which is on the MATLAB path.

Convert the modelWithLink model and the referenced model by specifying the files in a cell array.

convertedFiles = hydraulicToIsothermalLiquid({'modelWithLink' 'referenceModel'})
convertedFiles =

  2×1 cell array

    {'modelWithLink_converted' }
    {'referenceModel_converted'}

The conversion tool creates new two models, modelWithLink_converted and referenceModel_converted, in the same folders as the original models.

The converted model, modelWithLink_converted, has isothermal liquid blocks and links to the converted reference model, referenceModel_converted, which also has isothermal liquid blocks.

The tool saves the conversion report, HtoIL_report, in the location of the first file in the oldfiles input argument.

After you review the report, manually fix the issues, and compare the simulation results, you can use the hydraulicToIsothermalLiquidPostProcess function to restore the original file names:

finalFiles = hydraulicToIsothermalLiquidPostProcess(convertedFiles)

The function overwrites the original model files with the _converted models.

This example shows how to convert all the files in a top-level folder and its subfolders. The tool converts all the files that contain hydraulic blocks, preserves the links between them, and returns the list of converted files. If a file does not contain hydraulic blocks, the tool does not change it.

Suppose you have a folder named topFolder, that contains subfolders with custom Simulink® libraries, referenced models and subsystems, and models.

Ensure that topFolder and its subfolders are on the MATLAB path.

addpath(genpath('topFolder'))

Convert all the files in topFolder and its subfolders.

convertedFiles = hydraulicToIsothermalLiquid('topFolder')
convertedFiles =

  5×1 cell array

    {'model_converted'             }
    {'custom_Library1_converted'   }
    {'custom_Library2_converted'   }
    {'referenceModel_converted'    }
    {'referenceSubsystem_converted'}

The conversion tool names the converted files by using the original model names and adding _converted. The tool saves each converted model in the same folder as the original one.

In this example, the tool did not generate a _converted file for modelWithoutHydraulicBlocks, because this model does not contain hydraulic blocks.

The tool saves the conversion report in topFolder.

After you review the report, manually fix the issues, and compare the simulation results, you can use the hydraulicToIsothermalLiquidPostProcess function to restore the original file names:

finalFiles = hydraulicToIsothermalLiquidPostProcess('topFolder')

This function overwrites the original files by removing the _converted suffix from the file names and from the links between the files.

Input Arguments

collapse all

Block diagram system name or handle to convert, specified as a character vector, string scalar, or a handle. oldfile can be a model, subsystem, or library. It must be either on the MATLAB path or loaded. The file name can be an absolute or relative path name.

Example: 'HydraulicActuator'

Example: 'C:\Work\HydraulicActuator.slx'

Example: 'subfolder\HydraulicActuator'

Location of the converted block diagram system and report, specified as a character vector or string scalar that contains an absolute or relative path name.

If you omit the newpath argument, the tool saves the converted system and report in your current working folder.

Example: 'C:\Work'

List of the block diagram systems to convert, specified as a one-dimensional cell array of character vectors or string scalars, where each element is a file name. The cell array can be horizontal or vertical. File names can include absolute or relative path names. The files can be a model, subsystem, or library, and must be either on the MATLAB path or loaded. When you convert a list of files, the conversion tool preserves the links between the converted files in the list, saves each converted file in the same folder as the original file, and saves the conversion report at the location of the first file in oldfiles.

Example: {'HydraulicActuatorLibrary' 'PumpLibrary'}

Example: {'PumpLibrary';'C:\Work\MyPump.slx'}

Path name of the top folder that contains the block diagram systems to convert, specified as a character vector or string scalar that contains an absolute or relative path name. The top folder must be on the MATLAB path. The top folder can contain subfolders that also contain block diagram systems. The subfolders must also be on the MATLAB path. The tool preserves the links between the converted files, saves each converted file in the same folder as the original file, and saves the conversion report in the toppath folder.

Example: 'C:\Work\MyLibraries'

List of the customized hydraulic blocks to replace, specified as a one-dimensional cell array of character vectors or string scalars, where each element is a file name.

The two cell arrays, oldcustomblocks and newcustomblocks, must have the same number of elements, each element corresponding to a block name. The respective blocks listed in each array must have the same number of ports, matching port order, and the same programmatic parameter names.

List of the customized isothermal liquid blocks to use as replacements for oldcustomfiles, specified as a one-dimensional cell array of character vectors or string scalars, where each element is a file name.

The two cell arrays, oldcustomblocks and newcustomblocks, must have the same number of elements, each element corresponding to a block name. The respective blocks listed in each array must have the same number of ports, matching port order, and the same programmatic parameter names.

Option to place the converted blocks in subsystems, specified as 'omitsubsystems' or 'addsubsystems'. When subsystemflag is 'omitsubsystems' the function only uses subsystems if the tool replaces a single Hydraulic block with multiple Simscape blocks. If you specify subsystemflag as 'addsubsystems', the function places blocks that impact line routing into subsystems to preserve the Hydraulic model line routing.

If you specify a value for subsystemflag, it must be the last input argument.

Output Arguments

collapse all

Names of the converted models, subsystems, or libraries, returned as a one-dimensional column cell array of character vectors that contains the file names, without the path or extension.

The conversion tool forms each new file name by appending _converted to the name of the original file.

Version History

Introduced in R2020a

expand all