VM272 Input Listing


/COM,ANSYS MEDIA REL. 2024R2 (05/10/2024) REF. VERIF. MANUAL: REL. 2024R2
/VERIFY,VM272
/TITLE,VM272, TWO AND THREE DIMENSIONAL FRICTIONAL HERTZ CONTACT
/COM, REFERENCE: YANG, B., LAURSEN, T.A., MEGN, X. TWO DIMENSIONAL MORTAR CONTACT
/COM, METHODS FOR LARGE DEFORMATION FRICTIONAL SLIDING, IJNME VOL.62, PP 1183-1225.
/COM, (2005)
/COM, ANALYTICAL SOLUTION FROM REFERENCE:  JOHNSON KL, "CONTACT MECHANICS"
/COM, CAMBRIDGE UNIVERSITY PRESS: CAMBRIDGE, 1985.
/COM,
C***  USING 2D LOWER ORDER ELEMENTS
/PREP7
/NOPR
MP,EX,1,200.0			!YOUNG'S MODULUS (N/mm^2)
MP,NUXY,1,0.3			!POISSON'S RATIO
MP,MU,1,0.2				!COEFFICIENT OF FRICTION

ET,1,PLANE182			!2D STRUCTURAL SOLID
ET,2,PLANE182			!2D STRUCTURAL SOLID
KEYO,1,3,2				!PLANE STRAIN
KEYO,2,3,2				!PLANE STRAIN


PCIRC,8, ,0,90, 		!CONTACT SIDE
PCIRC,8, ,90,180,   	!CREATE SEMICIRCLES
RECT,0,1,7,8			!CREATE RECTANGLES
RECT,-1,0,7,8   				
WPOFF,0,16  			!TARGET SIDE
PCIRC,8, ,180,270,  	!CREATE SEMICIRCLES
PCIRC,8, ,270,360,  
WPAVE,0,0,0 
!*  
RECT,0,1,8,9			!CREATE RECTANGLES
RECT,-1,0,8,9   

AOVLAP,1,3				!COMBINES THE AREAS
AOVLAP,2,4
AOVLAP,6,7
AOVLAP,5,8

ASEL,S,,,1,2			!DELETES EXCESS GEOMETIES
ASEL,A,,,6,9,3
ALLSEL,BELOW,AREA   
ADEL,ALL
LSEL,U,,,2,6,4
LSEL,U,,,20,30,10
LDEL,ALL
KSEL,U,,,2,4,2
KSEL,U,,,10,16,3
KSEL,U,,,18,21,3
KSEL,U,,,29
KDEL,ALL

ALLSEL

AGLUE,3,10,11,12		!MERGES EXISTING AREAS

AGLUE,4,7,13,14

K,2,4					!CREATES POINTS AND AREAS
K,6,-4   				!TO DIVIDE THE GEOMETRY
K,7,4,16 				!AND MESH IT EXACTLY AS NEEDED
K,9,-4,16

A,3,2,8,12
A,7,20,24,23
A,20,9,28,24
A,11,6,3,12

APTN,2,7				!PARTITIONS OVERLAPPING AREAS 
APTN,9,13				!INTO SEPERATE ENTIITES
APTN,8,10
APTN,5,11

AGLUE,1,3,7,8,11,12

AGLUE,2,4,6,9,10,13  

LESI,27,,,8				!SETS NUMBER OF ELEMENTS
LESI,33,,,8				!ALONG EACH LINE
LESI,9,,,8
LESI,10,,,8
LESI,15,,,8

LESI,34,,,16
LESI,17,,,16
LESI,8,,,16
LESI,25,,,16
LESI,36,,,16

LESI,16,,,18
LESI,4,,,18
LESI,26,,,18
LESI,11,,,18
LESI,1,,,18
LESI,2,,,18

LESI,3,,,10
LESI,13,,,10
LESI,14,,,10
LESI,24,,,10
LESI,19,,,10

LESI,38,,,20
LESI,20,,,20
LESI,39,,,20
LESI,22,,,20
LESI,40,,,20

LESI,18,,,40
LESI,23,,,40
LESI,21,,,40
LESI,7,,,40
LESI,5,,,40
LESI,6,,,40

MSHAPE,0,2D 			!MESH TYPE IS SELECTED
MSHKEY,1

/OUT,SCRATCH
TYPE,1					!BOTTOM IS MESHED WITH TYPE 1
AMESH,1
AMESH,3
AMESH,12
AMESH,8
AMESH,7
AMESH,11

TYPE,2					!TOP IS MESHED WITH TYPE 2
AMESH,4
AMESH,6
AMESH,2
AMESH,9
AMESH,10
AMESH,13

