6.3. AML Python Module Classes and Methods

This table describes the classes and methods of AML Python Module.

ClassMethod

material(Boost.Python.instance)

Define, explore, and study material models.

_init_(material id): Constructor given a material ID.

  • Parameters:

    • material id: int. The material ID.

  • Return: None.

add_table(self, tbtype, tbopt, fldvar, params): Add a material table at the field variable combination.

  • Parameters:

    • self: material. This material object.

    • tbtype: str. Table type.

    • tbopt: str. Table option.

    • fldvar: dict. Field variable dictionary. fldvarobj['temp'] = 100,...

    • params: list. List of items representing material parameters.

      • For tbdata style input: List of doubles (for example, [1e6, 0.3]).

      • For tbpt style input: List of doubles (for example, [0, 100, 0.2, 200]) or list of lists (for example, [[0, 100], [0.1, 200]]).

  • Return: bool. True if successful. False if failed.

delete_table(self, tbtype, tbopt): Delete a material table.

  • Parameters:

    • self: material. This material object.

    • tbtype: str. Table type.

    • tbopt: str. Table option.

  • Return: bool. True if successful. False if failed.

delete_table(self, tbtype, tbopt, index): Delete a material sub-table.

  • Parameters:

    • self: material. This material object.

    • tbtype: str. Table type.

    • tbopt: str. Table option.

    • index: int. Index of sub-table to be deleted.

  • Return: bool. True if successful. False if failed.

evaluate(self, solverparams, defgrad_t, defgrad): Material driver call to take deformation gradients as inputs and return the material stress and tangent for large deformation problems.

  • Parameters:

    • self: material. This material object.

    • solverparams: dict. Dictionary of solution parameters.

      • 'time': Time.

      • 'dtime': Time increment.

      • 'tref': Reference temperature.

    • defgrad_t: list. The previous deformation gradient.

    • defgrad: list. The new deformation gradient at which the evaluation is done.

  • Return: list. List of output items.

    • stress: list. Calculated stress.

    • jacobian: list. Calculated material Jacobian.

    • additional info: dict. Dictionary of additional output. additionalinfo['converged'] gives the material converged status.

evaluate(self, solverparams, currentstrain): Material driver call to take strain tensors as inputs and return the material stress and tangent.

  • Parameters:

    • self: material. This material object.

    • solverparams: dict. Dictionary of solution parameters.

      • 'time': Time.

      • 'dtime': Time increment.

      • 'tref': Reference temperature.

    • currentstrain: list. Current strain tensors.

  • Return: list. List of output items.

    • stress: list. Calculated stress.

    • jacobian: list. Calculated material Jacobian.

    • additional info: dict. Dictionary of additional output. additionalinfo['converged'] gives material converged status.

get_state(self): Get material state variables.

  • Parameters:

    • self: material. This material object.

  • Return: dict. Dictionary of state variables.

initialize(arg1): Prepare the material data for the material drivers.

  • Parameters:

    • arg1: material.

  • Return: None.

print(self, matid, tbtype): Print a material table.

  • Parameters:

    • self: material. This material object.

    • matid: int. Material ID.

    • tbtype: str. Table type.

  • Return: bool. True if successful. False if failed.

set_state(self, statevars): Set material state variables.

  • Parameters:

    • self: material. This material object.

    • statevars: dict. Dictionary of state variables.

  • Return: bool. True if successful. False if failed.

fit(Boost.Python.instance)

Curve fit material models.

_init_(fitting object id): Constructor given a fitting object ID.

  • Parameters:

    • fitting object id: int. The fitting object ID.

  • Return: None.

add_experiment(self, exptype, filename): Add experimental data in command delimited form to be fitted.

  • Parameters:

    • self: fit. This fit object.

    • exptype: str. Experiment type.

    • filename: str. File to read the experiment data from.

      For more information, see Material Curve-Fitting.

  • Return: bool. True if successful. False if failed.

create_fit(self, fittingobjectname): Create a parameter fitting object.

  • Parameters:

    • self: fit. This fit object.

    • fittingobjectname: str. Unique name associated with the fitting object.

  • Return: bool. True if successful. False if failed.

