Dear Dave,
Thank you for sending me this code.
I tried to apply the second method under solution but the result that I got is a contour plot of variable elastic modulus which the maximum in the outer layer with the value which is obtained from the default value of the elastic modulus (that I had to defined in engineering data). However, I had added the command macro under the geometry to overwrite the default material data and the solution were done based on those new values of material data ( the elastic modulus as a function of radius(. So, I need to show those values of overrided elastic modulus on a contour plot-The values are changing from 0.02 to 0.25 MPa. How can I modify your code to make ansys to get the new material data not the default one? I would appreciate if you could help.
And, here is the code that solve the problem with the elastic modulus as a linear function of radius.
MPDELE, elastic,all
TBDELE,elastic,all
csys,1
esel, all
cm,remainingelem,elem
matid=1
*Do,ee,1,100000
*get,nextElem,ELEM,0,nxth
*get,elemxposition,ELEM,nextElem,cent,x
esel,r,cent,x,elemxposition
cm,elementXgroup,elem
*SET,x_pos,elemxposition
E_X=0.46*x_pos-2.74
Tb,elastic,matid,,2,Isot
Tbdata,1,E_X,0.49
MPCHG,matID,all
*get,count_control,elem,,count
cmsel,s,remainingelem
cmsel,u,elementXgroup
cm,remainingelem,elem
*get,Element_count,elem,,count
*if,element_count,eq,count_control,exit
matid=matid+1
*enddo
matid=matid+1
*get,nextElem,ELEM,0,nxth
*get,elemxposition,ELEM,nextElem,cent,x
esel,r,cent,x,elemxposition
cm,elementXgroup,elem
*SET,x_pos,elemxposition
E_X=0.46*x_pos-2.74
Tb,elastic,matid,,2,Isot
Tbdata,1,E_X,0.49
MPCHG,matID,all
esel,all