ET,3,CONTA172			!2D 3-NODE SURFACE SURFACE CONTACT
KEYO,3,4,3				!DETECTION BY MORTAR
KEYO,3,10,0				!CONTACT STIFFNESS BY STRESS
KEYO,3,5,1              !CLOSE INITIAL GAP

ET,4,TARGE169			!TARGET ELEMENTS
LSEL,S,,,5,6,1			!CHOOSE LOCATION FOR CONTACT
NSLL,S,1
ESLN,S

TYPE,3					!MESH WITH CONTACT ELEMENTS
REAL,3
ESURF

TYPE,4					!CHOOSE LOCATION FOR TARGET
LSEL,S,,,1,2,1
NSLL,S,1
ESLN,S

ESURF					!MESH WITH TARGET ELEMENTS

ET,5,SURF153			!2D SURFACE EFFECT ELEMENTS

LSEL,S,,,3				!PICK THE TOP OF THE MODEL
LSEL,A,,,18,19
LSEL,A,,,21
NSLL,S,1
ESLN,S
TYPE,5
REAL,5
ESURF					!ADD SURFACE ELEMENTS

ET,10,CONTA172			!2D 3-NODE SURFACE SURFACE CONTACT ELEMENT
KEYOP,10,2,2			!CONTACT STIFFNESS BY STRESS
KEYOP,10,4,2			!DETECTION BY TARGET NORMAL
KEYOP,10,12,5			!ALWAYS BONDED
LSEL,S,,,3				!PICK THE TOP OF THE MODEL
LSEL,A,,,18,19
LSEL,A,,,21
NSLL,S,1
ESLN,S
TYPE,10
REAL,10
ESURF					!MESH WITH CONTACT ELEMENTS
N,100000,,16			!ADD A PILOT NODE
ET,11,TARGE169,,1		!TARGET ELEMENTS FOR PILOT
TYPE,11				
TSHAP,PILOT
E,100000				!MAKE THE PILOT ELEMENT
D,100000,ROTZ,0			!SET BOUNDARY CONDITIONS
ALLSE						

NSEL,S,LOC,Y
D,ALL,ALL
ALLSEL
/GOLIST
R,3
FINISH

/SOLUTION
ANTYPE,STATIC
OUTRES,ALL,ALL			!SOLUTION OPTIONS
NSUB,250,2500,15
ESEL,S,ENAME,,SURF153
SFE,ALL,1,PRES,1,0.625 	!SMALL AXIAL PRESSURE LOAD
ALLSEL
CNVTOL,U,,0.0001
CNVTOL,F,,0.0001
NROP,UNSYM
NLGEOM,ON				!LARGE DEFLECTION
SOLVE					!SOLVE FIRST LOADSTEP
NSUB,6,100,6
ESEL,S,ENAME,,153
SFE,ALL,2,PRES,1,-0.05851		!SMALL TANGENTIAL LOAD
ALLSEL
!RMOD,3,11,-1E-8		!ALLOW VERY LITTLE DAMPING
SOLVE
FINISH
/POST1
SET,LAST
PI=ACOS(-1)				!PARAMS FOR ANALYTIC SOLUTION
P=10					!CALCULATED BELOW
R=8
V=0.3
E=200
U=0.2
Q=0.93622
B=2*SQRT(P*R*((1-V**2)/(PI*E)))	    !MAXIMUM X-LOCATION OF CONTACT
SNMAX=SQRT((P*E)/(PI*(1-V**2)*R))	!MAXIMUM CONTACT PRESSURE
C=B*SQRT(1-(Q/(U*P)))			    !LOCATION OF STICK-SLIP BOUNDARY


ESEL,S,TYPE,,3			!PICK THE IMPORTANT CONTACT ELEMENTS
NSEL,S,LOC,X,0,B		!AND NODES
ESLN,R
NSLE
NSEL,U,LOC,X,-0.1,-0.001
ESLN,R,1
ETAB,PRES_I,SMISC,1		!TABULATE THE PRESSURE AND FRICTION RESULTS
ETAB,FRIC_I,SMISC,3		!AT LEFT NODE OF ALL ELEMENTS FOR USE BELOW
ETAB,CSTAT,NMISC,1


*GET,NUMNODE1,NODE,,COUNT			!GET THE NUMBER OF NODES IN SELECTION
X=NUMNODE1						    !STORE THIS NUMBER
*DIM,LOCARRAY1,ARRAY,NUMNODE1+1,2	!MAKE AN ARRAY FOR NODE NUMBER AND X LOC
*GET,NODENUM,NODE,,NUM,MIN			!GET FIRST NODE NUMBER

