Let's start a new assignment project together, Get Exclusive Free Assistance Now!

Need Help? Call Us :

Place Order

Home-based Programming Assignment

Mar 13,23

Question:

Background:

EPRO1004 – 202002

Home-based Programming Assignment

Instructions (Read Carefully):

  1. This is an open book programming assignment. You are allowed to use online resources to assist in this assignment;
  2. This is an individual assignment and no collusion with other students of any kind is allowed;
  3. Your program has to work. That means it has to compile correctly, run according to specifications, and give correct results. The submitted assignment must also meet the following criteria:

 Good design, including good pseudo code, logic diagrams and algorithms

4. You must observe good programming practices, including comment, documentation, and readability of your program;

  1. To facilitate program readability, you must include function calls in your program whenever possible;
  2. All names of constants, types, variables, functions, etc. must be “self- documenting” and “self-describing.” For example, you should name a variable total if it is used to store a total. Give a function a name like printList if its job is to print a list;
  3. This home-based programming assignment constitutes 40% of the overall final mark of the EPRO1004 unit.
  4. Final submission deadline is 23:00, 20th The instructions on how to submit your file will be provided by your Unit Coordinator as soon as possible.

Calculating the ratio of applied load to capacity ofa structural steel beam under varying conditions

Background

The design of a steel beam must take into account a wide range of factors. Material strength, load position, magnitude of load, end restraints and compressive flange restraint are just some of the factors that must be taken into account.

This assignment will involve writing a simple application that will calculate the bending capacity of a simply supported steel beam, and compare it to the maximum moment brought about via a full length distributed load. A range of beam lengths and applied loads will be used in calculations and the results displayed in a table. A sample length/loading situation is illustrate below.

Two main equations govern the design of beams for bending. The first covers what is called the section capacity, Ms, the second the member capacity, Mb. In turn these equations are compared to the applied maximum bending moment:

s b

 

M *ϕM M *ϕM

where ɸ = 0.9, M*is the applied moment The calculation of Msis quite straight forward:

Ms=f y Ze

where:

Msis the section bending capacity

fyis the yield stress – in this exercise this is taken to be 300MPa

Zxis the effective section modulus – this is read from provided section tables (mm3)

The calculation of Mb is more complex, but still relatively straight forward.

Mb=αmαsMsMs

where:

Mbis the member bending capacity (Nmm)

αm= Moment modification factor – in this exercise this is taken as 1

αs= Slenderness reduction factor

αs=0.6

[√[(

M2

s )

 

+3

M o

]−(

M s

)

 

]

 

Mo

Mois the reference elastic buckling moment for a member subject to bending (Nmm)

l

 

l

 

Mo=

 

(

 

π2EI

2

e

 

y)[GJ +(

 

π2EI

2

e

 

w )

 

]

 

E = Modulus of elasticity – in this exercise this is taken as 200,000MPa

Iy= The second moment of area about the minor y-axis – this is read from provided section tables (mm4)

G = Shear Modulus – in this exercise this is taken as 80,000MPa

J = Section torsion constant – this is read from provided section tables (mm3) Iw= Section warping constant – this is read from provided section tables (mm4) le= Effective length – provided by the application (mm)

The applied moment, M*, will be calculated by the application using a value for an applied

Uniformly Distributed Load, UDL. The application will use the simple equation:

wl2

M*= e

8

where:

M*is the maximum moment at mid-span in kNm

w = Applied full length UDL in kN/m

l = The length of the beam – this will be equivalent to le(m)

It is important to note that the value for length in the capacity calculations is in mm

whereas when calculating the applied moment, the length is in m. So for a length of 3m, the capacities will be calculated using 3000mm but for the applied load, it will be calculated using 3m. In turn this results in Msand Mbbeing calculated in Nmm whereas M*is calculated in kNm. It is recommended that for the calculation of the capacity ratio that the capacities be divided by 106to bring them into kNm.

The ratio that is calculated is derived by dividing the applied moment by the two capacities and in turn taking the larger:

ratio MAX M(

 

M

 

M

 

)

 

* *

M

 

= ,

s b

Requirements

At its lowest level the app will take an effective length and in conjunction with member parameters calculate the section and member bending capacity of the member for said length. It will, for the same length, calculate a bending moment based upon an applied UDL. The bending moment will then be divided by the section & member bending capacities respectively to provide ratios. The larger ratio will then be displayed to the user.

Figure 1: Example App Output. n.b. Values are for illustration only

