Skip to content

Commit

Permalink
update cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
thermalogic committed Mar 5, 2021
1 parent 3a1617f commit 5d5d086
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 72 deletions.
6 changes: 5 additions & 1 deletion cpp/include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class CompBase
string energy;
Port *iPort;
Port *oPort;
Port *ePort; // turbineex1
Port *ePort; // turbineex1
Port *iPort_fw; // opendedheaterdw0
Port *oPort_fw; // opendedheaterdw0

mapPortObj portdict;

double workExtracted;
double heatAdded;
double workRequired;

virtual void setportaddress() = 0;
virtual void state() = 0;
virtual int balance() = 0;
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/condenser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class Condenser : public CompBase
double heatExtracted;
Condenser(umComponent dictComp);
~Condenser();

void setportaddress();
void state();
int balance();
string resultstring();

};

#endif /* Condenser_hpp */
18 changes: 9 additions & 9 deletions cpp/include/openedheaterdw0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
class OpenedHeaterDw0 : public CompBase
{
public:
double heatAdded;
double heatExtracted;
double heatAdded;
double heatExtracted;

// methods
OpenedHeaterDw0(umComponent dictComp);
~OpenedHeaterDw0();
// methods
OpenedHeaterDw0(umComponent dictComp);
~OpenedHeaterDw0();

void setportaddress();
void state();
int balance();
string resultstring();
void setportaddress();
void state();
int balance();
string resultstring();
};

#endif /* OpenedHeaterDw0_hpp */
2 changes: 1 addition & 1 deletion cpp/include/port.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Port
double x;
double fdot;
double mdot;

// methods
Port(mPort curmPort);
~Port();
Expand Down
36 changes: 18 additions & 18 deletions cpp/include/rankine81.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
#include "common.hpp"

Components Components81 = {
{{"name", "Turbine1"},
{"classstr", "TurbineEx0"},
{"ef", 1.0},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 0.008}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}}},
{{"name", "Condenser"},
{"classstr", "Condenser"},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 0.008}, {"t", NAN}, {"x", 0.0}, {"fdot", NAN}}}},
{{"name", "Pump1"},
{"classstr", "Pump"},
{"ef", 1.0},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 8.0}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}}},
{{"name", "Boiler1"},
{"classstr", "Boiler"},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 8.0}, {"t", NAN}, {"x", 1.0}, {"fdot", 1.0}}}}
{{"name", "Turbine1"},
{"classstr", "TurbineEx0"},
{"ef", 1.0},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 0.008}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}}},
{{"name", "Condenser"},
{"classstr", "Condenser"},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 0.008}, {"t", NAN}, {"x", 0.0}, {"fdot", NAN}}}},
{{"name", "Pump1"},
{"classstr", "Pump"},
{"ef", 1.0},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 8.0}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}}},
{{"name", "Boiler1"},
{"classstr", "Boiler"},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 8.0}, {"t", NAN}, {"x", 1.0}, {"fdot", 1.0}}}}

};

Expand Down
3 changes: 1 addition & 2 deletions cpp/include/rankine82.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

#include "common.hpp"


Components Components82 = {
{{"name", "Turbine1"},
{"classstr", "TurbineEx0"},
{"ef",0.85},
{"ef", 0.85},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 0.008}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}}},
{{"name", "Condenser"},
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/rankine85.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Components Components85 = {
{{"name", "Boiler1"},
{"classstr", "Boiler"},
{"iPort", (mPort){{"p", NAN}, {"t", NAN}, {"x", NAN}, {"fdot", NAN}}},
{"oPort", (mPort){{"p", 8.0}, {"t", 480.0}, {"x", NAN}, {"fdot", 1.0}}}}
};
{"oPort", (mPort){{"p", 8.0}, {"t", 480.0}, {"x", NAN}, {"fdot", 1.0}}}}};

Connectors Connectors85 = {
{{"Boiler1", "oPort"}, {"TurbineEx1", "iPort"}},
Expand Down
3 changes: 1 addition & 2 deletions cpp/include/rankinemodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "rankine82.hpp"
#include "rankine85.hpp"


rankinecycles cycles= {rankine81, rankine82, rankine85};
rankinecycles cycles = {rankine81, rankine82, rankine85};

#endif /* RANKINEMODEL_hpp */
18 changes: 9 additions & 9 deletions cpp/include/turbineex0.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
class TurbineEx0 : public CompBase
{
public:
double ef;
double workExtracted;
double ef;
double workExtracted;

// methods
TurbineEx0(umComponent dictComp);
~TurbineEx0();
// methods
TurbineEx0(umComponent dictComp);
~TurbineEx0();

void setportaddress();
void state();
int balance();
string resultstring();
void setportaddress();
void state();
int balance();
string resultstring();
};

#endif /* TurbineEx0_hpp */
2 changes: 1 addition & 1 deletion cpp/rankinesim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ int main()
curcycle->outresults();
};
return 0;
}
}
2 changes: 0 additions & 2 deletions cpp/src/boiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Boiler::Boiler(umComponent dictComp)
portdict = {{"iPort", iPort},
{"oPort", oPort}};
energy = "heatAdded";

}

Boiler::~Boiler()
Expand All @@ -26,7 +25,6 @@ Boiler::~Boiler()

void Boiler::state()
{

}

int Boiler::balance()
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/pump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Pump::~Pump()
void Pump::state()
{
oPort->h = iPort->h;
double sout_s =iPort->s;
double hout_s = seups(oPort->p, sout_s,4);
oPort->h = iPort->h + (hout_s -iPort->h) /ef;
double sout_s = iPort->s;
double hout_s = seups(oPort->p, sout_s, 4);
oPort->h = iPort->h + (hout_s - iPort->h) / ef;
oPort->ph();
}

Expand Down
29 changes: 9 additions & 20 deletions cpp/src/rankine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,13 @@ void RankineCycle::ComponentBalance()
{
try
{
rtn = Comps[item]->balance();
if (rtn == 1)
rtn=Comps[item]->balance();
if (rtn==1)
{
balanceok[i] = true;
numdeviceok = +1;
balanceok[i] = true;
numdeviceok = +1;
}

}
catch (...)
{
Expand Down Expand Up @@ -114,28 +115,16 @@ void RankineCycle::Simulator()
{
if (iter->second->energy == "workExtracted")
{
try
{
totalworkExtracted += ((TurbineEx0 *)iter->second)->workExtracted;
}
catch (...)
{
try
{
totalworkExtracted += ((TurbineEx1 *)iter->second)->workExtracted;
}
catch (...)
{
};
};
totalworkExtracted += iter->second->workExtracted;

};
if (iter->second->energy == "heatAdded")
{
totalheatAdded = ((Boiler *)iter->second)->heatAdded;
totalheatAdded += iter->second->heatAdded;
};
if (iter->second->energy == "workRequired")
{
totalworkRequired += ((Pump *)iter->second)->workRequired;
totalworkRequired +=iter->second->workRequired;
};
};
netpoweroutput = totalworkExtracted - totalworkRequired;
Expand Down

0 comments on commit 5d5d086

Please sign in to comment.