Do loop in ansys apdl

Do loop in ansys apdl


  • Marcos in Ansys Mechanical
  • Arrays and Tables in APDL – A QuickReference
  • Using a Snippet to Extract Ansys Workbench Results to a Text File with vmask and vget
  • Justin Verdirame 1 Comment Commonly, we need to save results from an Ansys Workbench study as a text file for post-processing in another program, such as Excel.

    One can right-click on a desired result and use Export, but that can be tedious if there a lot of results to save. Below we use a simple example of an L-shaped bracket. In this static structural example, there are three time steps as we change the forces on the bracket. One could also use this in a thermal, modal, or transient structural with a few changes needed.

    We begin by creating a Named Selection to define the regions of the model where we are interested in results. Here we have chosen to use a single face as the named selection. One could use a set of faces or edges, vertices, or volumes. Then, we must make sure to set the output to save an mapdl db file to yes.

    I typically do not use a file header but one could insert that if desired. Then, calculate the total number of results sets in the study. We use a DO-loop to cycle through all results. Then, we select the nodal named selection. 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. It helped me a lot. I am running a transient analysis,and I would like to extract some nodal information over the time, as you have extracted. The problem in my case is, some nodal information are written and some are not written. So, if I would like to extract nodal information of 10 nodes, 10 files are created therefore and half of them write the nodal information and other half not.

    The files which are not writing the nodal information are created correctly with right dimensions, but write only zeros. The code is as follows:!

    Get Started Marcos in Ansys Mechanical Ansys pours a lot of resources into creating the very powerful software products that have become an integral part of our engineering world today. However, with the wide spectrum of users, companies, and industries utilizing these products are used, it is impossible to provide a tool that does everything which all users might want it to.

    Inevitably, individual users have their own preferred methods of working. Companies often have their own standardized procedures too. The APDL code these macros are written in is straightforward and well documented.

    Ansys But right now, macros which might run in the Mechanical application are not documented at all. The good news is that while there is no formal documentation for creating macros to run within the Mechanical interface, there is a methodology that allows a motivated user to write macro code. This article is not intended to be even an introductory training to writing macros for Mechanical, but to merely show some of the basic concepts, illustrate what is possible, and hopefully plant ideas about how macros could make your analysis life even easier.

    The interested reader is encouraged to contact SimuTech for further information on personalized instruction or contract work in this area. When the user clicks Solve, the Mechanical application creates a text based APDL input file which is then submitted in batch mode to the solver. One is called select BySize. Note: this same type of selecting can now be accomplished in JavaScript itself is an interpreted programming language originally built for use on Web pages.

    Basic JScript information and resources are plentiful and a good place to start is W3Schools. Many of these functions are defined the. While this will work, a better option is the proper debugger in Microsoft Visual Studio. A consulting project required setting up several hundred Remote Points at the center of annular faces representing washers. Now creating a RP is not difficult but creating several hundred of them is a job for a macro not a human… It would be nice if we could simply create a Named Selection of the faces very easy using the NS criteria and have the macro loop over each face in the NS and insert a RP for it.

    The first step is to determine what happens when we click the button to insert a RP. Now we need to be able to loop over the faces in a Named Selection and call this function for each one individually… From here we need to fire up the debugger and get into the GUI code. To do this we simply create a dummy Jscript macro file with one line of code, debugger;. Assuming things are working properly, we will then be able to get into the code and go looking around. With a single face selected we can call the doInsertRemotePoint function, then more on to the next face.

    Determine how many faces in Named Selection 2. Loop over all faces in Named Selection a. Find partId and topoId information for each face and store this information in an array 3.

    Loop over the array from step 2 a. Clear out the Selection Manager : Clear b. Select an face : AddToSelection c. Because this article is running a bit long already we will wrap it up by noting that while every last nitty-gritty detail of our proposed macro has not yet been figured out, the approach described forms the foundation for writing macros. Through more investigation using the debugger and some trial and error, we can come up with the final version of this macro which is listed at the end of this article.

    Next Level As mentioned before, DesignModeler uses Jscript also, so the same type of approach is valid in that application too. Also, there is no official Ansys support for these endeavors, so writing macros should be approached by those who are comfortable with object oriented programming, using a debugger, and figuring stuff out on their own.

    As mentioned before, this article was not intended to be an all encompassing introductory training document, but rather to make the user aware of what is possible and illustrate the general approach. Appendix Final script listing Below is the final code from the example mentioned in this article. It worked great for my situation and I have endeavored to make it somewhat general and include some basic error checking. However, there are no guarantees that it will work in all situations!

    While this will work, a better option is the proper debugger in Microsoft Visual Studio. A consulting project required setting up several hundred Remote Points at the center of annular faces representing washers.

    Now creating a RP is not difficult but creating several hundred of them is a job for a macro not a human… It would be nice if we could simply create a Named Selection of the faces very easy using the NS criteria and have the macro loop over each face in the NS and insert a RP for it. The first step is to determine what happens when we click the button to insert a RP.

    Now we need to be able to loop over the faces in a Named Selection and call this function for each one individually… From here we need to fire up the debugger and get into the GUI code. To do this we simply create a dummy Jscript macro file with one line of code, debugger. Assuming things are working properly, we will then be able to get into the code and go looking around.

    Marcos in Ansys Mechanical

    With a single face selected we can call the doInsertRemotePoint function, then more on to the next face. Determine how many faces in Named Selection 2. Loop over all faces in Named Selection a. Find partId and topoId information for each face and store this information in an array 3. Loop over the array from step 2 a. Then, we must make sure to set the output to save an mapdl db file to yes. I typically do not use a file header but one could insert that if desired.

    Then, calculate the total number of results sets in the study. We use a DO-loop to cycle through all results. Then, we select the nodal named selection. 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. The users usually go to this processor only when they require the name changing or changes to the file properties.

    Arrays and Tables in APDL – A QuickReference

    This command is a way to interrogate your model with all sorts of the useful information such as the largest Y value for node position, number of nodes, loads on a particular node and the information on results. Named selection is the group of entities such as the edges, vertices, and elements that are grouped so that the user can scope on them rather than selecting each function individually.

    All the nodes that are in contact with the Named selection are converted into components. The user can also create their own nodes and elements.

    Using a Snippet to Extract Ansys Workbench Results to a Text File with vmask and vget

    The users must give it a unique name and operate it away. The jobname is the name of your solver job. In some cases, the users may want to write out specific information on the output file. This list is certainly not a definitive list of important commands for APDL. The key to using APDL is to know the fact that commands are your friend for this software, and you should learn how to implement these commands for your own benefit. The following are some of the reasons why many professionals still prefer APDL over other solver systems.

    More command and control at each step The current solving methods and the modern GUI allows the user to select from preset options and have limited selections.


    thoughts on “Do loop in ansys apdl

    1. I can suggest to visit to you a site, with an information large quantity on a theme interesting you.

    Leave a Reply

    Your email address will not be published. Required fields are marked *