CFD-ACE+ User Tips

The First User Subroutine is the Hardest
Many users are interested in using user subroutines to set special boundary conditions, do problem-specific post-processing, or try things that are not supported either by the GUI or the solver itself. We have developed many user subroutines over the past few years, to help users get started. Usually it only takes a couple days and doesn't cost very much.

Although the process of developing and using a user subroutine is straightforward, it is not easy at first. Many users have trouble getting started. If you fall into this category, this tip is for you.

This tip will take you through a specific example of making and using a UCOND user subroutine. This example is a simple heat conduction problem in a square, where the conductivity is higher in a circular region inside the square. UCOND is similar to UVISC or UDENS and many others --- one of many user subroutines that let you change specific material properties inside a given volume.
Prerequisites: In order to compile user subroutines, you must have a Fortran compiler. For Windows machines, we use the Compaq Visual Fortran V6.5 compiler. For Linux, we use NAGWare Fortran 95 V5.0. For other Unix platforms, we use that system's native compiler. We do not guarantee or recommend other compilers, but they may work too.

Step 1 – Model Creation. Using CFD-GEOM, create the 2D square grid shown in the figure (21 x 21), and save a clean DTF file.

Step 2 – Model Setup. Set up the model in CFD-ACE-GUI. Pay special attention to steps (c) and (e) below:

1. On the PT panel, turn on Heat
2. On the BC panel, pick the left wall and set it to ‘Heat Flux’ and specify q = 100 W/m2. Similarly, pick the right wall and set it to ‘Isothermal’ and specify T = 300K.
3. On the VC panel, pick the volume and change its conductivity to ‘User Sub(ucond)’
4. On the SC panel, set the number of iterations to 1000. On the Relax tab, set the enthalpy relaxation to 5E-06.
5. On the Run panel, indicate the name of the file containing the user subroutine you will be writing. Let's call the user subroutine "my_UCOND" .
Step 3 – User Subroutine Development. Follow these steps to create the user subroutine:

1. Copy the template file libUserAce.f over to your working directory, and rename it to my_UCOND.f The template file libUserAce.f is located in the bin directory of your software installation.
2. Edit the file my_UCOND.f with a non-formatting text editor or programming editor. On Windows, Notepad will work fine, but don’t use Microsoft Word or Wordpad, because these add extra hidden formatting into the file. You could also use the editor that came with your Fortran compiler.
3. Find the UCOND user subroutine. The template file starts by defining a MODULE named cfdrc_user at the top, containing some general parameters. Then, the file contains 50 empty templates for user subroutines. UCOND is the 5th one. In version 2003, UCOND starts on line 448 and ends on line 499. You are free to delete those user sub templates that aren't being used.
4. Type in the coding shown below inside the UCOND user subroutine template:

In order to understand what each line is doing, you can refer to the User Subroutine chapter in the CFD-ACE+ User Manual. Here I'll just give a short description.

The purpose of lines 15 through 17 is to get identifiers for each of the variables you need to get or set.

Line 19 gets the ‘active cell index’. Each iteration, the solver will call your UCOND for every grid cell in the volume, one cell at a time. Thus, there is a concept of the ‘current’ or ‘active’ cell. Some other routines work the same, but others work differently. For example, a UBOUND is called for a given boundary one face at a time, but a UINIT or USOURCE is called for an entire volume at a time. These things are well-documented both in the user manual and in comments inside the template user subroutine file.

Lines 21 through 29 determine what conductivity value to use, depending on the location of the current cell. Finally, line 31 sets the conductivity for the current cell.

Step 4 – Compile the User Sub. Now open up a DOS or Unix shell, change directories to your working directory, and type the following command at the shell prompt:

build-userlib my_UCOND

Note the absence of the “.f” on the filename. You must use the build-userlib script to compile the user subroutine, because it links the appropriate libraries for the solver.

Step 5 – Run the Simulation. Go back to the Run panel of CFD-ACE-GUI and press Run. Wait a few seconds and then launch CFD-VIEW to look at the results. You should get the results shown below. Because of the higher conductivity region, the overall resistance to heat flow is decreased, resulting in a lower temperature on the left wall. Also, the temperature contours are no longer vertical.

1.jpg
CFD-ACE+CAE通用CFD流体力学及仿真

CFD-ACE+ User Tips的评论4条

  • 0
    <SPAN class=javascript id=text809826>user subroutine</SPAN><div class="cae-img"><img src="http://img.jishulink.com/caenet/forums/upload/2006/7/24/ef5be7f8-c0b9-4c38-9401-775c3c99f3b2.jpg" title="2.jpg" alt="2.jpg"></div>
  • 0
    <SPAN class=javascript id=text809827>results</SPAN><div class="cae-img"><img src="http://img.jishulink.com/caenet/forums/upload/2006/7/24/078f558a-b3c3-46f9-b38d-c8ffdd5e9fdd.jpg" title="3.jpg" alt="3.jpg"></div>

CFD-ACE+ User Tips的相关案例教程

New Functions & Enhancements 其实最重要的下面没说:无论是中面网格还是2D表面网格,3D四面体网格,网格划分速度有重大提升,平均提升50%-80%!!! Check Volume Function This New function can automatically detect and define volumes from an FE-Model or CAD M
package 她; import java.util.*;//控制镜面输入 import java.util.Random;//随机数 public class t { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("please enter a firs
2022年元旦起,AQWA频域/频谱/时域后处理均突然报错plt文件不存在,导致曲线无法查看。 临时解决对策如下 Hello all, We have discovered a 'Y2K-style' bug in the Aqwa solver. At the moment I can provide a workaround which will allow you to evaluate r
原文标题:Why SYCL: Elephants in the SYCL Room By James Reinders and Michael Wong 摘录自:https://www.hpcwire.com/2022/02/03/why-sycl-elephants-in-the-sycl-room/ Commentary — In the second of a series of guest
8 - Drawing a Model绘制模型 After you insert a design into the current project, you can draw a model of the electromagnetic structure. The general strategy is to build the model as a collection of 3D obje
影响力
粉丝
内容
获赞
收藏
    项目客服
    培训客服
    4 0