*DO,I,1,X				            !LOOP THROUGH SELECTION TO FILL ARRAY
   LOCARRAY1(I,1)=NX(NODENUM)		!X LOCATIONS
   LOCARRAY1(I,2)=NODENUM		    !NODE NUMBER
   *GET,NODENUM,NODE,NODENUM,NXTH	!GET THE NEXT NODE NUMBER
*ENDDO					!REPEAT

LOCARRAY1(NUMNODE1+1,1)=B			!ADD AN ENTRY FOR THEORETICAL MAX CONTA
LOCARRAY1(NUMNODE1+1,2)=0

*GET,NUMELEM1,ELEM,,COUNT		    !GET THE NUMBER OF ELEMENTS IN SELECTION
*DIM,RES1,ARRAY,NUMELEM1+1,6		!MAKE AN ARRAY FOR ALL RESULTS NEEDED
*GET,ELEMNUM,ELEM,,NUM,MIN	    	!GET FIRST ELEMENT NUMBER

*DO,K,1,NUMELEM1				    	!LOOP THROUGH ELEMENTS IN SELECTION
   *GET,RES1(K,1),ELEM,ELEMNUM,NODE,1	!FILL ARRAY WITH NODE NUMBER
   *GET,RES1(K,2),ETAB,1,ELEM,ELEMNUM	!FILL ARRAY WITH TABULATED RESULT: PRES
   *GET,RES1(K,3),ETAB,2,ELEM,ELEMNUM	!FILL ARRAY WITH TABULATED RESULT: FRIC
   *GET,RES1(K,4),ETAB,3,ELEM,ELEMNUM	!FILL ARRAY WITH TABULATED RESULT: STAT

   *GET,ELEMNUM,ELEM,ELEMNUM,NXTH	!GET THE NEXT ELEMENT NUMBER
*ENDDO					!REPEAT

RES1(NUMELEM1+1,1)=0			    !ADD AN ENTRY FOR THEORETICAL MAX CONTA
RES1(NUMELEM1+1,2)=0
RES1(NUMELEM1+1,3)=0
RES1(NUMELEM1+1,4)=0

J=1
*DOWHILE,J			            	!BUBBLE SORT OF NODES TO MATCH ELEMENT
   J=0					            !RESULTS WITH NODE NUMBERS AND
   *DO,I,1,X				        !ORDER THE ARRAY BY X LOCATION
      VAR1=LOCARRAY1(I,1)
      VAR2=LOCARRAY1(I+1,1)
      *IF,VAR1,GT,VAR2,THEN
         TEMP1=LOCARRAY1(I,1)
         LOCARRAY1(I,1)=LOCARRAY1(I+1,1)
         LOCARRAY1(I+1,1)=TEMP1
         TEMP2=LOCARRAY1(I,2)
         LOCARRAY1(I,2)=LOCARRAY1(I+1,2)
         LOCARRAY1(I+1,2)=TEMP2
         J=1
      *ENDIF	
   *ENDDO
*ENDDO

					                !CALCULATE ANALYTICAL SOLUTION FOR PRESSURE
*DO,I,1,NUMELEM1+1			        !AND FRICTION RELATIONSHIP WITH X LOCATION
	
   LOCX=LOCARRAY1(I,1)			    !LOOP THROUGH ALL NODES
   *IF,LOCX,LT,B,THEN			    !IF(1) NODE IS WITHIN CONTACT RANGE
      					            !EQUATION FOR PRESSURE
      RES1(I,5)=SNMAX*SQRT(1-(((LOCARRAY1(I,1))/B)**2))
      *IF,LOCX,LT,C,THEN		    !IF(2) NODE IS WITHIN STICK RANGE
      					            !EQUATION FOR FRICTION
         RES1(I,6)=(U*SNMAX/B)*(SQRT(B**2-LOCX**2)-SQRT(C**2-LOCX**2))
      
      *ELSE				            !ELSE(2) NODE IS WITHIN SLIDE RANGE
      					            !EQUATION FOR FRICTION
         RES1(I,6)=U*RES1(I,5)	
      
      *ENDIF
   *ELSE				            !ELSE(1) ASSIGN AS ZERO TO AVIOD DIVIDING
      RES1(I,5)=0		        	!BY ZERO
      RES1(I,6)=0
   *ENDIF
*ENDDO

PARSAV,ALL,vm272-1,parm

