I am not new to c++. I took a module on computing 3 yrs ago. However, due to the lack on practice ever since, I am as good as a beginner now. Now in my final year, I have to come up with a program to predict failure loads of slender reinforced concrete column pertaining to Indian Standards (a small part of my final year project). According to my understanding, the Indian Standard on this subject is highly similar to that of BS8110 and Eurocode 2. So I'm hoping that I can get help on understanding the following extract of programming code for BS8110 and Eurocode 2, and thus, modify it for my own use. An explanation for each portion and what it does would be most helpful. Many thanks. And please do leave behind your full name as I would like add you to my acknowledgement page.
float N[300],M[300],Neadd[300],Nuz,Nbal,xbal,ik,Epsc,Epst,aa,fsc,fst,Escbal,Ba;
float eadd,Nmax,Mmax,Neaddmax,xmax,Epsy,xx,fscbal,K;
int i,bb,fos;
float b,h,L,e,dd,d,fcu,fy,Asc,Ast,Es,Epscu,Fmax,DAD,DAS,DAE,DAL;
int im,ii,mm;
I probably can't help with an explanation, but I'm sure that anyone who can would prefer that you use code tags (located to the right of the message box when posting).
It's not bad that you broken them into parts however try to separate header/source files. For instance if you have A.hpp, B.hpp, A.cpp and B.cpp your post should look like:
1 2 3 4 5 6
#ifndef A_HPP
#define A_HPP
// header stuff such as function prototypes, class declaration, template information etc.
#endif
1 2 3 4 5 6
#ifndef B_HPP
#define B_HPP
// Same as the previous
#endif
1 2 3
#include "A.hpp"
// Implementations, template specializations etc.
1 2 3
#include "B.hpp"
// Same as previous.
Using this style (#ifndef.. define.. endif, also called guards and they are recommended) for headers tells us the file name so one doesn't need to write extra information like: this is file A.hpp.
When implementing prototypes, class declarations or specializing templates written in a header one must include the respective file therefore by having the #include ... we, again, know the file name and what it implements.
Next stop is "code formatting". It is essential to write code in a specific format because it becomes more easy to follow and it's less tiring to read. One can view it as a book or a magazine.
Typically when you read books or magazines you don't see phrases start at different distances from the left side. All distances between paragraphs are the same, all important titles share the same style (font, color, underlined or not etc.). The same should happen with source code since one of its purposes is to make it easier for humans to read.
Most IDEs will format the code for you in a default format and some even allow you to fully customize it (Eclipse for example). What's important is that one should know things like: I have an opening brace, do I place it on a new line? Do I leave it at the end of the line? Do I indent it? Until the end of day it's trial and error. One needs to either try all possible situations or filter some with his own mind because it is clear that they will look horrible.
For instance a code like (I don't know what it does):
1 2 3 4 5 6 7 8 9 10
int myFunction(){
int i, j, k = 0;
for(i=0;i<10;i++)
if(i%2==0){
j = 1;
while(j<10)
k++;
j++;}
return k;
}
Is harder to read and understand than this (same code, only a bit formatted):
1 2 3 4 5 6 7 8 9 10 11
int myFunction(){
int i, j, k = 0;
for (i = 0; i < 10; i++)
if (i % 2 == 0){
j = 1;
while (j < 10)
k++;
j++;
}
return k;
}
Woah! Infinite loop at line 6.
Examples can go on. One important note thought, format your code. Make it readable. Make it say "READ ME EVEN IF I MAKE NO SENSE!". Off course I am exaggerating a bit, but still format your code if you want someone to read and debug it.
PS: for learning more about what code formatting means look into IDEs for code formatter or similar names. Once you get there you should be able to edit all formatting options and some IDEs have a code snippet next to the option pane so you can see the differences (before and after thingy, really nice).
A lot of this are physics formulas. Whats probably occurring is the do loop is traversing the data file applying calculations to each specific portion of the column to obtain a value which will later be determined as a possible failure.
You'll want to refer to your Indian Code standards and you physics books to determine what each calculation does.
You'll also have to be more specific about what it is you hope to accomplish.
Whoever wrote this did not intend to maintain it, or assumed that people who would be reading it would understand what is going on.
This is a C++ board, with topics that stay within the boundaries of the language. If you have questions on the proper usage of C++, this is a good place.
In other words: Determining failure loads on reinforced concrete as it pertains to Indian and European Standards might be a little off topic for this board.
Again, you'll need to be more specific about what you want to accomplish.
Thanks for your explanation. It was what i needed. I didn't understand what the do loop does but you helped clear that up.
In hand calculation of failure loads, we would first construct an design interaction curve with data of columns from experiments, such as column dimensions, reinforcements and end eccentricity. By your explanation, I think the values obtain in the loop are coordinates (M, N) used to generate the curve.
The next step in hand calculation is to assume an N value within the range in the interaction curve. The corresponding M value is then graphically read from the curve.
Using the combination of a few equations, the design moment is obtained.
When the design moment falls outside the interaction curve, the initial assumed value of N is too high. On the other hand, if design moment falls within the interaction curve, a higher N is to be used for the assumption.
When the design moment falls on the interaction curve, this indicated the column is in a state of failure. Therefore the assumed N value is the failure load of the column.
I think its safe to say that Neadd is the design moment.
My immediate challenge is to figure out what some of the abbreviation stand for. Usually in an analysis we would require 10 or less parameters but in this code there are 46. Nevertheless, with your help at least now I have some idea how to start.