fix_parameter_value(self, fitname, index, flag): Fix a parameter value to be constant in the fitting process.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • index: int. Index of the parameter.

    • flag: bool. Set to True to fix the parameter value to be constant. Set to False to free the parameter.

  • Return: bool. True if successful. False if failed.

generate_fitted_data(self, fitname, expindex): Get fitted values.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • expindex: int. Index of the experiment to get the data for.

  • Return: list. List of lists.

    • Dimension list (nrow, num ind cols, num dep cols, num fitted cols). The fitted value table dimensions.

      • nrow: int. Number of rows.

      • num ind cols: int. Number of independent columns.

      • num dep cols: int. Number of dependent columns.

      • num fitted cols: int. Number of fitted columns.

    • Data list: List of fitted values.

get_parameter_bounds(self, fitname, index): Get the parameter fitting coefficient bounds.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • index: int. Index of the coefficient, from 1 to the maximum number of coefficients.

  • Return: list. List of bound values.

get_parameter_values(self, fitname): Get the list of parameter values.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

  • Return: list. List of parameter values.

print(self): Print the parameter fitting object.

  • Parameters:

    • self: fit. This fit object.

  • Return: bool. True if successful. False if failed.

set_parameter_bounds(self, fitname, index, bounds): Set the parameter fitting coefficient bounds.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • index: int. Index of the coefficient, from 1 to the maximum number of coefficients.

    • bounds: list. List that includes the lower and upper bounds.

  • Return: bool. True if successful. False if failed.

set_parameter_values(self, fitname, paramlist): Set the parameter values.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • paramlist: list. Parameter value list.

  • Return: bool. True if successful. False if failed.

solve(self, fitname, numiter, errnorm, cctol, rctol): Fit a paramter fitting object.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • numiter: int. Number of iterations.

    • errnorm: int. Error normalize type. Use 1 for normalized least squares. Use 0 for unnormalized least squares.

    • cctol: double. Coefficient change tolerance value.

    • rctol: double. Residual change tolerance value.

  • Return: bool. True if successful. False if failed.

solve(self, fitname, solutionparams): Fit a paramter fitting object.

  • Parameters:

    • self: fit. This fit object.

    • fitname: str. Unique name associated with the fitting object.

    • solutionparams: dict. Dictionary that includes the following variables:

      • algorithm: string. Use lm for levenberg-marquardt or ga for genetic algorithms.

      • numiteration: int. Number of iterations.

      • initialpopulation: int. Initial population for generic algorithms.

      • errnorm: int. Error normalize type. Use 1 for normalized least squares. Use 0 for unnormalized least squares.

      • cctolerance: double. Coefficient change tolerance value.

      • rctolerance: double. Residual change tolerance value.

  • Return: bool. True if successful. False if failed.

output(Boost.Python.instance)

Manage console output.

get_print_status(self): Get the print status.

  • Parameters:

    • self: output. This output object.

  • Return: bool. True if printing to console is enabled. False if printing to console is disabled.

set_print_status(self, arg1): Set the print status.

  • Parameters:

    • self: output. This output object.

    • arg1: bool. Set to True to enable printing to console. Set to False to disable printing to console.

  • Return: None.

license(Boost.Python.instance)

Manage licenses.

checkin(self): Release the license.

  • Parameters:

    • self: license. This license object.

  • Return: None.

checkout(self): Initialize the license.

  • Parameters:

    • self: license. This license object.

  • Return: bool. True if successful. False if failed.

After you import AML in anspython, you can also access information about AML Python Module classes and methods via Pydoc on these two platforms:

  • To access information in the Python help utility, enter the help(ansys.mapdl.materials.aml) command in the command prompt.

  • To open AML Python Module documentation in your preferred web browser, follow these steps:

    1. Run the command python -m pydoc -p 1234. You can also specify 0 as the port number to select an arbitrary unused port.

    2. Input b for browser when prompted. This will start an HTTP server on the chosen port in your browser.

    3. To open the AML Python Module documentation, type ansys.mapdl.materials.aml in the search window of the main documentation page or follow this link.