A common yet powerful application of APDL scripting is to create parametric models that allow engineers to gain insight into the design.
To develop such models, one must be able to use selection logic while working with different entities and not simply rely on their numerical IDs.
In this video we’ll discuss
What is selection logic and why is it useful?
How to use selection logic using APDL commands?
How to create components and work with assemblies?
And we’ll do a workshop where we’ll setup, solve and post-process a cladded pipe model to demonstrate the power of select logic.
Let’s get started!
In MAPDL, all model information including geometry, mesh, material properties and other inputs are stored in a database.
It's designed such that one can access a sub-set of this data without altering other data.
While all entities such as nodes, elements, materials, geometric entities have unique IDs, referencing these entities through their ID numbers will not make the APDL script flexible.
For instance, if we develop a script where we refer to nodes or elements based on their IDs then the script is no longer usable if we decide to change the mesh density since the new node or element at a particular location may have a different ID number.
Due to these reasons, it's common to select entities based on their location, size, etc. rather than ID numbers.
Selection logic allows users to select a portion of the model based on more meaningful user-defined criteria without having to worry about the ID numbers.
Moreover, such criteria, such as spatial location, can also be based on parameters, too.
The selected portion, whether it is single or multiple entities, can then be further manipulated in the script.
This makes the script development more flexible and tolerant to any changes you may wish to include in the model, in addition to being completely parametric.
Selection logic is used during all stages of the modeling process, a few examples include
In defining loads and boundary conditions on specific regions
In defining local mesh controls
In extracting results from areas of interest during post-processing
In selecting and displaying a portion of the model to speed up graphics.
There are several APDL commands available for selecting different entities based on their locations, sizes, etc.,
These commands do not belong to a particular processor and may be used in any stage of the analysis.
There are two ways of selecting entities in MAPDL:
Direct selection of the entity using basic commands in the format xSEL where x stands for K, L, A, V, N or E.
Or selecting the entities by association using cross-over commands in the format xSLy where entity x is selected based on its association with entity y.
Again, both x and y stand for K, L, A, V, N or E.
For instance, one can select all elements associated with a volume using ESLV command.
Both basic and the cross-over commands require users to provide input for “type of selection” that allows working with sub-sets.
When we begin, the full set or all the entities in the database are part of the current active selection.
In a nutshell, selection logic is used to pick a sub-set and make it the current active selection.
One can add to or remove from this set using various selection options.
Starting with the option ‘s’, which is the default argument, this creates a selection set from the full set which then becomes the current active selection.
This option always starts with the full set in the database, so there is no need to select all of that entity before using the “s” option.
Next option is ‘r’ and this “re-selects” a sub-set from the current active selection.
‘A’ is another option where one can add additional entities to the current active selection.
Conversely, option ‘u’ is used to unselect certain entities from the current active selection.
Once can also invert the current active selection using ‘INVE’ option.
There are more options that are well documented in the Command Reference manual but let’s look at some examples where a combination of basic and cross-over commands using different selection options are used strategically.
Suppose we wish to apply a convection boundary condition to all external faces of components, via selection logic, rather than picking the faces or identifying the entities by their ID numbers.
Let’s say that this component is in a specific spatial location with z-coordinates between “z_base” and “z_top” and y-coordinates between “y_low” and “y_high”.
To do this we could use the following commands:
This will select volumes that are in a given y and z range.
It then selects areas that are external to the selected volumes, neglecting any areas internal to the parts.
If the component is complicated with many surfaces, these three commands provide a simple method to select all external areas, and, furthermore, the ranges are parametric!
Now let’s look at another example: suppose we wish to select the nodes on bottom face of a component to impose a fixed boundary condition.
We can use the following commands:
We first select volumes within a given y range, between "Y_location1" and "Y_location2".
We then select areas associated with the selected volumes.
A subset of these areas, those only at "Y_location1", are then selected.
Lastly, the nodes of the meshed area are then selected.
Since there may be additional areas located at "Y_location1", using this technique allows us to ensure that we are only selecting areas attached to the components of interest by using the combination of ASLV and ASEL,R commands.
As a small note, we did not supply the argument after the ASLV command – since selection from full set, or the “s” option is the default, this was used with ASLV.
These are just a couple of examples, but, as you can see, we usually use a series of selection logic commands to obtain what we want.
There may be more than one way to accomplish the same task with selection logic, but a common approach is to select “larger” entities, such as volumes, then select other entities attached to it.
A key point, however, is the flexibility selection logic provides, along with the ability to make the selection criteria based on parameters.
Before we move on to next discussion let’s go over a few important notes regarding the selected set of entities.
In several APDL commands, the argument “ALL” is used to indicate performing that action on all items in the active selection set, not the full-set.
For instance, if a set of nodes are selected, then issuing D,all,UX,0 will constraint the X displacement of only the currently selected nodes, not all nodes defined in the model.
Also, when an entity is selected, the lower or higher order entities associated with it are not added to current selection.
One must use the respective cross-over command to activate them.
For instance, as shown in the above example, if we selected a subset of areas, the associated nodes are not automatically selected.
Instead, we need to issue the NSLA,S,1 command to select the nodes based on the selected areas.
In the case of selection logic based on location, the program uses the centroid of the geometric entities to check if it falls within the specified location or range.
For instance, when we issue the command to select all volumes whose location is Y=0, then those volumes whose centroid lies on the XZ plane are selected.
Now let’s move on to creating and working with components.
Components are a group of similar entities that are assigned a user-specified name which may subsequently be used directly in APDL commands.
For instance, suppose we wish to impose a fixed constraint on all nodes in a location.
We can select those nodes using selection logic and create a nodal component called “Fixed_end”.
Without having to reselect these nodes, we can issue the command “D, Fixed_end, all, 0” later in our script to impose a displacement boundary condition to all of the nodes in the component “Fixed_end”.
This same nodal component can be used later during post-processing to extract the reaction force.
Components are very helpful in organizing the model entities and are commonly used in tandem with selection logic in APDL scripts.
One can create a component using the CM command, where Cname can be any user-specified name that is easily identifiable.
Once a component is created, it can also be selected to the active selection set using the CMSEL command.
Other commands such as CMPLOT and CMLIST are helpful in plotting or listing different entities grouped into a component.
With this information now let’s proceed to solving a workshop where we’ll employ both selection logic and creating and using components in setting up, solving and post-processing results from static analysis of a cladded pipe.
Cladded pipelines are used for transporting liquids in the oil and gas industry from one place to other.
These pipelines are often exposed to harsh weather conditions and the role of cladding is to reduce corrosion and to insulate the pipes from thermal loads.
In this example, we’ll analyze a structural steel pipe with polyethylene cladding on the outside.
The objective of the analysis is to plot the stresses developed in the cladding to check if it can withstand the loads that the pipe is exposed to.
The steel pipe has an inner radius of 0.875 m and an outer radius of 0.9 m with a 0.01 m thick polyethylene cladding on top of it.
Here are the material properties used for each material.
The pipe is exposed to a temperature of 0 degree C while its reference temperature at which there is no thermal strain is 23 degrees C.
The pipe is also subjected an internal pressure of 10 MPa.
It’s a long pipe with no loads acting along its axis so we can model this as a 2-D plane strain problem.
Also, the applied loads are symmetric, so we only need to model a quarter-symmetry of the geometry.
We’ll constraint X displacement on one end and the Y displacement on the other end.
Now, let’s develop an APDL script to create and solve this model.
First, we’ll issue FINISH and /CLEAR commands to start a session with clean database.
In step 1, we’ll define all the parameters such as all dimensions and material constants.
In practice, make sure that you provide appropriate comments to document your APDL script.
Similarly, define the thermal and pressure loads as parameters, too.
We can also define mesh sizing parameters here, "div1" and "div2" are number of divisions in the steel and cladding layers along the symmetry planes and "div3" is the number of divisions along the curved edges.
Now let’s get into step 2 which is to define the element type.
Enter /PREP7 and define the element type 183 with key-option 2 to use plane strain formulation.
Now proceed to step 3 which is geometry creation.
In this demo we’ll use the command PCIRC to create a quarter circular arc using dimensions of the steel pipe.
Since this is the only entity in the current active selection, go ahead and create an area component named “pipe”.
Use the same command with dimensions of cladding to create another arc.
Note that these two components are not connected to each other so we must perform Boolean operation to create a conformal mesh.
First select all components as the active selection and then issue AGLUE command.
This will merge the shared edges between the two areas.
So, select all components, unselect the pipe and create a component for cladding.
First select all components as the active selection and then issue AGLUE command.
This will merge both the areas into a new component which over-writes the previous area component which is cladding.
So, select all components, unselect the pipe and once again create a component for cladding.
Now we have two separate area components that have shared edge and this completes step 3.
In step 4, we’ll define materials.
Let’s use MP commands to define materials with IDs 1 & 2 representing steel and polyethylene respectively.
In step 5 we’ll assign these materials to different components and mesh them.
Starting with MSHKEY to use a mapped mesh.
Next, activate material 1, select the component “Pipe”, reselect the associated straight edges based on their lengths using LSEL command, and define mesh sizing on those edges using LESIZE command.
Next, select the inner curved edge of the pipe, add the outer edge of the steep pipe to this selection, and define mesh sizing on both the lines.
Now select the component “pipe” again and mesh it using AMESH command.
Now follow a similar approach to assign material 2, define mesh controls and mesh the component “cladding”.
Once all the parts are meshed, issue ALLSEL to revert the current selection to full set.
That completes step 5 so let's proceed to step 6 which is to create components for loads and boundary conditions.
First, select the nodes on straight edges along the X axis and create a nodal component called “x_fixed”.
Similarly, select the nodes on straight edges along the axis and created a nodal component called “y_fixed”.
Issue ALLSEL to revert to full set.
We need to define pressure load on the inner circular edge, select it based on its radius and create a component named “pressure_edge”.
We finished creating components for all loads and boundary conditions so let’s proceed to step 7.
In this step we enter the /SOLU processor, let’s define the analysis type to be “static” using ANTYPE command.
Note that by default, a static analysis is used so not issuing this command makes no difference.
It's just good practice, so one can identify the type of analysis easily.
Next define X and Y displacement constraints on the nodal components x_fixed and y_fixed respectively using D commands.
Next, use TREF command to define the reference temperature of the assembly and use BFE command to define thermal load on all the components.
Finally, use SFL command to define pressure load on component “pressure_edge”.
This finishes defining loads and boundary conditions.
Now we’re ready to solve, but before we issue the SOLVE command, it’s a good practice to issue ALLSEL,ALL in order to make sure that the full set is active before solving.
Otherwise, if we only have a subset of nodes or elements selected, the solution will only be based on that selected subset and not the entire model.
Thus, it’s good to keep in mind that even the SOLVE command is dependent on the active selection set of nodes and elements!
In the final step of post-processing, we wish to plot the equivalent stress contour on just the cladding.
So, enter /POST1 processor, load the last sub-step of the last load-step for processing with the SET command.
Use CMSEL command to make “cladding” the current selection, select the elements associated with this area using ESLA and then plot elemental solution sing PLESOL command.
This will plot the elemental equivalent stress contour on just the cladding.
This way, we can study the results in the component of interest.
This concludes the workshop, now we can change the dimensions of the pipe and cladding, or modify the loads and BCs, or even change the mesh density without breaking the references for any of the components.
This is because we have used selection logic at different stages of the modeling to strategically select entities.
This concludes the video, thank you for watching.