*DIM,LABEL1,,7				        !CONTACT PRESSURE LISTING
*DIM,VALUE1,,7,3
J=1
*DO,I,1,NUMELEM1,4
  LABEL1(J)=LOCARRAY1(I,1)
  VALUE1(J,1)=RES1(I,5)
  VALUE1(J,2)=RES1(I,2)
  ZERO1=RES1(I,5)
  ZERO2=RES1(I,2)
  *IF,ZERO1,EQ,0,AND,ZERO2,EQ,0,THEN
     VALUE1(J,3)=1
  *ELSEIF,ZERO1,EQ,0,AND,ZERO2,NE,0,THEN
     VALUE1(J,3)=0  
  *ELSE
     VALUE1(J,3)=ABS(RES1(I,2)/RES1(I,5))
  *ENDIF
  J=J+1
*ENDDO

*DIM,LABEL2,,7			            !CONTACT FRICTION LISTING
*DIM,VALUE2,,7,3
J=1
*DO,I,1,NUMELEM1,4
  LABEL2(J)=LOCARRAY1(I,1)
  VALUE2(J,1)=RES1(I,6)
  VALUE2(J,2)=RES1(I,3)
  ZERO1=RES1(I,6)
  ZERO2=RES1(I,3)
  *IF,ZERO1,EQ,0,AND,ZERO2,EQ,0,THEN
     VALUE2(J,3)=1  
  *ELSEIF,ZERO1,EQ,0,AND,ZERO2,NE,0,THEN
     VALUE2(J,3)=0
  *ELSE
     VALUE2(J,3)=ABS(RES1(I,3)/RES1(I,6))
  *ENDIF
  J=J+1
*ENDDO

/COM,
/OUT,vm272,vrt
/COM,----------------- VM272 RESULTS COMPARISON -------------------
/COM,
/COM,
/COM,2D LOW PRES   |  TARGET   |  Mechanical APDL  |   RATIO
/COM,
*VWRITE,LABEL1(1),VALUE1(1,1),VALUE1(1,2),VALUE1(1,3)
(6X,F5.3,6X,' ',F6.4,6X,'  ',F6.4,6X,'  ',F5.3)
/COM,
/COM,
/COM,----------------- VM272 RESULTS COMPARISON -------------------
/COM,
/COM,
/COM,2D LOW FRIC   |  TARGET   |  Mechanical APDL   |   RATIO
/COM,
*VWRITE,LABEL2(1),VALUE2(1,1),VALUE2(1,2),VALUE2(1,3)
(6X,F5.3,6X,' ',F6.4,6X,'  ',F6.4,6X,'  ',F5.3)
/COM,
/OUT,
rlist,all
etlist,all
FINI
/CLEAR,NOSTART

/OUT,
C***  USING 3D LOWER ORDER ELEMENTS
/PREP7
/NOPR
MP,EX,1,200.0				!YOUNG'S MODULUS (N/mm^2)
MP,NUXY,1,0.3				!POISSON'S RATIO
MP,MU,1,0.2				    !COEFFICIENT OF FRICTION

ET,1,SOLID185				!3D STRUCTURAL SOLID
ET,2,SOLID185				!3D STRUCTURAL SOLID


PCIRC,8, ,0,90, 			!CONTACT SIDE
PCIRC,8, ,90,180,   		!CREATE SEMICIRCLES
RECT,0,1,7,8				!CREATE RECTANGLES
RECT,-1,0,7,8   				
WPOFF,0,16  				!TARGET SIDE
PCIRC,8, ,180,270,  		!CREATE SEMICIRCLES
PCIRC,8, ,270,360,  
WPAVE,0,0,0 
!*  
RECT,0,1,8,9				!CREATE RECTANGLES
RECT,-1,0,8,9   

AOVLAP,1,3				    !COMBINES THE AREAS
AOVLAP,2,4
AOVLAP,6,7
AOVLAP,5,8

ASEL,S,,,1,2				!DELETES EXCESS GEOMETIES
ASEL,A,,,6,9,3
ALLSEL,BELOW,AREA   
ADEL,ALL
LSEL,U,,,2,6,4
LSEL,U,,,20,30,10
LDEL,ALL
KSEL,U,,,2,4,2
KSEL,U,,,10,16,3
KSEL,U,,,18,21,3
KSEL,U,,,29
KDEL,ALL

ALLSEL

AGLUE,3,10,11,12			!MERGES EXISTING AREAS

AGLUE,4,7,13,14

K,2,4					    !CREATES POINTS AND AREAS
K,6,-4   				    !TO DIVIDE THE GEOMETRY
K,7,4,16 				    !AND MESH IT EXACTLY AS NEEDED
K,9,-4,16

A,3,2,8,12
A,7,20,24,23
A,20,9,28,24
A,11,6,3,12

APTN,2,7				    !PARTITIONS OVERLAPPING AREAS 
APTN,9,13				    !INTO SEPERATE ENTIITES
APTN,8,10
APTN,5,11

AGLUE,1,3,7,8,11,12

