Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Collaborative Solutions Inc

An ANSYS Support Distributor


Date Subject Keywords Memo Number September 21, 2000 SMH000921 ANSYS Tip of the Week: Automated Parametric Studies in ANSYS Array: *do: /show: *uilist

1. Introduction It is often desired to solve a Finite Element Model with varying parameters to look at the sensitivity of some results quantity to these parameters. There are many ways to do this in ANSYS. The method illustrated in the attached input file uses an array to store the various values of the parameter in the first column. We then loop through each of the 3 values in the array using a *do command. For each value in the array, the FEM is solved. The largest nd maximum principal stress is stored in the 2 column of the array. A contour plot of maximum principal stress is made with the parameter value echoed as a label on the plot. The plot is stored as a jpeg picture file. This is repeated for each of the 3 values of the parameter. Finally, a summary text file is written and echoed to the screen with the parameter listed with the resulting maximum principal stress. This technique can be extended to multiple parameters by using an array with more columns. This technique can automate an analysis, and yield high productivity gains.

2. Details For this example we have a block with a hole in it. We vary the size of the hole 3 times. Each of the significant parts of the input file will be discussed below; In the below set of commands we set the size of the block, the location of the hole, and we dimension the array holdrad with the *dim command. This is a 3 row by 2-column array. We store in column 1 the hole radius, and later we will store in column 2 the largest maximum principal stress.
!DIMENSIONS OF THE BLOCK *SET,blkw,1 *SET,blkh,.5 *SET,blkt,.1 !LOCATION OF THE CYLINDER (HOLE) *SET,cylx,.5 *SET,cyly,.25 !RADII OF THE CYLINDER .05,.08,.15 *dim,holrad,array,3,2,1 holrad(1,1)=.05 holrad(2,1)=.08 holrad(3,1)=.15

Now we tell ANSYS we will loop through all of the commands between the *do and the *endo, 3 times. The parameter count is used as an index for use in the array as discussed blow. The *if command is used to tell ANSYS that if this is not the first time through the macro, then clear the mesh and delete the volume. The parameter of the hole radius is then stored in cylrad from the value in the array holrad from column 1 and row set to the value of count. The block and cylinder are then created using the parameters, and the cylinder is subtracted from block making the hole.

5962 La Place Court Suite 100 Carlsbad, CA 90008 760.431.4815 FAX 760.431.4824 http://www.csi-ansys.com

Collaborative Solutions Inc


An ANSYS Support Distributor *do,count,1,3 fini /prep7 *if,count,gt,1,then vclear,all vdele,all,,,1 *endif cylrad=holrad(count,1)
BLOCK,0,blkw,0,blkh,0,blkt, CYL4,cylx,cyly,cylrad, , , ,blkt VSBV, 1, 2

After we solve the model, we create a label using the /anum, /tspec, and /tlab command. The label is used to display the cylinder radius used for that particular run. Notice how we can substitute a parameter into the label by enclosing the array parameter inside parentheses as shown.
/post1 /ANUM ,0, 1,-0.59026 ,-0.86359 /TSPEC, 15, 1.200, 1, 0, 0 /TLAB,-0.947,-0.864,Cylinder Radius =%holrad(count,1)%

The maximum principal stress is contoured to the screen, the graphics are then re-directed to a jpeg file stored in the working directory, the stresses are plotted to the file, the file is closed, and the graphics are re-directed to the terminal. Note: each jpeg file is named the jobnamexxx.jpeg where xxx is an integer starting with 000.
plnsol,s,1 /show,jpeg plnsol,s,1 /show,close /show,term

The stress results are sorted by principal stress, and the largest principal stress is stored in the parameter maxs1 using the *get command. That value is then stored in our array holrad in column 2 and row determined by the value of our counter count. The *endo marks the end of the *do loop.
NSORT,S,1 *GET,maxs1,SORT, ,MAX holrad(count,2)=maxs1 *enddo

Lastly, we open a file called holrad.txt using the *cfopen command. When then write to the file using the *vwrite. The first *vwrite is issued w/o any parameters, and just labels on the subsequent line. The labels are similar to fortran. The 4x says to put 4 spaces between the st label Radius and Stress. The second *vwrite writes out the 1 column of holrad which is the nd hole radius and the 2 column of holrad which is the stress. Finally we echo this summary file to the screen using the *uilist command.
*CFOPEN,holrad,txt,

