I have written an if statement which states that when x == y a task should be carried out.
Now my values are in double and are decimal values the output is that x = 1.51675 and y= 1.51675 so they are the same. but when the statement is not executed and when i subtract y from x just to test the output is very strange its like 2.356exp-09
How can i stop this?
see code below: you'll see that it does not recognize the equlaity:
#include <fstream.h>
#include <iostream.h>
#include <math.h>
//ofstream fout("NikeSurvives1.rtf",ios:ut);
ofstream fout("NikeSurvives1.rtf",ios:ut);
//Enumerations
enum OCCUPANCY { Dwelling,Office,Shop,HotelReception,HotelBedroom,PictureGallery};
enum HEATOFCOMBUSTION { Timber, PolyvinylChloride,PolyUrethane_flexible,PolyUrethane_rigid,Polystyrene,Polypropylene,NotSure};
//Class Declarations
class Dimensions //class for taking dimensions //declaration + some implementations
{
public:
Dimensions(){}; //constructor
~ Dimensions(){}; //destructor
double GetOriginLenght() { return OLenght;} //Accessors
double GetOriginWidth(){ return OWidth;}
double GetOriginHeight(){ return OHeight;}
double GetOriginOpHeight() { return OoHeight;}
double GetOriginOpWidth(){ return OoWidth;}
double GetCorridorLenght(){ return CorrLenght;}
double GetCorridorWidth(){ return CorrWidth;}
double GetCorridorHeight(){ return CorrHeight;}
double GetCorridorOpHeight(){ return CoHeight;}
double GetCorridorOpWidth(){ return CoWidth;}
double GetAlpha() {return ItsAlpha;}
double GetTime() {return ItsTime;}
double GetOldQp() {return ItsOldQp;}
double GetTp() {return ItsTp;}
double GetTs() {return ItsTs;}
double GetZs() {return ItsZs;}
double GetZp() {return ItsZp;}
double GetUpperLayerVolume() {return ItsUpperLayerVolume;}
double GetCp() {return ItsCp;}
double GetHSmoke() {return ItsHSmoke;}
double GetQp();
double GetQs();
double GetMassFlowRatePlume();
void SetOriginDimensions( double SOLenght,double SOWidth,double SOHeight);
void SetOriginOpDimensions(double SOoHeight,double SOoWidth);
void SetCorridorDimensions(double SCorrLenght,double SCorrWidth,double SCorrHeight);
void SetCorridorOpDimensions(double SCoHeight,double SCoWidth);
void SetAlpha(double SAlpha);
void SetTime(double STime);
void SetOldQp(double TheOldQp);
void SetTp(double TheTp);
void SetTs(double TheTs);
void SetZs(double TheZs);
void SetZp(double TheZp);
void SetUpperLayerVolume(double TheUpperLayerVolume);
void SetCp( double TheCp);
void SetHSmoke (double TheHSmoke);
private:
double OLenght,OWidth,OHeight,OoHeight,OoWidth,CorrLenght,CorrWidth,CorrHeight,CoHeight,CoWidth;
double ItsAlpha,ItsTime,ItsTp,ItsTs,ItsZs,ItsZp;
double ItsUpperLayerVolume,ItsCp,ItsHSmoke,ItsOldQp;
};//close class Dimensions
double DoOccupancy();
double AlphaSelection(double Selection1);
double DoAnalyseZ(Dimensions &rAdjacent);
void DoIterations(Dimensions &rAdjacent);
double Dimensions::GetQp()
{
return (GetAlpha() * (pow(GetTime(),2)));
}
double Dimensions::GetQs()
{
double T=0;
while (T == 0)
{
if (GetTime() == 0)
{
T = (GetAlpha() * (pow(GetTime(),2)));
break;
}
if (GetTime() > 0)
{
T = GetOldQp() + (GetAlpha() * (pow(GetTime(),2)));
break;
}
}
SetOldQp(T);
GetOldQp();
return T;
}
double Dimensions::GetMassFlowRatePlume()
{
return ((0.071) * (pow(GetQp(),0.3333)) * (pow(GetZp(),1.6666)));
}
void Dimensions::SetOriginDimensions(double SOLenght,double SOWidth,double SOHeight)
{
OLenght = SOLenght;
OWidth = SOWidth;
OHeight = SOHeight;
}
void Dimensions::SetOriginOpDimensions(double SOoHeight,double SOoWidth)
{
OoHeight = SOoHeight;
OoWidth = SOoWidth;
}
void Dimensions::SetCorridorDimensions(double SCorrLenght,double SCorrWidth,double SCorrHeight)
{
CorrLenght = SCorrLenght;
CorrWidth = SCorrWidth;
CorrHeight = SCorrHeight;
}
void Dimensions::SetCorridorOpDimensions(double SCoHeight,double SCoWidth)
{
CoHeight = SCoHeight;
CoWidth = SCoWidth;
}
void Dimensions::SetAlpha(double SAlpha)
{
ItsAlpha = SAlpha;
}
void Dimensions::SetTime(double STime)
{
ItsTime = STime;
}
void Dimensions::SetTp(double TheTp)
{
ItsTp = TheTp;
}
void Dimensions::SetTs(double TheTs)
{
ItsTs = TheTs;
}
void Dimensions::SetZs(double TheZs)
{
ItsZs = TheZs;
}
void Dimensions::SetZp(double TheZp)
{
ItsZp = TheZp;
}
void Dimensions::SetUpperLayerVolume(double TheUpperLayerVolume)
{
ItsUpperLayerVolume = TheUpperLayerVolume;
}
void Dimensions::SetCp( double TheCp)
{
ItsCp = TheCp;
}
void Dimensions::SetHSmoke( double TheHSmoke)
{
ItsHSmoke = TheHSmoke;
}
void Dimensions::SetOldQp(double TheOldQp)
{
ItsOldQp = TheOldQp;
}
double DoOccupancy()//Function To point out occupancies and types of fires associated with them ref.TM19
{
double Selection;
cout << "Please Select the type of occupancy to be analysed from the selection below: "<<endl;
fout << "Please Select the type of occupancy to be analysed from the selection below: "<<endl;
cout << "(0) DWELLING (medium fire),(1) OFFICE (medium fire), (2) SHOP (Ultrafast Fire), (3) HOTEL (medium fire)(4) HOTEL BEDROOM (medium fire), (5) PICTURE GALLERY (slow fire)" <<endl;
fout << "(0) DWELLING (medium fire),(1) OFFICE (medium fire), (2) SHOP (Ultrafast Fire), (3) HOTEL (medium fire)(4) HOTEL BEDROOM (medium fire), (5) PICTURE GALLERY (slow fire)" <<endl;
cin >> Selection;
fout << Selection <<endl;
if ((Selection!= Dwelling) && (Selection!= Office) && (Selection != Shop) && (Selection != HotelReception) && (Selection != HotelBedroom) && (Selection != PictureGallery))
{
cout << "\t** Invalid Choice **, Please Reselect!" <<endl;
//fout << "\t** Invalid Choice **, Please Reselect!" <<endl;
Selection = DoOccupancy();
}
return Selection;
}
double AlphaSelection(double Selection1) //Function that allocates the alpha values according to occupancy selection
{
double AlphaValue;
while( Selection1 == Dwelling||Office||Shop ||HotelReception||HotelBedroom||PictureGallery)
{
if (Selection1 == Dwelling)
{
//cout <<"I'm here0" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == Office)
{
//cout <<"I'm here1" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == Shop)
{
//cout <<"I'm here2" <<endl;
AlphaValue = 0.0469;
break;
}
if (Selection1 == HotelReception)
{
//cout <<"I'm here3" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == HotelBedroom)
{
//cout <<"I'm here4" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == PictureGallery)
{
// cout <<"I'm here" <<endl;
AlphaValue = 0.0029;
break;
}
}
return AlphaValue;
}
double DoAnalyseZ(Dimensions &rAdjacent)
{
double SmokeTemp,VolumeOfLayer,HSmoke,ZSmoke;
rAdjacent.GetMassFlowRatePlume();
if (rAdjacent.GetTime() == 0)
{
/*cout << "Qs is " << rAdjacent.GetQs()<<endl;
fout << "Qs is " << rAdjacent.GetQs()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTemp = (rAdjacent.GetQs() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTemp);
rAdjacent.GetTs();
VolumeOfLayer = ((rAdjacent.GetMassFlowRatePlume() * SmokeTemp)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayer);
rAdjacent.GetUpperLayerVolume();
cout << "Volume is " << rAdjacent.GetUpperLayerVolume()<<endl;
HSmoke = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmoke);
rAdjacent.GetHSmoke();
ZSmoke = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmoke);
rAdjacent.GetZs();
cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << ZSmoke << "at zero"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << ZSmoke << "at zero"<<endl;
}
while (rAdjacent.GetTime() >0)
{
/*cout << "Qs is " << rAdjacent.GetQs()<<endl;
fout << "Qs is " << rAdjacent.GetQs()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTemp = (rAdjacent.GetQs() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTemp);
rAdjacent.GetTs();
VolumeOfLayer = ((rAdjacent.GetMassFlowRatePlume() * SmokeTemp)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayer);
rAdjacent.GetUpperLayerVolume();
HSmoke = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmoke);
rAdjacent.GetHSmoke();
ZSmoke = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmoke);
rAdjacent.GetZs();
/*cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting1"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting1"<<endl;
*/
if (rAdjacent.GetZs() == rAdjacent.GetZp())
{
cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting"<<endl;
break;
}
if (rAdjacent.GetZs() != rAdjacent.GetZp())
{
DoIterations(rAdjacent);
break;
}
}
return ZSmoke;
}
void DoIterations(Dimensions &rAdjacent)
{
double NewZ = rAdjacent.GetZs(),Check =1,SmokeTempHere,VolumeOfLayerHere,HSmokeHere,ZSmokeHere ;
rAdjacent.SetZp(NewZ);
rAdjacent.GetZp();
while (Check == 1)
{
/*cout << "OldQp is " << rAdjacent.GetOldQp()<<endl;
fout << "OldQp is " << rAdjacent.GetOldQp()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTempHere = (rAdjacent.GetOldQp() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTempHere);
rAdjacent.GetTs();
VolumeOfLayerHere = ((rAdjacent.GetMassFlowRatePlume() * SmokeTempHere)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayerHere );
rAdjacent.GetUpperLayerVolume();
HSmokeHere = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmokeHere );
rAdjacent.GetHSmoke();
ZSmokeHere = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmokeHere);
rAdjacent.GetZs();
if (rAdjacent.GetZs() == rAdjacent.GetZp())
{
cout << "Zp is equal to Zs" <<endl;
fout << "Zp is equal to Zs" <<endl;
break;
}
if (rAdjacent.GetZs() != rAdjacent.GetZp())
{
cout << "\nZp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm continuing"<<endl;
fout << "\nZp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm continuing"<<endl;
rAdjacent.SetZp(ZSmokeHere);
rAdjacent.GetZp();
continue;
}
}
}
int main()
{
double CompLenght=2.34,CompWidth=2.34,CompHeight=2.16,CompOpHeight=1.6,CompOpWidth=0.81;
double CorrLenght=5,CorrWidth=3,CorrHeight=5,CorrOpHeight=3,CorrOpWidth=1,Choice1,Alpha;
double Time=0,Z;
/*cout << "Please enter the dimensions for the Main Compartment." <<endl;
fout << "Please enter the dimensions for the Main Compartment." <<endl;
cout << "Enter Compartment Lenght: " ;
fout << "Enter Compartment Lenght: " ;
cin>> CompLenght;
fout << CompLenght <<endl;
cout << "\nCompartment Width: " ;
fout << "\nCompartment Width: " ;
cin>> CompWidth;
fout << CompWidth << endl;
cout << "\nCompartment Height: ";
fout << "\nCompartment Height: ";
cin >> CompHeight;
fout << CompHeight <<endl;
cout << "\nPlease enter dimensions for compartment opening" <<endl;
fout << "\nPlease enter dimensions for compartment opening" <<endl;
cout << "Enter Opening Height: " <<endl;
fout << "Enter Opening Height: " <<endl;
cin >> CompOpHeight;
fout << CompOpHeight<<endl;
cout << "Enter Opening Width: " <<endl;
fout << "Enter Opening Width: " <<endl;
cin >> CompOpWidth;
fout << CompOpWidth <<endl;
fout << "DIMENSIONS OF RoO(Metres)" <<endl;
fout << "LENGHT,WIDTH,HEIGHT,OPENING HEIGHT,OPENING WIDTH" <<endl;
fout << CompLenght << "," <<CompWidth << "," << CompHeight << "," << CompOpHeight << "," << CompOpWidth << endl;
*/
//CLASS DIMENSIONS
Dimensions Adjacent;
/*cout << "Please enter the dimensions for the Corridor." <<endl;
cout << "Please enter the dimensions for the Corridor." <<endl;
cout << "Enter Corridor Lenght: " ;
fout << "Enter Corridor Lenght: " ;
cin>> CorrLenght;
fout<< CorrLenght <<endl;
cout << "\nCorridor Width: " ;
fout << "\nCorridor Width: " ;
cin>> CorrWidth;
fout << CorrWidth << endl;
cout << "\nCorridor Height: ";
fout << "\nCorridor Height: ";
cin >> CorrHeight;
fout << CorrHeight <<endl;
cout << "\nPlease enter dimensions for Corridor opening" <<endl;
fout << "\nPlease enter dimensions for Corridor opening" <<endl;
cout << "Enter Opening Height: " <<endl;
fout << "Enter Opening Height: " <<endl;
cin >> CorrOpHeight;
fout << CorrOpHeight<<endl;
cout << "Enter Opening Width: " <<endl;
fout << "Enter Opening Width: " <<endl;
cin >> CorrOpWidth;
fout << CorrOpWidth <<endl;*/
Choice1 = DoOccupancy();
Alpha = AlphaSelection(Choice1);
Adjacent.SetTime(Time);
Adjacent.SetAlpha(Alpha);
Adjacent.SetOriginDimensions(CompLenght,CompWidth,CompHeight);
Adjacent.SetOriginOpDimensions(CompOpHeight,CompOpWidth);
Adjacent.SetCorridorDimensions(CorrLenght,CorrWidth,CorrHeight);
Adjacent.SetCorridorOpDimensions(CorrOpHeight,CorrOpWidth);
Adjacent.SetZp(CompHeight);
Adjacent.GetZp();
for (Time = 0; Time <5;Time++)
{
cout << "Time is :" << Time <<endl;
fout << "Time is :" << Time <<endl;
Adjacent.SetTime(Time);
Adjacent.GetTime();
Z = DoAnalyseZ(Adjacent);
cout << "\nAt time" << Time << "Z is " << Z <<endl;
fout << "\nAt time" << Time << "Z is " << Z <<endl;
}
cout << "THE END" <<endl;
return 0;
}
Now my values are in double and are decimal values the output is that x = 1.51675 and y= 1.51675 so they are the same. but when the statement is not executed and when i subtract y from x just to test the output is very strange its like 2.356exp-09
How can i stop this?
see code below: you'll see that it does not recognize the equlaity:
#include <fstream.h>
#include <iostream.h>
#include <math.h>
//ofstream fout("NikeSurvives1.rtf",ios:ut);
ofstream fout("NikeSurvives1.rtf",ios:ut);
//Enumerations
enum OCCUPANCY { Dwelling,Office,Shop,HotelReception,HotelBedroom,PictureGallery};
enum HEATOFCOMBUSTION { Timber, PolyvinylChloride,PolyUrethane_flexible,PolyUrethane_rigid,Polystyrene,Polypropylene,NotSure};
//Class Declarations
class Dimensions //class for taking dimensions //declaration + some implementations
{
public:
Dimensions(){}; //constructor
~ Dimensions(){}; //destructor
double GetOriginLenght() { return OLenght;} //Accessors
double GetOriginWidth(){ return OWidth;}
double GetOriginHeight(){ return OHeight;}
double GetOriginOpHeight() { return OoHeight;}
double GetOriginOpWidth(){ return OoWidth;}
double GetCorridorLenght(){ return CorrLenght;}
double GetCorridorWidth(){ return CorrWidth;}
double GetCorridorHeight(){ return CorrHeight;}
double GetCorridorOpHeight(){ return CoHeight;}
double GetCorridorOpWidth(){ return CoWidth;}
double GetAlpha() {return ItsAlpha;}
double GetTime() {return ItsTime;}
double GetOldQp() {return ItsOldQp;}
double GetTp() {return ItsTp;}
double GetTs() {return ItsTs;}
double GetZs() {return ItsZs;}
double GetZp() {return ItsZp;}
double GetUpperLayerVolume() {return ItsUpperLayerVolume;}
double GetCp() {return ItsCp;}
double GetHSmoke() {return ItsHSmoke;}
double GetQp();
double GetQs();
double GetMassFlowRatePlume();
void SetOriginDimensions( double SOLenght,double SOWidth,double SOHeight);
void SetOriginOpDimensions(double SOoHeight,double SOoWidth);
void SetCorridorDimensions(double SCorrLenght,double SCorrWidth,double SCorrHeight);
void SetCorridorOpDimensions(double SCoHeight,double SCoWidth);
void SetAlpha(double SAlpha);
void SetTime(double STime);
void SetOldQp(double TheOldQp);
void SetTp(double TheTp);
void SetTs(double TheTs);
void SetZs(double TheZs);
void SetZp(double TheZp);
void SetUpperLayerVolume(double TheUpperLayerVolume);
void SetCp( double TheCp);
void SetHSmoke (double TheHSmoke);
private:
double OLenght,OWidth,OHeight,OoHeight,OoWidth,CorrLenght,CorrWidth,CorrHeight,CoHeight,CoWidth;
double ItsAlpha,ItsTime,ItsTp,ItsTs,ItsZs,ItsZp;
double ItsUpperLayerVolume,ItsCp,ItsHSmoke,ItsOldQp;
};//close class Dimensions
double DoOccupancy();
double AlphaSelection(double Selection1);
double DoAnalyseZ(Dimensions &rAdjacent);
void DoIterations(Dimensions &rAdjacent);
double Dimensions::GetQp()
{
return (GetAlpha() * (pow(GetTime(),2)));
}
double Dimensions::GetQs()
{
double T=0;
while (T == 0)
{
if (GetTime() == 0)
{
T = (GetAlpha() * (pow(GetTime(),2)));
break;
}
if (GetTime() > 0)
{
T = GetOldQp() + (GetAlpha() * (pow(GetTime(),2)));
break;
}
}
SetOldQp(T);
GetOldQp();
return T;
}
double Dimensions::GetMassFlowRatePlume()
{
return ((0.071) * (pow(GetQp(),0.3333)) * (pow(GetZp(),1.6666)));
}
void Dimensions::SetOriginDimensions(double SOLenght,double SOWidth,double SOHeight)
{
OLenght = SOLenght;
OWidth = SOWidth;
OHeight = SOHeight;
}
void Dimensions::SetOriginOpDimensions(double SOoHeight,double SOoWidth)
{
OoHeight = SOoHeight;
OoWidth = SOoWidth;
}
void Dimensions::SetCorridorDimensions(double SCorrLenght,double SCorrWidth,double SCorrHeight)
{
CorrLenght = SCorrLenght;
CorrWidth = SCorrWidth;
CorrHeight = SCorrHeight;
}
void Dimensions::SetCorridorOpDimensions(double SCoHeight,double SCoWidth)
{
CoHeight = SCoHeight;
CoWidth = SCoWidth;
}
void Dimensions::SetAlpha(double SAlpha)
{
ItsAlpha = SAlpha;
}
void Dimensions::SetTime(double STime)
{
ItsTime = STime;
}
void Dimensions::SetTp(double TheTp)
{
ItsTp = TheTp;
}
void Dimensions::SetTs(double TheTs)
{
ItsTs = TheTs;
}
void Dimensions::SetZs(double TheZs)
{
ItsZs = TheZs;
}
void Dimensions::SetZp(double TheZp)
{
ItsZp = TheZp;
}
void Dimensions::SetUpperLayerVolume(double TheUpperLayerVolume)
{
ItsUpperLayerVolume = TheUpperLayerVolume;
}
void Dimensions::SetCp( double TheCp)
{
ItsCp = TheCp;
}
void Dimensions::SetHSmoke( double TheHSmoke)
{
ItsHSmoke = TheHSmoke;
}
void Dimensions::SetOldQp(double TheOldQp)
{
ItsOldQp = TheOldQp;
}
double DoOccupancy()//Function To point out occupancies and types of fires associated with them ref.TM19
{
double Selection;
cout << "Please Select the type of occupancy to be analysed from the selection below: "<<endl;
fout << "Please Select the type of occupancy to be analysed from the selection below: "<<endl;
cout << "(0) DWELLING (medium fire),(1) OFFICE (medium fire), (2) SHOP (Ultrafast Fire), (3) HOTEL (medium fire)(4) HOTEL BEDROOM (medium fire), (5) PICTURE GALLERY (slow fire)" <<endl;
fout << "(0) DWELLING (medium fire),(1) OFFICE (medium fire), (2) SHOP (Ultrafast Fire), (3) HOTEL (medium fire)(4) HOTEL BEDROOM (medium fire), (5) PICTURE GALLERY (slow fire)" <<endl;
cin >> Selection;
fout << Selection <<endl;
if ((Selection!= Dwelling) && (Selection!= Office) && (Selection != Shop) && (Selection != HotelReception) && (Selection != HotelBedroom) && (Selection != PictureGallery))
{
cout << "\t** Invalid Choice **, Please Reselect!" <<endl;
//fout << "\t** Invalid Choice **, Please Reselect!" <<endl;
Selection = DoOccupancy();
}
return Selection;
}
double AlphaSelection(double Selection1) //Function that allocates the alpha values according to occupancy selection
{
double AlphaValue;
while( Selection1 == Dwelling||Office||Shop ||HotelReception||HotelBedroom||PictureGallery)
{
if (Selection1 == Dwelling)
{
//cout <<"I'm here0" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == Office)
{
//cout <<"I'm here1" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == Shop)
{
//cout <<"I'm here2" <<endl;
AlphaValue = 0.0469;
break;
}
if (Selection1 == HotelReception)
{
//cout <<"I'm here3" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == HotelBedroom)
{
//cout <<"I'm here4" <<endl;
AlphaValue = 0.0117;
break;
}
if (Selection1 == PictureGallery)
{
// cout <<"I'm here" <<endl;
AlphaValue = 0.0029;
break;
}
}
return AlphaValue;
}
double DoAnalyseZ(Dimensions &rAdjacent)
{
double SmokeTemp,VolumeOfLayer,HSmoke,ZSmoke;
rAdjacent.GetMassFlowRatePlume();
if (rAdjacent.GetTime() == 0)
{
/*cout << "Qs is " << rAdjacent.GetQs()<<endl;
fout << "Qs is " << rAdjacent.GetQs()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTemp = (rAdjacent.GetQs() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTemp);
rAdjacent.GetTs();
VolumeOfLayer = ((rAdjacent.GetMassFlowRatePlume() * SmokeTemp)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayer);
rAdjacent.GetUpperLayerVolume();
cout << "Volume is " << rAdjacent.GetUpperLayerVolume()<<endl;
HSmoke = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmoke);
rAdjacent.GetHSmoke();
ZSmoke = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmoke);
rAdjacent.GetZs();
cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << ZSmoke << "at zero"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << ZSmoke << "at zero"<<endl;
}
while (rAdjacent.GetTime() >0)
{
/*cout << "Qs is " << rAdjacent.GetQs()<<endl;
fout << "Qs is " << rAdjacent.GetQs()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTemp = (rAdjacent.GetQs() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTemp);
rAdjacent.GetTs();
VolumeOfLayer = ((rAdjacent.GetMassFlowRatePlume() * SmokeTemp)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayer);
rAdjacent.GetUpperLayerVolume();
HSmoke = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmoke);
rAdjacent.GetHSmoke();
ZSmoke = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmoke);
rAdjacent.GetZs();
/*cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting1"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting1"<<endl;
*/
if (rAdjacent.GetZs() == rAdjacent.GetZp())
{
cout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting"<<endl;
fout << "Zp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm setting"<<endl;
break;
}
if (rAdjacent.GetZs() != rAdjacent.GetZp())
{
DoIterations(rAdjacent);
break;
}
}
return ZSmoke;
}
void DoIterations(Dimensions &rAdjacent)
{
double NewZ = rAdjacent.GetZs(),Check =1,SmokeTempHere,VolumeOfLayerHere,HSmokeHere,ZSmokeHere ;
rAdjacent.SetZp(NewZ);
rAdjacent.GetZp();
while (Check == 1)
{
/*cout << "OldQp is " << rAdjacent.GetOldQp()<<endl;
fout << "OldQp is " << rAdjacent.GetOldQp()<<endl;
cout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;
fout << "m is " << rAdjacent.GetMassFlowRatePlume() << endl;*/
SmokeTempHere = (rAdjacent.GetOldQp() /( rAdjacent.GetMassFlowRatePlume()*1) + 273);
rAdjacent.SetTs(SmokeTempHere);
rAdjacent.GetTs();
VolumeOfLayerHere = ((rAdjacent.GetMassFlowRatePlume() * SmokeTempHere)/352);
rAdjacent.SetUpperLayerVolume(VolumeOfLayerHere );
rAdjacent.GetUpperLayerVolume();
HSmokeHere = (rAdjacent.GetUpperLayerVolume()/ (rAdjacent.GetOriginLenght() * rAdjacent.GetOriginWidth()));
rAdjacent.SetHSmoke(HSmokeHere );
rAdjacent.GetHSmoke();
ZSmokeHere = rAdjacent.GetOriginHeight() - rAdjacent.GetHSmoke();
rAdjacent.SetZs(ZSmokeHere);
rAdjacent.GetZs();
if (rAdjacent.GetZs() == rAdjacent.GetZp())
{
cout << "Zp is equal to Zs" <<endl;
fout << "Zp is equal to Zs" <<endl;
break;
}
if (rAdjacent.GetZs() != rAdjacent.GetZp())
{
cout << "\nZp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm continuing"<<endl;
fout << "\nZp is " << rAdjacent.GetZp() << " and Zs is " << rAdjacent.GetZs() << "so i'm continuing"<<endl;
rAdjacent.SetZp(ZSmokeHere);
rAdjacent.GetZp();
continue;
}
}
}
int main()
{
double CompLenght=2.34,CompWidth=2.34,CompHeight=2.16,CompOpHeight=1.6,CompOpWidth=0.81;
double CorrLenght=5,CorrWidth=3,CorrHeight=5,CorrOpHeight=3,CorrOpWidth=1,Choice1,Alpha;
double Time=0,Z;
/*cout << "Please enter the dimensions for the Main Compartment." <<endl;
fout << "Please enter the dimensions for the Main Compartment." <<endl;
cout << "Enter Compartment Lenght: " ;
fout << "Enter Compartment Lenght: " ;
cin>> CompLenght;
fout << CompLenght <<endl;
cout << "\nCompartment Width: " ;
fout << "\nCompartment Width: " ;
cin>> CompWidth;
fout << CompWidth << endl;
cout << "\nCompartment Height: ";
fout << "\nCompartment Height: ";
cin >> CompHeight;
fout << CompHeight <<endl;
cout << "\nPlease enter dimensions for compartment opening" <<endl;
fout << "\nPlease enter dimensions for compartment opening" <<endl;
cout << "Enter Opening Height: " <<endl;
fout << "Enter Opening Height: " <<endl;
cin >> CompOpHeight;
fout << CompOpHeight<<endl;
cout << "Enter Opening Width: " <<endl;
fout << "Enter Opening Width: " <<endl;
cin >> CompOpWidth;
fout << CompOpWidth <<endl;
fout << "DIMENSIONS OF RoO(Metres)" <<endl;
fout << "LENGHT,WIDTH,HEIGHT,OPENING HEIGHT,OPENING WIDTH" <<endl;
fout << CompLenght << "," <<CompWidth << "," << CompHeight << "," << CompOpHeight << "," << CompOpWidth << endl;
*/
//CLASS DIMENSIONS
Dimensions Adjacent;
/*cout << "Please enter the dimensions for the Corridor." <<endl;
cout << "Please enter the dimensions for the Corridor." <<endl;
cout << "Enter Corridor Lenght: " ;
fout << "Enter Corridor Lenght: " ;
cin>> CorrLenght;
fout<< CorrLenght <<endl;
cout << "\nCorridor Width: " ;
fout << "\nCorridor Width: " ;
cin>> CorrWidth;
fout << CorrWidth << endl;
cout << "\nCorridor Height: ";
fout << "\nCorridor Height: ";
cin >> CorrHeight;
fout << CorrHeight <<endl;
cout << "\nPlease enter dimensions for Corridor opening" <<endl;
fout << "\nPlease enter dimensions for Corridor opening" <<endl;
cout << "Enter Opening Height: " <<endl;
fout << "Enter Opening Height: " <<endl;
cin >> CorrOpHeight;
fout << CorrOpHeight<<endl;
cout << "Enter Opening Width: " <<endl;
fout << "Enter Opening Width: " <<endl;
cin >> CorrOpWidth;
fout << CorrOpWidth <<endl;*/
Choice1 = DoOccupancy();
Alpha = AlphaSelection(Choice1);
Adjacent.SetTime(Time);
Adjacent.SetAlpha(Alpha);
Adjacent.SetOriginDimensions(CompLenght,CompWidth,CompHeight);
Adjacent.SetOriginOpDimensions(CompOpHeight,CompOpWidth);
Adjacent.SetCorridorDimensions(CorrLenght,CorrWidth,CorrHeight);
Adjacent.SetCorridorOpDimensions(CorrOpHeight,CorrOpWidth);
Adjacent.SetZp(CompHeight);
Adjacent.GetZp();
for (Time = 0; Time <5;Time++)
{
cout << "Time is :" << Time <<endl;
fout << "Time is :" << Time <<endl;
Adjacent.SetTime(Time);
Adjacent.GetTime();
Z = DoAnalyseZ(Adjacent);
cout << "\nAt time" << Time << "Z is " << Z <<endl;
fout << "\nAt time" << Time << "Z is " << Z <<endl;
}
cout << "THE END" <<endl;
return 0;
}