AGLUE,2,4,6,9,10,13  

LESI,27,,,8				    !SETS NUMBER OF ELEMENTS
LESI,33,,,8				    !ALONG EACH LINE
LESI,9,,,8
LESI,10,,,8
LESI,15,,,8

LESI,34,,,16
LESI,17,,,16
LESI,8,,,16
LESI,25,,,16
LESI,36,,,16

LESI,16,,,18
LESI,4,,,18
LESI,26,,,18
LESI,11,,,18
LESI,1,,,18
LESI,2,,,18

LESI,3,,,10
LESI,13,,,10
LESI,14,,,10
LESI,24,,,10
LESI,19,,,10

LESI,38,,,20
LESI,20,,,20
LESI,39,,,20
LESI,22,,,20
LESI,40,,,20

LESI,18,,,40
LESI,23,,,40
LESI,21,,,40
LESI,7,,,40
LESI,5,,,40
LESI,6,,,40

K,30,0,0 ,0
K,31,0,0 ,1
K,32,0,16,0
K,33,0,16,1
L,30,31,1
L,32,33,1
VDRAG,1,3,12,8,7,11,12		!DRAGS THE BOTTOM INTO A VOLUME
VDRAG,4,6,2,9,10,13,28


MSHAPE,0,3D 				!MESH TYPE IS SELECTED
MSHKEY,1


/OUT,SCRATCH
TYPE,1					    !BOTTOM IS MESHED WITH TYPE 1
VMESH,1
VMESH,2
VMESH,3
VMESH,4
VMESH,5
VMESH,6

TYPE,2					    !TOP IS MESHED WITH TYPE 2
VMESH,7
VMESH,8
VMESH,9
VMESH,10
VMESH,11
VMESH,12

ET,3,CONTA174			    !3D 8-NODE SURFACE SURFACE CONTACT
KEYO,3,4,3				    !DETECTION BY MORTAR
KEYO,3,10,0				    !CONTACT STIFFNESS BY STRESS
KEYO,3,5,1                  !CLOSE INITIAL GAP
ET,4,TARGE170				!TARGET ELEMENTS
ASEL,S,,,35,41,6
NSLA,S,1
ESLN,S

TYPE,3					    !MESH WITH CONTACT ELEMENTS
REAL,3
ESURF

TYPE,4					    !CHOOSE LOCATION FOR TARGET
ASEL,S,,,14,18,4
NSLA,S,1
ESLN,S
ESURF					    !MESH WITH TARGET ELEMENTS

ET,5,SURF154				!3D SURFACE EFFECT ELEMENTS

ASEL,S,,,51,55,4			!PICK THE TOP OF THE MODEL
ASEL,A,,,45,48,3
NSLA,S,1
ESLN,S
TYPE,5
REAL,5
ESURF					    !ADD SURFACE ELEMENTS

ET,10,CONTA174				!3D 8-NODE SURFACE SURFACE CONTACT ELEMENT
KEYOP,10,2,2				!CONTACT STIFFNESS BY STRESS
KEYOP,10,4,2				!DETECTION BY TARGET NORMAL
KEYOP,10,12,5				!ALWAYS BONDED
ASEL,S,,,51,55,4			!PICK THE TOP OF THE MODEL
ASEL,A,,,45,48,3
NSLA,S,1
ESLN,S
TYPE,10
REAL,10
ESURF					    !MESH WITH CONTACT ELEMENTS
N,100000,,16				!ADD A PILOT NODE
ET,11,TARGE170,,1			!TARGET ELEMENTS FOR PILOT
TYPE,11					
TSHAP,PILOT
E,100000					!MAKE THE PILOT ELEMENT
D,100000,ROTZ,0				!SET BOUNDARY CONDITIONS
ALLSE						

NSEL,S,LOC,Y
D,ALL,ALL
ALLSEL
D,ALL,UZ
NSEL,S,LOC,Y,16
D,ALL,ROTX
D,ALL,ROTY

/GOLIST
R,3
RMOD,3,3,10                 !HIGH FKN TO MINIMIZE PENETRATION
RMOD,3,4,0.01               !SMALL FTOLN TO MINIMIZE PENETRATION
RMOD,3,23,1E-4 
FINISH

/SOLU
OUTRES,ALL,ALL				!SOLUTION OPTIONS
NSUB,200,500,10
ESEL,S,ENAME,,154
SFE,ALL,1,PRES,1,0.625 		!SMALL AXIAL PRESSURE LOAD
ALLSEL
CNVTOL,U,,0.0001
CNVTOL,F,,0.0001
NROP,UNSYM
NLGEOM,ON				    !LARGE DEFLECTION
SOLVE					    !SOLVE FIRST LOADSTEP
NSUB,4,10,1

