CSCE 155N Fall 2012 Homework Assignment 2: Stress

CSCE 155N
Fall 2012
Homework Assignment 2: Stress-Strain Curve
Assigned: September 11, 2012
Due: October 02, 2012
Note: This assignment is to be completed individually - collaboration is strictly prohibited.
Points: 100 points
Objectives
The objectives of this homework assignment:
1. Master the use of standard I/O in Matlab.
2. Master the use of plots in Matlab.
3. Master the use of selection statements in Matlab.
4. Master the use of loops in Matlab.
5. Familiarize with the use of File Input/Output
(I/O) in Matlab.
6. Familiarize with the user of functions in Matlab.
7. Familiarize with the use of matrices in Matlab.
8. Familiarize with the concept of control
statements (selection and loop) in solution
design
9. Be exposed to the concept of problem
decomposition and the design-implementationtest cycle.
10. Appreciate and understand the application of
computational thinking in solving engineering
problems
Problem Description
Memo To: The programmer Memo From: Your boss Well, another job has come in! And you are my only hope! This time, the customer is from a mechanical engineering company. They want a program that takes in the parameters of a material specimen, loading force and elongation corresponding to the load, and returns the area of the specimen and the stress-­‐strain curve. I don’t know much about the setup … all I have is this description of the tensile testing and the stress-­‐strain curve. Please take care of this task! Have a nice day! Your boss Studying the properties of different materials is a
crucial field in mechanical engineering, because it helps engineers select appropriate materials
for different engineering applications. Generally, materials undergo a set of tests; different tests
give information about a specific property of the studied material. One of the well-known tests
is the tension testing.
In tension testing, a uniaxial tension force is applied to a sample of the material (specimen) we
are interested to study. This sample is called tensile specimen. A typical tensile specimen (see
Figure 1) has enlarged ends or shoulders used for gripping, and a gage section. The two most
commonly used cross section shapes of the tensile specimen are the circular and square cross
sections. In both of them, the gage section has a smaller cross sectional area than the shoulders.
1
The tension testing involves mounting the specimen in a machine, from the two shoulders, and
then tension force is applied until it fractures. (Note from boss: This is cool!) As the load
increases, the test sample elongates. This elongation in the gage section is recorded against the
applied load (force).
F
F
Lo
Figure 1: Typical tensile specimen
An example of data recorded during a real tension testing is shown in the following table:
Applied Force
(N)
0
7248.7792
14497.5584
21604.2047
28852.9839
36101.7631
40103.6987
43005.4237
46508.0824
47908.1165
49009.6138
49202.6332
47802.5992
46501.6484
44301.2273
38097.5838
Elongation
(mm)
50.8000
50.8510
50.9020
50.9520
51.0030
51.0540
51.3080
51.8160
52.8320
53.8480
54.8640
55.8800
56.8960
57.6580
58.4200
59.1820
Two important values are calculated from the force applied and the elongation experienced by
the specimen, namely: engineering stress and engineering strain, respectively.
Engineering stress (𝜎) is a value that describes how the body having the force exerted upon it
counteracts the pressure that results from this force, and it is defined as:
! 𝜎 = ! N/m!
!
(1)
where F is the applied force, 𝐴! is the cross section area of the gage section assuming a circular
specimen with diameter 𝐷! , or a specimen with a square cross section of side length 𝐷! .
Engineering strain (𝜖) describes the deformation and change of the specimen's length. By
definition, it is the ratio between the change in the length of the specimen and the initial length
before the test., and it is defined as:
2
𝜀=
!!
!!
=
!!!!
!!
(2)
where Δ𝐿, 𝐿! , and 𝐿 are the change in gage length, initial gage length, and the final gage length,
respectively. Strain is a unit-less value since it represents a ratio of parameters of the same units.
Hence, you have to make sure of unit consistency, i.e., that all of the lengths used are of the same
unit (either meters or millimeters).
A typical stress-strain curve is shown in
Figure 2.
IMPORTANT: For each force-elongation
pair, we have to compute the corresponding
engineering stress and strain. However,
usually a large set of data points are
recorded in this kind of material tests. This
makes the process of calculating the
engineering stress and strain at each point
manually, a time-consuming process. (Note
from boss: Consider using loops!)
As you may have noticed, a stress-strain
curve for a ductile material always starts
with a linear region. This linear region is
called the elastic range. In the elastic range
if the load is removed, the material goes
back to its original length, i.e., the
deformation exists as long as the load is
applied but the deformation disappears if
the load is removed. However, after the
elastic range ends, the plastic range starts,
in which the material suffers permanent
deformation. In other words, the material
cannot get back to its original state even if
the load is removed.
Figure 2: Stress-Strain Curve.
Figure 3: Stress-Strain curve (Colored Elastic
Region)
Using visuals are helpful in making data
interpretation an easy process. One way to
make it easy for the engineers to recognize
different phases of a material's stress-strain curve is to use colors to differentiate these different
phases. For example, we can use the green color to represent the elastic range (the straight line in
the curve), as shown in Fig. 3.
To identify this elastic region, we need to identify the points that form it. And, in order to
identify these points, we have to characterize them first. In other words, we need to find the
common characteristics that the points in the elastic range have in common, and make them
different from other points in the curve. Let's have a closer look at the given data, so we can
identify these characteristics. In Table 1 below, we can see, the segments that define the elastic
region are all of the same slope value, which is equal to 56,332. This makes them different from
3
all other points, because any other consecutive points that form a segment that has this exact
slope, should be part of this straight line.
Point
number (i)
1
Applied Force
(N)
0.0000
Elongation
(mm)
50.8000 Stress
(MPa)
0.0000 0.0000 2
7248.7792 50.8510 56.3320 0.0010 56111.0900 3
14497.5584 50.9020 112.6640 0.0010 56111.0900 4
21604.2047 50.9520 167.8915 0.0030 56111.0900 5
28852.9839 51.0030 224.2235 0.0040 56111.0900
6
36101.7631 51.0540 280.5555 0.0050 56111.0900 7
40103.6987 51.3080 311.6555 0.0100
6220.0001 8
43005.4237 51.8160 334.2055 0.0200 2255.0000 9
46508.0824 52.8320 361.4255 0.0400 1361.0000 10
47908.1165 53.8480 372.3055 0.0600 544.0000 11
49009.6138 54.8640 380.8655 0.0800 428.0000 12
49202.6332 55.8800 382.3655 0.1000 75.0000 13
47802.5992 56.8960 371.4855 0.1200 -­‐544.0000 14
46501.6484 57.6580 361.3755 0.1350 -­‐674.0000 15
44301.2273 58.4200 344.2755 0.1500 -­‐1140.0000 16
38097.5838 59.1820 296.0655 0.1650 -­‐3214.0000 Strain
Slope of the segment (i,
i+1)
Table 1. Points and interactions between applied force and elongation, and the slope of each successive pair
of points (segment).
You tasks are as follows:
1. Design and implement a program that takes in an input file with the following format.
a. The type of the specimen's cross section, either circular or square. (You need to give the
user the option of choosing either. You must use either an "if" or a "switch" statement in
your solution.)
b. The diameter (or the side length) of the specimen D! in millimeters. If the user selects 1
as an answer for the previous step, then the question should ask him/her for the diameter,
and if s/he selects 2, the question should ask for the side length.
c. The initial length of the specimen L! in millimeters.
2. Load the two vectors of the loads and resultant elongations from two input files,
ForceVector.dat and ElongationVector.dat, respectively. Note: We will provide two sample
input files on the course website at:
http://www.cse.unl.edu/~lksoh/Classes/CSCE155N_Fall12/homeworks.html
4
3. Calculate the engineering stress 𝜎
a. Calculate the cross section area 𝐴! (based on the inputs of the user in 1-b and 1-c).
b. Design a "for" loop that uses the cross-sectional area 𝐴! (found in 2-a) and the vector of
forces applied to find the engineering stress at each load applied using Equation (1).
4. Calculate the engineering strain (𝜖)
a. Design a "for" loop that uses both; the initial length of the specimen 𝐿! and the vector of
the resultant elongations to calculate the engineering strain using Equation (2).
5. Calculate the slopes of the segments. In the following an illustration of how to find the slope.
For any two points on the straight line 𝐴 = (𝑥! , 𝑦! ) and 𝐵 = (𝑥! , 𝑦! ), the slope is defined as:
𝑦! − 𝑦!
slope = 𝑥! − 𝑥!
6. Define a vector to store the indices of the set of points that form the elastic region. Of course
you do not know the length of this vector ahead of time.
7. Use a "while" loop to fill in this vector of indices. You should scan the vector of slopes you
formed in Step 4, and check if the slope satisfies the condition that characterizes the points in
the elastic range or not. If yes, then the indices of the two points that form this segment
should be placed in the vector of indices. Generally, we take the first slope, which
corresponds to the first segment, as the condition. Then any other segment has a slope that
matches this condition, is considered an extension of the first segment For example, in the
given problem, the condition of an elastic region is "while the slope is equal to 56,332, place
the point in the vector of the elastic range". Scanning the vector of slopes, we find that the
first slope is 56,332, and the indices 1 and 2 should be placed in the vector of Step 5, because
these two points from the segment (1, 2) which has the slope 56,332. Then, we take the slope
of the next segment (2, 3), and compare it with the condition 56,332. As we can see, the
slope of the segment (2, 3) satisfies the condition, and hence, we should place the index 3 in
the vector (because 2 has already been placed there). The while loop should stop once the
slope value is no longer 56,111, in this example. (Note: In our test case, we will use different
set of values and thus the condition will not be always 56,111. But it will always be based on
the slope value of the first segment derived from the input points.)
8. The output of the program should show the following:
a. The cross-sectional area 𝐴!
b. A matrix of size (M x 5). Columns from 1 to 5 represent the load, length, stress and
strain and slopes, respectively. (Note: In the table shown in the previous page, each cell
in the vector of slopes is centered—offset—between two of the data points, this is done
just to illustrate that this slope is obtained using these two data points. However, in
Matlab, we will not be able to generate table with such an offset; instead, a segment’s
slope is aligned with the row of the first point of the segment. Please see the sample
output in the next page.)
c. The vector of the indices of the points that form the elastic region.
9. Generate plots
5
a. The stress-strain curve must be plotted. This curve shows the relation between the stress
and the strain you calculated previously in Steps 2 and 3. This graph should show the
elastic range plotted in green color, while the rest of the curve is plotted in the black color
See Figure 3 for an example.
A sample run of the required program is shown below. (Note: Bold texts are user input.)
Sample Output (SSCalc)
Welcome to SSCalc:
Please enter the following:
Specimen's Type (1-Circular 2-Square):
1
Diameter of the specimen (Do) in millimeter:
12.8
Length of the specimen (Lo) in millimeter:
50.8
Filename for the load’s vector in N:
ForceVector
Filename for the elongation’s vector in millimeter:
ElongationVector
Output:
Cross-sectional area (Ao) in mm^2=
128.6796
The values of the stress and strain are shown in the following table
Load(N)-Length(mm)-Stress(MPa)-Strain - Slope
SSvalues_output=
1.0e+04 *
0.0000 0.7249 1.4498 2.1604 2.8853 3.6102 4.0104 4.3005 4.6508 4.7908 4.9010 4.9203 4.7803 4.6502 4.4301 3.8098 0.0051 0.0051 0.0051 0.0051 0.0051 0.0051 0.0051 0.0052 0.0053 0.0054 0.0055 0.0056 0.0057 0.0058 0.0058 0.0059 0 0.0056 0.0113 0.0168 0.0224 0.0281 0.0312 0.0334 0.0361 0.0372 0.0381 0.0382 0.0371 0.0361 0.0344 0.0296 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 5.6111 5.6111 5.6111 5.6111 5.6111 0.6220 0.2255 0.1361 0.0544 0.0428 0.0075 -­‐0.0544 -­‐0.0674 -­‐0.1140 -­‐0.3214 0 6
Elastic_Rregion_Indices:
1 2 3 4 5 6
Thank you for using SSCalc.
Note: The "..." is used to split a long vector of input into two lines as
shown above.
IMPORTANT: Note that this program will be more complicated than the one you did to solve
the chemical engineering problem last week. Thus, you should consider using functions to
increase the modularity of your solution. That means, you should have multiple m-files in your
solution package. Your boss will be looking at the quality of modularity of your work. (Hint:
Think about how to break this task into multiple, smaller steps, and how each step is to process
an input and then return an output to be used by the subsequent step.)
Challenge - Extra Credit (10 points)
As mentioned above, after the elastic range, the plastic range begins. This transition in the
properties of the material concerns the designers, because it has a great impact on the design
calculations. For example, while designing certain mechanical application, the engineers should
know the maximum load expected to be applied to this application; and subsequently, based on
this expected maximum load, the designers should use a material that will remain in its elastic
range even under this maximum load. That is why it is very important to know the stress at
which the elastic range ends and the plastic range starts, which is called the yield strength 𝜎! .
Sometimes this yield strength is clear and can be easily detected. But sometimes the material’s
properties make it hard to be detected. For such materials, a method called the offset yield
method is used to determine the yield strength. In the offset yield method, a straight line that is
parallel to the elastic range is plotted. This line crosses the x-axis at the point corresponding to
𝜀 = 2%. The intersection point of this straight line with the stress-strain curve represents the
yield strength point.
Your task is to add to your program such that it plots the straight line of the offset yield method.
The benefit of this addition is twofold: (1) it will save engineers time spent on drawing this line
manually, and (2) since the engineers plot this line manually, there is a high probability of error
while drawing, and consequently, the value of the yield strength observed might be erroneous.
On the other hand, plotting this straight line using the computer will reduce the probability of
this error. An example is shown in Figure 4. As we can see, the intersection between the
straight line and the stress-strain curve is almost at 280 MPa. Hence,
𝜎! = 280 MPa.
Since this straight line is parallel to the line of the elastic range, then they have the same slope.
So what you have to do is to use the slope of the elastic range, you have already computed in
Step 6, along with the information that this straight line passes through the point (0.002,0), to get
the equation of this straight line. You need to do these calculations using paper and pencil (you
should document these calculations in a document file named ANALYSIS_Challenge.doc), and
then use Matlab to plot it. Your code also should print the statement "The 2% straight line of the
offset yield method" beside the plotted straight line, as shown in Figure 4. You can't write this
7
statement on the curve using the plot
editor, you have to do it using the Matlab
commands. (Hint: Consider using the
functions "str" and "text".)
IMPORTANT: Note that you have to
adjust the x-axis scale to make sure that
(1) the plot is readable and (2) the straight
line of the offset yield method is clear, as
shown in Figure 4.
As a check for the correctness of your
calculations and code, make sure that the
point of intersection is located inside the
range between 250 MPa and 300 MPa.
You can do this step visually, and just
write down your observation that it is located
within this range. In other words, you do not
need to verify this using Matlab.
Figure 4: The 2% straight line in the offset yield
method.
Submission Procedure
This assignment is due at the start of class (2:00 PM). Assignments five minutes late will
NOT be accepted. It is highly recommended that you read the grading policy and grading
guidelines on the course website for a complete explanation of how the assignments will be
graded. Remember, your program should follow a good programming style, include plenty of
comments – both inline documentation and Matlabdoc documentation, and perform all of the
functionality outlined above. Also, in the welcome message of your program, state whether you
are implementing the extra credit functionality.
There are two submission steps:
(1) You must “handin” the following files on-line:
Source files: SSCalc.m and other m-files and m-file functions
Readme file: README
Testing file: TEST (Also, if you complete the Challenge, please submit your input text
file, TEST_Challenge, and a document that shows the work and calculations done by
you, ANALYSIS_Challenge.)
(2) You must submit a stapled paper copy of a coversheet, your source files, the README file,
and the TEST file.
Both of these steps must be done by the start of the class on the day the assignment is due.
Please download this coversheet from the instructor’s course website, under the Homework
Assignments link. This coversheet allows the grader to give comments and categorize the points
for your homework.
•
•
•
8