# 20. Parametric Studies Scripting parametric studies 20.1 Parametric studies: commands 20.2 # 20.1 Scripting parametric studies • “Scripting parametric studies,” Section 20.1.1 # 20.1.1 SCRIPTING PARAMETRIC STUDIES Products: Abaqus/Standard Abaqus/Explicit # References • “Parametric input,” Section 1.4.1 • “Parametric shape variation,” Section 2.1.2 • “Parametric studies,” Section 3.2.11 # Overview Parametric studies allow you to generate, execute, and gather the results of multiple analyses that differ only in the values of some of the parameters used in place of input quantities. Parametric studies can be performed by: • Creating a “template” parametrized input file from which the different parametric variations are generated. • Preparing a script (a file with the .psf extension) that contains Python (Lutz, 1996) instructions to generate, execute, and gather output for the parametric variations of the parametrized input file. The Python commands for scripting parametric studies are discussed in this section. # Introduction Parametric studies require that multiple analyses be performed to provide information about the behavior of a structure or component at different design points in a design space. The inputs for these analyses differ only in the values assigned to the parameters of a parametrized keyword input file (identified with the .inp extension). Parametric studies in Abaqus require a user-developed Python script in a file (identified with the .psf extension) that contains Python commands to define the parametric study. For example, consider a case where you wish to perform a parametric study in which the thickness of a shell is varied. You need to create a parametrized input file (in this example, a file named shell.inp) containing the parameter definition ```txt *PARAMETER thick1 = 5. ``` and the parameter usage: ```txt *SHELL SECTION, ELSET=name, MATERIAL=name ``` You create the parametric study by developing a .psf file that contains a script of Python instructions specifying the different designs that are to be analyzed, as follows: ```txt thick = ParStudy(par='thick1', name='shell') thick.define(CONTINUOUS, par='thick1', domain=(10., 20.)) thick.sample(NUMBER, par='thick1', number=5) thick.combine(MESH) ``` These scripting commands create five designs with corresponding section thicknesses of 10., 12.5, 15., 17.5, and 20.0. Each of these thicknesses will, in turn, replace the value of 5. specified in the parameter definition in shell.inp. You may then provide additional Python scripting commands in the .psf file instructing Abaqus to do the following: • Generate a number of shell\_id.inp files and corresponding Abaqus jobs using the shell.inp file as a template. (The identifier id that is appended to the input file name is unique to each design in the parametric study.) An example of the Python command for this is ```javascript thick.generate(template='shell') ``` In this example the shell\_id.inp files will differ only in the value to be used for the shell thickness. • Execute all the Abaqus jobs representing the different variations of the parametric study. The Python command for this is ```javascript thick.execute(ALL) ``` You generally want to review certain key results from the large amount of data that is generated by a parametric study. Abaqus provides the following capabilities for this purpose: • A command specifying the source from which the results of a parametric study will be gathered. For example: ```python thick.output(file=ODB, step=1, inc=LAST) ``` The command above sets the output location to the last frame of the first step in the output database (.odb) file. The default behavior is to gather results from the last frame of a given step in the results (.fil) file. • Commands to gather the required results from the multiple analyses generated by the parametric study and report them in a file or table. For example, the sequence of Python scripting commands used to gather and report the value of a displacement at a key node for each of the designs is: ```python thick.gather(results='n33_u', variable='U', node=33, step=1) thick.report(PRINT, par='thick1', results=('n33_u.2')) ``` The commands above gather the results record ’n33\_u’ (the displacement vector of node 33 at the end of Step 1 of the analysis) for each of the designs and then print a table of the U2 component (the second component of the results record) of displacement for all designs. • The ability to visualize X–Y plot data gathered across multiple analyses using the Visualization module of Abaqus/CAE. A typical example is to obtain an X–Y plot of the value of the displacement at a key node versus the value of the shell thickness. This is done by gathering the appropriate parametric study results in an ASCII file that can be read into the Visualization module to display the plot. # Organization of parametric studies A parametric study in Abaqus is associated with a particular set of parameters that define the design space. Only the values of the parameters can change in a parametric study. A new parametric study must be created if you wish to consider a different set of parameters. Having selected the parameters to be considered in a parametric study, you must specify how each parameter is defined. Parameters are distinguished as either continuous or discrete in nature and may have a domain and reference value. The design points in the design space that are to be analyzed are created by specifying sample values for each parameter (sampling) and by combining the parameter samples to create sets of design points. A few simple commands are provided for parameter value sampling and for combining the sampled parameter values; these commands are described in detail later. An initial definition and sampling of the parameters in the parametric study must be given before any combinations of parameter samples can be specified. After the first combination the initial definition and/or sampling of any individual parameter can be changed before the next combination is specified, thus providing a great deal of flexibility within one parametric study. The domain of possible values and the reference value for a parameter given in the parameter definition can be temporarily redefined in any sampling of that parameter by specifying them differently during the sampling. You need not specify the parameter domain and reference value in the parameter definition so long as these are specified during sampling. Design constraints can be imposed on all of the designs. A design that violates any of the constraints will be eliminated. Finally, after all parametric study variations have been analyzed, you can gather and report results across all or some of the designs of the parametric study. In summary, parametric studies in Abaqus are organized as follows: • Create parametric study. • Define parameters: define parameter type (continuous or discrete valued) and possibly the parameter domain and reference value. • Sample parameters: specify sampling option and data and possibly temporarily redefine the parameter domain and reference value. • Combine parameter samples to create sets of designs. • Constrain designs (optional). • Generate designs and analysis job data. • Execute the analysis jobs for selected designs of the study. • Gather key results for selected designs of the study. • Report gathered results. Note: The sequence of steps—define, sample, and combine—can be repeated as often as is necessary to create all the required design sets. Multiple parametric studies can be performed on a model contained in one input file. In general, more parameters will be defined and used in place of input quantities in the input file than those involved in any particular parametric study. In these cases parameters not involved in a particular parametric study will retain their values defined in the input file for the purposes of that parametric study. Therefore, we can think of the parameter values defined in the input file as representing a nominal design; parametric studies create modified designs by overwriting the values of some (or all) parameters. # Defining the design space The design space is defined by the selection of the parameters to be varied in the study as well as the specification of the parameter types and possible values they can have. # Parametric study creation Use the aStudy=ParStudy scripting command (see “Create a parametric study.,” Section 20.2.8) to create a parametric study and select the independent parameters to be considered for variation. aStudy is the Python variable name assigned by you to the parametric study object created by the command. The methods of the parametric study object are used to carry out all the actions of the parametric study. Input File Usage: aStudy=ParStudy (par=, name=, verbose=, directory=) # Parameter definition Use the aStudy.define command (see “Define parameters for parametric studies.,” Section 20.2.3) to specify the parameter type (choose the CONTINUOUS or the DISCRETE token; a token is a symbolic constant used to select an option within a specific command) and, optionally, to specify the domain of possible parameter values and a reference value for the parameter. If the domain and/or reference value are not specified in this command, they can be specified in the parameter sampling. Redefinitions of a parameter are treated as complete redefinitions; that is, no information is retained from the previous definition of that parameter. Input File Usage: aStudy.define (token, par=, domain=, reference=) # CONTINUOUS parameter type In this case the parameter can take any value in a continuous domain specified by minimum and maximum values; for example, domain=(3., 10.). # DISCRETE parameter type In this case the parameter can take only the values specified in a list that defines the discrete domain; for example, domain=(1, 4, 9, 16). # Sampling and combining parameter values to create sets of design points Each parameter in the parametric study must be sampled before the combination operation is used to create the first set of design points. Any parameter in the parametric study can be redefined or resampled before a subsequent combination operation is performed. # Parameter sampling Use the aStudy.sample command (see “Sample parameters for parametric studies.,” Section 20.2.10) and choose one of the available tokens (INTERVAL, NUMBER, REFERENCE, or VALUES) to select how the sampling is done. The sampling data that must be given depend on how the sampling is done, as described next. # Sampling by INTERVAL This sampling command assumes that you specify a domain of possible parameter values and wish to sample parameter values at fixed intervals in the domain. Sampling of the extreme values of the parameter is always done. The number of parameter values sampled depends on the interval and the domain. Because the extreme values are sampled, the last sampling interval will generally be smaller than the interval you specify. The domain specification in this sampling command is optional: • If a domain is specified in this command, it temporarily redefines a domain specified in the define command. • If a domain is not specified in this command, the domain specification from the define command is used for sampling. • An error is flagged when a domain is not specified in this command or in the define command. The sampling interval is interpreted differently for continuous and discrete parameters: • For continuously valued parameters the interval at which the samples are spaced is based on a numerical value. For example, specifying interval=10. for a continuous parameter with domain=(10., 35.) will sample values of 10., 20., 30., and 35. for this parameter. • For discrete valued parameters the interval at which the samples are spaced is based on the index of the list of values. The index means the position of the entry in the list, starting at position 0 and continuing with positions 1, 2, 3, etc. In this case interval must be an integer number. For example, specifying interval=−2 for a discrete parameter with domain=(1., 2., 3., 5., 7., 10.) will create sample values of 10., 5., 2., and 1. for this parameter. The interval can have a positive or negative value (zero is not permitted). A positive interval indicates that sampling starts at the minimum value for a continuous parameter or at the first value in the list of values for a discrete parameter (forward sampling). A negative interval indicates that sampling starts at the maximum value for a continuous parameter or at the last value in the list of values for a discrete parameter (reverse sampling). Reverse sampling is useful when the TUPLE combination operation is used (see the discussion of combination of parameter samples). Two special cases of the INTERVAL option are noteworthy: • A positive interval value larger than the range of continuous parameter values or the number of discrete parameter values will sample the minimum and maximum values of the continuous parameter or the first and last values in the discrete parameter list. • A negative interval value larger (in absolute terms) than the range of continuous parameter values or the number of discrete parameter values will sample the maximum and minimum values of the continuous parameter or the last and first values in the discrete parameter list. Input File Usage: aStudy.sample (INTERVAL, par=, interval=, domain=) # Sampling by NUMBER This sampling option assumes that you specify a domain of possible parameter values and wish to sample a fixed number of parameter values in the domain. Except for a special case documented below, sampling of the extreme values of the parameter is always done. The parameter is sampled at equally spaced intervals (with some exceptions for discrete parameters, as discussed below) and the size of the interval depends on the number of values sampled as well as the domain. The domain specification in this sampling command is optional: • If a domain is specified in this command, it temporarily redefines the domain specified in the define command. • If a domain is not specified in this command, the domain specification from the define command is used for sampling. • An error is flagged when a domain is not specified in this command or in the define command. The sampling interval is calculated and interpreted differently for continuous and discrete parameters: • For continuous valued parameters the interval at which the samples are spaced is based on a numerical value. For example, specifying number=4 for a continuous parameter with domain=(10., 25.) will sample values of 10., 15., 20., and 25. for this parameter. • For discrete valued parameters the interval at which the samples are spaced is based on the index of the list of values (indexing starts at zero). For example, specifying number=3 for a discrete parameter with domain=(1., 2., 3., 5., 7., 10., 12.) will create sample values of 1., 5., and 12. for this parameter. The number of discrete parameter samples specified by you may not allow equally spaced sampling; for example, specifying number=5 or number=6 for the discrete parameter above does not allow equally spaced sampling. This is resolved by sampling the parameter values that are closest to being equally spaced by rounding the sampling index to the closest index in the list of values. For example, specifying number=5 for the discrete parameter above will create sample values of 1., 3., 5., 10., and 12. The values 1. and 12. are sampled because they are the extreme values. The explanation for the second sampled value being the third value in the list (the value 3.) is as follows: the sampling interval is (highest index − lowest index)/(number − 1) = (6 − 0)/(5 − 1) = 1.5; the second sampled value should then be the one with index = 0 + 1.5 = 1.5 in the list; since the index has to be an integer number, we round off to index = 2 and, thus, sample the third value in the list. The other sampled values can be explained similarly. The same rule is used for character string type discrete parameters. For example, specifying number=3 for a discrete parameter with