NSEL,S,LOC,X,-4,-8
ESLN,S,1
ESEL,R,ENAME,,154
SFE,ALL,3,PRES,1,0.05851	!SMALL TANGENTIAL LOAD
NSEL,S,LOC,X,-4,8
ESLN,S,1
ESEL,R,ENAME,,154
SFE,ALL,3,PRES,1,-0.05851
ALLSEL
SOLVE
FINISH

/POST1
SET,LAST
/OUT
PI=ACOS(-1)				    !PARAMS FOR ANALYTIC SOLUTION
P=10					    !CALCULATED BELOW
R=8
V=0.3
E=200
U=0.2
Q=0.93622
B=2*SQRT(P*R*((1-V**2)/(PI*E)))		!MAXIMUM X-LOCATION OF CONTACT
SNMAX=SQRT((P*E)/(PI*(1-V**2)*R))	!MAXIMUM CONTACT PRESSURE
C=B*SQRT(1-(Q/(U*P)))			    !LOCATION OF STICK-SLIP BOUNDARY


ESEL,S,TYPE,,3				!PICK THE IMPORTANT CONTACT ELEMENTS
NSEL,S,LOC,X,0,B			!AND NODES
ESLN,R
ESEL,U,ELEM,,4000
NSLE,S
NSEL,R,LOC,Z,1
ETAB,PRES_I,SMISC,1			!TABULATE THE PRESSURE AND FRICTION RESULTS
ETAB,TAUR_I,SMISC,5			!AT LEFT NODE OF ALL ELEMENTS FOR USE BELOW
ETAB,TAUS_I,SMISC,9
ETAB,CSTAT,NMISC,1


*GET,NUMNODE2,NODE,,COUNT		    !GET THE NUMBER OF NODES IN SELECTION
X=NUMNODE2				            !STORE THIS NUMBER
*DIM,LOCARRAY2,ARRAY,NUMNODE2+1,2	!MAKE AN ARRAY FOR NODE NUMBER AND X LOC
*GET,NODENUM,NODE,,NUM,MIN		    !GET FIRST NODE NUMBER

*DO,I,1,X				            !LOOP THROUGH SELECTION TO FILL ARRAY
   LOCARRAY2(I,1)=NX(NODENUM)		!X LOCATIONS
   LOCARRAY2(I,2)=NODENUM		    !NODE NUMBER
   *GET,NODENUM,NODE,NODENUM,NXTH	!GET THE NEXT NODE NUMBER
*ENDDO					            !REPEAT

LOCARRAY2(NUMNODE2+1,1)=B			!ADD AN ENTRY FOR THEORETICAL MAX CONTA
LOCARRAY2(NUMNODE2+1,2)=0

*GET,NUMELEM2,ELEM,,COUNT		    !GET THE NUMBER OF ELEMENTS IN SELECTION
*DIM,RES2,ARRAY,NUMELEM2+1,6		!MAKE AN ARRAY FOR ALL RESULTS NEEDED
*GET,ELEMNUM,ELEM,,NUM,MIN		    !GET FIRST ELEMENT NUMBER

*DO,K,1,NUMELEM2				        !LOOP THROUGH ELEMENTS IN SELECTION
   *GET,RES2(K,1),ELEM,ELEMNUM,NODE,1	!FILL ARRAY WITH NODE NUMBER
   *GET,RES2(K,2),ETAB,1,ELEM,ELEMNUM	!FILL ARRAY WITH TABULATED RESULT: PRES
   *GET,TAUS,ETAB,2,ELEM,ELEMNUM	    !FILL ARRAY WITH TABULATED RESULT: FRIC
   *GET,TAUR,ETAB,3,ELEM,ELEMNUM
   RES2(K,3)=SQRT(TAUR**2+TAUS**2)
   *GET,RES2(K,4),ETAB,4,ELEM,ELEMNUM	!FILL ARRAY WITH TABULATED RESULT: STAT

   *GET,ELEMNUM,ELEM,ELEMNUM,NXTH	    !GET THE NEXT ELEMENT NUMBER
*ENDDO					!REPEAT

RES2(NUMELEM2+1,1)=0			        !ADD AN ENTRY FOR THEORETICAL MAX CONTA
RES2(NUMELEM2+1,2)=0
RES2(NUMELEM2+1,3)=0
RES2(NUMELEM2+1,4)=0

