How to Use ANSYS APDL Command *Vread

How to Use ANSYS APDL Command *Vread

Please Share Us

点击此处查看 ✿水哥原创ANSYS视频教程清单 ✿

水哥专属答疑服务已开通,点此此处查看详情

The *Vread command is used to read in data from an external file in ANSYS Parametric Design Language (APDL). Here is the format of the command:

*Vread, ParP, Frname, Ext, –, Label, n1, n2, n3, Nskip

In this command, ParP is the assigned object array to store the data that is being read in. Prior to using this command, the *dim command should be used to define the object array. Frname is the name of the file with its path. Note that the path cannot contain any Chinese characters. If the file is located in the working directory, then simply the file name can be used. Ext is the file extension. Label is the character string that represents the order in which the values are taken, which can be IJK, IKJ, JIK, JKI, KIJ, or KJI. The default is IJK. n1, n2, and n3 represent the number of values taken according to the order represented by Label. Nskip is the number of rows skipped at the beginning of the data file, which defaults to 0, meaning that the data is read in from the first row.

How to Use APDL Command *Vread

The *Vread command is used to read in data from an external file in ANSYS Parametric Design Language (APDL). Here is the format of the command:

*Vread, ParP, Frname, Ext, –, Label, n1, n2, n3, Nskip

In this command, ParP is the assigned object array to store the data that is being read in. Prior to using this command, the *dim command should be used to define the object array. Frname is the name of the file with its path. Note that the path cannot contain any Chinese characters. If the file is located in the working directory, then simply the file name can be used. Ext is the file extension. Label is the character string that represents the order in which the values are taken, which can be IJK, IKJ, JIK, JKI, KIJ, or KJI. The default is IJK. n1, n2, and n3 represent the number of values taken according to the order represented by Label. Nskip is the number of rows skipped at the beginning of the data file, which defaults to 0, meaning that the data is read in from the first row.

It is worth noting that the *Vread command is used through an external macro file and cannot be directly copied and pasted into the command window. Generally, the format used is as follows, where students only need to modify the macro file name and the content of the *Vread command:

! Create a macro file named dataread (the name can be changed)

*Create, dataread, mac

*dim, Elcentro,, 2600   ! Create an array to store the data read in

! Read in the data from file Elcentro.txt

*Vread, Elcentro(1,1), Elcentro, txt, , ijk, n1, n2

(f6.3)

 *End    ! End the creation of the macro file

! Run the macro file

Dataread

The above gives a general outline of how to use *Vread. Students can refer to this outline when using the command. Because the *Create command is used to create a macro file, and *Vread is used within the macro file, the above commands can be directly copied and pasted into the ANSYS command window to use. After running this command, a macro file with the extension .mac will be generated in the current working directory with the name Dataread, which can be modified as needed.

The file being read in should preferably have a .txt extension or others and should be properly formatted before being placed in the working directory.

One of the difficulties of using the *Vread command is the setting of the label that determines the order in which the data is written, as well as the setting of N1, N2, and N3.

1. Setting the Label

The Label setting determines the order in which the data is written. I represents row, J represents column, and K represents plane. If it is IJK, the plane is written first, then the column, and finally the row, meaning that the column changes faster than the row. If it is JIK, the plane is written first, then the row, and finally the column, meaning that the row changes faster than the column. In normal use, only the IJK and JIK formats are used. For a two-dimensional array, there is no plane to write, only the row and column changes.

2. Setting Values for N1, N2, and N3

N1, N2, and N3 represent the number of data points to be written for each subscript in the order specified. For example, “IJK,3,4,1” indicates that the array “ParP” should be written by column, with a total of 3 columns and 4 rows. The default value for N2 and N3 is 1.

To demonstrate how to use *Vread, let’s consider a two-dimensional array.

Suppose we have a file named “data.txt” with the following contents, representing a 6×5 two-dimensional array, which we will read using *Vread:

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

26 27 28 29 30

31 32 33 34 35

36 37 38 39 40

(1) Using the IJK Reading Order

To read the entire array in IJK order, we can use the following command flow:

*Create,dataread,mac
*dim,DD,array,6,5
*vread,DD(1,1),data,txt,,ijk,6,5
(5f3.0)
*End
Dataread

图片[1]-How to Use ANSYS APDL Command *Vread-峰设教育

In the above command flow, “(5F3.0)” represents the format for reading the data. ANSYS always reads files by row, and the final result depends on the order in which the array is written and the number of data points read. “(5F3.0)” means that we read five data points per row using the F format, where each data point has three bytes, with no decimal places. If the number of data points read exceeds the number we specified, the excess points will be replaced by 0s.

The data points are written to the array in the order specified beforehand, which in this case is IJK (column-wise). The first six data points are written to the first column, followed by the next six to the second column, and so on, until all five columns are written. This produces the result shown above. If we change the number of data points written, we can observe the effect. For example, if we modify the *Vread command as follows:

*vread,DD(1,1),data,txt,,ijk,5,1

图片[2]-How to Use ANSYS APDL Command *Vread-峰设教育

Then each column will only have five data points, with only one column, and the remaining points will be replaced by 0s.

*vread,DD(1,1),data,txt,,ijk,3,2

图片[3]-How to Use ANSYS APDL Command *Vread-峰设教育

(2) Using the JIK Reading Order

To read the entire array in JIK order, we can use the following command flow:

*Create,dataread,mac
*dim,DD,array,6,5
*vread,DD(1,1),data,txt,,jik,5,6 (5f3.0)
*End
Dataread

图片[4]-How to Use ANSYS APDL Command *Vread-峰设教育

The resulting array will be written by row, then by column, and finally by subscripts. The final result will be the same as the IJK order result.

Once you understand how the reading process works, the following steps can be followed for practical use:

  1. Determine the dimensions of the data to be read, such as the number of rows (m) and columns (n).

  2. Define the array with dimensions m x n.

    *dim,parp,array,m,n

  3. Use the *Vread command, and specify the JIK order.

欢迎扫描如下二维码关注本站微信公众号:ANSYS结构院

有时间麻烦帮忙点击下公众号文末的广告哦, 权当码字的辛苦费,感谢大家!

Please Share Us
© 版权声明
THE END
喜欢就支持一下吧
点赞2赞赏 分享
评论 共2条
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码

YOU MAY LIKE…