0
$\begingroup$

I am trying to match FEA results with an experiment, wherein I need to match mode shapes and frequencies. I am testing different models, and I would like to parameterize several material properties.

It is easy to extract frequencies as a parameter, however since the mode shapes change with the material parameters, this is not terribly helpful. I thought that it would be a simple workaround to create an image of each deformation result, labeled with the parameter settings using an ADPL Command as output, however I have now spent two days on this and I am not much further.

My ideal solution would be to extract the images, with the parameter values (eg: "P=.5, Q=.1, Ez = 110MPa") as text within the image.

The farthest that I have gotten is to make an image object under the command in the model tree using the following:

SET,LAST
/SHOW,PNG
PLDISP,0

However I cannot find this image file and I do not think that it is actually saved.

If there is another (more straightforward) way of obtaining these mode shapes, I am all ears!

Thank you.

$\endgroup$
2
  • $\begingroup$ Why not just retain the information from all your design points? Do you lack disk space? $\endgroup$
    – Orbit
    May 10, 2022 at 11:12
  • $\begingroup$ @Orbit No, retaining the information is not a problem. It is cycling through it for each of the mode shapes. Now that the mode shapes are saved as images, I am able to do so very quickly, and I can use OpenCV in Python to merge images for relatively easy error-checking. $\endgroup$
    – user109527
    May 16, 2022 at 10:21

2 Answers 2

1
$\begingroup$

After spending a great deal of time testing, and trying out different things, this is the code that ended up working:

!Commands inserted into this file will be executed immediately after the ANSYS /POST1 command.

!   Active UNIT system in Workbench when this object was created:  Metric (m, kg, N, s, V, A)
!   NOTE:  Any data that requires units (such as mass) is assumed to be in the consistent solver unit system.
!                See Solving Units in the help system for more information.


set,list,0   !This lists the attributes for the active set
*Get,nmds,ACTIVE,,SET,NSET   !This gets the number of modes

/DEV,PSFN,NINC   !This disables the incremental naming of image files (I think)

!All of these are string creations
*DIM,P,STRING,80
*DIM,Q,STRING,80
*DIM,Ez,STRING,80
*DIM,mode,STRING,80

! This convers the floats to shorter strings
P_ = CHRVAL(ARG1)
Q_ = CHRVAL(ARG2)
R_ = CHRVAL(ARG3)

!This creates a two-subplot plot for viewing modes from different angles
/WINDOW, 1, LEFT
/WINDOW, 2, RIGH

!This sets up a loop to save the images
*DO,i_,7,nmds,1

!This selects the mode number from the set
set,1,i_,
/Dscale,ALL,0.1  !This sets the scale of the distortion

!This retrieves the frequency of the mode
*get,frq_,ACTIVE,0,SET,FREQ

!This produces the title on each image
/title, P=%P_%, Q=%Q_%, R = %R_%, Mode %i_%, %frq_%Hz


!j_ = i_-6

!This sets the viewpoint for each window (subplot)
/VIEW,1,.25,.25,1
/VIEW,2,1,.25,.25

!This instructs the plotter to create a .jpeg (PNGs did not work! This was one of the main problems that I was getting!)
/show,jpeg
PLDISP,0 !This requests a displacement plot
/show,close  !This closes the plot, so that the next one starts out fresh

!This was the most important bit. Renaming the image file so that each image is not overwritten!
/RENAME,file,jpg,,C:\mode_images\P%P_%_Q%Q_%_R%R_%_mode%j_%,jpg


*ENDDO
$\endgroup$
0
$\begingroup$

You can try constructing your title like this:

*DIM,P,STRING,80
*DIM,Q,STRING,80
*DIM,Ez,STRING,80
P = CHRVAL(0.5)
Q = CHRVAL(0.1)
Ez = CHRVAL(110)

/title, P=%P%, Q=%Q%, Ez = %Ez%MPa

Padtinc did nice blogposts on APDL. Here is one on strings.

Than you can try saving plots with APDL to your user_files:

/post1
set,last
finish
/inquire,aa,directory
ii = strpos(aa(1),'dp')
ij = strpos(aa(ii+1),'')-1
dpn = strsub(aa(1),ii+1,ij)
dpn = strcat(dpn,'_')
/file,dpn
/post1
/view,1,1,1,1
/vup,1,z
/show,png
PLDISP,0
/show,close
/sys,copy *.png ......user_files
finish
/file,file

This was also taken from padinc's blog.

$\endgroup$
1
  • $\begingroup$ I am not certain why this did not work, but it did not. I think that it failed on two points: First, /show,png fails to produce a file to be copied. Second, the /sys command failed to copy files when a copy was made. $\endgroup$
    – user109527
    Apr 8, 2022 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.