J=1
*DOWHILE,J				                !BUBBLE SORT OF NODES TO MATCH ELEMENT
   J=0					                !RESULTS WITH NODE NUMBERS AND
   *DO,I,1,X				            !ORDER THE ARRAY BY X LOCATION
      VAR1=LOCARRAY2(I,1)
      VAR2=LOCARRAY2(I+1,1)
      *IF,VAR1,GT,VAR2,THEN
         TEMP1=LOCARRAY2(I,1)
         LOCARRAY2(I,1)=LOCARRAY2(I+1,1)
         LOCARRAY2(I+1,1)=TEMP1
         TEMP2=LOCARRAY2(I,2)
         LOCARRAY2(I,2)=LOCARRAY2(I+1,2)
         LOCARRAY2(I+1,2)=TEMP2
         J=1
      *ENDIF	
   *ENDDO
*ENDDO

				                        !CALCULATE ANALYTICAL SOLUTION FOR PRESSURE
*DO,I,1,NUMELEM2+1			            !AND FRICTION RELATIONSHIP WITH X LOCATION
	
   LOCX=LOCARRAY2(I,1)			        !LOOP THROUGH ALL NODES
   *IF,LOCX,LT,B,THEN			        !IF(1) NODE IS WITHIN CONTACT RANGE
      					                !EQUATION FOR PRESSURE
      RES2(I,5)=SNMAX*SQRT(1-(((LOCARRAY2(I,1))/B)**2))
      *IF,LOCX,LT,C,THEN		        !IF(2) NODE IS WITHIN STICK RANGE
      					                !EQUATION FOR FRICTION
         RES2(I,6)=(U*SNMAX/B)*(SQRT(B**2-LOCX**2)-SQRT(C**2-LOCX**2))
      
      *ELSE				                !ELSE(2) NODE IS WITHIN SLIDE RANGE
      					                !EQUATION FOR FRICTION
         RES2(I,6)=U*RES2(I,5)	
      
      *ENDIF
   *ELSE				                !ELSE(1) ASSIGN AS ZERO TO AVIOD DIVIDING
      RES2(I,5)=0		            	!BY ZERO
      RES2(I,6)=0
   *ENDIF
*ENDDO

PARSAV,ALL,vm272-2,parm

*DIM,LABEL3,,7				            !CONTACT PRESSURE LISTING
*DIM,VALUE3,,7,3
J=1
*DO,I,1,NUMELEM2,4
  LABEL3(J)=LOCARRAY2(I,1)
  VALUE3(J,1)=RES2(I,5)
  VALUE3(J,2)=RES2(I,2)
  ZERO1=RES2(I,5)
  ZERO2=RES2(I,2)
  *IF,ZERO1,EQ,0,AND,ZERO2,EQ,0,THEN
     VALUE3(J,3)=1
  *ELSEIF,ZERO1,EQ,0,AND,ZERO2,NE,0,THEN
     VALUE3(J,3)=0  
  *ELSE
     VALUE3(J,3)=ABS(RES2(I,2)/RES2(I,5))
  *ENDIF
  J=J+1
*ENDDO

*DIM,LABEL4,,7			                !CONTACT FRICTION LISTING
*DIM,VALUE4,,7,3
J=1
*DO,I,1,NUMELEM2,4
  LABEL4(J)=LOCARRAY2(I,1)
  VALUE4(J,1)=RES2(I,6)
  VALUE4(J,2)=RES2(I,3)
  ZERO1=RES2(I,6)
  ZERO2=RES2(I,3)
  *IF,ZERO1,EQ,0,AND,ZERO2,EQ,0,THEN
     VALUE4(J,3)=1  
  *ELSEIF,ZERO1,EQ,0,AND,ZERO2,NE,0,THEN
     VALUE4(J,3)=0
  *ELSE
     VALUE4(J,3)=ABS(RES2(I,3)/RES2(I,6))
  *ENDIF
  J=J+1
*ENDDO

/COM,
/OUT,vm272,vrt,,APPEND
/COM,----------------- VM272 RESULTS COMPARISON -------------------
/COM,
/COM,
/COM,3D LOW PRES   |  TARGET   |   Mechanical APDL   |   RATIO
/COM,
*VWRITE,LABEL3(1),VALUE3(1,1),VALUE3(1,2),VALUE3(1,3)
(6X,F5.3,6X,' ',F6.4,6X,'  ',F6.4,6X,'  ',F5.3)
/COM,
/COM,
/COM,----------------- VM272 RESULTS COMPARISON -------------------
/COM,
/COM,
/COM,3D LOW FRIC   |  TARGET   |   Mechanical APDL   |   RATIO
/COM,
*VWRITE,LABEL4(1),VALUE4(1,1),VALUE4(1,2),VALUE4(1,3)
(6X,F5.3,6X,' ',F6.4,6X,'  ',F6.4,6X,'  ',F5.3)
/COM,
/OUT,
*LIST,vm272,vrt
etlist,all
rlist,all
FINI
/CLEAR,NOSTART

