CSCE 155N Spring 2013 Homework Assignment 2: Material Query Tool Assigned: February 1, 2013 Due: February 15, 2013 Note: This assignment is to be completed individually - collaboration is strictly prohibited. Points: 100 points (1.2 in terms of weight towards the total score of homework assignments) Objectives The objectives of this homework assignment: 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Master the use of standard I/O in Matlab. Master the use of selection statements in Matlab. Master the use of loops in Matlab. Familiarize with the concept and use of index vectors. Familiarize with the use of File Input/Output (I/O) in Matlab. Familiarize with the use of functions in Matlab. Familiarize with the use of matrices in Matlab. Familiarize with the concept of control statements (selection and loop) in solution design. Be exposed to the concept of problem decomposition and the design-implementation test cycle. Appreciate and understand the application of computational thinking to solving engineering problems. Problem Description A Thermoplastic, known as a thermosoftening plastic, is a polymer that becomes pliable or moldable above a specific temperature, and returns to a solid state upon cooling. Most thermoplastics have a high molecular weight, whose chains associate through intermolecular forces; this property allows thermoplastics to be remolded because the intermolecular interactions spontaneously reform upon cooling. Memo To: The Programmer Memo From: Your boss This is a useful tool for our mechanical engineers. When the engineers design a new machine, a lot of materials have to be considered for their properties. To check these properties either from the document or the online web site is a hazard for our engineers. This costs a lot of time for our engineers. We really need your help to design a good reference tool. We give you a sample on thermoplastic. And write a first version reference tool for the mechanical engineers. They can use your tool easily to check all the properties and search the right material in a short time. Thank you! Many thermoplastics can be selected as machine design materials, such as polyethylene, polyvinyl chloride, polypropylene, polycarbonate, and so on. Material properties to determine which thermoplastics to use are density, tensile strength, elastic modulus, elongation at rupture, thermal stability etc. It is impossible for a general technician in our factory to remember all the properties, and they often refer to a document for such properties. The following is an example of such a document. (There is a Wikipedia link for each material listed below if you are interested.) 1 Thermoplastic Materials Self-reinforced polyphenylene Polyvinyl Chloride Polytetrafluoroethylene Polysulfone Polypropylene Polymethylmethacrylate Polyimide Polyethylene terephthalate Polyetherimide Polyether ether ketone Polycarbonate Polyaryletherketone (tough) Polyaryletherketone (strong) Polyamide-imide, electrical grade Polyamide-imide, bearing grade Polyamide-imide Density 3 [g/cm ] 1.19 1.44 2.17 1.25 0.91 1.19 1.38 1.35 1.27 1.32 1.2 1.29 1.46 1.41 1.46 1.42 Tensile Flexural strength strength [MPa] [Mpa] 152 234 47 91 24 33 68 115 37 49 61 103 96 143 61 105 105 151 100 68 95 87 124 136 213 138 193 103 159 152 241 Elastic Elongation atThermal modulus rupture stability [Gpa] [%] [°C] 5.52 10 151 3.32 60 80 0.49 300 260 2.61 75 160 1.36 350 150 2.77 4 100 3.1 7 380 1.35 170 120 2.9 60 210 3.6 50 343 2.3 130 120 3 40 190 12.4 2.1 267 4.1 12 260 5.5 6 260 4.9 15 278 Expansion at 20°C −6 [10 /°C] 75 95 56 90 65 43 70 31 66 30 25 The problem that we want to solve here is that searching and reading such a document to find and identify the proper material to use for a particular application is time consuming for designers. It is your job to help the designers to find the correct material quickly. Specifically, you have been tasked to design and implement a program to do the following: 1. Design and implement a program that reads data from external files, which include the information above. We have saved the materials’ name (the 16 material names), property (the 7 property or attribute names), and the values (the 16 x 7 values), in three separate Matlab files. You can load them directly into your program. The data files are name.mat, property.mat, value.mat, available at our course website at http://cse.unl.edu/~lksoh/Classes/homeworks.html. (Important: After you “load” the external files in, figure out how the contents are stored and consider how to access and manipulate them.) 2. Ask the user to input which property or attribute they want to consider in their search. For example, if the user wants to consider the tensile strength of the material, they would choose the tensile strength in this step. (IMPORTANT NOTE: It is POSSIBLE for the values in the input file to be arranged differently!!! The correct orders are provided by the name.mat and property.mat, respectively. Do not assume that, for example, the second material is Polyvinvl Chloride, or the sixth property is thermal stability. THINK: Why is this note significant?) 3. Ask the user if they would like to see the range of values of the property they have selected. For example, not every user may know the tensile strength is measured in MPa, and they may not know whether a tensile strength of 87 MPa is a high or a low tensile strength. By showing the user the range of values a particular property may have, the user will be able to better determine what values of that property they may need for a particular application. However, if the user is an expert in this area, allow them the option to skip this step. The tool should work better for an expert. (Hint: Use selection statements. You may need to use a loop to find out the value range of a particular property.) To display the range of values to the user: a) Calculate the maximum and the minimum of the property value. For example, if the user chooses the tensile strength, show them what the most tensile material is and its corresponding tensile strength, as well as the least tensile material and its tensile strength. (Note: Not all properties can be measured. These values are saved as -1. So you cannot use the “min” function directly. Use a loop statement and a selection statement to find the least positive value. 2 4. Ask the user to input the range of values they want to select by providing the minimum and maximum values. For example, if the user wants the tensile strength to be less than 30 MPa, they should enter the minimum to be 0 and the maximum to be 30. Your program should search the list of materials and return Polytetrafluorethylene , the only item that falls in the queried range of tensile strength values. When you display the search results, you should display a “table”-like output: the list of found materials and their corresponding values for the queried property. a) Of course, if the search results only return one material, like the example above, then your “table” will only consist of two rows: the headings and one row of values. b) Since the user will input two numbers to define the desired range, your program must error check the input to make sure that the first number the user enters is always smaller than the second number. If it is not, then your program should inform the user and allow the user to re-enter the range until they enter it correctly. (Hint: Use a loop statement for this.) 5. The user may have several choices of materials now (if there are several materials that meet the user’s query criteria from Step-4). Prompt the user to find out whether (1) they want to refine their search or query, (2) they want to start a brand new query, or (3) they want to exit the program. a) If they want to exit, then the program shows an acknowledgement statement and then terminates. b) If they want to start a brand new query, then the program goes back to Step-2 above. c) If they want to refine the existing query, then the program goes back to Step-2 above with a twist. While a brand new query always looks at the entire set of data, a refinement query only looks at a subset! The subset is the search result of the existing query. (Hint: Think about using the concept of “index vector”!) So, the twist is to keep track of this subset. (Important: It is possible that the user may want to keep refining and refining his or her query. Therefore, it is important to make sure that your solution is elegant: it should allow the user to keep refining and thus the subset gets smaller and smaller – but never gets bigger. Use loops.) Sample Output (MechSol) (User input is bold.) >> MechSol Welcome to the Material Query Tool!! Hello, which of the following properties by which you want to query: 1, Density[g/cm3] 2, Tensile strength[MPa] 3, Flexural strength[MPa] 4, Elastic modulus[GPa] 5, Elongation at rupture[%] 6, Thermal stability[°C] 7, Expansion at 20°C[10-6/°C] 0, exit Hello, input your choice: 1 Hello, do you want to consider the details of Density[g/cm3] (Y/N)? y Material with the maximum value is: is Polytetrafluoroethylene , 2.170000 Material with the minimum value is: is Polypropylene , 0.910000 Hello, input your query range: Minimum: 1.2 Maximum: 1.5 Search results are: Material Name Density[g/cm3] Polyvinyl Chloride , 1.440000 Polysulfone , 1.250000 3 Polyimide , 1.380000 Polyethylene terephthalate , 1.350000 Polyetherimide , 1.270000 Polyether ether ketone , 1.320000 Polyaryletherketone (tough) , 1.290000 Polyaryletherketone (strong) , 1.460000 Polyamide-imide electric grade , 1.410000 Polyamide-imide, bearing grade , 1.460000 Polyamide-imide , 1.420000 Hello, please tell us what you want to do next: 1, Refine existing query 2, Start a brand new query 0, exit Hello, input your Choice: 1 Hello, which of the following properties by which you want to query: 1, Density[g/cm3] 2, Tensile strength[MPa] 3, Flexural strength[MPa] 4, Elastic modulus[GPa] 5, Elongation at rupture[%] 6, Thermal stability[°C] 7, Expansion at 20°C[10-6/°C] 0, exit Hello, input your choice: 2 Hello, do you want to consider the details of Tensile strength[MPa] (Y/N)? y Material with the minimum value is: is Polyvinyl Chloride , 47.000000 Material with the maximum value is: is Polyamide-imide , 152.000000 Hello, input your query range: Minimum: 80 Maximum: 50 Sorry, the minimum value should be smaller than the maximum value. Please re-enter: Minimum: 50 Maximum: 80 Search results are: Material Name Tensile strength[MPa] Polysulfone , 68.000000 Polyethylene terephthalate , 61.000000 Hello, please tell us what you want to do next: 1, Refine existing query 2, Start a brand new query 0, exit Hello, input your Choice: 2 Hello, which of the following properties by which you want to query: 1, Density[g/cm3] 2, Tensile strength[MPa] 3, Flexural strength[MPa] 4, Elastic modulus[GPa] 5, Elongation at rupture[%] 4 6, Thermal stability[°C] 7, Expansion at 20°C[10-6/°C] 0, exit Hello, input your choice: 2 Hello, do you want to consider the details of Tensile strength[MPa] (Y/N)? y Material with the maximum value is: is Self-reinforced polyphenylene , 152.000000 Material with the minimum value is: is Polytetrafluoroethylene , 24.000000 Material with the maximum value is: is Polyamide-imide , 152.000000 Hello, input your query range: Minimum: 50 Maximum: 80 Search results are: Material Name Tensile strength[MPa] Polysulfone , 68.000000 Polymethylmethacrylate , 61.000000 Polyethylene terephthalate , 61.000000 Polycarbonate , 68.000000 Hello, please tell us what you want to do next: 1, Refine existing query 2, Start a brand new query 0, exit Hello, input your Choice: 0 Thank you for using ChemSol. Challenge - Extra Credit (10 points) The Material Query Tool is not that user-friendly, actually. The user may want to set several properties (their value range) all at once for a query. They may want to set the tensile strength between 50 MPa and 70 MPa and the flexural strength between 100 MPa and 110 MPa, before submitting the query. They may or may not want to set the other requirements for other properties. Design a program that allows the user to decide what range of values they want to set for each property (or if they want to set a range of values at all), then show them all the materials that meet all the criteria the user has set (or if none of the materials meet their criteria). Treat this tool as the Material Query Tool 2.0! As part of this Challenge, you are required to also turn in a README_v1 file that explains the differences in program designs and solution strategies between Material Query Tool and Material Query Tool 2.0. Further, you are required to reflect on the differences. (Hint: We know that the 2.0 tool is userfriendlier. However, what about extensibility, maintainability, scalability, and modularity of the 2.0 tool?) Submission Procedure This assignment is due at the start of class (8:30 AM). 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 so that your program will receive the proper credit. There are two submission steps: 5 1. You must “handin” the following files on-line: a) Source files: MechSol.m and MechSol_v1.m (for the extra credit Challenge) b) Readme file: README and README_v2.m (for the extra credit Challenge) c) Testing file: TEST and TEST_v2.m (for the extra credit Challenge) 2. You must submit a stapled paper copy of a coversheet, all your source files, README files, and TEST files. 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. Additional Information The README file should contain information about all the files that you hand in. List the files, and describe each file in terms of whether the file is a program or a text file, the objective of each file, and so on. The README file is also part of the files that you hand in too! Further, the README file should contain information about how to compile your programs and how to run your programs. It should also contain information about your testing results. In the future, as your program becomes more complicated, you will also have to include the hierarchy of the files, the call-links of the files, and so on. For testing, capture the screen output for your various tests. Show the interactions that display the testing of the two components. Show the interactions that demonstrate the robustness of your program (for example, by inputting an invalid response). If you turn in the extra credit portion, also show the interactions that demonstrate that your program accomplishes the additional features. Basically, the testing should show that you are confident that your program works convincingly. (If you do not know how to capture the screen output, please go to the Student Resource Center at Room 13A, Avery Hall and ask for help. (It is straightforward.) 6
© Copyright 2026 Paperzz