-
-
February 18, 2022 at 1:49 pm
Shekhar
SubscriberDear Community,
I have been practicing a thermal modelling routine in APDL.
The modelling includes a repetition of a certain set of commands and scalar parameters in a cycle. I got it through the *DO and *IF commands. However, the code is getting extremely lengthy and time taking (for compilation) to set *IF command for every *DO parameter value (Like *DO is running from 1 to 100). But, in actuality the scalar parameters on change for the even and odd values of the *DO parameter.
The code I want goes like this (but it is not working)
!-----------------------------------------------------------------------------
*DO,ii,1,100,1
*IF,ii,EQ,'EVEN',THEN
X = 1
*ELSEIF,ii,EQ,'ODD',THEN
X = 2
*ELSE
*ENDIF
!--------------------------------------------------------------------------
If anybody knows how to set this working, please help
February 21, 2022 at 9:44 pmdanielshaw
Ansys EmployeeThere are probably multiple approaches that will work. One approach might be to use the MOD(x,y) function. to find the remainder. Something like:
x1 = mod(ii,2) ! place immediately after *DO command
If ii is an even number; then x1 would be equal to zero
If ii is an odd number, then x1 would be equal to 1
You can then use x1 in the *IF statements
Viewing 1 reply thread- The topic ‘About the selection of odd and even numbers through *IF and *DO loop’ is closed to new replies.
Innovation SpaceTrending discussionsTop Contributors-
6570
-
1906
-
1463
-
1311
-
1022
Top Rated Tags© 2026 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-
Ansys Assistant will be unavailable on the Learning Forum starting January 30. An upgraded version is coming soon. We apologize for any inconvenience and appreciate your patience. Stay tuned for updates.