5962 La Place Court Suite 100 Carlsbad, CA 90008 760.431.4815 FAX 760.431.4824 http://www.csi-ansys.com

Collaborative Solutions Inc


An ANSYS Support Distributor
*vwrite ('Radius',4x,'Stress') *VWRITE,holrad(1,1),holrad(1,2) (f6.3,4x,f8.3) *uilist,holrad.txt

3. Conclusions/Recommendations By include a couple of commands into an ANSYS batch file, one can easily automate an analysis to analyze multiple configurations and permutations. In the example illustrated above we vary just one geometric variable, the hole radius. There is little limit to the number of parameters that can be included. Additionally, the parameter(s) being varied can be geometric values, material properties, etc.

4. Appendix I Entire Input file


!THIS MODEL CREATES A BLOCK WITH A HOLE AND LOADS IT. THE RADIUS OF THE HOLE IS !CHANGED 3 TIMES. THE VALUES OF THE HOLE RADIUS IS STORED IN THE ARRAY HOLRAD !THE BLOCK IS LOADED WITH A TENSILE LOAD OF 1000 PSI. !THE BLOCK IS RUN WITH THE 3 HOLES SIZES USING A *DO LOOP !A LABEL IS CREATED FOR EACH PLOT THAT ECHOS BACK THE RADIUS OF THE HOLE. SEE THE !/TLAB COMMAND !A PLOT IS CREATED FOR EACH OF THE 3 CONFIGURATIONS SHOWING THE PART WITH THE !MAX PRINCIPLE STRESSES AND EACH PLOT IS STORED IN A JPEG FILE IN THE WORKING DIRECTORY !THE MAXIMUM PRINCIPLE STRESS VALUE IS THEN RETRIEVED FOR EACH CONFIGURATION AND !STORED IN COLUMN 2 OF THE ARRAY HOLRAD !A TEXT FILE OF THE ARRAY IS WRITTEN OUT WITH A SUMMARY OF HOLE SIZE VERSUS STRESS !THIS FILE IS ECHOED TO THE SCREEN. ! !THIS FILE IS PROVIDED AS IS AND IS FOR DEMONSTRATION PURPOSES ONLY. ! !DIMENSIONS OF THE BLOCK *SET,blkw,1 *SET,blkh,.5 *SET,blkt,.1 !LOCATION OF THE CYLINDER (HOLE) *SET,cylx,.5 *SET,cyly,.25 !RADII OF THE CYLINDER .05,.08,.15 *dim,holrad,array,3,2,1 holrad(1,1)=.05 holrad(2,1)=.08 holrad(3,1)=.15 !REVERSE VIDEO /RGB,INDEX,100,100,100, 0 /RGB,INDEX, 80, 80, 80,13 /RGB,INDEX, 60, 60, 60,14 /RGB,INDEX, 0, 0, 0,15 *do,count,1,3 fini /prep7 *if,count,gt,1,then vclear,all vdele,all,,,1 *endif cylrad=holrad(count,1) BLOCK,0,blkw,0,blkh,0,blkt, CYL4,cylx,cyly,cylrad, , , ,blkt VSBV, 1, 2

5962 La Place Court Suite 100 Carlsbad, CA 90008 760.431.4815 FAX 760.431.4824 http://www.csi-ansys.com

Collaborative Solutions Inc


An ANSYS Support Distributor
ET,1,SOLID45 MAT,1, /NOP TBDEL,ALL,_MATL MPDEL,ALL,_MATL MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,EX ,_MATL , 1, 10399368.0 , MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,NUXY,_MATL , 1, 0.330000000 , MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,ALPX,_MATL , 1, 1.372222222E-05, MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,DENS,_MATL , 1, 2.564201600E-04, MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,KXX ,_MATL , 1, 1.619948000E-03, MPTEMP,R5.0, 1, 1, 0.000000000E+00, MPDATA,R5.0, 1,C ,_MATL , 1, 88.7924520 , ESIZE,0.03,0, vsweep,all FINISH /SOLU FLST,2,1,5,ORDE,1 FITEM,2,5 /GO DA,P51X,ALL, FLST,2,1,5,ORDE,1 FITEM,2,6 /GO SFA,P51X,1,PRES,-1000 EQSLV,PCG,1E-6 solve fini /post1 /ANUM ,0, 1,-0.59026 ,-0.86359 /TSPEC, 15, 1.200, 1, 0, 0 /TLAB,-0.947,-0.864,Cylinder Radius =%holrad(count,1)% plnsol,s,1 /show,jpeg plnsol,s,1 /show,close /show,term NSORT,S,1 *GET,maxs1,SORT, ,MAX holrad(count,2)=maxs1 *enddo *CFOPEN,holrad,txt, *vwrite ('Radius',4x,'Stress') *VWRITE,holrad(1,1),holrad(1,2) (f6.3,4x,f8.3) *uilist,holrad.txt !

