This tutorial was written by Carolina Penteado, University of Stuttgart and intern at Altair / Germany
CURVE FITTING FOR STRESS STRAIN EXPERIMENTAL DATA WITH
HYPERMATH
The stress vs. plastic strain law is
where is the true stress, the plastic deformation, “a” the value of when the
plastic deformation starts (i.e. yield stress) and “b”, “n” (hardening parameter and
exponent) are the fit parameters.
In this tutorial, the stress-strain experimental data
(“Hardening_curve_Experimental_data.lst”) is used to determine the parameters “b”
and “n”.
Step 1: Visualize the data using the text editor
Open the file “Hardening_curve_Experimental_data.lst” using the text editor.
The information required for the fitting task are the true stress (fourth column) and the
true plastic strain (fifth column) which begin at line 9.
1
Step 2: Launch HyperMath
1. From the Start menu, select All programs > Altair HyperWorks 11.0 >
HyperMath.
2. From the File menu, select open and load the file titled
[Link]
Step 3: Open the file to read
The following command (below the header of the just imported script) is used to open
the file to read:
fileid=Open("D:/home/penteado/Curve_Fitting_StressStrainExperimentalData/Hardening_curve
_Experimental_data.lst",'r')
It is necessary to define the path and the filename, which can be in “lst” or “txt”
format. The variable “r” indicates that the file is being opened to read and not to write.
(If the script is executed the first time the command “DeleteAllPlots()” needs to be
deactivated (as a comment) /* DeleteAllPlots() */
Step 4: Skip the text at the beginning of the file
To read each line from a file, the command fileid::read() is used.
Since the required data for the fitting starts, in this case, at line 9 (see step 1), this
command has to be repeated using a loop from 1 to 8 to skip the first 8 lines.
Step 5: Read the file
Before reading the file, it is necessary to define the vectors (“E” and “sigma”) where
the information are going to be written (lines 21 to 23 in the figure above). The
variable “a” is defined as global because it is going to be used inside the fitting
2
function. The variable “k” is the index that assigns each line of the file to a line on the
vectors.
To read the file until the end, the command fileid::read() is used inside a “while” loop
which stops when the value of “nil” is reached. In this case, it is necessary to convert
the “,” into “.” so that HyperMath is able to recongnize the decimals (8,30E-05 should
be written as 8.30E-05). This is done using the command [Link].
Each line has to be divided in order to get the true stress and true plastic strain
values. The command StrTok(line) splits a line in two parts whenever it finds a space.
After divided, the part of interest of the line has to be converted to number (command
tonumber(line)) and written in the vectors “E” and “sigma”.
In the data used for this example, after a certain point, the stress starts to decrease.
These values are not useful for the intended analysis (i.e. the derived values for “b”
and “n” are used in a Finite Element model). Hence, they are removed from the
vectors as shown in the figure below:
After that, the parameter “a” (yield stress), is assigned as the first value of sigma,
since it is the stress at which plastic deformation begins. The first value of “E”
(“E(1,1)”) is set to zero with 5 decimals to avoid errors since when the deformations
starts, “E” is very small, but may not be exactly zero.
Step 6: Define fitting function (Stress - plastic strain law)
The function FittingFunction receives the vector “c” with the initial values of the
parameters “b” and “n” and the vector “E” containing the strain values. It returns a
new stress value for each “E(i)” calculated using the “stress - plastic strain law”.
3
First the function is defined, then the initial values for “c” are defined and then the
function can be called to write the calculated values in vector sigma_f1. Calling the
function before the iteration process is not necessary unless you want to see how
good the fitting with the initial values was.
Step 7: Fit data using NLCurveFit (Iterative process)
The function “FittingFunction”, the initial values of “b” and “n” (contained in vector “c”),
the strain (“E”) and the stress (“sigma”) are used in the function NLCurveFit to
determine the best values of “b” and “n” using an iterative process. The maximal
number of iterations is set to [400] and the tolerance for the fitting is controlled by
[1.0e-6]. Both values can be changed in order to modify the results.
The searched (fitted) parameters are given by the vector “p” (“p(1)” is”b” and “p(2)” is
“n”). They can be seen by clicking on the variable browser to get the exact value or at
the command window to get the approximation. They are used as input for the
function “FittingFunction” to calculate the final values for the stress which can be
plotted using the following commands:
4
The result is shown in the following figure, where the original Data is a red scattered
plot and the fitted data is drawn in green color.
Step 8: Close the file
The command Close(fileid) closes the file.