(844) 825-5971   Contact Us SimuTech Group’s YouTube Channel SimuTech Group on Facebook

Get Our Latest Tips & Tricks

Receive the latest updates to our popular Tips & Tricks articles and videos by subscribing to our Monthly Newsletter and Subscribe to the SimuTech Group YouTube channel channel.
For even more advanced ANSYS instruction, check out our consulting and training services. Or simply contact us to discuss any of your ANSYS needs.

Offsetting a Temperature Result to Degrees Absolute in ANSYS Mechanical APDL

ANSYS Temp Conversion 1a ANSYS Temp Conversion 1b

Figure 1: Temperature Plots, Fahrenheit and Rankine

 

Users performing thermal analysis occasionally want to change the plotted temperature result to degrees absolute, or to convert a result in degrees absolute into the usual scale.

This article illustrates a small macro that switches a temperature result in degrees Fahrenheit into degrees Rankine by adding 459.67 degrees to the temperature at each selected node. The macro can be easily adapted to work with Celsius/Kelvin.

The macro presented uses vectorized commands so that the conversion is quick when dealing with very large FEA models. Its action will typically be faster than a SET command that retrieves a result from the RTH results file for a large model.

Method
The following macro assumes that a temperature result exists in the user’s model. The result is usually loaded by a SET command that points to the desired load step and substep. It is up to the user to make a suitable selection of elements and nodes (usually the entire model), and to use the SET command to load the thermal result of interest, before applying the macro below to raise the temperatures at nodes by the amount 459.67. The macro can be easily changed to add 273.15 so that a Celsius result is converted to a Kelvin result.


fini
/post1
! Adjust temperature result by +459.67 degrees.
! Method using vectorized commands.
! This adjustment is undone by a SET command.
*get,min_node,node,,num,min
*get,max_node,node,,num,max
! Perform some basic error checking
*if,max_node,eq,0,then
   *MSG,ERROR
   No nodes are selected. Stopping.
   *return,-1
   /EOF
*endif
*get,dummytemp,node,min_node,temp
*if,_STATUS,ge,2,then
   *MSG,ERROR,min_node
   No temperature result, node %G. Stopping.
   *return,-1
   /EOF
*endif
! Prepare
*del,tempvec,,nopr   ! In case it exists
*del,my_mask,,nopr
*del,toffset,,nopr
*dim,tempvec,array,max_node-min_node+1
*dim,toffset,array,max_node-min_node+1
*dim,my_mask,array,max_node-min_node+1
*vget,my_mask(1),node,min_node,nsel
*vfill,toffset(1),ramp,459.67
! Add the temperature offset, *VPUT into result
*vmask,my_mask(1)
*vget,tempvec(1),node,min_node,temp
*vmask,my_mask(1)
*voper,tempvec(1),tempvec(1),ADD,toffset(1)
*vmask,my_mask(1)
*vput,tempvec(1),node,min_node,temp
! Clean up and plot
*del,tempvec,,nopr
*del,my_mask,,nopr
*del,toffset,,nopr
*del,dummytemp
*del,min_node
*del,max_node
/title,Temperatures were offset.
plnsol,temp
/com, .
/com, Warning--temperature results of selected nodes were raised.
/com, .

 


Two checks on the model are performed. There is a check that at least one node is selected, and a check that a temperature result exists for the lowest numbered node. Masking is employed with *VMASK so that a model with gaps in node numbering will work. Minimum to maximum node numbers are used so that the arrays are as small as possible. A plot title change is provided to warn users that the temperatures presented have been modified.

The macro is easily misapplied by a user, such as using it two times in a row, further increasing the temperature values. Another error would be to add to the node selection after running the macro.

Vectorized commands could be used to convert between Celsius and Fahrenheit, or to perform other conversions.

A return to the results file temperature is performed if a SET command is executed by the user, preferably with all nodes and elements selected.

The RTH results file is not affected by the above macro.

Many users will want to modify the above macro—it is intended to serve as a starting point for other work. Possible changes could include providing the offset temperature value in a first argument ARG1 for the macro, or providing ARG1 as an integer value that selects the desired temperature conversion type, noting that there are 12 possible conversions among Fahrenheit, Rankine, Celsius and Kelvin.

Conclusions
A small macro can convert temperature results in an ANSYS Mechanical APDL analysis. An example has been provided to convert degrees Fahrenheit to degrees Rankine. Vectorizing the commands employed lets the macro run very quickly with large FEA models.

Correct use of such a macro is up to the user. The example presented is intended as a starting point for whatever other conversions might be wanted.