ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
423 stars 120 forks source link

Some tbft commands are not working. #1074

Closed raviraj3997 closed 2 years ago

raviraj3997 commented 2 years ago

I was trying to create python (pyMAPDL) script from working mapdl script. I translated the script form mapdl to pyMAPDL using below code. While running this code in jupyter notebook I observed that result is not correct.

from ansys.mapdl import core as pymapdl
inputfile = 'mapdl_input.dat'
pyscript = 'pyscript.py'
pymapdl.convert_script(inputfile, pyscript)

Just to pinpoint the issues I printed out the output from each commands, some of the commands gave 'None' as output. However in mapdl this has some output. (Commands are marked as # NOT WORKING)

print(mapdl.prep7())
# Enter the elastic properties. If you have data for 3 temperatures, enter Young's modulus and
# mu for each temperature
print(mapdl.tb("elas", 1))
print(mapdl.tbtemp(0))
print(mapdl.run("tbdat,,1.5e5,0.3"))
print(mapdl.tbtemp(100))
print(mapdl.run("tbdat,,1.3e5,0.3"))
print(mapdl.tbtemp(200))
print(mapdl.run("tbdat,,1.2e5,0.3"))

# Define the Chaboche material property order 3
print(mapdl.tb("chab", 1, 2, 2))
print(mapdl.tbtemp(0))
print(mapdl.tbdata(1, 150, 1, 1, 1, 1))
print(mapdl.tbtemp(100))
print(mapdl.tbdata(1, 130, 1, 1, 1, 1))
print(mapdl.tbtemp(200))
print(mapdl.tbdata(1, 120, 1, 1, 1, 1))

# Import material parameters
print(mapdl.tbft("fadd", 1, "aml", "genr", "myfit"))         # NOT WORKING

# Add experimental data
print(mapdl.tbft("eadd", 1, "unia", "a0.exp"))
print(mapdl.tbft("eadd", 1, "unia", "a100.exp"))
print(mapdl.tbft("eadd", 1, "unia", "a200.exp"))

# Automatically initialize the parameters
print(mapdl.tbft("aini", 1, "aml", "genr", "myfit"))         # NOT WORKING

# List the properties and experimental data
print(mapdl.tbft("list", 1))                                 # NOT WORKING

# Solve for Parameters
print(mapdl.tbft("solve", 1, "aml", "genr", "myfit", 1, 100))         # NOT WORKING

# Plot
# TPLT,materialid,'amgenrmyfit',EXPINDEX,COLX,COLY1,COLY2
# COLY1 is stress here
# COLY2 = NCOL+1 has the calculated stress value         # NOT WORKING
print(mapdl.run("TBFPLOT,1,'amgenrmyfit',3,1,2,3"))

# Export to TB table database
print(mapdl.tbft("fset", 1, "aml", "genr", "myfit"))          # NOT WORKING
print(mapdl.run("tblis,all,all"))
print(mapdl.run("fini"))
# mapdl.run("/exit")
print(mapdl.exit())

Output:

*** ANSYS - ENGINEERING ANALYSIS SYSTEM  RELEASE 2022 R1          22.1     ***
 DISTRIBUTED Ansys Mechanical Enterprise                       

 00000000  VERSION=WINDOWS x64   10:54:16  APR 27, 2022 CP=      0.312

          ***** ANSYS ANALYSIS DEFINITION (PREP7) *****
ISOTROPIC ELASTIC OPTION FOR MATERIAL 1
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  0.0000
    TEMPERATURE SPECIFICATION=  1
DATA FOR  ELAS  TABLE FOR MATERIAL   1
 LOC=  1 1.50000e+05     3.00000e-01
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  100.0000
    TEMPERATURE SPECIFICATION=  2
DATA FOR  ELAS  TABLE FOR MATERIAL   1
 LOC=  1 1.30000e+05     3.00000e-01
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  200.0000
    TEMPERATURE SPECIFICATION=  3
DATA FOR  ELAS  TABLE FOR MATERIAL   1
 LOC=  1 1.20000e+05     3.00000e-01
DEFINE DATA TABLE  CHAB  FOR MATERIAL 1 
 NONLINEAR KINEMATIC/ISOTROPIC HARDENING MODEL 
 WITH A MAXIMUM OF 2 TEMPERATURES AND 2 KINEMATIC COMPONENTS 5DATA POINTS
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  0.0000
    TEMPERATURE SPECIFICATION=  1
DATA FOR  CHAB  TABLE FOR MATERIAL   1 AT TEMPERATURE=  0.0000    
 LOC=  1 1.50000e+02     1.00000e+00     1.00000e+00     1.00000e+00     1.00000e+00
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  100.0000
    TEMPERATURE SPECIFICATION=  2
DATA FOR  CHAB  TABLE FOR MATERIAL   1 AT TEMPERATURE=  100.0000    
 LOC=  1 1.30000e+02     1.00000e+00     1.00000e+00     1.00000e+00     1.00000e+00
TEMPERATURE TO BE USED FOR THE NEXT TBDAT COMMAND=  200.0000
    TEMPERATURE SPECIFICATION=  3
DATA FOR  CHAB  TABLE FOR MATERIAL   1 AT TEMPERATURE=  200.0000    
 LOC=  1 1.20000e+02     1.00000e+00     1.00000e+00     1.00000e+00     1.00000e+00
None
Successfully Constructed Material Model 1 
 Successfully added Experimental Data for Material 1.
Successfully Constructed Material Model 1 
 Successfully added Experimental Data for Material 1.
Successfully Constructed Material Model 1 
 Successfully added Experimental Data for Material 1.
None
None
None
None
None
LIST DATA TABLE  ALL   FOR ALL MATERIALS

 *** ANSYS - ENGINEERING ANALYSIS SYSTEM  RELEASE 2022 R1          22.1     ***
 DISTRIBUTED Ansys Mechanical Enterprise                       

 00000000  VERSION=WINDOWS x64   10:54:16  APR 27, 2022 CP=      0.359

               N.L. KIN (CHAB) Table For Material     1
                     1             2             3 
 Temps     0.0000000e+00 1.0000000e+02 2.0000000e+02 
 C 1      1.5000000e+02 1.3000000e+02 1.2000000e+02 
 C 2      1.0000000e+00 1.0000000e+00 1.0000000e+00 
 C 3      1.0000000e+00 1.0000000e+00 1.0000000e+00 
 C 4      1.0000000e+00 1.0000000e+00 1.0000000e+00 
 C 5      1.0000000e+00 1.0000000e+00 1.0000000e+00 

               ELASTIC  (ELAS) Table For Material     1
                     1             2             3 
 Temps     0.0000000e+00 1.0000000e+02 2.0000000e+02 
 C 1      1.5000000e+05 1.3000000e+05 1.2000000e+05 
 C 2      3.0000000e-01 3.0000000e-01 3.0000000e-01
***** ROUTINE COMPLETED *****  CP =         0.359
None

I have attached files for your reference: @ summary_shared.zip

  1. CASE_1_mapdl_input.dat: working mapdl script
  2. CASE_2_pyMAPDL_script_with_file_INPUT.ipynb: WORKIGN if used with mapdl.INPUT()
    mapdl = launch_mapdl(run_location=os.getcwd(), loglevel="WARNING", print_com=True)
    mapdl.input('mapdl_input.dat', verbose=True)
  3. CASE_3_pyMAPDL_all_commands.ipynb: notebook with issue
  4. other files are supporting files

System Information:

mikerife commented 2 years ago

Hi @raviraj3997 AML,GENR are not options for the FADD operation when fitting Chaboche material model. I've not yet tried your MAPDL script in MAPDL to see what happens. KM 2046249 has example MAPDL scripts on curve fitting Chaboche: https://support.ansys.com/KnowledgeResources/Solutions?solutionIdentifier=sol2046249&productName=ANSYS+Mechanical%20APDL&productFamily=Structural%20Mechanics

Mike

raviraj3997 commented 2 years ago

Hi @mikerife, I am referring to the example in Ansys help at page (6.5.9.1) with some small change: https://ansyshelp.ansys.com/account/secured?returnurl=/Views/Secured/corp/v221/en/ans_mat/Hlp_AM_TMFMCF.html

Ravi

mikerife commented 2 years ago

Hi @raviraj3997 Sorry, I've not yet worked with the TMF material model and forgot about this feature! It does look like an issue with the tbft command; if we use the run("tbft,....") style instead it works. See the attached JL notebook. Oh, and ran some commands non-interactively.

@germa89 Could tblist be extended to include the to_list, to_array, to_dataframe methods as well?

Mike

CASE_3_Edited.zip

germa89 commented 2 years ago

I have implemented the required changes to fix tbft in #1080.

Hi @mikerife about using to_list in tblist. It could be done, but it will have to wait at the moment.

raviraj3997 commented 2 years ago

Hi @raviraj3997 Sorry, I've not yet worked with the TMF material model and forgot about this feature! It does look like an issue with the tbft command; if we use the run("tbft,....") style instead it works. See the attached JL notebook. Oh, and ran some commands non-interactively.

@germa89 Could tblist be extended to include the to_list, to_array, to_dataframe methods as well?

Mike

CASE_3_Edited.zip

Thanks @mikerife for looking in to it. Yes it works fine with mapdl.run("......")