handout # 1
Transcription
handout # 1
ANSYS TUTORIAL 1. 1 Introduction With ANSYS finite element analysis software engineers are able to build computer models or transfer CAD models of structures, products, components, or systems; apply operating loads or other design performance conditions; study physical responses, such as stress levels, temperature distributions, or electromagnetic fields; optimize a design early in the development process to reduce production costs; and do prototype testing environments where it otherwise would be undesirable or impossible (for example, biomedical applications). 2. Launching of ANSYS Like any other program, to start ANSYS go to the windows Start menu and on Programs look for ANSYS. Select the ANSYS Classic or Interactive (depending on the version, for newer versions Classic appears) to launch it. Figure 2-1. ANSYS Launching 2 The following dialog box appears: Figure 2-2. Interactive Set up Dialog box A brief description of each option in the interactive set up dialog box follows. Product: Displays the list of ANSYS products available at your site. The default is ANSYS/Mechanical. The list of products displayed is the products your site has licenses for. Language: Specifies a translated language file. To use a translated file, create a subdirectory with the appropriate language name and place the translated file in that directory. ANSYS provides only English files. If you specify a language that does not have the associated translated files, the launcher defaults to US English. 3 Jobname: Defines the base filename used for all files generated by the ANSYS run. The initial jobname defaults to file. Any alphanumeric string up to 32 characters long can be used as a jobname. Working directory: Sets the directory in which the ANSYS run will be executed. The program writes files it generates to this directory. Initially, the working directory defaults to the directory in which the launcher was activated. To change the working directory, type the new directory name in the Working Directory text box or press the Browse button to display a file selection dialog box. Enable ANSYS Parallel Performance: Enables the Parallel Performance for ANSYS advanced task (add-on). When Parallel Performance for ANSYS is licensed, two multiprocessor solver options can be specified from the EQSLV command: AMG and DOMAIN. AMG initiates the Algebraic Multigrid solver (AMG) and DOMAIN initiates the Distributed Domain Solver (DDS). The Parallel Performance option is only available if a license for Parallel Performance for ANSYS is available. Use ANSYS Drop Test Module: Enables the Drop Test Module (DTM) advanced task (add-on). The DTM is an optional add-on feature to the ANSYS/LS-DYNA product which simplifies the procedure for simulating a drop test. Read start.ans at start-up: Suppresses reading of the start.ans file. start.ans is a file in which you can include commands to be executed when the program starts up. Memory requested (megabytes) for Total Workspace: Specifies the amount of memory requested for the ANSYS run. It defaults to 512 megabytes for Windows systems and 1024 megabytes for UNIX systems, which is sufficient for most modestsized models. Choosing a higher number allows more space for solution of largewavefront models, and choosing a lower number allows more concurrent ANSYS runs. To use the default memory setting, click the Use Default Memory button. If default memory settings are chosen, the - m or - db options cannot be set. Memory requested (megabytes) for Database: Specifies the portion (in megabytes) of total memory that the database will use. It defaults to 128 megabytes for Windows systems and 256 megabytes on UNIX systems, which is sufficient for most modest-sized models. Send output to: Directs the output of the ANSYS program to the screen only or to the screen and to an output file. For systems that support two-way redirection of output, the default is to send output to both the screen and the output file (Jobname.OUT). Custom ANSYS EXE: The launcher provides an option to start a customized ANSYS executable. Additional Parameters: This option sets parameter values at ANSYS start-up. Click Run to save the settings and launch ANSYS in interactive mode. Clicking Save saves the settings but does not launch an ANSYS session. Clicking Reset restores the settings from the last Run or Save. Once ANSYS is running, it is important to recognize the enviroment. 4 3. ANSYS environment Let’s start with the basics. Besides some suitable knowledge of FEA, the first step in working with ANSYS is recognizing its environment. ANSYS starts with the following screen. Figure 3-1. ANSYS Graphical User Interface This is called the ANSYS GUI (Graphical User Interface) and provides the interface between the program and its user. At the top there is the Utility menu, which contains functions such as file controls, selecting, graphics controls, and parameters. Under the Utility menu there is the Standard Toolbar and the Input Window. The Standard Toolbar contains a set of icon buttons that execute commonly used functions, shortcuts from some of the functions available in the Utility menu. Like New, Save, Open, etc. The Input Window is where the user provides input to the program by entering commands directly. 5 The menu that appears to the left is called the Main Menu, this is where modeling begins. The functions in this menu are “modal” with respect to each other, meaning that the use of one of its function must be completed before starting with another. Figure 3-2. ANSYS Main Menu Next to the Main menu is the Graphics Window, which is where graphical drawings are displayed and where graphical picking done. Figure 3-3. Graphics Window Behind the GUI is the Output Window. It receives all text output from the program such as command responses, notes, warnings, errors, and any other messages. 6 Figure 3-4. Output Window 7 4. Processors The ANSYS program is organized into two basic levels: Begin level and processor (or Routine) level. The begin level acts as a gateway into and out of the ANSYS program. It is also used for certain global program controls such as changing the jobname, clearing (zeroing out) the database, and copying binary files. When you first enter the program, you are at the Begin level. At the processor level, several processors are available. Each processor is a set of functions that perform a specific analysis task. For example, the general preprocessor (PREP7) is where the model is build, the solution processor (SOLUTION) is where loads are applied and the solution is obtained, and the general postprocessor (POST1) is where the results of a solution are evaluated. An additional postprocessor, POST26, enables evaluation of solution results at specific points in the model as a function of time. The following table lists each processor, its function, and the command to enter it. Besides the GUI path, a command name can be used to access each processor. It’s the name of the processor following /. For example, if accessing the preprocessor is desired enter /PREP7 in the Input Window. Table 4-1 Processors (Routines) Available in ANSYS Processor Function GUI Path Build the model PREP7 Main Menu>Preprocessor (geometry, materials, etc.) Apply loads and obtain the SOLUTION Main Menu>Solution finite element solution Review results over the POST1 entire model at specific Main Menu>General Postproc time points Review results at specific POST26 points in the model as a Main Menu>TimeHist Postpro function of time OPT Improve an initial design Main Menu>Design Opt Quanitfy the effect of scatter and uncertainties associated with input PDS Main Menu>Prob Design variables of a finite element analysis on the results of the analysis Utility Menu>File> List>Binary Dump binary files in AUX2 FilesUtility Menu>List>Files> readable form Binary Files Calculate radiation view factors and generate a AUX12 Main Menu>Radiation Matrix radiation matrix for a thermal analysis Command /PREP7 /SOLU /POST1 /POST26 /OPT /PDS /AUX2 /AUX12 8 Processor Function GUI Path Translate files from a CAD AUX15 Utility Menu>File>Import or FEA program Predict CPU time, RUNSTAT wavefront requirements, Main Menu>Run-Time Stats etc. for an analysis Command /AUX15 /RUNST During an analysis, it is sometimes desirable to modify or delete commands entered since your last SAVE or RESUME. Access the session editor by issuing the UNDO command, or by choosing Main Menu > Preprocessor > Session Editor. The session editor display is shown below. Figure 4-1. Session Editor This editor can be use to modify command parameters, delete whole sections of text, and even save a portion of the command string to a separate file. The following file operations can accessed from the session editor dialog: OK: Enters the series of operations displayed in the window below. You will use this option to input the command string after you have modified it. Save: Saves the command string displayed in the window below to a separate file. ANSYS names the file Jobnam000.cmds, with each subsequent save operation incrementing the filename by one digit. You can use the /INPUT command to re-enter the saved file. Cancel: Dismisses this window and returns to your analysis. Help: Displays the command reference for the UNDO command. The Session Editor is available in interactive (GUI) mode only. 9 Once the user is ready to analyze a problem, some preferences can be set in the Main menu. Figure 4-2. Preferences for GUI filtering This dialog box allows changing the controls for context filtering of menu choices. By default, filtering does not occur. Menu choices for all analysis disciplines (structural, thermal, electromagnetic, ANSYS Fluid, and FLOTRAN CFD) will appear, with nonapplicable choices grayed out based on the set of element types in the model. In order to not see those grayed choices, choose, from within the "Preferences for GUI Filtering" dialog box, the appropriate discipline that will be performing. Not all menu options may be visible during the analysis. If the desired option is not available, check the preferences and element types in the model. For example, choosing Thermal suppresses structural, magnetic, and fluid element types in the "Element Types" dialog box, displacements, and potentials, etc. in the "Apply Loads" and "Delete Loads" menus, and so on. Another item for controlling the menu filtering is the methodology used for structural analysis hmethod, p-method, or LS-DYNA Explicit. By default, ANSYS uses h-method. These will be discussed later. System of Units The ANSYS program does not assume a system of units for the analysis. Except in magnetic field analyses, where the user can use any system of units so long as he or she makes sure that the same system is used for all the data entered. That is, units must be consistent. Using the /UNITS command, the user can set a marker in the ANSYS database indicating the system of units that is being used. This command does not convert data from one system of units to another; it simply serves as a record for subsequent reviews of the analysis. 10 4.1. File Types The following table lists the main ANSYS file types and their formats. Table 3.1 ANSYS File types and Formats File Type File Name File Format Log file Jobname.LOG ASCII Error file Jobname.ERR ASCII Output file Jobname.OUT ASCII Database file Jobname.DB Binary Results file: Jobname.xxx structural or coupled Jobname.RST Thermal Jobname.RTH Binary Magnetic Jobname.RMG FLOTRAN Jobname.RFL Load step file Graphics file Element matrices 4.2. Jobname.Sn ASCII Jobname.GRPH ASCII (special format) Jobname.EMAT Binary Utility Menu: File Contains file and database related functions, such as clearing the database, saving it to a file, and resuming it from a file. Some of the functions under the File menu are valid at Begin level only. Clear Database and Start New: Allows commands to be executed when the program starts up. Clears (zeros out) the database stored in memory. Clearing the database has the same effect as leaving and reentering the ANSYS program, but does not requires to exit. Change Jobname: Changes the default jobname using /FILNAME or the following dialog box. Change Working Directory: Changes the working directory where ANSYS is running. Change Title: Defines a title for the analysis. ANSYS includes the title on all graphics displays and the solution output. Resume Jobname.db: Reads the file jobname.db. Resume the database from anywhere in the ANSYS program. Resume from: Allows to restore a *.db or *.dbb with a filename other than jobname.db. 11 Save as Jobname.db: The ANSYS program stores all input data (model dimensions, material properties, load data, etc.) and results data (displacements, stresses, temperature, etc.) in one large database. Save as: Any save operation first writes a backup of the current database file (if the database already exists) to jobname.dbb. If a jobname.dbb file already exists, the new backup file overwrites it. To specify a different file name use the following dialog box. Write db log file: Establishes a command log file from the database log. Read Input from: Read in the edited command log file. Switch Output to: Switch between output window or output file for the output of the ANSYS program. List: Displays the log file, error file, other, or binary file. File Operations: Rename, delete, and/or copy a file. ANSYS File Options: Reassigns a file name to an ANSYS file identifier. Assigns an external or internal type to a binary file. Deletes a binary file after it is used. Import: As an alternative to creating a model directly in ANSYS, create a solid model in another CAD system, save that model as an IGES file, and then import that model into ANSYS. Export: Write model data in IGES format. Report Generator: Allows the capture of graphical and numerical data at any time throughout the analysis process and then assemble an HTML-based report using the captured data. Exit: Leave the ANSYS program. By default, the program saves the model and loads portions of the database automatically and writes them to the database file, jobname.db. If a backup of the current database file already exists, ANSYS writes it to jobname.dbb. 4.3. Utility menu: Select Includes functions that allow the selection of subsets of entities and to create components. In a large model, it is helpful to work with just a portion of the model data. Because all ANSYS data are in a database subsets of the data can be conventionally chosen by using selecting. Selecting enables the selection of subsets of nodes, elements, keypoints, lines, etc. so that working with just a handful of entities is possible. The ANSYS program uses a database to store all the data that defined during an analysis. This database design allows selection of only a portion of the data without destroying other data. Sometimes it is convenient to group portions of the model and give them recognizable names. The groupings may be components or assemblies. A component consists of one type of entity: nodes, elements, keypoints, lines, areas, or volumes. Use the CM command (Utility Menu> Select> Comp/Assembly> Create Component) to define a component. An assembly may consist of any number of components and other 12 assemblies. Use the CMGRP command (Utility Menu> Select> Comp/Assembly> Create Assembly) to define an assembly. 13 4.4. Utility menu: List Enables the user to list virtually any data item stored in the ANSYS database. The user can also obtain status information about different areas of the program and list the contents of files residing on the system. 4.5. Utility menu: Plot Lets the user plot keypoints, lines, areas, volumes, nodes, elements, and other data that can be graphically displayed. 4.6. Utility menu: PlotCtrls Includes functions which control the view, style, and other characteristics of graphics displays. The Hard Copy function lets you obtain hard copies of the entire screen or just the Graphics Window. One of the most basic and useful features is the Pan Zoom Rotate which manipulates the view by panning, zooming, and rotating the model. Numbering is also helpful, it displays the number of a geometry or feature according to the order in which they were created. 4.7. Utility menu: WorkPlane Enables the user to toggle the working plane on or off and to move, rotate, and otherwise maneuver the working plane. The user can also create, delete, and switch coordinate systems by using this menu. 14 4.8. Utility menu: Parameters Includes functions to define, edit, and delete scalar and array parameters. The user can either assign values to parameters or retrieve values supplied by ANSYS and store these values in parameters. For retrieving values from ANSYS, either the *GET command or the various inline get functions can be used. The *SET command defines parameters. The format of the shortcut is Name = Value, where Name is the name assigned to the parameter and Value is the numeric or character value stored in that parameter. For character parameters, the assigned value must be enclosed in single quotes and cannot exceed eight alphanumeric characters. 4.9. Utility menu: Macro Allows the user to execute macros and data blocks. Also to create, edit, and delete abbreviations, which appear as push buttons on the Toolbar. Macros will be discussed later in more detail. 4.10. Utility menu: MenuCtrls Lets the user switch from fully functional ANSYS to the Mechanical Toolbar. It also lets create, edit, and delete abbreviations on the Toolbar. The Save Menu Layout function saves the current GUI configuration (including menu, window and overall GUI size). 4.11. Utility menu: Help Brings up the ANSYS Help System. The online help system gives the user information on virtually any component in the Graphical User Interface (GUI) and any ANSYS command or concept. On a PC, the online help is in standard Microsoft HTML Help format. It includes the usual features such as a cascading table of contents, index, and full text search capability. 15 5. Modeling Considerations As the model generation begins, the user will make a number of decisions that determine how the physical system will be mathematically simulated. Such as the objectives of the analysis, the variation of modification of the data, changes in the geometric topology, system completeness or just a portion to model, the amount of detail, the kind of elements to be used, the density of the finite element mesh. In general, the user will attempt to balance computational expense (CPU time, etc.) against precision of results as these questions are answer. The decisions made in the planning stage of the analysis will largely govern the success or failure of the analysis efforts. Take into consideration if the elements to use are liner or of a higher order. Higher order elements will increase the level of difficulty of the model and the solution of the analysis, so the best choice is the lowest possible order. Also, symmetry can simplify the analysis, but the user must keep in mind that the axis of symmetry must coincide with the global Cartesian y-axis. In symmetry negative nodal x coordinates are not permitted. The global Cartesian y-direction represents the axial direction, the global Cartesian x-direction represents the radial direction, and the global Cartesian z-direction corresponds to the circumferential direction. Selecting an appropriate element type is very important. Check the purpose of the design, its geometry, application, etc. The element type chosen should take these factors into account. Whether it is solid, plane, 3D, 2D, if it is a beam, what kind of loads will be applied, degrees of freedom, boundary constraints are all example of factors that depend upon the selection of the element type. Figure 4. 1 Some Element Types 5.1. Element Type The ANSYS element library contains more than 150 different element types. Each element type has a unique number and a prefix that identifies the element category: BEAM4, PLANE77, SOLID96, etc. The following element categories are available: BEAM CIRCUit COMBINation MESH PIPE PLANE 16 CONTACt FLUID HF (High Frequency) HYPERelastic INFINite INTERface LINK MASS MATRIX PRETS (Pretension) SHELL SOLID SOURCe SURFace TARGEt TRANSducer USER VISCOelastic (or viscoplastic) The element type determines, among other things the degree-of-freedom set (which in turn implies the discipline - structural, thermal, magnetic, electric, quadrilateral, brick, etc.) and whether the element lies in two-dimensional or three-dimensional space. Defining element types takes place in the general preprocessor, /PREP7. To add, edit, or delete an element type the GUI path to follow is: Main menu>Preprocessor>Element Type>Add/Edit/Delete the following dialog box: Figure 5-1. Library of Element Types Many element types have additional options, known as KEYOPTs, and are referred to as KEYOPT(1), KEYOPT(2), etc. For example, KEYOPT(9) for BEAM4 allows the user to choose results to be calculated at intermediate locations on each element, and KEYOPT(3) for SHELL63 allows to suppress extra displacement shapes. The user can specify KEYOPTs using the ET command or the KEYOPT command. Command: ET, ITYPE, Ename, KOP1, KOP2, KOP3, KOP4, KOP5, KOP6, INOPR — Defines a local element type from the element library. ITYPE Arbitrary local element type number 17 Ename Element name (or number) KOP1, KOP2, KOP3, KOP4, KOP5, KOP6 KEYOPT values (1 through 6) for this element INOPR If 1, suppress all element solution printout for this element type 5.2. Real Constants Element real constants are properties that depend on the element type, such as crosssectional properties of a beam element. For example, real constants for BEAM3, the 2-D beam element, are area, moment of inertia, height, shear deflection constant, initial strain, and added mass per unit length. Not all element types require real constants, and different elements of the same type may have different real constant values. As with element types, each set of real constants has a reference number. At least one element type must be defined in order to define a set of real constants. If not, the program will prompt a message (left) indicating that no element type is define and a set of generic real constant can be defined. Depending on the element type selected, an example of a real constant dialog box is shown next. 18 Figure 4. 2 Example of Real Constants Definition Command: R, NSET, R1, R2, R3, R4, R5, R6 — Defines the element real constants. NSET Set identification number (arbitrary). R1, R2, R3, R4, R5, R6 Real constant values (interpreted as area, moment of inertia, thickness, etc., as required for the particular element type using this set), or table names for tabular input of boundary conditions. 5.3. Sections A cross section defines the geometry of the beam in a plane perpendicular to the beam axial direction. ANSYS supplies a library of eleven commonly-used beam cross section shapes, and permits user-defined cross section shapes. When a cross section is defined, ANSYS builds a numeric model using a nine node cell for determining the properties of the section and for the solution to the Poisson's equation for torsional behavior. Plot of a “Z” cross section shows the centroid and shear center of the cross section and the calculated section properties: 19 Figure 5-2. Example of a 'Z' Cross Section Cross sections and user section meshes may be saved and stored in cross section library files. The user may assign beam cross sections as attributes of a line using the LATT command. These section definitions will be incorporated into the generated beam elements when the line is meshed with BEAM44, BEAM188, or BEAM189. Command: SECTYPE, SECID, Type, Subtype, Name, REFINEKEY — Associates section type information with a section ID number. SECID Section identification number. Type BEAM -- Defines a beam section. SHELL -- Defines a shell. PRETENSION -- Defines a pretension section Subtype When Type = BEAM, the possible beam sections that can be defined for Subtype are: 20 RECT Rectangle QUAD Quadrilateral CSOLID Circular solid CTUBE Circular tube CHAN Channel I I-shaped section Z Z-shaped section L L-shaped section T T-shaped section HATS Hat-shaped section HREC Hollow rectangle or box Arbitrary section -- integrated cross-section inertia properties supplied ASEC by user MESH User-defined mesh Name An 8-character name for the section. REFINEKEY Sets mesh refinement level for thin-walled beam sections. Values are 0 (the default - no mesh refinement) to 5 (high level of mesh refinement). SECDATA, VAL1, VAL2, VAL3, VAL4, VAL5, VAL6, VAL7, VAL8, VAL9, VAL10 — Describes the geometry of a section. VAL1, VAL2, VAL3, VAL4, VAL5, VAL6, VAL7, VAL8, VAL9, VAL10 Values, such as thickness or the length of a side or the numbers of cells along the width, that describe the geometry of a section. The terms VAL1, VAL2, etc. are specialized for each type of cross-section. Next are shown the different Subtypes along with their respective values to define the section in SECDATA. 21 22 23 24 5.4. Coordinate Systems The ANSYS program has several types of coordinate systems, each used for a different reason: Global and local coordinate systems are used to locate geometry items (nodes, keypoints, etc.) in space. The display coordinate system determines the system in which geometry items are listed or displayed. The nodal coordinate system defines the degree of freedom directions at each node and the orientation of nodal results data. The element coordinate system determines the orientation of material properties and element results data. The results coordinate system is used to transform nodal or element results data to a particular coordinate system for listings, displays, or general postprocessing operations (POST1). A global coordinate system can be thought of as an absolute reference frame. The ANSYS program provides three predefined global systems: Cartesian, cylindrical, and spherical. All three of these systems are right-handed and, by definition, share the same origin. They are identified by their coordinate system (C.S.) numbers: 0 for Cartesian, 1 for cylindrical, and 2 for spherical. Figure 4. 3 Coordinate Systems (a) Cartesian (X, Y, Z components) coordinate system 0 (C.S.0) (b) Cylindrical (R, θ, Z components) coordinate system 1 (C.S.1) (c) Spherical (R, θ, φ components) coordinate system 2 (C.S.2) (d) Cylindrical Y(R, θ, Y components) coordinate system 5 (C.S.5) 5.5. Modeling – Create Keypoints, the points that define the vertices of the model, are the "lowest-order" solid model entities. If, in building the solid model, you first create your keypoints, and then use those keypoints to define the "higher-order" solid model entities (that is, lines, 25 areas, and volumes), you are said to be building your model "from the bottom up." Keep in mind that models built from the bottom up are defined within the currently active coordinate system. Figure 5-3. Entities "Orders" The ANSYS program also gives you the ability to assemble your model using geometric primitives, which are fully-defined lines, areas, and volumes. As you create a primitive, the program automatically creates all the "lower" entities associated with it. If your modeling effort begins with the "higher" primitive entities, you are said to be building your model "from the top down." You can freely combine bottom up and top down modeling techniques, as appropriate, in any model. Remember that geometric primitives are built within the working plane while bottom up techniques are defined against the active coordinate system. If you are mixing techniques, you may wish to consider using the CSYS, WP or CSYS, 4 command to force the coordinate system to follow the working plane. Commands: The following commands are the simplest and most straight forward of creating the geometric primitives. The user is encourage to further explore other ways and commands to create them. Keypoints: K, NPT, X, Y, Z — Defines a keypoint. NPT Reference number for keypoint. X,Y,Z Keypoint location in the active coordinate system (may be R,θ,Z or R,θ,Φ). Lines: 26 L, P1, P2, NDIV, SPACE, XV1, YV1, ZV1, XV2, YV2, ZV2 — Defines a line between two keypoints. P1 Keypoint at the beginning of line. P2 Keypoint at the end of line. NDIV Number of element divisions within this line. Normally this field is not used; specifying divisions with LESIZE, etc. is recommended (See meshing). SPACE Spacing ratio. Normally this field is not used, as specifying spacing ratios with the LESIZE command is recommended. The following fields are used only if specified end slopes on the line are desired; otherwise zero curvature end slopes will be automatically calculated to produce a line which is "straight" in the active coordinate system. XV1, YV1, ZV1 Location (in the active coordinate system) of the head of the "slope vector" corresponding to the slope at the P1 end of the line. The tail of the vector is at the origin of the coordinate system. XV2, YV2, ZV2 Location of the head of the "slope vector" corresponding to the slope at the P2 end of the line. Arcs: LARC, P1, P2, PC, RAD — Defines a circular arc. P1 Keypoint at one end of circular arc line. P2 Keypoint at other end of circular arc line. PC Keypoint defining plane of arc and center of curvature side (with positive radius). Must not lie along the straight line from P1 to P2. PC need not be at the center of curvature. RAD 27 Radius of curvature of the arc. If negative, assume center of curvature side is opposite to that defined by PC. If RAD is blank, RAD will be calculated from a curve fit through P1, PC, and P2. Areas: RECTNG, X1, X2, Y1, Y2 — Creates a rectangular area anywhere on the working plane. X1,X2 Working plane X coordinates of the rectangle. Y1, Y2 Working plane Y coordinates of the rectangle. BLC4, XCORNER, YCORNER, WIDTH, HEIGHT, DEPTH — Creates a rectangular area or block volume by corner points. XCORNER, YCORNER Working plane X and Y coordinates of one corner of the rectangle or block face. WIDTH The distance from XCORNER on or parallel to the working plane X-axis. HEIGHT The distance from YCORNER on or parallel to the working plane Y-axis. DEPTH The perpendicular distance (either positive or negative based on the working plane Z direction) from the working plane representing the depth of the block. CYL4, XCENTER, YCENTER, RAD1, THETA1, RAD2, THETA2, DEPTH — Creates a circular area or cylindrical volume anywhere on the working plane. XCENTER, YCENTER Working plane X and Y coordinates of the center of the circle or cylinder. RAD1, RAD2 Inner and outer radii (either order) of the circle or cylinder. A value of zero or blank for either RAD1 or RAD2, or the same value for both RAD1 and RAD2, defines a olid circle or cylinder. THETA1, THETA2 Starting and ending angles (either order) of the circle or faces of the cylinder. AL, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10 — Generates an area bounded by previously defined lines. 28 L1, L2, L3, L4, L5, L6, L7, L8, L9, L10 List of lines defining area. The minimum number of lines is 3. Volumes: V, P1, P2, P3, P4, P5, P6, P7, P8 — Defines a volume through keypoints. P1, P2, P3, P4, P5, P6, P7, P8 Keypoints defining respective corners of the volume. VA, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 — Generates a volume bounded by existing areas. A1, A2, A3, A4, A5, A6, A7, A8, A9, A10 List of areas defining volume. The minimum number of areas is 4. 5.6. Modeling – Operate – Booleans Boolean algebra provides a means for combining sets of data, using such logical operators as intersect, union, subtract, etc. The ANSYS program allows the user to apply these same Boolean operators to the solid model, so that its constructions can be modified more easily. Boolean operations can be applied to almost any solid model construction, whether it was created from the top down or from the bottom up. The only exceptions are that Boolean operations are not valid for entities created by concatenation and that some Boolean operations cannot always be performed on entities that contain degeneracies. Also, all solid-model loads and element attributes should be defined after complete use of the Boolean operators. 7.1.1. Intersects: An intersection defines a new set of entities which is common to every original entity included in the operation. In other words, an intersection represents the region of overlap of two or more entities. The new set can be of the same or lower dimension as the original entities. For instance, the intersection of two lines can be a keypoint (or a set of keypoints), or it can be a line (or set of lines). Commands: LINL, NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 — Finds the common intersection of lines. NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 Numbers of lines to be intersected. 29 Figure 5-4. Line intersecting Lines AINA, NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 — Finds the intersection of areas. NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 Numbers of areas to be intersected. Figure 5-5. Areas intersecting areas VINV, NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 — Finds the intersection of volumes. NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 Numbers of volumes to be intersected. 30 Figure 5-6. Volumes intersecting volumes LINA, NL, NA — Finds the intersection of a line with an area. NL Number of line to be intersected. NA Number of area to be intersected. Figure 5-7. Lines, intersecting areas AINV, NA, NV — Finds the intersection of an area with a volume. 31 NA Number of area to be intersected. NV Number of volume to be intersected. Figure 5-8. Areas intersectting volumes LINV, NL, NV — Finds the intersection of a line with a volume. NL Number of line to be intersected. NV Number of volume to be intersected. Figure 5-9. Lines intersecting volumes 7.1.2. Add: An addition of entities defines a new entity that includes all parts of the originals. (This operation is also known mathematically as a union, joining, or summation.) The resulting entity is a single seamless whole, containing no internal divisions. Commands: 32 AADD, NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 — Adds separate areas to create a single area. NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 Numbers of areas to be added. Figure 4. 4 Adding of areas VADD, NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 — Adds separate volumes to create a single volume. NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 Numbers of volumes to be added. Figure 5-10. Adding of volumes 7.1.3. Subtract: If one entity (E2) is subtracted from another (E1), one of two results will be obtained: either create a new entity or entities (E1 - E2 ≥ E3) that is of the same 33 dimensionality as E1 and that contains no overlap with E2, or, if the overlap is of a lower dimensionality, E1 will simply be divided into two or more new entities (E1 - E2 ≥ E3 and E4). If the command field SEPO on the subtract command is set to blank (default), the subtraction of entities can result in lines with a common end point, or areas with a common line boundary, or volumes sharing a common boundary area. If the command field is set to "SEPO", the resulting entities will no longer share common boundaries but have distinct but coincident boundaries. This latter operation is not valid if the overlap of entities does not divide one of the input entities into at least two distinct lines, areas, or volumes. Commands: LSBL, NL1, NL2, SEPO, KEEP1, KEEP2 — Subtracts lines from lines. NL1 Line (or lines, if picking is used) to be subtracted from. NL2 Line (or lines, if picking is used) to subtract. KEEP1 Specifies whether NL1 lines are to be deleted: DELETE -- Delete NL1 lines after LSBL operation . KEEP -- Keep NL1 lines after LSBL operation. KEEP2 Specifies whether NL2 lines are to be deleted: DELETE -- Delete NL2 lines after LSBL operation . KEEP -- Keep NL2 lines after LSBL operation. 34 Figure 5-11. Subtracting lines from lines ASBA, NA1, NA2, SEPO, KEEP1, KEEP2 — Subtracts areas from areas. NA1 Area (or areas, if picking is used) to be subtracted from. NA2 Area (or areas, if picking is used) to subtract. KEEP1 Specifies whether NA1 lines are to be deleted: DELETE -- Delete NA1 lines after ASBA operation . KEEP -- Keep NA1 lines after ASBA operation. KEEP2 Specifies whether NA2 lines are to be deleted: DELETE -- Delete NA2 lines after ASBA operation . KEEP -- Keep NA2 lines after ASBA operation. 35 Figure 5-12. Subtracting areas from areas VSBV, NV1, NV2, SEPO, KEEP1, KEEP2 — Subtracts volumes from volumes. NV1 Volume (or volumes, if picking is used) to be subtracted from. NV2 Volume (or volume, if picking is used) to subtract. KEEP1 Specifies whether NV1 lines are to be deleted: DELETE -- Delete NV1 lines after VSBV operation . KEEP -- Keep NV1 lines after VSBV operation. KEEP2 Specifies whether NV2 lines are to be deleted: DELETE -- Delete NV2 lines after VSBV operation . KEEP -- Keep NV2 lines after VSBV operation. 36 Figure 5-13. Subtracting volumes from volumes LSBA, NL, NA, SEPO, KEEPL, KEEPA — Subtracts areas from lines. NL Line (or lines, if picking is used) to be subtracted from. NA Area (or areas, if picking is used) to be subtracted. KEEPL Specifies whether NL lines are to be deleted: DELETE -- Delete NL lines after LSBA operation . KEEP -- Keep NL lines after LSBA operation. KEEPA Specifies whether NA lines are to be deleted: DELETE -- Delete NA lines after LSBA operation . KEEP -- Keep NA lines after LSBA operation. 37 Figure 5-14. Subtracting areas from lines LSBV, NL, NV, SEPO, KEEPL, KEEPV — Subtracts volumes from lines. NL Line (or lines, if picking is used) to be subtracted from. NV Volume (or volumes, if picking is used) to be subtracted. KEEPL Specifies whether NL lines are to be deleted: DELETE -- Delete NL lines after LSBV operation . KEEP -- Keep NL lines after LSBV operation. KEEPV Specifies whether NV lines are to be deleted: DELETE -- Delete NV lines after LSBV operation . KEEP -- Keep NV lines after LSBV operation. 38 Figure 5-15. Subtracting volumes from lines ASBV, NA, NV, SEPO, KEEPA, KEEPV — Subtracts volumes from areas. NA Area (or areas, if picking is used) to be subtracted from. NV Volume (or volumes, if picking is used) to subtract. KEEPA Specifies whether NA lines are to be deleted: DELETE -- Delete NA lines after ASBV operation . KEEP -- Keep NA lines after ASBV operation. KEEPV Specifies whether NV lines are to be deleted: DELETE -- Delete NV lines after ASBV operation . KEEP -- Keep NV lines after ASBV operation. 39 Figure 5-16. Subtracting volumes from areas ASBL, NA, NL, --, KEEPA, KEEPL — Subtracts lines from areas. NA Area (or areas, if picking is used) to be subtracted from. NL Line (or lines, if picking is used) to subtract. KEEPA Specifies whether NA lines are to be deleted: DELETE -- Delete NA lines after ASBL operation . KEEP -- Keep NA lines after ASBL operation. KEEPL Specifies whether NL lines are to be deleted: DELETE -- Delete NL lines after ASBL operation . KEEP -- Keep NL lines after ASBL operation. Figure 5-17. Subtracting lines from areas 40 VSBA, NV, NA, SEPO, KEEPV, KEEPA — Subtracts areas from volumes. NV Volume (or volumes, if picking is used) to be subtracted from. NA Area (or areas, if picking is used) to subtract. KEEPV Specifies whether NV lines are to be deleted: DELETE -- Delete NV lines after VSBA operation . KEEP -- Keep NV lines after VSBA operation. KEEPA Specifies whether NA lines are to be deleted: DELETE -- Delete NA lines after VSBA operation . KEEP -- Keep NA lines after VSBA operation. Figure 5-18. Subtracting areas from volumes 7.1.4. Overlap: The overlap commands will join two or more entities to create three or more new entities that encompass all parts of the originals. The end result is similar to an "add" operation, except that boundaries will be created around the overlap zone. Thus, the overlap operation produces a number of relatively uncomplicated regions, as compared to the single relatively complicated region created by the add operation. For this reason, overlapped entities will often mesh better than added entities. 41 Commands: LOVLAP, NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 — Overlaps lines. NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 Numbers of lines to be overlapped. Figure 5-19. Overlapping lines AOVLAP, NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 — Overlaps areas. NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 Numbers of areas to be operated on. Figure 5-20. Overlapping areas VOVLAP, NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 — Overlaps volumes. NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 Numbers of volumes to be operated on. 42 Figure 5-21. Overlapping volumes 7.1.5. Glue: Glue is similar to overlap, except that it applies only to cases in which the intersection between entities occurs at a boundary, and is one dimension lower than the original entities. The entities maintain their individuality (they are not "added"), but they become connected at their intersection. Commands: LGLUE, NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 — Generates new lines by "gluing" lines. NL1, NL2, NL3, NL4, NL5, NL6, NL7, NL8, NL9 Numbers of the lines to be glued. Figure 5-22. Gluing lines AGLUE, NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 — Generates new areas by "gluing" areas. NA1, NA2, NA3, NA4, NA5, NA6, NA7, NA8, NA9 Numbers of the areas to be glued. 43 Figure 5-23. Gluing areas VGLUE, NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 — Generates new volumes by "gluing" volumes. NV1, NV2, NV3, NV4, NV5, NV6, NV7, NV8, NV9 Numbers of the volumes to be glued. Figure 5-24. Gluig volumes 5.7. Meshing The procedure for generating a mesh of nodes and elements consists of three main steps: set the element attributes, set mesh controls (optional), and generate the mesh. The second step, setting mesh controls, is not always necessary because the default mesh controls are appropriate for many models. If no controls are specified, the program will use the default settings on the DESIZE command to produce a free mesh. As an alternative, the user can use the SmartSize feature to produce a better quality free mesh. Before meshing the model, and even before building the model, it is important to think about whether a free mesh or a mapped mesh is appropriate for the analysis. A free mesh has no restrictions in terms of element shapes, and has no specified pattern applied to it. Compared to a free mesh, a mapped mesh is restricted in terms of the element shape it contains and the pattern of the mesh. A mapped area mesh contains either only quadrilateral or only triangular elements, while a mapped volume mesh contains only hexahedron elements. In addition, a mapped mesh typically has a regular pattern, with obvious rows of elements. 44 Figure 5-25. Free and mapped mesh Before generating a mesh of nodes or elements the appropriate element attributes must be defined. That is, the element type, its set real constants, material properties, the element coordinate system, and the section id must all be specified. Once the element attributes are defined they can be attributed to the solid model by the following commands: To assign attributes to keypoints: KATT, MAT, REAL, TYPE, ESYS — Associates attributes with the selected, unmeshed keypoints. MAT, REAL, TYPE, ESYS Material number, real constant set number, type number, and coordinate system number to be associated with selected, unmeshed keypoints. To assign attributes to lines: LATT, MAT, REAL, TYPE, --, KB, KE, SECNUM — Associates element attributes with the selected, unmeshed lines. MAT, REAL, TYPE Material number, real constant set number, and type number to be associated with selected, unmeshed lines. -Unused field. KB, KE Beginning and ending orientation keypoints to be associated with selected, unmeshed lines SECNUM Section identifier to be associated with selected, unmeshed lines. To assign attributes to areas: 45 AATT, MAT, REAL, TYPE, ESYS, SECN — Associates element attributes with the selected, unmeshed areas. MAT, REAL, TYPE, ESYS, SECN Material number, real constant set number, type number, coordinate system number, and section number to be associated with selected, unmeshed areas. To assign attributes to volumes: VATT, MAT, REAL, TYPE, ESYS — Associates element attributes with the selected, unmeshed volumes. MAT, REAL, TYPE, ESYS Material number, real constant set number, type number, and coordinate system number to be associated with selected, unmeshed volumes. The following GUI menu path is also possible: Main Menu> Preprocessor> Meshing> Mesh Attributes. Then choose the desired entity and its attributes. For example, for the line attributes the following dialog box will appear after selecting lines in the previous menu path. Figure 5-26. Example of mesh attributes After the model has its respective attributes the real meshing continues. The user can go to Main Menu>Preprocessor>Meshing>Meshing Tool. This will prompt the mesh tool. The ANSYS MeshTool provides a convenient path to many of the most common mesh controls, as well as to the most frequently performed meshing operations. The MeshTool is an interactive "tool box”, since it contains numerous functions. Although all of the 46 functions available via the MeshTool are also available via the traditional ANSYS commands and menus, using the MeshTool is a valuable shortcut. The many functions available via the MeshTool include: • • • • • • • Controlling SmartSizing levels Setting element size controls Specifying element shape Specifying meshing type (free or mapped) Meshing solid model entities Clearing meshes Refining meshes Smart element sizing (SmartSizing) is a meshing feature that creates initial element sizes for free meshing operations. SmartSizing gives the mesher a better chance of creating reasonably shaped elements during automatic mesh generation. This feature, which is controlled by the SMRTSIZE command, provides a range of settings (from coarse to fine mesh) for meshing both h-method and p-method models. Figure 5-27. Example of smart-sizing level Command: SMRTSIZE, SIZLVL, FAC, EXPND, TRANS, ANGL, ANGH, GRATIO, SMHLC, SMANC, MXITR, SPRX — Specifies meshing parameters for automatic (smart) element sizing. SIZLVL Overall element size level for meshing. The level value controls the fineness of the mesh. (Any input in this field causes remaining arguments to be ignored.) Activate SmartSizing and set the size level integer value from 1 (fine mesh) to 10 (coarse mesh). 47 FAC Scaling factor applied to the computed default mesh sizing. EXPND Mesh expansion (or contraction) factor. It s used to size internal elements in an area based on the size of the elements on the area's boundaries. If less than 1, a mesh with smaller elements on the interior of the area will be allowed. Should be greater than 0.5 but less than 4. TRANS Mesh transition factor. It is used to control how rapidly elements are permitted to change in size from the boundary to the interior of an area. Must be greater than 1 and, for best results, should be less than 4. ANGL Maximum spanned angle per lower-order element for curved lines. Defaults to 22.5 degrees per element (size level 6). This angle limit may be exceeded if the mesher encounters a small feature (hole, fillet, etc.). ANGH Maximum spanned angle per higher-order element for curved lines. Defaults to 30 degrees per element (size level 6). This angle limit may be exceeded if the mesher encounters a small feature (hole, fillet, etc.). GRATIO Allowable growth ratio used for proximity checking. Defaults to 1.5 for helements (size level 6). Values from 1.2 to 5.0 are allowed; however, values from 1.5 to 2.0 are recommended. SMHLC Small hole coarsening key, can be ON (default for size level 6) or OFF. I f ON, this feature suppresses curvature refinement that would result in very small element edges. SMANC Small angle coarsening key, can be ON (default for all levels) or OFF. If ON, this feature restricts proximity refinement in areas where it is ill-advised. MXITR Maximum number of sizing iterations (defaults to to 4 for all levels). SPRX Surface proximity refinement key, can be off (SPRX = 0, which is the default for all levels) or on via two different values (SPRX = 1 or SPRX = 2). If SPRX = 1, surface proximity refinement is performed and any shell elements that need to be modified are 48 modified. If SPRX=2, surface proximity refinement is performed but no shell elements are altered. Depending on the geometry, sometimes it is simpler to use the following commands ESIZE, KSIZE, LESIZE, and AESIZE. At a minimum, the user should set the allowable element shapes if he or she plans on meshing with an element type that can take on more than one shape. For instance, many area elements can be both triangular and quadrilateral shaped within the same meshed area. Volume elements can often be either hexahedral (brick) or tetrahedral shaped, but a mixture of the two shapes in the same model is not recommended. Command: MSHAPE, KEY, Dimension — For elements that support multiple shapes, specifies the element shape to be used for meshing. KEY Key indicating the element shape to be used: 0 -- Mesh with quadrilateral-shaped elements when Dimension = 2D; mesh with hexahedral-shaped elements when Dimension = 3D. 1 -- Mesh with triangle-shaped elements when Dimension = 2D; mesh with tetrahedral-shaped elements when Dimension = 3D. Dimension Specifies the dimension of the model to be meshed: 2D -- 2-D model (area mesh). 3D -- 3-D model (volume mesh). In addition to specifying element shape, the user may also want to specify the type of meshing (free or mapped) that should be used to mesh the model. This is done by setting the meshing key. Command MSHKEY, KEY — Specifies whether free meshing or mapped meshing should be used to mesh a model. KEY Key indicating the type of meshing to be used: 0 -- Use free meshing (the default). 49 1 -- Use mapped meshing. 2 -- Use mapped meshing if possible; otherwise, use free meshing. Once the user has built the solid model, established element attributes, and set meshing controls, he or she is ready to generate the finite element mesh. First, however, it is usually good practice to save the model before initiating mesh generation. To mesh the model, the user must use a meshing operation that is appropriate for the entity type being meshed. Keypoints, lines, areas, and volumes can be meshed using the commands and GUI paths described below. KMESH, NP1, NP2, NINC — Generates nodes and point elements at keypoints. NP1, NP2, NINC Mesh keypoints from NP1 to NP2 (defaults to NP1) in steps of NINC (defaults to 1). Main Menu> Preprocessor> Meshing> Mesh> Keypoints LMESH, NL1, NL2, NINC — Generates nodes and line elements along lines. NL1, NL2, NINC Mesh lines from NL1 to NL2 (defaults to NL1) in steps of NINC (defaults to 1). Main Menu> Preprocessor> Meshing> Mesh> Lines AMESH, NA1, NA2, NINC — Generates nodes and area elements within areas. NA1, NA2, NINC Mesh areas from NA1 to NA2 (defaults to NA1) in steps of NINC (defaults to 1). Main Menu> Preprocessor> Meshing> Mesh> Areas> Free VMESH, NV1, NV2, NINC — Generates nodes and volume elements within volumes. NV1, NV2, NINC Mesh volumes from NV1 to NV2 (defaults to NV1) in steps of NINC (defaults to 1). When generating your model, you typically define the relationships among different degrees of freedom by using elements to connect the nodes. However, you sometimes need to be able to model distinctive features (rigid regions, pinned structural joints, sliding symmetry boundaries, periodic conditions, and other special inter-nodal connections) which cannot be adequately described with elements. You can establish such special associations among nodal degrees of freedom by using coupling and 50 constraint equations. Using these techniques enables you to link degrees of freedom in ways that elements cannot. Coupling When you need to force two or more degrees of freedom (DOFs) to take on the same (but unknown) value, you can couple these DOFs together. A set of coupled DOFs contains a prime DOF, and one or more other DOFs. Coupling will cause only the prime DOF to be retained in your analysis' matrix equations, and will cause all the other DOFs in a coupled set to be eliminated. The value calculated for the prime DOF will then be assigned to all the other DOFs in a coupled set. Typical applications for coupled DOFs include: 1) maintaining symmetry on partial models, 2) forming pin, hinge, universal, and slider joints between two coincident nodes, and 3) forcing portions of your model to behave as rigid bodies (see this chapter's discussion of constraint equations for more general rigid region capability). To define (or modify) a set of coupled degrees of freedom, use one of these methods: Command(s): CP GUI: Main Menu>Preprocessor>Coupling / Ceqn>Couple DOFs After creating a coupled set of nodes, you can include more nodes in that set by simply performing an additional coupling operation (be sure to use the same set reference number). You can also use selecting logic to couple "ALL" of the selected nodes. Nodes can be deleted from a coupled set by inputting them as negative node numbers on the CP command. To modify a coupled DOF set (that is, add or delete nodes, or change the DOF label), use the CPNGEN command. (You cannot access the CPNGEN command directly in the GUI.) The CPINTF command couples coincident nodes in a model by generating one coupled set for each specified DOF label at every pair of coincident nodes. This operation is useful for "buttoning" together several pairs of nodes (such as at a seam). Command(s): CPINTF GUI: Main Menu>Preprocessor>Coupling / Ceqn>Coincident Nodes 51 Instead of coupling coincident nodes, you can use one of these alternative methods to force the nodes to behave in the same way: a. If all DOFs are to be coupled for coincident nodes, it is usually more efficient to simply merge those nodes together by using the NUMMRG command (Main Menu> Preprocessor> Numbering Ctrls> Merge Items). b. You can connect coincident pairs of nodes by creating 2-noded elements between them by using the EINTF command (Main Menu> Preprocessor> Modeling> Create> Elements> Auto Numbered> At Coincid Nd). c. To tie together two regions having dissimilar mesh patterns, use the CEINTF command (Main Menu>Preprocessor>Coupling/Ceqn> Adjacent Regions). This operation generates constraint equations that connect the selected nodes of one region to the selected elements of the other region. 52 6. Material Properties As with element types and real constants, each set of material properties has a material reference number. The table of material reference numbers versus material property sets is called the material table. Preprocessor > materials props > materials models > structural > linear/nonlinear 53 7. Loading The most common loads are divide into: – Structural: displacements, forces, pressures, temperatures (for thermal strain), gravity – Thermal: temperatures, heat flow rates, convections, internal heat generation, infinite surface – Magnetic: magnetic potentials, magnetic flux, magnetic current segments, source current density, infinite surface – Electric: electric potentials (voltage), electric current, electric charges, charge densities, infinite surface – Fluid: velocities, pressures However loads are divided into six categories: • DOF constraints • forces (concentrated loads) • surface loads • body loads • inertia loads • coupled-field loads 7.1. Load step A load step is simply a configuration of loads for which a solution is obtained. In a linear static or steady-state analysis, you can use different load steps to apply different sets of loads - wind load in the first load step, gravity load in the second load step, both loads and a different support condition in the third load step, and so on. In a transient analysis, multiple load steps apply different segments of the load history curve. 7.1.6. Substep Substeps are points within a load step at which solutions are calculated. You use them for different reasons: 1. • In a nonlinear static or steady-state analysis, use substeps to apply the loads gradually so that an accurate solution can be obtained. 2. • In a linear or nonlinear transient analysis, use substeps to satisfy transient time integration rules (which usually dictate a minimum integration time step for an accurate solution). 3. • In a harmonic response analysis, use substeps to obtain solutions at several frequencies within the harmonic frequency range. 4. • Equilibrium iterations are additional solutions calculated at a given substep for convergence purposes. They are iterative corrections used only in nonlinear analyses (static or transient), where convergence plays an important role. 54 7.2. Time tracking The ANSYS program uses time as a tracking parameter in all static and transient analyses, whether they are or are not truly time-dependent. The advantage of this is that you can use one consistent "counter" or "tracker" in all cases, eliminating the need for analysis dependent terminology. Moreover, time always increases monotonically, and most things in nature happen over a period of time, however brief the period may be. In a rate-independent analysis, however, time simply becomes a counter that identifies load steps and substeps. By default, the program automatically assigns time = 1.0 at the end of load step 1, time = 2.0 at the end of load step 2, and so on. Any substeps within a load step will be assigned the appropriate, linearly interpolated time value. By assigning your own time values in such analyses, you can establish your own tracking parameter. For example, if a load of 100 units is to be applied incrementally over one load step, you can specify time at the end of that load step to be 100, so that the load and time values are synchronous. In the postprocessor, then, if you obtain a graph of deflection versus time, it means the same as deflection versus load. This technique is useful, for instance, in a large-deflection buckling analysis where the objective may be to track the deflection of the structure as it is incrementally loaded. Time takes on yet another meaning when you use the arc-length method in your solution. In this case, time equals the value of time at the beginning of a load step, plus the value of the arc-length load factor (the multiplier on the currently applied loads). ALLF does not have to be monotonically increasing (that is, it can increase, decrease, or even become negative), and it is reset to zero at the beginning of each load step. As a result, time is not considered a "counter" in arc-length solutions. A load step is a set of loads applied over a given time span. Substeps are time points within a load step at which intermediate solutions are calculated. The difference in time between two successive substeps can be called a time step or time increment. Equilibrium iterations are iterative solutions calculated at a given time point purely for convergence purposes. For use arc-method analysis Preprocessor>Loads>Analysis Type>Sol'n Controls>advanced nl 55 7.3. Arc-Length Method Arc-length Diagram • Most loads are applied either – on the solid model (on keypoints, lines, and areas) or – on the finite element model (on nodes and elements) Solid-model loads • Advantages – Solid-model loads are independent of the finite element mesh. That is, you can change the Element mesh without affecting the applied loads. This allows you to make mesh modifications and conduct mesh sensitivity studies without having to reapply loads each time. 56 – The solid model usually involves fewer entities than the finite element model. Therefore, selecting solid model entities and applying loads on them is much easier, especially with graphical picking. • Disadvantages – Elements generated by ANSYS meshing commands are in the currently active element coordinate system. Nodes generated by meshing commands use the global Cartesian coordinate system. Therefore, the solid model and the finite element model may have different coordinate systems and loading directions. – Solid-model loads are not very convenient in reduced analyses, where loads are applied at master degrees of freedom. (You can define master DOF only at nodes, not at keypoints.) – Applying keypoint constraints can be tricky, especially when the constraint expansion option is used. (The expansion option allows you to expand a constraint specification to all nodes between two keypoints that are connected by a line.) – You cannot display all solid-model loads. Finite element loads • Advantages – Reduced analyses present no problems, because you can apply loads directly at master nodes. – There is no need to worry about constraint expansion. You can simply select all desired nodes and specify the appropriate constraints. • Disadvantages – Any modification of the finite element mesh invalidates the loads, requiring you to delete the previous loads and re-apply them on the new mesh. – Applying loads by graphical picking is inconvenient, unless only a few nodes or elements are involved. DOF Constraints • A DOF constraint fixes a degree of freedom (DOF) to a known value. Examples of constraints are specified displacements and symmetry boundary conditions in a structural analysis, prescribed temperatures in a thermal analysis, and flux-parallel boundary conditions 57 Preprocessor>Loads>Define loads >Apply >Structural> displacement Displacement constrain • Applying Symmetry or Antisymmetry Boundary Conditions - The symmetric boundary conditions apply constrains of the displacement in both sides of the geometry, and the antisymmetric boundary condition is applied in only one side of the geometry. • Transferring Constraints – To transfer constraints that have been applied to the solid model to the corresponding finite element model • Resetting Constraints – By default, if you repeat a DOF constraint on the same degree of freedom, the new specification replaces the previous one. You can change this default to add (for accumulation) or ignore • Scaling Constraint Values Forces (Concentrated Loads) • A force is a concentrated load applied at a node in the model. Examples are forces and moments in a structural analysis, heat flow rates in a thermal analysis, and current segments in a magnetic field analysis. 58 • Repeating a Force – By default, if you repeat a force at the same degree of freedom, the new specification replaces the previous one. You can change this default to add (for accumulation) or ignore • Scaling Force Values • Transferring Forces Preprocessor Loads>Define loads >Apply >Structural> force/moment Force Load Surface Loads • A surface load is a distributed load applied over a surface. Examples are pressures in a structural analysis and convections and heat fluxes in a thermal analysis. • Specifying a Gradient Slope • Repeating a Surface Load 59 – By default, if you repeat a surface load at the same surface, the new specification replaces the previous one. • Transferring Surface Loads • Using Surface Effect Elements to Apply Loads – to apply a surface load that the element type you are using does not accept. For example, you may need to apply uniform tangential (or any non-normal or directed) pressures on structural solid elements, radiation specifications on thermal solid elements, etc. Preprocessor> Loads>Define loads >Apply >Structural> pressure Surface Load Pressure Loads on Beams Specifies surface loads on beam elements. Preprocessor> Loads>Define loads >Apply >Structural> pressure> on beams 60 Body Loads • A body load is a volumetric or field load. Examples are temperatures and fluences in a structural analysis, heat generation rates in a thermal analysis, and current densities in a magnetic field analysis • Specifying Body Loads for Elements • Specifying Body Loads for Keypoints • Specifying Body Loads on Lines, Areas and Volumes • Specifying a Uniform Body Load • Repeating a Body Load Specification – By default, if you repeat a body load at the same node or same element, the new specification replaces the previous one. • Transferring Body Loads • Scaling Body Load Values Others Types of Loads • Inertia Loads 61 – Inertia loads are those attributable to the inertia (mass matrix) of a body, such as gravitational acceleration, angular velocity, and angular acceleration. You use them mainly in a structural analysis • Coupled-Field Loads – Coupled-field loads are simply a special case of one of the above loads, where results from one analysis are used as loads in another analysis. For example, you can apply magnetic forces calculated in a magnetic field analysis as force loads in a structural analysis. • Axisymmetric Loads and Reactions An axisymmetric structure (defined with the axial direction along the global Y axis and the radial direction parallel to the global X axis) may be represented by a plane (X,Y) finite-element model. The use of an axisymmetric model greatly reduces the modeling and analysis time compared to that of an equivalent three-dimensional model. • Loads to Which the DOF Offers No Resistance – If an applied load acts on a DOF which offers no resistance to it (i.e. perfectly zero stiffness), the ANSYS program ignores the load. • Initial Stress Loading – Initial stress loading is only allowed in a static or full transient analysis (the analysis can be linear or nonlinear). Initial stresses can be applied only in the first load step of an analysis. • Applying Loads Using TABLE Type Array Parameters • Graphing or Listing the Boundary Condition Functions Load steps • As mentioned earlier, load step options is a collective name for options that control how loads are used during solution and other options such as output controls, damping specifications, and response spectrum data. Load step options can vary from load step to load step. • There are six categories of load step options: – General Options – Dynamics Options – Nonlinear Options – Output Controls – Biot-Savart Options – Spectrum Options Multiple load steps • Multiple Load Step Files – All loads and load step options put together form a load step, for which the program can calculate the solution. If you have multiple load steps, you can store the data for each load step on a file, called the load step file, and read it in later for solution. 62 Applying loads 63 64 8. Solution The Solution menu will be either “abridged” or “unabridged,” depending on the actions you took prior to this step in your ANSYS session. The abridged menu contains only those solution options that are valid and/or recommended for modal analyses. • If you are using the GUI to perform a structural static, transient, modal, or buckling analysis, you have the choice of using abridged or unabridged Solution menus: – Unabridged Solution menus list all solution options, regardless of whether it is recommended, or even possible, for you to use them in the current analysis. (If it is not possible for you to use an option in the current analysis, the option is listed but is grayed out.) – Abridged Solution menus are simpler. They list only those options that apply to the type of analysis that you are performing. For example, if you are performing a static analysis, the Modal Cyclic Sym option does not appear on the abridged Solution menu. Only those options that are valid and/or recommended for the current analysis type appear. • Several methods of solving the system of simultaneous equations re available in the ANSYS program: – sparse direct solution – frontal direct solution – Jacobi Conjugate Gradient (JCG) solution – Incomplete Cholesky Conjugate Gradient (ICCG) solution – Preconditioned Conjugate Gradient (PCG) solution – Automatic iterative solver option (ITER) • The sparse direct solver is the default solver for all analyses, except or electromagnetic analyses, analyses that include both p-elements nd constraint equations, spectrum analyses, and substructuring nalyses (which each use the frontal direct solver by default). • In addition to these solvers, the Parallel Performance for ANSYS add-on product includes two multiprocessor solvers: – Algebraic Multigrid (AMG) solution – Distributed Domain Solver (DDS) 65 Solution Table Solution controls – Basic • • • Specify the type of analysis that you want to perform. Control varioustime settings. Specify the solution data that you want ANSYS to write to the database. Preprocessor>Loads>Analysis Type>Sol'n Controls 66 Solution controls – Transient • • • Specify transient options, such as transient effects and ramped vs. stepped loading Specify damping options. Define integration parameters. • • Specify the type of equation solver that you want to use. Specify parameters for performing a multiframe restart. 67 • • • • • Control nonlinear options, such as line search and solution predictor. Specify the maximum number of iterations that are allowed per substep. Indicate whether you want to include creep calculation in the analysis. Control bisections. Set convergence criteria. • • Specify analysis termination criteria. Control activation and termination of the arc-length method. Solving Multiple Load Steps 68 • There are three ways to define and solve multiple load steps: • Multiple SOLVE method – This method is the most straightforward. It involves issuing the SOLVE command after each load step is defined. The main disadvantage, for iteractive use, is that you have to wait for the solution to be completed before defining the next load step. SOLVE • Load step file method – The load step file is a convenient method to use when you want to solve problems while you are away from your terminal or PC (for example, overnight). It involves writing each load step to a load step file (via the LSWRITE command or its GUI equivalent) and, with one command, reading in each file and obtaining the solution. LSWRITE • Array parameter method. – This method, mainly intended for transient or nonlinear static (steadystate) analyses, requires knowledge of array parameters and do-loops, which are part of APDL (ANSYS Parametric Design Language). Restart of analysis 69 • Sometimes you may need to restart an analysis after the initial run has been completed. For instance, you may want to add more load steps to the analysis. These may be additional loading conditions in a linear static analysis or additional portions of a timehistory loading curve in a transient analysis. Or, you may need to recover from a convergence failure in a nonlinear analysis. • ANSYS allows two different types of restarts: the singleframe restart and the multiframe restart, which can be used for static or full transient structural analyses. The singleframe restart only allows you to resume a job at the point it stopped. The multiframe restart can resume a job at any point in the analysis for which information is saved. This capability allows you to do multiple analyses of a model and gives you more options for recovering from an abort. – The model must meet the following conditions to restart an analysis: – The analysis type must be either static (steady-state), harmonic (2-D magnetic only), or transient (full method only). No other analysis can be restarted. – At least one iteration must have been completed in the initial run. – The initial run should not have stopped due to a "killed" job, system break, or system crash. – You performed your initial analysis and generated the restart file under the same ANSYS version number. 70 9. Post-processing The solution phase calculates two types of results data: – Primary data consist of the degree-of-freedom solution calculated at each node: displacements in a structural analysis, temperatures in a thermal analysis, magnetic potentials in a magnetic analysis – Derived data are those results calculated from the primary data, such as stresses and strains in a structural analysis, thermal gradients and fluxes in a thermal analysis, magnetic fluxes in a magnetic analysis, and the like. They are typically calculated for each element and may be reported at any of the following locations: at all nodes of each element, at all integration points of each element, or at the centroid of each element. Derived data are also known as element solution data, except when they are averaged at the nodes. In such cases, they become nodal solution data. The POST1, the general postprocessor, is use to review analysis results over the entire model, or selected portions of the model, for a specifically defined combination of loads at a single time (or frequency). POST1 has many capabilities, ranging from simple graphics displays and tabular listings to more complex data manipulations such as load case combinations. The SET command reads results data over the entire model from the results file into the database for a particular loading condition, replacing any data previously stored in the database. The boundary condition information (constraints and force loads) is also read in, but only if either element nodal loads or reaction loads are available. 9.1. Graphics -Contour Plot Contour displays show how a result item (such as stress, temperature, magnetic flux density, etc.) varies over the model. -Deformed shape displays You can use these in a structural analysis to see how the structure has deformed under the applied loads. – Vector displays Vector displays use arrows to show the variation of both the magnitude and direction of a vector quantity in the model. Examples of vector quantities are displacement (U), rotation (ROT), magnetic vector potential (A), magnetic flux density (B), thermal flux (TF), thermal gradient (TG), fluid velocity (V), principal stresses (S), etc. – Path plots These are graphs that show the variation of a quantity along a predefined path through the model. – Reaction force displays These are similar to boundary condition displays and are activated using the labels RFOR or RMOM on the /PBC command. Any subsequent display (produced by commands such as NPLOT, EPLOT, or PLDISP) will include reaction force symbols at points where DOF constraints were specified. The sum of nodal forces for a DOF belonging to a constraint equation does not include the force passing through that equation. 71 – Particle flow traces. A particle flow trace is a special form of graphics display that shows how a particle travels in a flowing fluid. A charged particle trace is a graphics display that shows how a charged particle travels in an electric or magnetic field. Steps to plot results Contour Plot General Postproc > Plot Results > Contour Plot > Nodal Sol 72 Element Table 73 Plot paths 74 75 76 Parameters APDL APDL stands for ANSYS Parametric Design Language, a scripting language that you can use to automate common tasks or even build your model in terms of parameters (variables). APDL also encompasses a wide range of other features such as repeating a command, macros, if-then-else branching, do-loops, and scalar, vector and matrix operations. Parameters are APDL variables (they are more similar to Fortran variables than to Fortran parameters). You don't need to explicitly declare the parameter type. All numeric values (whether integer or real) are stored as double-precision values. Parameters that are used but not defined are assigned a near-zero, or "tiny," value of approximately 2-100. For example, if parameter A is defined as A=B, and B is not defined, then A is assigned the tiny value. Types of parameters ANSYS uses two types of parameters: – Scalar – Array Character strings (up to eight characters long) can be assigned to parameters by simply enclosing the string in single quotes APDL also provides several types of array parameters: – Numeric – Character – String – Table (a special numeric type that automatically interpolates values) You can use a parameter (instead of a literal number or character string) as an argument to any ANSYS command; the parameter is evaluated and its current value is used for that argument. – For example, if you assign the value 2.7 to a parameter named AA and then issue the command: N,12,AA,4 the ANSYS program will interpret the command as N,12,2.7,4 (which defines node 12 at X=2.7 and Y=4) Naming Parameters Parameter names must: – Begin with a letter – Contain only letters, numbers, and underscore characters – Contain no more than 32 characters Examples of valid and invalid parameter names are – Valid: ABCPIX_OR_Y – Invalid: 77 MY_PARAMETER_NAME_LONGER_THAN_32_CHARACTERS (more than 32 characters)2CF3 (begins with a number)M&E (invalid character "&") When naming parameters: Avoid parameter names that match commonly used ANSYS labels, such as: – Degree of freedom (DOF) labels (TEMP, UX, PRES, etc.) – Convenience labels (ALL, PICK, STAT, etc.) – User-defined labels (such as those defined with the ETABLE command) – Array type field labels (such as CHAR, ARRAY, TABLE, etc.) Array Parameters In addition to scalar (single valued) parameters, you can define array (multiple valued) parameters. ANSYS arrays can be • • • One-dimensional (a single column) Two-dimensional (rows and columns) Three-dimensional (rows, columns, and planes) ANSYS provides three types of arrays ARRAY This type is similar to FORTRAN 77 arrays and is the default array type when dimensioning arrays. As with FORTRAN arrays, the indices for rows, columns, and planes are sequential integer numbers beginning with one. Array elements can be either integers or real numbers. CHAR This is a character array, with each element consisting of an alphanumeric value not exceeding eight characters. The indices for rows, columns, and planes are sequential integer numbers beginning with one. TABLE This is a special type of numeric array which allows ANSYS to calculate (through linear interpolation) values between these array elements explicitly defined in the array. Moreover, you can define the array indices for each row, column, and plane and these indices are real (not integer) numbers. Array elements can be either integers or real numbers. As we'll see in the later discussion on TABLE arrays, this capability provides a powerful method for describing mathematical functions. STRING 78 You can use the *DIM, STRING capability to enter character strings into your arrays. Index numbers for columns and planes are sequential values beginning with 1. Row indices are determined by the character position in the string. See the *DIM command for more information. All three types of arrays can have up to 231 -1 rows, columns, and planes. 7.1.7. Array Parameter Basics Consider a two-dimensional array (either ARRAY or CHAR). It is m rows long and n columns wide; that is, its dimensions are m times n. Each row is identified by a row index number i, which varies from 1 to m, and each column is identified by a column index number j, which varies from 1 to n. The quantities that make up the array are array elements. Each array element is identified as (i,j), where i is its row index number and j is its column index number. We can extend these definitions to a three-dimensional array parameter, which may be m rows long, n columns wide, and p planes deep. The plane index number is k, which varies from 1 to p. Each array element is identified as (i,j,k,). A type CHAR array parameter is structured similarly to an ARRAY parameter, with the tabular values being alphanumeric character strings (up to eight characters). 7.1.8. TABLE Type Array Parameters A type TABLE array parameter consists of numbers (alphanumeric values are not valid) arranged in a tabular fashion, much like the ARRAY type. However, there are three important differences • • • ANSYS can calculate (through linear interpolation) any values that fall between the explicitly declared array element values. A table array contains a 0 row and 0 column used for data-access index values, and unlike standard arrays, these index values can be real numbers. The only restriction is that the index values must be numerically increasing (never decreasing) numbers. You must explicitly declare a data access index value for each row and column; otherwise the default value assigned is the "tiny number" (7.888609052E-31). A plane index value resides in the 0,0 location for each plane. 7.1.9. Defining and Listing Array Parameters To define an array parameter, you must first declare its type and dimensions using the *DIM command (Utility Menu>Parameters>Array Parameters>Define/Edit). This following examples illustrate the *DIM command used to dimension various types of arrays: 79 *DIM,AA,,4 ! Type ARRAY is default, dimension 4[x1x1] *DIM,XYZ,ARRAY,12 ! Type ARRAY array, dimension 12[x1x1] *DIM,FORCE,TABLE,5 ! Type TABLE array, dimension 5[x1x1] *DIM,T2,,4,3 ! Dimensions are 4x3[x1] *DIM,CPARR1,CHAR,5 ! Type CHAR array, dimension 5[x1x1] 7.1.10. Note Array elements for ARRAY and TABLE are initialized to 0 (except for the 0 row and column for TABLE, which is initialized to the tiny value). Array elements for CHAR are initialized to a blank value. 7.1.11. Specifying Array Element Values You can specify array element values by • • • • Setting individual array element values through the *SET command or "=" shortcut. Filling individual vectors (columns) in the array with either specified or calculated values (the *VFILL command, for example). Interactively specifying values for the elements through the *VEDIT dialog box. Reading the values from an ASCII file (*VREAD or *TREAD commands). Specifying Individual Array Values You can use either the *SET command or the "=" shortcut. Usage is the same as for scalar parameters, except that you now define a column of data (up to ten array element values per "=" command). Filling Array Vectors You can use the *VFILL command (Utility Menu>Parameters>Array Parameters> Fill) to "fill" an ARRAY or TABLE vector (column). See the *VFILL command reference information in the ANSYS Commands Reference for more detail about the command syntax. The following example illustrates the capabilities of the *VFILL command. *DIM,DTAB,ARRAY,4,3 ! dimension 4 x 3 numeric array *VFILL,DTAB(1,1),DATA,-3,8,-12,57 ! four data values loaded into vector 1 *VFILL,DTAB(1,2),RAMP,2.54,2.54 ! fill vector 2 with values starting at ! 2.54 and incrementing by 2.54 *VFILL,DTAB(1,3),RAND,1.5,10 ! fill vector 3 with random numbers between ! 1.5 and 10. Results will vary due to ! random number generation. 80 Interactively Editing Arrays The *VEDIT command (Utility Menu>Parameters>Array Parameters>Define/Edit), which is available only in interactive mode, launches a data entry dialog box you can use to edit an ARRAY or TABLE (not CHAR) array. The dialog box provides a number of convenient features: • • • • A spreadsheet-style editor for array element values. Navigational controls for scrolling through large arrays. An initialize function to set any row or column to a specified value (ARRAY type only). Delete, copy, and insert functions for moving rows or columns of data (ARRAY type only). Filling an Array From a Data File Using *VREAD You can fill an array from a data file using the *VREAD command (Utility Menu>Parameters>Array Parameters>Read from File). The command reads information from an ASCII data file and begins writing it into the array, starting with the index location that you specify. You can control the format of the information read from the file through data descriptors. The data descriptors must be enclosed in parenthesis and placed on the line following the *VREAD command. See Vector Operations for more information about data descriptors. The data descriptors control the number of fields to be read from each record, the width of the data fields, and the position of the decimal point in the field. For example, given the following data file named dataval: 1.5 7.8 12.3 15.6 -45.6 42.5 and an array called EXAMPLE that has been dimensioned as 2 x 3, the following commands (provided as either a part or a macro or input listing) *DIM,EXAMPLE,,2,3 *VREAD,EXAMPLE(1,1),dataval,,,JIK,3,2 (3F6.1) result in 1.5 7.8 12.3 EXAMPLE = 15.6 -45.6 42.5 The *VREAD command cannot be issued directly from the command input window. However, the Utility Menu>Parameters>Array Parameters>Read from File dialog box offers a way to specify the data descriptors and issue the command in interactive mode. 81 Filling a TABLE Array From a Data File Using *TREAD Once configured, you have two options for specifying values for the TABLE array elements: you can add values as you would for any other type of array, or you can read in a table of data from an external file. To read in a table of data from an external file, you still define the TABLE array first, specifying the number of rows, columns, and planes, and the labels for each. You can then read an ASCII file containing the table of data using the *TREAD command (Utility Menu>Parameters>Array Parameters>Read from File). At this time, you also specify the number of lines to skip (NSKIP) between the top of the file and the first line of the table. When reading data from an external file, remember: • • • The file containing the table of data can be created in a text editor or an external application (such as Microsoft Excel), but it must be in ASCII form, tabdelimited, to be read into ANSYS. You must first define the array in ANSYS, remembering to allow for the index values (0,0). The values are read straight across the rows until all columns on each row of the array are filled; ANSYS then wraps from one row to the next and begins to fill those columns, and so on. Be sure that the dimensions of the array you defined are correct. If you mistakenly define fewer columns in the ANSYS array than required, ANSYS will start filling in the next row of the array using the values remaining in the first row of the data table being read. Similarly, if you define more columns in the ANSYS array than required, ANSYS will fill all columns of the array using values from the next row of the data table being read, and only then wrap and begin filling the next row. You can create 1-D, 2-D, and 3-D tables by reading data from an external file. Listing Array Parameters As with scalar parameters, you can use the *STATUS command to list array parameters. The following examples illustrate the *STATUS command in use: *STATUS ABBREVIATION STATUSABBREV STRING SAVE_DB SAVE RESUM_DB RESUME QUIT Fnc_/EXIT POWRGRPH Fnc_/GRAPHICS ANSYSWEB Fnc_HomePage PARAMETER STATUS- ( 5 PARAMETERS DEFINED) 82 (INCLUDING 2 INTERNAL PARAMETERS) NAME VALUE TYPE DIMENSIONS MYCHAR hi CHARACTER MYPAR ARRAY 4 6 1 MYPAR1 .987350000 SCALAR *STATUS,XYZ(1),5,9 ! Lists rows 5 through 9 of XYZ PARAMETER STATUS- XYZ ( 4 PARAMETERS DEFINED) LOCATION VALUE 5 1 1 -8.98000000 6 1 1 9.01000000 7 1 1 -30.6000000 8 1 1 51.0000000 9 1 1 -51.9000000 *STATUS,FORCE(1),,,0 ! Lists parameter FORCE, includes j=0 column PARAMETER STATUS- FORCE ( 4 PARAMETERS DEFINED) LOCATION VALUE 1 0 1 0.000000000E+00 2 0 1 0.800000000 3 0 1 7.20000000 4 0 1 8.50000000 5 0 1 9.30000000 1 1 1 0.000000000E+00 2 1 1 560.000000 3 1 1 560.000000 4 1 1 238.500000 5 1 1 0.000000000E+00 *STATUS,T2(1,1) ! Lists parameter T2 PARAMETER STATUS- T2 ( 4 PARAMETERS DEFINED) LOCATION VALUE 1 1 1 0.600000000 2 1 1 2.00000000 3 1 1 -1.80000000 4 1 1 4.00000000 1 2 1 7.00000000 2 2 1 5.00000000 3 2 1 9.10000000 4 2 1 62.5000000 1 3 1 2.000000000E-04 2 3 1 -3.50000000 3 3 1 22.0000000 4 3 1 1.000000000E-02 *STATUS,RESULT(1)!Lists parameter RESULT PARAMETER STATUS- RESULT ( 4 PARAMETERS DEFINED) LOCATION VALUE 1 1 1 SX(CHAR) 2 1 1 SY(CHAR) 3 1 1 SZ(CHAR) 9.2. Local Variables APDL provides two sets of specially named scalar parameters which are available for use as local variables. These consist of 83 • • A set of scalar parameters that provide a way of passing command line arguments to the macro. A set of scalar parameters that can be used within the macro. These provide a set of local variables that can be used to define values only within that macro. The following sections discuss both of these variable types in detail. 7.1.12. Passing Arguments to a Macro There are 19 scalar parameters that you can use to pass arguments from the macro execution command line to the macro. These scalar parameters can be reused with multiple macros; that is, their values are local to each macro. The parameters are named ARG1 through AR19 and they can be used for any of the following items: • • • • Numbers Alphanumeric character strings (up to eight characters enclosed in single quotes) Numeric or character parameters Parametric expressions 7.1.13. Note You can pass only the values of parameters ARG1 through AR18 to a macro as arguments with the *USE command. If you create a macro that can be used as an ANSYS command (the macro files has a .mac extension), you can pass the values of parameters ARG1 through AR19 to the macro. For example, the following simple macro requires four arguments, ARG1, ARG2, ARG3, and ARG4: /prep7 /view,,-1,-2,-3 block,,arg1,,arg2,,arg3 sphere,arg4 vsbv,1,2 finish To execute this macro, a user might enter mymacro,4,3,2.2,1 7.1.14. Local Variables Within Macros Each macro can have up to 79 scalar parameters used as local variables (AR20 through AR99). These parameters are completely local to the macro, and multiple macros can each have their own unique values assigned to these parameters. These parameters are not passed to macros called from macros (nested macros). They are passed to any files processed through a /INPUT command or a "do loop" processed within the macro. 84 7.1.15. Local Variables Outside of Macros ANSYS also has a similar set of ARG1 through AR99 scalar parameters that are local to an input file, and are not passed to any macros called by that input file. Thus, once a macro finishes and execution returns to an input file, the values of ARG1 through ARG99 revert to whatever values were defined within the input file. Controlling Program Flow in APDL When executing an input file, ANSYS is normally restricted to linear program flow; that is, each statement is executed in the order that it is encountered in the listing. However, APDL provides a rich set of commands that you can use to control program flow. • • • • • Call subroutines (nested macros). Branch unconditionally to a specified location with a macro. Branch based upon a condition to a specified location within a macro. Repeat the execution of a single command, incrementing one or more command parameters. Loop through a section of a macro a specified number of times. The following sections detail each of these program control capabilities. For the exact syntax of the commands, refer to the ANSYS Commands Reference. Nested Macros: Calling Subroutines Within a Macro APDL allows you to nest macros up to 20 levels deep, providing functionally similar capability to a FORTRAN 77 CALL statement or to a function call. You can pass up to 19 arguments to the macro and, at the conclusion of each nested macro, execution returns to the level that called the macro. For example, the following simply macro library file shows the MYSTART macro, which calls the MYSPHERE macro to create the sphere. mystart /prep7 /view,,-1,-2,-3 mysphere,1.2 finish /eof mysphere sphere,arg1 /eof Unconditional Branching: Goto The simplest branching command, *GO, instructs the program to go to a specified label without executing any commands in between. Program flow continues from the specified label. For example 85 *GO,:BRANCH1 --- ! This block of commands is skipped (not executed) --:BRANCH1 ----- The label specified by the *GO command must start with a colon (:) and must not contain more than eight characters, including the colon. The label can reside anywhere within the same file. Note The use of *GO is now considered obsolete and is discouraged. See the other branching commands for better methods of controlling program flow. Conditional Branching: The *IF Command APDL allows you to execute one of a set of alternative blocks based on the evaluation of a condition. The conditions are evaluated by comparing two numerical values (or parameters that evaluate to numerical values). The *IF command has the following syntax *IF, VAL1, Oper, VAL2, Base Where • • • • VAL1 is the first numerical value (or numerical parameter) in the comparison. Oper is the comparison operator. VAL2 is the second numerical value (or numerical parameter) in the comparison. Base is the action that occurs if the comparison evaluates as true. APDL offers eight comparison operators, which are discussed in detail in the *IF command reference. Briefly these are: EQ Equal (for VAL1 = VAL2). NE Not equal (for VAL1 ≠ VAL2). LT Less than (for VAL1 < VAL2). GT Greater than (for VAL1 > VAL2). LE Less than or equal (for VAL1 VAL2). 86 GE VAL2). Greater than or equal (for VAL1 ABLT Absolute values of VAL1 and VAL2 before < operation. ABGT Absolute values of VAL1 and VAL2 before > operation. By giving the Base argument a value of THEN, the *IF command becomes the beginning of an if-then-else construct (similar to the FORTRAN equivalent). The construct consists of • • • • An *IF command, followed by One or more optional *ELSEIF commands An optional *ELSE command A required *ENDIF command, marking the end of the construct. In its simplest form, the *IF command evaluates the comparison and, if true, branches to a label specified in the Base argument. This is similar to the "computed goto" in FORTRAN 77. (In combination, a set of such *IF commands could function similarly to the CASE statements in other programming languages.) Take care not to branch to a label within an if-then-else construct or do-loop. If a batch input stream hits an end-of-file during a false *IF condition, the ANSYS run will not terminate normally. You will need to terminate it externally (use either the UNIX “kill” function or the Windows task manager). By setting the Base argument to a value of STOP, you can exit from ANSYS based on a particular condition. An if-then-else construct simply evaluates a condition and executes the following block or jumps to the next statement following the *ENDIF command (shown with the "Continue" comment). *IF,A,EQ,1,THEN ! Block1 . . *ENDIF ! Continue 7.1.16. Repeating a Command The simplest looping capability, the *REPEAT command, allows you to execute the directly preceding command a specified number of times, incrementing any field in that command by a constant value. In the example E,1,2 *REPEAT,5,0,1 87 the E command generates one element between nodes 1 and 2 and the following *REPEAT command specifies that E executes a total of five times (including the original E command), incrementing the second node number by one for each additional execution. The result is five total elements with node connectivities 1-2, 1-3, 1-4, 1-5, and 1-6. 7.1.17. Note Most commands that begin with a slash (/) or an asterisk (*), as well as macros executed as "unknown commands," cannot be repeated. However, graphics commands that begin with a slash can be repeated. Also, avoid using the *REPEAT command with interactive commands, such as those that require picking or those that require a user response. 7.1.18. Looping: Do-Loops A do-loop allows you to loop through a series of commands a specified number of times. The *DO and *ENDDO commands mark the beginning and ending points for the loop. *DO command has the following syntax: The following example do-loop edits five load step files (numbered 1 through 5) and makes the same changes in each file. *DO,I,1,5 ! For I = 1 to 5: LSREAD,I ! Read load step file I OUTPR,ALL,NONE ! Change output controls ERESX,NO LSWRITE,I ! Rewrite load step file I *ENDDO You can add your own loop controls by using the *IF, *EXIT, or *CYCLE commands. Keep the following guidelines in mind when constructing do-loops. • • • • Do not branch out of a do-loop with a :Label on the *IF or *GO commands. Avoid using a :Label to branch to a different line within a do-loop. Use if-thenelse-endif instead. Output from commands within a do-loop is automatically suppressed after the first loop. Use /GOPR or /GO (no response line) within the do-loop if you need to see output for all loops. Take care if you include a /CLEAR command within a do-loop. The /CLEAR command does not clear the do-loop stack, but it does clear all parameters including the loop parameter in the *DO statement itself. You can avoid the problem of having an undefined looping value by issuing a PARSAV command before the /CLEAR command, and then following the /CLEAR command with a PARRES command. 7.1.19. 88 7.1.20. Additional Looping: Do-While You can also perfom looping functions that will repeat indefinitely until an external parameter changes. The *DOWHILE command has the following syntax: *DOWHILE,Parm The loop repeats as long as the parameter Parm is TRUE. If Parm becomes false (less than or equal to 0.0), the loop terminates. The *CYCLE and commands can be used within a *DOWHILE loop. 89 Lesson 12: Macros 9.3. Creating a Macro You can create macros either within ANSYS itself or using your text editor of choice (such as emacs, vi, or wordpad). If your macro is fairly simple and short, creating it in ANSYS can be very convenient. If you are creating a longer, more complex macro or editing an existing macro then you will need a text editor. Also, using a text editor allows you to use a similar macro or ANSYS log file as the source for your macro. For any long, complex macro you should always consider either using a similar macro as a starting point or running the task interactively in ANSYS and using the resulting log file as the basis of your macro. Either method can greatly reduce the time and effort required to create a suitable macro. 7.1.21. Macro File Naming Conventions Macros are a sequence of ANSYS commands stored in a file. Macros should not have the same name as an existing ANSYS command; ANSYS will execute the internal command instead of the macro. The following naming restrictions apply to macro files: • • • • • The file name cannot exceed 32 characters. The file name cannot begin with a numeral. The file extension cannot contain more than eight characters (if you are executing the macro as if it were an ANSYS command it should have the extension .mac.) The file name or extension cannot contain spaces. The file name or extension cannot contain any characters prohibited by your file system and for portability should not contain any characters prohibited by either UNIX or Windows file systems. To ensure that you are not using the name of an ANSYS command, before creating a macro try running the file name that you wish to use as an ANSYS command. If ANSYS returns the message shown below, you will know that the command is not used in the current processor. You should check the macro file name in each processor in which you plan to use the macro. (You could also check if the macro file name matches any command listed in the online documentation; however, this method cannot locate the names of undocumented commands.) Using the .mac extension allows ANSYS to execute the macro as it would any internal command. You should avoid using the extension .MAC because it is used for ANSYS internal macros. 7.1.22. 7.1.23. 7.1.24. Macro Search Path 90 By default, ANSYS searches for a user macro file (.mac extension) in the following locations: 1. The ANSYSnn/docu directory. 2. The directory (or directories) designated by the ANSYS_MACROLIB environment variable (if defined) or the login (home) directory. This environment variable is documented in the ANSYS installation and configuration guide for your platform. 3. The directory designated by the $HOME environment variable. 4. The working directory. You can place macros for your personal use in your home directory. Macros that should be available across your site should be placed in the ANSYSnn/docu directory or some commonly accessible directory that everyone can reference through the ANSYS_MACROLIB environment variable. • • For Windows Me users: You must designate the "home directory" and drive using environment variables, see the ANSYS Installation and Configuration Guide for Windows. For Windows XP, 2000, and NT users: The "current directory" is the default directory (usually a network resource) set by administrators and you should ask your network administrator for its location. You can use environment variables to create a local "home directory." The local home directory is checked after the default directory designated in your domain profile. See the ANSYS Installation and Configuration Guide for Windows for more information. 7.1.25. Creating a Macro Within ANSYS You can create a macro by four methods from within ANSYS: • • • • Issue the *CREATE command in the input window. Parameter values are not resolved and parameter names are written to the file. Use the *CFOPEN, *CFWRITE, and *CFCLOS commands. Parameter names are resolved to their current values and those values are written to the macro file. Issue the /TEE command in the input window. This command writes a list of commands to a file at the same time that the commands are being executed. As the commands are executed in the current ANSYS session, parameter names are resolved to their current values. However, in the file that is created, parameter values are not resolved and parameter names are written instead. Choose the Utility Menu>Macro>Create Macro menu item. This method opens a dialog box that can be used as a simple, multi-line editor for creating macros. Parameter values are not resolved and parameter names are written to the file. The following sections detail each of these methods. 91 Using *CREATE Issuing *CREATE redirects ANSYS commands entered in the command input window to the file designated by the command. All commands are redirected until you issue the *END command. If an existing file has the same name as the macro file name you specify, the ANSYS program overwrites the existing file. For example, suppose that you want to create a macro called matprop.mac, which automatically defines a set of material properties. The set of commands entered into the input window for this macro might look like this: *CREATE,matprop,mac,macros MP,EX,1,2.07E11 MP,NUXY,1,.27 MP,DENS,1,7835 MP,KXX,1,42 *END The *CREATE command takes arguments of the file name, the file extension, and the directory path (in this case, the macros directory is specified). When using *CREATE, all parameters used in commands are written to the file (the currently assigned values for the parameter are not substituted). You cannot use *CREATE within a DO loop. Using *CFWRITE If you wish to create a macro file in which current values are substituted for parameters you can use *CFWRITE. Unlike *CREATE, the *CFWRITE command cannot specify a macro name; you must first specify the macro file with the *CFOPEN command. Only those ANSYS commands that are explicitly prefaced with a *CFWRITE command are then written to the designated file; all other commands entered in the command input window are executed. As with the *CREATE command, *CFOPEN can specify a file name, a file extension, and a path. The following example writes a BLOCK command to the currently open macro file. *cfwrite,block,,a,,b,,c Note that parameters were used for arguments to the BLOCK command. The current value of those parameters (and not the parameter names) are written to the file. So, for this example, the line written to the macro file might be *cfwrite,block,,4,,2.5,,2 To close the macro file, issue the *CFCLOS command. 92 7.1.26. Note While it is possible to create a macro through this method, these commands are most useful as a method for writing ANSYS commands to a file during macro execution. Using /TEE Issuing /TEE,NEW or /TEE,APPEND redirects ANSYS commands entered in the command input window to the file designated by the command at the same time that the commands are being executed. All commands are executed and redirected until you issue the /TEE,END command. If an existing file has the same name as the macro file name you specify with /TEE,NEW, the ANSYS program overwrites the existing file. To avoid this, use /TEE,APPEND instead. In addition to the Label argument (which can have a value of NEW, APPEND, or END), the /TEE command takes arguments of the file name, the file extension, and the directory path. As the commands are executed in the current ANSYS session, all parameter names are resolved to their current values. However, in the file that is created, parameter names are written (the currently assigned values for the parameter are not substituted). If your current parameter values are important, you can save the parameters to a file using the PARSAV command. For an example, see the description of the /TEE command in the ANSYS Commands Reference. Using Utility Menu>Macro>Create Macro Choosing this menu item opens an ANSYS dialog box that you can use as a simple editor for creating macros. You cannot open and edit an existing macro with this facility; if you use the name of an existing macro as the arguments for the *CREATE field, the existing file will be overwritten. As with the *CREATE command, parameters are not evaluated but are written verbatim into the macro file. Note that you do not make the last line a *END command. 7.1.27. Creating Macros with a Text Editor You can use your favorite text editor to create or edit macro files. Any ASCII editor will work. Moreover, ANSYS macros can have their lines terminated by either UNIX or Windows line ending conventions (carriage-return, line-feed pairs or simply line-feeds) so you can create a macro on one platform and use it on several platforms. If you use this method to create macros, do not include the *CREATE and *END commands. 93 7.1.28. Using Macro Library Files As a convenience, ANSYS allows you to place a set of macros in a single file, called a macro library file. You can create these either through the *CREATE command or through a text editor. Given that macro libraries tend to be longer than single macros, using a text editor normally provides the best approach. Macros libraries have no explicit file extension and follow the same file naming conventions as macro files. A macro library file has the following structure: MACRONAME1 . . . /EOF MACRONAME2 . . . /EOF MACRONAME3 . . . ./EOF For example, the following macro file contains two simple macros: mybloc /prep7 /view,,-1,-2,-3 block,,4,,3,,2 finish /EOF mysphere /prep7 /view,,-1,-2,-3 sphere,1 finish /EOF Note that each macro is prefaced with a macro name (sometimes refered to as a data block name) and ends with a /EOF command. A macro library file can reside anywhere on your system, although for convenience you should place it within the macro search path. Unlike macro files, a macro library file can have any extension up to eight characters. 94 9.4. Interfacing with the GUI Within an ANSYS macro, you have several ways to access components of the ANSYS graphical user interface (GUI): • • • • • • • You can modify and update the ANSYS toolbar (this is discussed in detail in Adding Commands to the Toolbar). You can issue the *ASK command to prompt a user to enter a single parameter value. You can create a dialog box to prompt a user to enter multiple parameter values. You can issue the *MSG command to have the macro write an output message. You can have the macro update or remove a status bar. You can allow the user to select entities through graphical picking from within a macro. You can call any dialog box. 9.5. Executing Macros and Macro Libraries You can execute any macro file by issuing the *USE command. For example, to execute the macro called MYMACRO (no extension) residing somewhere in the macro search path, you would issue *use,mymacro In this case, the macro takes no arguments. If instead the macro was called MYMACRO.MACRO and resided in /myaccount/macros, you could call it with *use,/myaccount/macros/mymacro.macro Note that the *USE command allows you to enter the path and extension along with the file name and that these are not entered as separate arguments. If a macro has a .mac file extension and resides in the search path, you can execute it as if it were an ANSYS command by simply entering it in the command input window. For example, to call mymacro.mac you could simply enter mymacro You can also execute macros with a .mac extension through the Utility Menu>Macro>Execute Macro menu item. If the same macro takes arguments (see Passing Arguments to a Macro for more information about passing arguments to macros), then these can be entered on the command line as follows mymacro,4,3,2,1.5 95 or *use,mymacro.mac,4,3,2,1.5 The Utility Menu>Macro>Execute Macro menu item dialog provides fields for arguments. Executing macros contained in macro libraries is similar. You must first specify the library file using the *ULIB command. For example, to specify that macros are in the mymacros.mlib file, which resides in the /myaccount/macros directory, you would issue the following command: *ulib,mymacros,mlib,/myaccount/macros/ After selecting a macro library, you can execute any macro contained in the library by specifying it through the *USE command. As with macros contained in individual files, you can specify arguments as parameters in the *USE command. 7.1.29. Note You cannot use the *USE command to access macros not contained in the specified macro library file after issuing the *ULIB command. 96 97