ANSYS - APDL scripts

Here you find some of our Ansys input files, i.e. APDL scripts, which we use with Ansys Classic 11.0 and 14.0. We work on optimising parametrised models of liquid-filled resonators. So if you are interested in modeling one of the following things with Ansys, then some of the scripts here might be interesting for you.

  • assigning Fluid-Structure interaction (FSI) via APDL in a robust way
  • structure motion driven by piezoelectric transducer
  • change node numbers to an ordered sequence along lines
  • harmonic analysis of piezo-driven resonator
  • optimise an Ansys model with a function from scipy.optimize, e.g. Nelder-Mead algorithm
  • optimise an Ansys model with a custom evolutionary algorithm (EA)

Find below our collection of instructive APDL and Python scripts.


This is the most simple model describing just the piezoelectric transducer ring.

bottle_regmesh.inp and bottle_regmesh_commented.inp

simple geometry but it contains the whole set of features I am working with:

a) fluid-structure interaction (FSI) between plane82 and fluid29 (acoustic fluid) elements
b) plane223 used to model piezoelectric transducer made of PZT-8, which is a type of lead-zirconate-titanate polycrystalline ceramic
c) forced harmonic analysis, where voltage across transducer is driving the whole model
d) damping alternatives: how mp,damp relates to mp,dmpr; mp,lsst also used for the PZT ring (plane223)
d) lots of output files

There are two versions: a slim one and a thoroughly commented one, so the latter one is a good learning example for Ansys beginners.




For that same simple geometry a sample application of the internal optimizer of Ansys Classic


This is the model of our "chamber no.4", the one seen on the pictures in the talk (add link or better directly the picture). This model served as validation base because it allowed comparison to characterization measurements on the real chamber. It offers choices of mapped and free meshes (just play around with the parameter 'meshchoice') and comparisons between different implementations of the acoustic fluid: by setting the parameter 'flel' (short for fluid element) one can choose the different element types fluid29, fluid79, plane182, and plane183. Have a look at the material definition macro

mac_sf_materials_chno4.mac for this model to see how the different element types were implemented according to Sheldon Imaoka's tips and tricks on

All the above files in one zip archive:


Those presented files need to call a bunch of macros, which you can download as zip archive here:

all used macros