The code example below shows how to define a material model in Python using AML Python Module. Run this code in anspython.
import ansys.mapdl.materials.aml as aml import numpy as np # Material Definition mymaterial = aml.material(1) mylist = [10,-1,1e-3] myfld = dict() myfld['temp'] = 0.0 mymaterial.add_table("hype","moon",myfld,mylist) mymaterial.print("hype","moon") # Calling the driver disp = 0.1 # Assuming an example uniaxial stress state l2 can be calculated as sqrt(1/l1) l1 = 1+disp l2 = (1/(l1))**0.5 #solution parameters solutiondata = dict() solutiondata['time'] = 101.0 solutiondata['dtime'] = 0.0 defgrad_t = [1,0,0,0,1,0,0,0,1] defgrad = [l1,0,0,0,l2,0,0,0,l2] outputstress = [] jacobian = [] mymaterial.initialize() [outputstress,jacobian,status] = mymaterial.evaluate(solutiondata,defgrad_t,defgrad) print("Stress is ", outputstress) jacobmatrix = np.array(jacobian) jacobmatrix = jacobmatrix.reshape((6,6)) print('Material Algorithms Converged Status is', status['converged']) print("Jacobian :") print(jacobmatrix)