## Defining Antenna Array Excitations with Nested-If Statements in HFSS

HFSS offers various methods to define array excitations. For a large array, you may take advantage of an option “Load from File” to load the magnitude and phase of each port. However, in many situations you may have specific cases of array excitation. For example, changing amplitude tapering or the phase variations that happens due to frequency change. In this blog we will look at using the “Edit Sources” method to change the magnitude and phase of each excitation. There are cases that might not be easily automated using a parametric sweep. If the array is relatively small and there are not many individual cases to examine you may set up the cases using “array parameters” and “nested-if”.

In the following example, I used nested-if statements to parameterize the excitations of the pre-built example “planar_flare_dipole_array”, which can be found by choosing File->Open Examples->HFSS->Antennas (Fig. 1) so you can follow along. The file was then saved as “planar_flare_dipole_array_if”. Then one project was copied to create two examples (Phase Variations, Amplitude Variations).

Fig. 1. Planar_flare_dipole_array with 5 antenna elements (HFSS pre-built example).

# Phase Variation for Selected Frequencies

In this example, I assumed there were three different frequencies that each had a set of coefficients for the phase shift. Therefore, three array parameters were created. Each array parameter has 5 elements, because the array has 5 excitations:

A1: [0, 0, 0, 0, 0]

A2: [0, 1, 2, 3, 4]

A3: [0, 2, 4, 6, 8]

Then 5 coefficients were created using a nested_if statement. “Freq” is one of built-in HFSS variables that refers to frequency. The simulation was setup for a discrete sweep of 3 frequencies (1.8, 1.9 and 2.0 GHz) (Fig. 2). The coefficients were defined as (Fig. 3):

E1: if(Freq==1.8GHz,A1[0],if(Freq==1.9GHz,A2[0],if(Freq==2.0GHz,A3[0],0)))

E2: if(Freq==1.8GHz,A1[1],if(Freq==1.9GHz,A2[1],if(Freq==2.0GHz,A3[1],0)))

E3: if(Freq==1.8GHz,A1[2],if(Freq==1.9GHz,A2[2],if(Freq==2.0GHz,A3[2],0)))

E4: if(Freq==1.8GHz,A1[3],if(Freq==1.9GHz,A2[3],if(Freq==2.0GHz,A3[3],0)))

E5: if(Freq==1.8GHz,A1[4],if(Freq==1.9GHz,A2[4],if(Freq==2.0GHz,A3[4],0)))

Please note that the last case is the default, so if frequency is none of the three frequencies that were given in the nested-if, the default phase coefficient is chosen (“0” in this case).

Fig. 2. Analysis Setup.

Fig. 3. Parameters definition for phase varaitioin case.

By selecting the menu item HFSS ->Fields->Edit Sources, I defined E1-E5 as coefficients for the phase shift. Note that phase_shift is a variable defined to control the phase, and E1-E5 are meant to be coefficients (Fig. 4):

Fig. 4. Edit sources using the defined variables.

The radiation pattern can now be plotted at each frequency for the phase shifts that were defined (A1 for 1.8 GHz, A2 for 1.9 GHz and A3 for 2.0 GHz) (Figs 5-6):

Fig. 5. Settings for radiation pattern plots.

Fig. 6. Radiation patten for phi=90 degrees and different frequencies, the variation of phase shifts shows how the main beam has shifted for each frequency.

# Amplitude Variation for Selected Cases

In the second example I created three cases that were controlled using the variable “CN”. CN is simply the case number with no units.

The variable definition was similar to the first case. I defined 3 array parameters and 5 coefficients. This time the coefficients were used for the Magnitude. The variable in the nested-if was CN. That means 3 cases and a default case were created. The default coefficient here was chosen as “1” (Figs. 7-8).

A1: [1, 1.5, 2, 1.5, 1]

A2: [1, 1, 1, 1, 1]

A3: [2, 1, 0, 1, 2]

E1: if(CN==1,A1[0],if(CN==2,A2[0],if(CN==3,A3[0],1)))*1W

E2: if(CN==1,A1[1],if(CN==2,A2[1],if(CN==3,A3[1],1)))*1W

E3: if(CN==1,A1[2],if(CN==2,A2[2],if(CN==3,A3[2],1)))*1W