/OUT,SCRATCH
/SHOW,PNG


PARRES,      ,vm272-1,parm
PARRES,CHANGE,vm272-2,parm
*DIM,RES_TABLE1,TABLE,NUMELEM1+1,6   !CREATE A "TABLE" DATA FORMAT FOR CLEANER
RES_TABLE1(0,1)=0		             !PLOTTING THAN POSSIBLE WITH ARRAYS ALONE
RES_TABLE1(0,2)=0		             !ZERO COLUMN FILLED WITH ZEROS
RES_TABLE1(0,3)=0
RES_TABLE1(0,4)=0
RES_TABLE1(0,5)=0
RES_TABLE1(0,6)=0

					                 !HIGH MESH DENSITY/LOWER ORDER
*DO,I,1,NUMELEM1+1		             !LOOP THROUGH NODE ARRAY
   N_NODE=LOCARRAY1(I,2)	         !STORE THE NODE NUMBER
   *DO,J,1,NUMELEM1+1		         !LOOP THROUGH ELEMENT RESULT ARRAY

      TEMP=RES1(J,1)		         !STORE LEFT NODE OF EACH ELEMENT
      *IF,TEMP,EQ,N_NODE,THEN	     !IF THEY ARE THE SAME NODE
	 RES_TABLE1(I,3) =RES1(J,2)      !FILL TABLE WITH 2D LOWER ORDER PRESSURE
	 RES_TABLE1(I,4) =RES1(J,3)      !FILL TABLE WITH 2D LOWER ORDER FRICTION
	 RES_TABLE1(I,5) =RES2(J,2)      !FILL TABLE WITH 3D LOWER ORDER PRESSURE
	 RES_TABLE1(I,6) =RES2(J,3)      !FILL TABLE WITH 3D LOWER ORDER FRICTION	
      *ENDIF
   *ENDDO
*ENDDO
     				                !CALCULATE ANALYTICAL SOLUTION FOR PRESSURE
*DO,I,1,NUMELEM1+1		            !AND FRICTION RELATIONSHIP WITH X LOCATION
   RES_TABLE1(I,0)=LOCARRAY1(I,1)   !FILL THE ZERO COLUMN OF THE TABLE (X-AXIS)

   LOCX=LOCARRAY1(I,1)  	        !LOOP THROUGH ALL NODES
   *IF,LOCX,LT,B,THEN		        !IF(1) NODE IS WITHIN CONTACT RANGE
				                    !EQUATION FOR PRESSURE
      RES_TABLE1(I,1)=RES1(I,5)
      *IF,LOCX,LT,C,THEN	        !IF(2) NODE IS WITHIN STICK RANGE
				                    !EQUATION FOR FRICTION
     	 RES_TABLE1(I,2)=RES1(I,6)

      *ELSE			                !ELSE(2) NODE IS WITHIN SLIDE RANGE
				                    !EQUATION FOR FRICTION
     	 RES_TABLE1(I,2)=RES1(I,6)    

      *ENDIF
   *ELSE			                !ELSE(1) ASSIGN AS ZERO TO AVIOD DIVIDING
      RES_TABLE1(I,1)=0  	        !BY ZERO
      RES_TABLE1(I,2)=0
   *ENDIF
*ENDDO

/OUT,
/TITLE,FRICTIONAL HERTZIAN CONTACT LOWER ORDER
/GCOLUMN,1,ANA_PRE		  !ASSIGNS ANALYTICAL PRESSURE
/GMARKER,1,0
/GCOLUMN,2,ANA_FRI		  !ASSIGNS ANALYTICAL FRICTION
/GMARKER,2,0
/GCOLUMN,3,PRES 1 		  !ASSIGNS 2D LOWER ORDER PRESSURE
/GMARKER,3,1
/GCOLUMN,4,FRIC 1 		  !ASSIGNS 2D LOWER ORDER FRICTION
/GMARKER,4,1
/GCOLUMN,5,PRES 3 		  !ASSIGNS 3D LOWER ORDER PRESSURE
/GMARKER,5,3
/GCOLUMN,6,FRIC 3 		  !ASSIGNS 3D LOWER ORDER PRESSURE
/GMARKER,6,3  
/XRANGE,0,0.7
/AXLAB,X,X DISTANCE FROM CENTER   !X-AXIS LABEL
/AXLAB,Y,CONTACT RESULTS	  !Y-AXIS LABEL
/YRANGE,0,10
*VPLO,RES_TABLE1(1,0),RES_TABLE1(1,1),2,3,4,5,6
FINISH