__________________________ Sean Harvey Collaborative Solutions, Inc. Engineering Consultant

5962 La Place Court Suite 100 Carlsbad, CA 90008 760.431.4815 FAX 760.431.4824 http://www.csi-ansys.com

Collaborative Solutions Inc


An ANSYS Support Distributor

ANSYS Tip of the Week


ANSYS Tip of the Week (TOTW) is provided for customers of Collaborative Solutions, Inc. (CSI) with active TECS agreements, distributed weekly in Adobe Acrobat PDF format via email. Unless otherwise stated, information contained herein should be applicable to ANSYS 5.4 and above, although usage of the latest version (5.6 as of this writing) is assumed. Users who wish to subscribe/unsubscribe or to view older TOTW archives can visit
http://www.csi-ansys.com/tip_of_the_week.htm

Corrections, comments, and suggestions are welcome and can be sent to [email protected] [they will be distributed to the appropriate person(s)]. While CSI engineers base their TOTW on technical support calls and user questions, ideas on future topics are appreciated. Users who wish to submit their own TOTW are encouraged to do so by emailing the above address for more information.

XANSYS Mailing List


The XANSYS mailing list is a forum for questions and discussions of the use of ANSYS. As of 04/00, there are more than 1000 subscribers with topics ranging from Structural, Thermal, Flotran, to Emag analyses, to name a few. Users are encouraged to subscribe to evaluate the usefulness of the mailing list for themselves. Also, either (a) using the mail program to filter [xansys] messages or (b) using the digest option to receive one combined email a day is strongly recommended to minimize sorting through the volume of postings.
This list is for *ALL* users of the ANSYS finite element analysis program from around the world. The list allows rapid communication among users concerning program bugs/ideas/modeling techniques. This list is NOT affiliated with ANSYS, Inc. even though several members of the ANSYS, Inc. staff are subscribers and regular contributors. To SUBSCRIBE: send blank email to [email protected] To unsubscribe send blank email to [email protected] Archived on http://www.infotech.tu-chemnitz.de/~messtech/ansys/ansys.html ANOTHER archive on http://www.eScribe.com/software/xansys/ (A poor archive is also at http://www.onelist.com/archives.cgi/xansys)

CSI ANSYS Technical Support, Training, & Mentoring


Collaborative Solutions, Inc. is committed to providing the best customer support in our industry. Three people will be devoted to technical support from 8:00 a.m. to 5:00 p.m. PST every working day. CSI customers with active TECS (maintenance) agreements may contact CSI by any of the following ways:
Phone: 760-431-4815 WWW: http://www.csi-ansys.com Fax: 760-431-4824 FTP: ftp://ftp.csi-ansys.com E-mail: [email protected] CSI Engineers: Karen Dhuyvetter Greg Miller Bill Bulat Sheldon Imaoka

Sean Harvey David Haberman

Alfred Saad Mike Rife

CSI believes strongly in the value of training and mentoring to help make customers successful using ANSYS. Training classes are usually 2-3 days in duration and provide instruction on various topics, including structural nonlinearities, heat transfer, and dynamics. Mentoring sessions involve working with a CSI engineer one-on-one on specific projects. These sessions help reinforce applicable subject matter covered in training classes or help ensure that the customer is using ANSYS most efficiently and effectively. Training class schedules are posted at: http://www.csi-ansys.com/training.htm Please contact your account manager for more details on training, mentoring, consulting, and other CSI services.

5962 La Place Court Suite 100 Carlsbad, CA 90008 760.431.4815 FAX 760.431.4824 http://www.csi-ansys.com

You might also like