Hello ANsys experts,
Could someone help me with the below queries in MAPDL please?
How to output an integer by formatting as per the required digits
after the decimal. For example (12/19) = 0.6315789474 in APDL for which
I would like to have the output with 20 digits after the decimal.
How to write two to three conditions in an *if statement. For
example, the condition
(*if,a,gt,b-tol,and,a,lt,b+tol,or,b,gt,c-tol,and,b,lt,c+tol,then) gives
me an error where my requirement is if a=b or c=b then with tolerance
for b and c it should execute the following statements and so on.
Kindly let me know how to move forward.
Thanks & Regards,
Shravani Bojja
FUAS
Shravani,
Check out the *vwrite command, https://www.padtinc.com/2012/05/18/writing-text-files-with-vwrite/
20 digits after the decimal is meaningless as the computer does not store numbers to that precision. If ANSYS is storing results as a 32-bit number, the most you can get is 6-8 digits of precision and anything after than that is lost in rounding errors. Reference this Stack Overflow question for more details: https://stackoverflow.com/questions/13542944/how-many-significant-digits-do-floats-and-doubles-have-in-java
Break it into multiple *if statements using THEN. You may need to get creative by assigning intermediate Boolean operations to a variable. I don't write APDL much, but I program a lot in other languages so others on the list may have a better answer.
*if,a,gt,b-tol,THEN
*if,a,lt,b+tol,THEN
...
*endif
*endif
Aaron C. Caba, Ph.D.
Sr. Principal R&D Engineer
BAE Systems, Inc.
4050 Peppers Ferry Road, Radford VA 24143-0100
www.baesystems.com
Shravani,
Regarding *IF question, Aaron's approach is usually used and the most general since it can nest up to 20 levels.
However, *IF handles two conditions combined through AND, OR or XOR. For example :
*IF,a,gt,b-tol,AND,a,lt,b+tol,THEN
...
*ENDIF
David Galindo
Chief Executive
PHAREA - 213 rue de Gerland - 69007 Lyon - France
-----Message d'origine-----
De : Caba, Aaron (US) via Xansys xansys-temp@list.xansys.org
Envoyé : lundi 28 novembre 2022 15:14
À : XANSYS Mailing List Home xansys-temp@list.xansys.org
Cc : Caba, Aaron (US) Aaron.Caba@baesystems.com
Objet : [Xansys] Re: Formatting in APDL
Shravani,
Check out the *vwrite command, https://www.padtinc.com/2012/05/18/writing-text-files-with-vwrite/
20 digits after the decimal is meaningless as the computer does not store numbers to that precision. If ANSYS is storing results as a 32-bit number, the most you can get is 6-8 digits of precision and anything after than that is lost in rounding errors. Reference this Stack Overflow question for more details: https://stackoverflow.com/questions/13542944/how-many-significant-digits-do-floats-and-doubles-have-in-java
Break it into multiple *if statements using THEN. You may need to get creative by assigning intermediate Boolean operations to a variable. I don't write APDL much, but I program a lot in other languages so others on the list may have a better answer.
*if,a,gt,b-tol,THEN
*if,a,lt,b+tol,THEN
...
*endif
*endif
Aaron C. Caba, Ph.D.
Sr. Principal R&D Engineer
BAE Systems, Inc.
4050 Peppers Ferry Road, Radford VA 24143-0100 www.baesystems.comhttp://www.baesystems.com _______________________________________________
Xansys mailing list -- xansys-temp@list.xansys.orgmailto:xansys-temp@list.xansys.org To unsubscribe send an email to xansys-temp-leave@list.xansys.orgmailto:xansys-temp-leave@list.xansys.org If you are receiving too many emails from XANSYS please consider changing account settings to Digest mode which will send a single email per day.
Please send administrative requests such as deletion from XANSYS to xansys-mod@tynecomp.co.ukmailto:xansys-mod@tynecomp.co.uk and not to the list