As can be seen in Figure 1, the app will generate UDL values from 1kN/m to 10 kN/m with 1kN/m increments. In turn, for each load value, bending moments and bending capacities will be calculated for effective lengths ranging from 0m to 10m with 1m increments. Ratios of bending moment to capacity, both section and member, are to be calculated for each UDL – effective length pair. The result, the greater of the two ratios, will be displayed in a table, similar to Figure 1.

Note:An effective length of 0m is a special case which relates to what is known as full lateral restraint. An explanation of this is well outside the scope of this subject. You will only have to calculate the section capacity but you will need to calculate an applied moment for each UDL for an assumed effective length of 5m. You only need to calculate the ratio using the calculated 5m applied moment and the section bending capacity, Ms.

To control the app, the user will use a simple text file. The text file will contain the name of the steel section being investigated and the parameters that are listed in the Background section above as being read from provided section tables. Using a 460 UB 82 as an example, a possible input file format would be:

Section name Zx

IyJ

Iw

 

460UB82

1610000

18600000

701000

919000000000

 

Which correspond to

The data is sourced from a pdf file that is available on Moodle, Week 8, titled Steel Section Properties.

The input file can have any name, but the app must prompt the user for this name.

Once entered the app will open it and read its contents. Note that there should be no spaces

in the beams name string. Once the data file has been read in, the calculations will take place.

Output in a format similar to Figure 1 is expected to both the screen and to a file that is named after the steel section being investigated. The above section would provide output to a file called 460UB82.dat.

Programming Tasks

Your task is to develop a working C program that will:

  • Prompt the user for the name of a data file that contains the data needed to calculate the section and member bending
  • Open then read the data file. If the file is not found, appropriate action should be taken.
  • Calculate the bending moment and capacities for each combination of UDL and effective length. Calculate the appropriate
  • Output the results to both the screen and file

You should demonstrate good programming practise, making use of functions and return values. As files are being opened, care should be taken to ensure the opening has actually succeeded. Magic Numbers should not be used. The code should be well laid out and consistent in format. Variable names are expected to provide an indication of their purpose.

What you have to submit

  1. The pseudo code and flow charts documenting the design of the program. This should be submitted as a pdf named pdf (20%);
  2. The testing document. This will provide hand calculations to show that the calculations in the app are correct. It should also indicate what happens when erroneous data is entered. For example what happens if not all of the data file is present or a value is negative. This will be called pdf (20%);
  3. Well-documented, syntax-free and correctly-compiling C source code. This should include an example data file. Name this file c (50%);
  4. A compliance/summary document. This is the developer showing that the app produces results that match with the testing document. Also if there are any conditions when the app is run. This will be called pdf (10%).

Submission Guideline:

Submission will be through Moodle. Submission will be in three parts on three different dates.

Item Date

Design document, design.pdf 23:00, Sunday 30th of August

Testing Document, testing.pdf 23:00, Sunday 6th of September Code & compliance, program.c & comply.pdf 23:00, Friday 18th of September

More information will be provided closer to the day.

Appendix

Marking Rubric for Programming

Criteria Exceptional

(>=80%)

Acceptable

(between 65%

and 79%)

Amateur

(between 50%

and 64%)

Unsatisfactory

(<50%)

Specifications The program works and meets all of the specifications. The program works and produces the correct results and displays them correctly. It also meets most of the

other specifications.

The program produces correct results but does not display them correctly. The program is producing incorrect results.
Readability The code is exceptionally well organized and very easy to follow. The code is fairly easy to read. The code is readable only by someone who knows what it is supposed to be

doing.

The code is poorly organized and very difficult to read
Reusability The code could be reused as a whole or each

routine could be reused.

Most of the code could be reused in other programs. Some parts of the code could be reused in other programs. The code is not organized for reusability.
Documentatio n The documentation is well written and clearly explains what the code is accomplishing and how. The documentation consists of embedded comment and some simple header documentation that is somewhat useful in understanding

the code.

The documentation is simply comments embedded in the code with some simple header comments separating routines. The documentation is simply comments embedded in the code and does not help the reader understand the code.
Delivery The program was delivered on time. The program was delivered within a week of

the due date.

The code was within 2 weeks of the due date. The code was more than 2 weeks overdue.
Efficiency The code is extremely efficient without sacrificing readability and

understanding.

The code is fairly efficient without sacrificing readability and

understanding.

The code is brute force and unnecessarily long. The code is huge and appears to be patched together.

 