E4: if(CN==1,A1[3],if(CN==2,A2[3],if(CN==3,A3[3],1)))*1W

E5: if(CN==1,A1[4],if(CN==2,A2[4],if(CN==3,A3[4],1)))*1W

Fig. 7. Parameters definition for amplitude varaitioin case.

Fig. 8. Exciation setting for amplitude variation case.

Notice that CN in the parametric definition has the value of “1”. To create the solution for all three cases I used a parametric sweep definition by selecting the menu item Optimetrics->Add->Parametric. In the Add/Edit Sweep I chose the variable “CN”, Start: 1, Stop:3, Step:1. Also, in the Options tab I chose to “Save Fields and Mesh” and “Copy geometrically equivalent meshes”, and “Solve with copied meshes only”. This selection helps not to redo the adaptive meshing as the geometry is not changed (Fig. 9). In plotting the patterns I could now choose the parameter CN and the results of plotting for CN=1, 2, and 3 is shown in Fig. 10. You can see how the tapering of amplitude has affected the side lobe level.

Fig. 9. Parameters definition for amplitude varaitioin case.

Fig. 10. Radiation patten for phi=90 degrees and different cases of amplitude tapering, the variation of amplitude tapering has caused chagne in the beamwidth and side lobe levels.

# Drawback

The drawback of this method is that array parameters are not post-processing variables. This means changing them will create the need to re-run the simulations. Therefore, it is needed that all the possible cases to be defined before running the simulation.

## Automating Subsea Design (or How I Learned to Love Parameters)

In a previous life, I worked in the maritime and offshore energy industries and used ANSYS as part of my daily routine in structural design. I eventually discovered myself in a position where I was designing subsea equipment for use in offshore oil and gas fields. One thing I quickly discovered was that although subsea structures tend to be fairly simplistic looking (think playground equipment…but 10000 feet underwater) there are multiple design factors that can easily cause a domino effect that would require redesign(s). Whether it was a change brought upon by the client, tool manufacturer, or to satisfy the whims of marine warranty companies, there was always a need to evaluate multiple variants of any subsea structure.

Sounds like a very reactive process, right? So how can we bring this process into a more streamlined analysis workflow within ANSYS? Just use parameters with SpaceClaim and ANSYS Mechanical!

So what can parameters do to aid in this process?

• Account for geometric changes to CAD models
• Use a range of values for material properties
• Create associative connections between CAD models and ANSYS results
• Allow for automatic goal driven design exploration

Now let’s look at some common use cases for parameters that I’ve run into in the past:

## Accelerations for Onboard Equipment and Cargo

Cargo transported on the ocean is subject to the same accelerations that affect the vessel transporting it (surge, sway, heave, pitch, roll, and yaw). These accelerations are then combined into three representative accelerations and applied in multiple loadcases.

Typically, these loadcases are resolved in independent analysis systems but we can remove all that fluff with a simple parameter driven analysis. All one has to do is tag inputs and result items as parameters and then input values for each load case (or Design Point). In this case I have selected the XYZ components of an acceleration input applied to a mass point as well as the total deformation and maximum equivalent stress. With the push of a button ANSYS will then solve all of these design points and will amend the table to show the selected results corresponding with each design point. Results from the Design Points can be uploaded individually but this parametric analysis has made it very easy for us to determine which Design Points / load cases have the greatest influence on the design.

## Geometry Influence Study

So one of the questions often asked during the design process is “Will the design work after we change this dimension to compensate for X?” which is often followed by a discussion on robustness (which is then followed by a change order). So let’s skip the discussion middle-man and move to be proactive by using parameters to quantify just how much we can change our geometry before a problem arises.

Here we have an example subsea Pipeline End Termination (PLET) structure and let’s say a client has asked us to verify if this design can work for various pipeline sizes. The PLET has some major parts that can be influenced by this change: The pipeline clamp, cradle, flanges, ball valve, and bulkhead.

Because we can use parameters there’s no need to make a new model. Merely tag items you wish to create parameters for in SpaceClaim:

Then ANSYS Workbench will start to populate its parameter tables accordingly:

We can then make certain parameters dependent on others, or define them via simple expressions. In this way we can enforce clearances and relations between the various bodies in our model.

From here all we have to do is define our variables for our future analyses:

Then tell ANSYS to solve all the design points with a single click. Note that users can create charts and tables before the solve and ANSYS will populate these live during the solution process. Individual design point results and geometries can also be reviewed at any time.

For this particular analysis we provided the same load to each Design Point but a good next step would be to set a goal driven analysis and have a range of loadings on the pipeline end of the PLET to represent various installation conditions.

Parameters are a very powerful tool within the ANSYS toolbox. They can remove repetitive tasks within FEA, easily create loadcases, and address concerns about design robustness by letting ANSYS and SpaceClaim handle CAD model rework.

That’s it for this blog post! I’ll be creating a few offshore industry-specific posts in the future as well so stay tuned!

## Meshing Updates in ANSYS 2019 R2 – Webinar

An intelligent, high-quality mesh is at the core of any effective simulation based model; creating the basis for what will help to drive valuable results for even the most complex engineering problems.

Among a variety of tools in ANSYS 2019 R2 are enhanced meshing capabilities that can help reduce pre-processing time and provide a more streamlined solution.

Join PADT’s Specialist Mechanical Engineer, Joe Woodward for a look at what new meshing capabilities are available in the latest release of ANSYS. This presentation will focus predominately on updates regarding:

 ANSYS Mechanical MeshingBatch ConnectionsAxisymmetric SweepLayered Tetrahedron EnhancementsLocal Sizing Enhancements SpaceClaim MeshingParameter ManagementDirect Modeling/MeshingHex MeshingBlock Decomposition

And much more!

Register Here

If this is your first time registering for one of our Bright Talk webinars, simply click the link and fill out the attached form. We promise that the information you provide will only be shared with those promoting the event (PADT).

You will only have to do this once! For all future webinars, you can simply click the link, add the reminder to your calendar and you’re good to go!

## Video Tips – Two-way connection between Solidworks and ANSYS HFSS

This video will show you how you can set up a two-way connection between Solidworks and ANSYS HFSS so you can modify dimensions as you are iterating through designs from within HFSS itself. This prevents the need for creating several different CAD model iterations within Solidworks and allows a more seamless workflow.  Note that this process also works for the other ANSYS Electromagnetic tools such as ANSYS Maxwell.

## Can I parameterize ANSYS Mechanical material assignments?

So we have known for a long time that we can parameterize material properties in the Engineering Data screen. That works great if we want to adjust the modulus of a material to account for material irregularities. But what if you want to change the entire material of a part from steel to aluminum? Or if you have 5 different types of aluminum to choose, on several different parts, and you want to run a Design Study to see what combination of materials is the best? Well, then you do this. The process includes some extra bodies, some Named Selections, and a single command snippet.
The first thing to do is to add a small body to your model for each different material that you want to swap in and out, and assign your needed material to them. You’ll have to add the materials to your Engineering Data prior to this. For my example I added three cubes and just put Frictionless supports on three sides of each cube. This assures that they are constrained but not going to cause any stresses from thermal loads if you forget and import a thermal profile for “All Bodies”.

Next, you make a Named Selection for each cube, named Holder1, Holder2, etc. This allows us to later grab the correct material based on the number of the Holder.

You also make a Named selection for each group of bodies for which you want to swap the materials. Name these selections as MatSwap1, MatSwap2, etc.

The command snippet goes in the Environment Branch. (ex. Static Structural, Steady-State Thermal, etc.)

