[S0067] Create mesh channel conditions and set heat transfer boundaries

Mesh channel conditions can be used to define channels with specified cross-sectional shapes and arrangements during mesh generation without modifying the model geometry. This function can arrange circular or rectangular channels in a circular pattern around a specified central axis by defining parameters such as cross-sectional dimensions, pitch diameter and the number of channels. The created mesh channels can also be referenced as targets of heat transfer boundary conditions.
This script creates circular and rectangular axial mesh channel conditions and sets them as targets of existing heat transfer boundary and layered heat transfer boundary conditions.

Preconditions

  • One or more studies have been created.
    This script runs on the active thermal analysis study in the project tree.
  • Heat transfer boundary and layered heat transfer boundary conditions can be used for thermal analysis or thermal stress analysis studies.
  • Heat transfer boundary and layered heat transfer boundary conditions have already been created and their titles are known.
  • The units of the setting values follow the unit system set for the model.
  • The mesh channel condition is available in JMAG-Designer v25.1 and later.
  • Script Function

    • Create an axial circular mesh channel condition and set its channel shape, arrangement, and reference axis.
      For mesh channels, specify a reference axis and arrange the specified number of channels in a circular pattern.
    • Create an axial rectangular mesh channel condition and set its channel shape, arrangement, and reference axis.
    • Set the target of the heat transfer boundary condition to a mesh region and set the created circular mesh channel.
    • Set the target of the layered heat transfer boundary condition to a mesh region and set the created rectangular mesh channel.
    # Copyright (c) 2026 JSOL CORPORATION
    #
    # This script is released under the MIT License.
    # See the full license text at:
    # https://www.jmag-international.com/scriptlibrary/jmag_script_library_mit/
    
    app = designer.GetApplication()
    
    # Condition names
    CircularChannelName = u"circle"
    RectangularChannelName = u"rectangle"
    HeatTransferConditionName = u"left"
    HeatTransferLayeredConditionName = u"right"
    
    # Circular channel settings
    CircularDiameter = 8
    CircularNumberOfChannel = 2
    CircularChannelLengthUpper = 80
    CircularChannelLengthLower = 0
    CircularReferenceAxisAngle = 45
    CircularPitchDiameter = 40
    CircularOriginX = -100
    CircularOriginY = 50
    CircularOriginZ = 0
    CircularAxisX = 0
    CircularAxisY = 0
    CircularAxisZ = 1
    CircularReferenceDirectionX = 1
    CircularReferenceDirectionY = 0
    CircularReferenceDirectionZ = 0
    
    # Rectangular channel settings
    RectangularChannelWidth = 20
    RectangularChannelHeight = 20
    RectangularNumberOfChannel = 2
    RectangularChannelLengthUpper = 80
    RectangularChannelLengthLower = 0
    RectangularReferenceAxisAngle = 0
    RectangularPitchDiameter = 50
    RectangularOriginX = 60
    RectangularOriginY = 50
    RectangularOriginZ = 40
    RectangularAxisX = 1
    RectangularAxisY = 0
    RectangularAxisZ = 0
    RectangularReferenceDirectionX = 0
    RectangularReferenceDirectionY = 1
    RectangularReferenceDirectionZ = 0
    
    
    def createCircularMeshChannel(meshControl):
        """Create an axial mesh channel with a circular cross-section."""
        channel = meshControl.CreateCondition(u"MeshChannel", CircularChannelName)
        channel.SetValue(u"ChannelType", u"AxialDirection")
        channel.SetValue(u"ChannelShape", u"CircularChannel")
        channel.SetValue(u"CircularDiameter", CircularDiameter)
        channel.SetValue(u"NumberOfChannel", CircularNumberOfChannel)
        channel.SetValue(u"ChannelLengthUpper", CircularChannelLengthUpper)
        channel.SetValue(u"ChannelLengthLower", CircularChannelLengthLower)
        channel.SetValue(u"ReferenceAxisAngle", CircularReferenceAxisAngle)
        channel.SetValue(u"PitchDiameter", CircularPitchDiameter)
    
        origin = app.CreatePoint(CircularOriginX, CircularOriginY, CircularOriginZ)
        axis = app.CreatePoint(CircularAxisX, CircularAxisY, CircularAxisZ)
        referenceDirection = app.CreatePoint(
            CircularReferenceDirectionX,
            CircularReferenceDirectionY,
            CircularReferenceDirectionZ
        )
        channel.SetPoint(u"Origin", origin)
        channel.SetPoint(u"Axis", axis)
        channel.SetPoint(u"ReferenceDirection", referenceDirection)
    
        return channel
    
    
    def createRectangularMeshChannel(meshControl):
        """Create an axial mesh channel with a rectangular cross-section."""
        channel = meshControl.CreateCondition(u"MeshChannel", RectangularChannelName)
        channel.SetValue(u"ChannelType", u"AxialDirection")
        channel.SetValue(u"ChannelShape", u"RectangularChannel")
        channel.SetValue(u"RectangularChannelWidth", RectangularChannelWidth)
        channel.SetValue(u"RectangularChannelHeight", RectangularChannelHeight)
        channel.SetValue(u"NumberOfChannel", RectangularNumberOfChannel)
        channel.SetValue(u"ChannelLengthUpper", RectangularChannelLengthUpper)
        channel.SetValue(u"ChannelLengthLower", RectangularChannelLengthLower)
        channel.SetValue(u"ReferenceAxisAngle", RectangularReferenceAxisAngle)
        channel.SetValue(u"PitchDiameter", RectangularPitchDiameter)
    
        origin = app.CreatePoint(RectangularOriginX, RectangularOriginY, RectangularOriginZ)
        axis = app.CreatePoint(RectangularAxisX, RectangularAxisY, RectangularAxisZ)
        referenceDirection = app.CreatePoint(
            RectangularReferenceDirectionX,
            RectangularReferenceDirectionY,
            RectangularReferenceDirectionZ
        )
        channel.SetPoint(u"Origin", origin)
        channel.SetPoint(u"Axis", axis)
        channel.SetPoint(u"ReferenceDirection", referenceDirection)
    
        return channel
    
    
    def setMeshChannelToHeatTransferCondition(condition, meshChannel):
        """Set a mesh channel as the target of a heat transfer boundary condition."""
        condition.SetValue(u"TargetType", u"Mesh")
        condition.SetLinkWithType(u"LinkedMeshChannel", meshChannel.GetName())
    
    
    def main():
        """Create mesh channels and set them as targets of heat transfer boundary conditions."""
        study = app.GetCurrentStudy()
        meshControl = study.GetMeshControl()
    
        circularChannel = createCircularMeshChannel(meshControl)
        rectangularChannel = createRectangularMeshChannel(meshControl)
    
        heatTransferCondition = study.GetCondition(HeatTransferConditionName)
        setMeshChannelToHeatTransferCondition(heatTransferCondition, circularChannel)
        heatTransferLayeredCondition = study.GetCondition(HeatTransferLayeredConditionName)
        setMeshChannelToHeatTransferCondition(
            heatTransferLayeredCondition,
            rectangularChannel
        )
    
    
    main()

    Download Python source code

How to use script file

Use the JMAG Script Library after reading and agreeing to the following terms of use.

Search Filter
  • All Categories

An engineer's diary
JMAG-Express Online