https://uwf.edu/media/university-of-west-florida/academic-affairs/departments/cutla/documents/Computer-Programming-Grading-Rubric—California-State-University-Long-Beach.pdf Marking Rubric for Pseudocode design

Criteria Exceptional

(>=80%)

Acceptable

(between 65%

and 79%)

Amateur

(between 50%

and 64%)

Unsatisfactory

(<50%)

Algorithm Complete working algorithm created with strong supporting understanding of the domain

area.

Incomplete nearly working algorithm created with strong supporting understanding of the domain

area.

Incomplete non working algorithm created with incomplete supporting understanding of the domain

area.

No working algorithm created or no supporting understanding of the domain area.
Readability Pseudocode is very clear, understandable, readable, and organised into as few steps necessary as possible. Pseudocode is clear, understandable, and

the code is organised into steps, though there may be a few

extra steps.

Pseudocode is somewhat understandable, but

very little of the code is organised logically.

Pseudocode is difficult to understand and is unorganised.
Ability to convert to a program The code can be easily converted into a program. The code can be converted into a program. The code can be converted into a program

only with much difficulty.

Code cannot be converted

into a program.

 

Answer:

Introduction

#include<stdio.h>
#include<string.h>
#include <unistd.h>
#include<stdlib.h>
#include <math.h>

int cfileexists(char *filename);
void fileHandling(char *filename);
double max(double ratio1,double ratio2);
void output(double arr[][10]);
void calculations(double effectiveSectionModulus, double secondMomentArea,double torsionConstant,double warpingConstant, double arr[][10]);
FILE *file;
/**
* Function to check whether a file exists or not
*/

int cfileexists(char* fileName)
{
if (access(fileName, F_OK) == -1)
return 0;

return 1;
}

//Utility function to check which value is greater
double max(double ratio1, double ratio2)
{
return (ratio1 > ratio2 ) ? ratio1 : ratio2;
}

//Function to perform all the calculation required

void calculations(double effectiveSectionModulus, double secondMomentArea,double torsionConstant,double warpingConstant,double ans[][10]){

//Declaring all variable required to perform the calculations
double modulusElasticity = 200000;
double shearModulus = 80000;
double yieldStress = 300;
double modificationFactor = 1;
int effectiveLength = 0;
int appliedFullLength =1;

double slendernessReduction;
double bendingCapacity;
double appliedMoment;
double sectionBending;
double bucklingMoment;
double converstionLength;
double convertedSectionBending;

//Calculating section bending
sectionBending = yieldStress * effectiveSectionModulus;

//Calculating buckling Moment in parts to make calculation simpler
//bucklingMoment = sqrt((partA/length*length)* (partC+((partB)/length*length));
//part A,B and C are defined below
//length will keep on changing thus we can calculate these values rather than putting them in loops

double partA = (3.14*3.14*modulusElasticity*secondMomentArea);//π^2*E*Iy

double partC = shearModulus * torsionConstant; //G*J

double partB = (3.14*3.14*modulusElasticity*warpingConstant); //π^2*E*Iw

//for convertion of length to m from mm
converstionLength = pow(10.0,6.0);

convertedSectionBending = sectionBending / converstionLength;

for(effectiveLength = 0; effectiveLength<=10; effectiveLength++)
{
for(appliedFullLength = 1; appliedFullLength<=10; appliedFullLength++)
{

if(effectiveLength == 0)
{
double appliedLength = 5;

appliedMoment = ((appliedFullLength) * (appliedLength* appliedLength))/8; //w*L*e/8
double ratio = (appliedMoment/convertedSectionBending); //(M*)/Ms
ans[appliedFullLength][effectiveLength] = ratio;

}
else
{
double effectiveLengthIn_mm = effectiveLength * 1000; //multiplying effective length by 1000 as it’s given in m
double updatedPartA = partA / (effectiveLengthIn_mm * effectiveLengthIn_mm); //π^2*E*Iy / l^2
double updatedPartB = partB / (effectiveLengthIn_mm * effectiveLengthIn_mm); //π^2*E*Iw / l^2

bucklingMoment = updatedPartA* (partC+updatedPartB); //(π^2*E*Iy / l^2) + (GJ + (π^2*E*Iw / l^2))
bucklingMoment = sqrt(bucklingMoment);

double partD = sectionBending/bucklingMoment; //Ms/Mo

slendernessReduction = 0.6*(sqrt((partD * partD) + 3)-(partD)); //0.6 [√[(Ms/ Mo )^2 +3]−(Ms/Mo )]

bendingCapacity = modificationFactor * slendernessReduction * sectionBending;//αm*αs*Ms

double convertedBendingCapacity = bendingCapacity/converstionLength; //converting the bending capacity calculated in KNm

appliedMoment = (double)((appliedFullLength) * (effectiveLength* effectiveLength))/8; //w*L*e/8

double ratio1 = (appliedMoment/convertedSectionBending);
double ratio2 = (appliedMoment/convertedBendingCapacity);

//MAX(M*/Ms, M*/Mb )
ans[appliedFullLength][effectiveLength] = max(ratio1,ratio2);
}

}
}

}