```!###############################################################################################################################
! MATSWAP.MAC
! Created by Joe Woodward at PADT,Inc.
! Created on 2/12/2016
!
! Usage: Create Named Selections, Holder1, Holder2, etc.,for BODIES using the materials that you want to use.
! Create Named Selections called MatSwap1, MatSwap2, etc. for the groups of BODIES for which you want to swap materials.
! Set ARG1 equal to the Holder number that has the material to give to MatSwap1.
! Set ARG2 equal to the Holder number that has the material to give to MatSwap2.
! And so on....
! A value of 0 will not swap materials for that given group.
!
! Use as is. No Modification to this command snippet is necessary.
!###############################################################################################################################
/prep7
*CREATE,MATSWAP,MAC
*if,arg1,NE,0,then
*get,isthere,COMP,holder%arg1%,TYPE
*get,swapgood,COMP,matswap%ARG2%,TYPE
*if,isthere,eq,2,then
esel,s,,,holder%arg1%
*get,newmat,elem,ELNEXT(0),ATTR,MAT
!swap material for Body 1
*if,swapgood,eq,2,then
esel,s,,,matswap%ARG2%
emodif,all,mat,newmat
*else
/COM,The Named Selection - MatSwap%ARG2% is not set to one or more bodies
*endif
*else
/COM,The Named Selection Holder%ARG1% is not set to one or more bodies
*endif
*endif
*END
MATSWAP,ARG1,1 !Use material from Holder1 for Swap1
MATSWAP,ARG2,2 !Use material from Holder1 for Swap2
MATSWAP,ARG3,3 !Use material from Holder1 for Swap3
MATSWAP,ARG4,4 !Use material from Holder1 for Swap4
MATSWAP,ARG5,5 !Use material from Holder1 for Swap5
MATSWAP,ARG6,6 !Use material from Holder1 for Swap6
MATSWAP,ARG7,7 !Use material from Holder1 for Swap7
MATSWAP,ARG8,8 !Use material from Holder1 for Swap8
MATSWAP,ARG9,9 !Use material from Holder1 for Swap9

alls
/solu```

Now, each of the Arguments in the Command Snippet Details corresponds to the ‘MatSwap’ Name Selection of the same number. ARG1 controls the material assignment for all the bodies in the MatSwap1 name selection. The value of the argument is the number of the ‘Holder’ body with the material that you want to use. A value of zero leaves the material assignment alone and does not change the original material assignment for the bodies of that particular ‘MatSwap’ Named Selection. There is no limit on the number of ‘Holder’ bodies and materials that you can use, but there is a limit of nine ‘MatSwap’ groups that you can modify, because there are only nine ARG variables that you can parameterize in the Command Snippet details.

You can see how the deflection changes for the different material combinations. These three steps, holder bodies, Named Selections, and the command snippet above, will give you design study options that were not available before. Hopefully I’ll have an even simpler way in the future. Stay tuned.

## Video Tips: DesignXplorer – Single Objective Parameterization

This video gives an example of using DesignXplorer to automate the optimization of a tuning fork to achieve a particular desired frequency

## Making APDL Parameters Available in the ANSYS Parameter Manager or DesignXplorer: Prep, Solve, and Post

This is one of those questions that comes up every once in a while that is not so obvious at first glance, but that is simple once you understand how ANSYS Mechanical interacts with ANSYS Mechanical APDL.  After a couple of email exchanges around a tech support question, we thought it would be good to share with everyone.

Before we get started, if you need a refresher on Command Objects in ANSYS Mechanical, the way in which you send APDL commands to the ANSYS Mechanical APDL solver, here is a seminar from a couple of years ago that covers the whole deal:

The basic problem is this: you have an APDL script you execute as a command object that does some sort of model interrogation or stores the result of some calculation, and you want to use that parameter in the parameter manager or in DesignXplorer.  If you look at the details view for a command object you will notice that it only supports input parameters: ARG1-ARG9.

If you look at the example (silly) macro you will see that it:

1. Grabs component (named selection) END1
2. Figures out how many nodes are attached to END1 (NMND)
5. Applies that per node load
6. Reselects all the nodes

If I want to know how many nodes I put the load on and what the per node load is I’m kind of stuck here.  Any command object you add to the tree above the Solution branch only allows input parameters.

But a command snippet applied in the Solution branch is different, it allows you to pull parameters back and share them through the parameter manager.

When you first insert a command object you only get input parameters (ARG1-ARG9) as usual, and an empty section called “Results”

The way you get result parameters, or what I think should be called “Output Parameters” is you create a parameter in the command object’s APDL script that starts with “my_”  When you click outside the text input window the program parses you script and if it finds any “my_” parameters in the text, it sticks them in the Results section:

Note, the default is “my_” but you can change it n the “Output Search Prefix” line in the Definition block.

Initially they will show up pinkish because the model has not been run and they are not defined. Click on the box to make them parameters that get passed outside of the program and then run:

If you pop back out to the project view you will see that we now have a Parameter Set bar with both input and output parameters:

And if you open the parameter manager up you can see the input and output parameters:

This works because all ANSYS mechanical is doing is making one big batch input file for ANSYS MAPDL.  That file contains any command objects you insert into the tree and extracts any parameters that you tagged in a post processing command object for return to ANSYS Mechanical.