void fileHandling(char* fileName)
{
file = fopen(fileName,”r”); //opening the file whose name has been given

char contentOfFile = fgetc(file);
char inputLines[100][20]; //array to store the data inputs
int i=0;
int totalInputs =0;
while(fgets(inputLines[i],100, file) != NULL)
{
inputLines[i][strlen(inputLines[i]) – 1] = ‘’;
i++;
}
fclose(file); //closing the input file as it’s no longer require

char outputFile[100];
strcpy(outputFile,inputLines[0]);
strcat(outputFile,”.dat”); //The ouput file in which we have to post the results
printf(“%s”,outputFile);
file = fopen(outputFile,”w”); //opening the file in write mode. IF the file is not present, it will be created in the same directory

//Writing contents in the file and console
printf(” ** Beam Capacity Ratio Calculator ** n”);
fprintf(file,” ** Beam Capacity Ratio Calculator ** n”);
printf(“nFor a %s the ratio of applied UDL ton”,inputLines[0]);
fprintf(file,”nFor a %s the ratio of applied UDL ton”,inputLines[0]);
printf(“moment capacity is as followsn”);
fprintf(file,”moment capacity is as followsn”);

double results[10][10];
char *ptr;

//Converting the inputs fetched into double for calculation
double effectiveSectionModulus = strtod(inputLines[1], &ptr);
double secondMomentArea = strtod(inputLines[2], &ptr);
double torsionConstant = strtod(inputLines[3], &ptr);
double warpingConstant = strtod(inputLines[4], &ptr);

calculations(effectiveSectionModulus,secondMomentArea,torsionConstant,warpingConstant,results);

printf(” UDL ttttt Effective Length(m)n”);
fprintf(file,” UDL ttttt Effective Length(m)n”);
printf(“(kN/m)* t”);
fprintf(file,”(kN/m)* t”);

//styling the data as per the requirements

int j=0;
printf(“bb”);
for(i=0; i<=10; i++)
{
if(i<4)
{
printf(“%d t”,i);
fprintf(file,”%d “,i);
}
else if(i>=4 && i<=6)
{
if(i==6)
{
printf(” %d “,i);
fprintf(file,” %d “,i);
}
else
{
printf(” %d t “,i);
fprintf(file,” %d “,i);
}
}
else if(i>=7)
{
if(i==7)
{
printf(” %d “,i);
fprintf(file,” %d “,i);
}
else
{
printf(” %d”,i);
fprintf(file,” %d”,i);
}

}
}
printf(“n”);
fprintf(file,”n”);

for(i=0; i<=108; i++)
{
printf(“*”);

}
for(i=0; i<=60; i++)
{
fprintf(file,”*”);

}

printf(“n”);
fprintf(file,”n”);
for(i=1; i<=10; i++)
{
if(i==10)
{
printf(” %d * “,i);
fprintf(file,” %d * “,i);
}
else
{
printf(” %d * “,i);
fprintf(file,” %d * “,i);
}
for(j=0; j<=10; j++)
{
printf(” %f”,results[i][j]);
fprintf(file,” %f”, results[i][j]);
}
printf(“n”);
fprintf(file,”n”);
}

}

int main()
{
//Ask USER for name of input file
char fileName[100];
printf(“Please enter the input file name with extension: “);
scanf(“%s”, fileName); //read string

//Check if input file is present in the project
//If not present – prompt again for right name

while(!cfileexists(fileName))
{
printf(“FILE NOT foundn”);
printf(“Please enter the input file name with extension: “);
scanf(“%s”, fileName);
}
//Else

//Fetch the data and perform calculation
//Print the data on console and onto the file as the output provided

fileHandling(fileName);

return 0;
}

0 responses on "Home-based Programming Assignment"

Leave a Message

Your email address will not be published. Required fields are marked *