Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
c6f585a
Update bioCHP.cpp
gonzalodelalamo Feb 21, 2025
a342720
Update bioCHP_inputs
gonzalodelalamo Feb 21, 2025
bfca2e0
Update bioCHP_plant.h
gonzalodelalamo Feb 21, 2025
c52d3e7
Update combustion.h
gonzalodelalamo Feb 21, 2025
48d5741
Update Rankine_cycle.h
gonzalodelalamo Feb 21, 2025
b10782c
Update bioCHP.cpp
gonzalodelalamo Feb 22, 2025
1ea1b86
Create CREDITS.md
gonzalodelalamo Feb 22, 2025
a6146ab
Update CREDITS.md
gonzalodelalamo Feb 22, 2025
76312e4
Update CREDITS.md
gonzalodelalamo Feb 22, 2025
65873b9
Update CREDITS.md
gonzalodelalamo Feb 22, 2025
d64fd3a
Update CREDITS.md
gonzalodelalamo Feb 22, 2025
df14844
Update CREDITS.md
gonzalodelalamo Feb 22, 2025
3599bb6
Update CREDITS.md
gonzalodelalamo Feb 25, 2025
bfe4915
Create README.md
gonzalodelalamo Mar 14, 2025
a511076
Update README.md
gonzalodelalamo Mar 14, 2025
0cfd489
Update flow_definitions.h
gonzalodelalamo Mar 14, 2025
2694165
Update bioCHP.cpp
gonzalodelalamo Mar 14, 2025
0f37491
Update bioCHP.cpp
gonzalodelalamo Mar 14, 2025
80142e3
Update bioCHP.cpp
gonzalodelalamo Mar 14, 2025
230051e
Add files via upload
gonzalodelalamo Mar 17, 2025
54927d5
Add files via upload
gonzalodelalamo Mar 18, 2025
3b588dc
Update thermodynamics.h
gonzalodelalamo Mar 18, 2025
c06c32f
Update Thermodynamics_package.h
gonzalodelalamo Mar 18, 2025
1b253f9
Update feedstock_characterization.h
gonzalodelalamo Mar 18, 2025
7f3669c
Update flow_calculations.h
gonzalodelalamo Mar 18, 2025
913638c
Update Rankine_cycle.h
gonzalodelalamo Mar 18, 2025
7b58a95
Delete submodels/bioCHP_plant/Thermodynamic_library/conversion.h
gonzalodelalamo Mar 18, 2025
fdea782
Delete submodels/bioCHP_plant/Thermodynamic_library/thermodynamics.h
gonzalodelalamo Mar 18, 2025
cd471a8
Delete submodels/bioCHP_plant/Thermodynamic_library/thermodata.h
gonzalodelalamo Mar 18, 2025
df1ca06
Delete submodels/bioCHP_plant/Thermodynamic_library/thermo_property_m…
gonzalodelalamo Mar 18, 2025
633d979
Delete submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_dat…
gonzalodelalamo Mar 18, 2025
e418c4b
Delete submodels/bioCHP_plant/bioCHP.so
gonzalodelalamo Mar 18, 2025
6b429b8
Add files via upload
gonzalodelalamo Mar 18, 2025
c49b3cb
Update Parameters.h
gonzalodelalamo Mar 18, 2025
d98362a
Update Parameters.h
gonzalodelalamo Mar 18, 2025
7b268b5
Update flow_definitions.h
gonzalodelalamo Mar 18, 2025
f08f2a9
Update species_thermodynamics.h
gonzalodelalamo Mar 18, 2025
dc132cd
Update species_thermodynamics.h
gonzalodelalamo Mar 18, 2025
0a35986
Update Library_Water_Correlations.h
gonzalodelalamo Mar 18, 2025
3b42bf2
Update flow_definitions.h
gonzalodelalamo Mar 18, 2025
35d722b
Update Cost.h
gonzalodelalamo Mar 18, 2025
bb170ae
Update bioCHP_inputs
gonzalodelalamo Mar 24, 2025
c9b9e1b
Update Rankine_cycle.h
gonzalodelalamo Mar 24, 2025
21546db
Update README.md
gonzalodelalamo Mar 24, 2025
091ed00
Add files via upload
gonzalodelalamo Mar 24, 2025
bea5527
Add files via upload
gonzalodelalamo Mar 25, 2025
fc3642e
Update Rankine_cycle.h
gonzalodelalamo Mar 25, 2025
4af1556
Update bioCHP_function_test_1.cpp
gonzalodelalamo Mar 25, 2025
d7918e6
Update bioCHP_function_test_2.cpp
gonzalodelalamo Mar 25, 2025
b04fd7b
Update bioCHP_function_test_3.cpp
gonzalodelalamo Mar 25, 2025
6a424b1
Update bioCHP_function_test_1.cpp
gonzalodelalamo Mar 25, 2025
ac1ac92
Update bioCHP_function_test_1.cpp
gonzalodelalamo Mar 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions submodels/bioCHP_plant/CREDITS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bioCHP plant model.

author: Gonzalo del Alamo.

github user: gonzalodelalamo

e-mail: gonzalo.alamo@sintef.no

Tf: +47 93002014.
2 changes: 1 addition & 1 deletion submodels/bioCHP_plant/Cost.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ double I_cecpi(int year_ref, int year){
if (i==1){year_input = year;}
CECPI = cecpi(year_input);
if (i==0){CECPI_ref = CECPI;}
if (i==1){return CECPI/CECPI_ref;}
}
return CECPI/CECPI_ref;
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <string>
#include <boost/array.hpp>
//#include <boost/array.hpp>

void Heating_Value(flow &feed);

Expand Down
13 changes: 0 additions & 13 deletions submodels/bioCHP_plant/Flows_library/flow_calculations.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,3 @@ void flow::calculate_flow_parameters()
if( F.Hf == 0 and F.H > 0 and F.Ht > 0 ){F.Hf = F.H - F.Ht;}

}

void flow::calculate_gas_thermodynamics()
{
P.ht = 0;
for( int n=0; n<j.size(); n++)
{
j[n].P.ht = HGas_j(j[n].id, F.T)-HGas_j(j[n].id, 25);
P.ht = P.ht + j[n].P.ht*j[n].X;
}
if(F.N > 1e-10) {F.Ht = F.N * P.ht;}
if(F.N == 0) {F.Ht = (F.M/P.MW) * P.ht;}
}

49 changes: 48 additions & 1 deletion submodels/bioCHP_plant/Flows_library/flow_definitions.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#include <stdio.h>
#include <fstream>
#include <string.h>
Expand Down Expand Up @@ -33,7 +34,7 @@ struct physical_parameters_set
double physical_parameters_set::f(string symb){
bool found = false;
for(int np = 0; np < p.size(); np++){if (p[np].symb == symb){ found = true; return p[np].val;}}
if( found == false ){return -1;}
return -1;
}

struct properties
Expand Down Expand Up @@ -813,4 +814,50 @@ void flow::print_flow(){

}

bool find_flow(string input_def){

ifstream db_file;

string line_txt, txt, flow_cls, flow_db, error = input_def + " not found in the database";

db_file.open("Flows_library/Flows_database/Flow_list.txt");

if(!db_file.good()){ cout << error << endl; db_file.close(); return false;}
if(db_file.good()){
bool flow_found = false;
while (flow_found == false) {
getline(db_file, line_txt); stringstream sst(line_txt);
getline(sst, txt, ' ');
if(txt == input_def){
flow_found = true;
getline(sst, flow_cls, ' ');
getline(sst, flow_db, ' ');
break;
}
if(db_file.eof()){break;}
}

if(flow_found == false){cout << error << endl; db_file.close(); return false;}
}

db_file.close();

ifstream db;
db.open(flow_db);
if(!db.good()){cout << error << endl; db.close(); return false;}
if(db.good()){
bool flow_found = false;
while (flow_found == false) {
getline(db, line_txt); stringstream sst(line_txt);
getline(sst, txt, ' ');
if(txt == "Flow_def" or txt == "Flow_def:" or txt == "flow_def" or txt == "flow_def:" ){
while(getline(sst, txt, ' ')){if(txt == input_def){flow_found = true; return true;}}
}
if(db.eof()){break;}
}
}
return false;

}


32 changes: 27 additions & 5 deletions submodels/bioCHP_plant/Parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct parameter
{
public:
string sys_type, sys_def;
string data_def, data_id, data_type;
string data_def, data_id, data_type, data_info;
int pos;
vector<string> str;
vector<double> num;
Expand All @@ -58,6 +58,7 @@ struct object
object(){};
int ic(string type, string def);
int ip(string symb);
bool bp(string symb);
double fp(string symb);
vector<double> vctp(string symb);
string sp(string symb);
Expand All @@ -82,6 +83,7 @@ string get_parameter_value(vector<parameter> &par, string sys_type, string sys_d
}
}
if( found == false ) { return "null"; }
return "null";
}


Expand Down Expand Up @@ -152,9 +154,14 @@ void get_parameters( vector<parameter> &par, string sys_type, string sys_def, st
p.data_def = txt;
sst >> p.data_id;
//cout << "data_def: " << txt << " data_id: " << p.data_id << endl;
bool str_complete = false;
p.data_info = "";
while(sst >> str) {
//cout << "str[]: " << str << endl;
p.str.push_back(str);
vector<char> cstr(str.begin(), str.end());
if(!str_complete and cstr[0] != '#'){ p.str.push_back(str);}
if(cstr[0] == '#'){ str_complete = true; }
if(str_complete and cstr[0] != '#'){ p.data_info = str + " ";}

}
p.pos = 0; par.push_back(p); p = parameter(); p.str.clear(); p.num.clear();
}
Expand Down Expand Up @@ -227,7 +234,8 @@ vector<double> fp_vct(vector<parameter> &par, string sys_type, string sys_def, s
found = true; return vct;
}
}
if( found == false ) { return vct; }
//if( found == false ) { return vct; }
return vct;
}

vector<string> sp_vct(vector<parameter> &par, string sys_type, string sys_def, string data_id){
Expand All @@ -240,6 +248,7 @@ vector<string> sp_vct(vector<parameter> &par, string sys_type, string sys_def, s
}
}
if( found == false ) { return vct; }
return vct;
}

void fval_p(vector<parameter> &par, string data_def, string sys_type, string sys_def, string data_id, double val){
Expand Down Expand Up @@ -315,7 +324,20 @@ int object::ip(string symb){
for( int np = 0; np < p.size(); np++){
if(p[np].data_id == symb ){ return np; }
}
if( found == false ) { return -1; }
//if( found == false ) { return -1; }
return -1;


}

bool object::bp(string symb){

bool found = false;
for( int np = 0; np < p.size(); np++){
if(p[np].data_id == symb ){ return true; }
}
//if( found == false ) { return false; }
return false;

}

Expand Down
147 changes: 121 additions & 26 deletions submodels/bioCHP_plant/Processes_library/Rankine_cycle.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


struct steam_turbine_parameters
{
public:
Expand Down Expand Up @@ -115,7 +116,14 @@ void steam_turbine_model(flow &in, flow &out, object &par){

double W = 0;

if (N_bleed == 0){ steam_turbine(in, out, ST);}
if (N_bleed == 0){
steam_turbine(in, out, ST);
par.fval_p("W_el", 1e-6 * ST.W);

cout << "-------------------------- " << endl;
cout << "Steam turbine power output: (MW): " << 1e-6 * W << endl;

}

if (N_bleed > 0){
steam_turbine_parameters ST_n;
Expand Down Expand Up @@ -181,44 +189,128 @@ void steam_condenser(flow &steam, flow &cond, object &par){
cout << "District heating: " << endl;
cout << "---------------------- " << endl;

cout << "Heat capacity (MW): " << par.fp("Q_dh") << endl;
cout << "T_dh_in (deg. C): " << par.fp("T_dh_in") << endl;
cout << "T_dh_out (deg. C): " << par.fp("T_dh_out") << endl;


vector<double> P_bleed, M_bleed;

dh_in = flow("dh_in", "water"); dh_out = flow("dh_out", "water");

dh_in.F.T = par.fp("T_dh_in"); dh_in.F.P = 1.01325; dh_in.P.h = hTWater(dh_in.F.T); //h_in.calculate_flow_properties("PT");
dh_out.F.T = par.fp("T_dh_out"); dh_out.F.P = 1.01325; dh_out.P.h = hTWater(dh_out.F.T); //dh_out.calculate_flow_properties("PT");
if( par.vctp("Qk").size() > 0 ){

for(int nk = 0; nk < par.vctp("Qk").size(); nk++){

dh_in.F.T = par.vctp("Tk_in")[nk]; dh_in.F.P = 1.01325; dh_in.P.h = hTWater(dh_in.F.T); //h_in.calculate_flow_properties("PT");
dh_out.F.T = par.vctp("Tk_out")[nk]; dh_out.F.P = 1.01325; dh_out.P.h = hTWater(dh_out.F.T); //dh_out.calculate_flow_properties("PT");

dh_in.F.M = par.vctp("Qk")[nk] / (dh_out.P.h - dh_in.P.h);
dh_out.F.M = dh_in.F.M;

flow hf_in, hf_out; // In / out heating fluid to for exporting heat to district heating
hf_in = flow("hf_in", "water"); hf_out = flow("hf_out", "water");
hf_in.F.T = dh_out.F.T + 25.0; hf_in.F.P = PSatWater(hf_in.F.T); double Tsat_hf_in = TSatWater(hf_in.F.P); hf_in.P.h = hPSatSteam(hf_in.F.P);
hf_out.F.T = Tsat_hf_in - 5.0; hf_out.F.P = hf_in.F.P; hf_out.P.h = hTWater(hf_out.F.T);

hf_in.F.M = 1e3*par.vctp("Qk")[nk] / (hf_in.P.h - hf_out.P.h);
hf_out.F.M = hf_in.F.M;

cout << "Heating fluid:" << '\t' << "in" << '\t' << "out" << endl;
cout << "M (kg/s)" << '\t' << hf_in.F.M << '\t' << hf_out.F.M << endl;
cout << "P (bar-a)" << '\t' << hf_in.F.P << '\t' << hf_out.F.P << endl;
cout << "T (deg-C)" << '\t' << hf_in.F.T << '\t' << hf_out.F.T << endl;
cout << "h (kJ/kg)" << '\t' << hf_in.P.h << '\t' << hf_out.P.h << endl;

cout << "Qk (MW): " << par.vctp("Qk")[nk] << endl;
cout << "DH HX duty (MW): " << hf_in.F.M * (hf_in.P.h - hf_out.P.h) * 1e-3 << endl;

P_bleed.push_back(hf_in.F.P); M_bleed.push_back(hf_in.F.M);
}

// interpret_bleeds(P_bleed,M_bleed);

vector<int> merged;
if( P_bleed.size() > 1){ for(int nb = 1; nb < P_bleed.size(); nb++){

if( (P_bleed[nb] - P_bleed[nb-1]) < 5.0 ){
merged.push_back(nb);
M_bleed[nb-1] += M_bleed[nb];
}
}}

if( merged.size() > 0){ for(int n = 0; n < merged.size(); n++){

P_bleed.erase(P_bleed.begin()+merged[n]);
M_bleed.erase(M_bleed.begin()+merged[n]);

}}

vector<double> P_bleed_ord = P_bleed, M_bleed_ord;

cout << "h dh_in: " << dh_in.P.h << endl;
cout << "h dh_out: " << dh_out.P.h << endl;
//sort(P_bleed_ord.begin(), P_bleed_ord.end(), greater<>());

dh_in.F.M = par.fp("Q_dh") / (dh_out.P.h - dh_in.P.h);
dh_out.F.M = dh_in.F.M;
for (size_t i = 0; i < P_bleed_ord.size() - 1; ++i) {
for (size_t j = 0; j < P_bleed_ord.size() - i - 1; ++j) {
if (P_bleed_ord[j] < P_bleed_ord[j + 1]) { swap(P_bleed_ord[j], P_bleed_ord[j + 1]); }
}
}

for(int nbo = 0; nbo < P_bleed_ord.size(); nbo++){ for(int nb = 0; nb < P_bleed_ord.size(); nb++){

flow hf_in, hf_out; // In / out heating fluid to for exporting heat to district heating
hf_in = flow("hf_in", "water"); hf_out = flow("hf_out", "water");
hf_in.F.T = dh_out.F.T + 25.0; hf_in.F.P = PSatWater(hf_in.F.T); double Tsat_hf_in = TSatWater(hf_in.F.P); hf_in.P.h = hPSatSteam(hf_in.F.P);
hf_out.F.T = Tsat_hf_in - 5.0; hf_out.F.P = hf_in.F.P; hf_out.P.h = hTWater(hf_out.F.T);
if( P_bleed_ord[nbo] == P_bleed[nb] ){ M_bleed_ord.push_back(M_bleed[nb]); }

hf_in.F.M = 1e3*par.fp("Q_dh") / (hf_in.P.h - hf_out.P.h);
hf_out.F.M = hf_in.F.M;
}}


par.vct_fp("P_bleed", P_bleed_ord);
par.vct_fp("M_bleed", M_bleed_ord);

}

}

void heat_extractions(object &par){

cout << "---------------------- " << endl;
cout << " District heating: " << endl;
cout << "---------------------- " << endl;

cout << "Number of heat demands: " << par.vctp("Qk").size() << endl;

cout << "Heating fluid:" << '\t' << "in" << '\t' << "out" << endl;
cout << "M (kg/s)" << '\t' << hf_in.F.M << '\t' << hf_out.F.M << endl;
cout << "P (bar-a)" << '\t' << hf_in.F.P << '\t' << hf_out.F.P << endl;
cout << "T (deg-C)" << '\t' << hf_in.F.T << '\t' << hf_out.F.T << endl;
cout << "h (kJ/kg)" << '\t' << hf_in.P.h << '\t' << hf_out.P.h << endl;

cout << "DH Qh (MW): " << par.fp("Q_dh") << endl;
cout << "DH HX duty (MW): " << hf_in.F.M * (hf_in.P.h - hf_out.P.h) * 1e-3 << endl;
vector<double> P_bleed, M_bleed;

flow dh_in = flow("dh_in", "water"), dh_out = flow("dh_out", "water");

for(int nk = 0; nk < par.vctp("Qk").size(); nk++){

dh_in.F.T = par.vctp("Tk_in")[nk]; dh_in.F.P = 1.01325; dh_in.P.h = hTWater(dh_in.F.T); //h_in.calculate_flow_properties("PT");
dh_out.F.T = par.vctp("Tk_out")[nk]; dh_out.F.P = 1.01325; dh_out.P.h = hTWater(dh_out.F.T); //dh_out.calculate_flow_properties("PT");

dh_in.F.M = par.vctp("Qk")[nk] / (dh_out.P.h - dh_in.P.h);
dh_out.F.M = dh_in.F.M;

flow hf_in, hf_out; // In / out heating fluid to for exporting heat to district heating
hf_in = flow("hf_in", "water"); hf_out = flow("hf_out", "water");
hf_in.F.T = dh_out.F.T + 25.0; hf_in.F.P = PSatWater(hf_in.F.T); double Tsat_hf_in = TSatWater(hf_in.F.P); hf_in.P.h = hPSatSteam(hf_in.F.P);
hf_out.F.T = Tsat_hf_in - 5.0; hf_out.F.P = hf_in.F.P; hf_out.P.h = hTWater(hf_out.F.T);

hf_in.F.M = 1e3*par.fp("Q_dh") / (hf_in.P.h - hf_out.P.h);
hf_out.F.M = hf_in.F.M;

vector<double> P_bleed, M_bleed; P_bleed.push_back(hf_in.F.P); M_bleed.push_back(hf_in.F.M);
cout << "Heating fluid:" << '\t' << "in" << '\t' << "out" << endl;
cout << "M (kg/s)" << '\t' << hf_in.F.M << '\t' << hf_out.F.M << endl;
cout << "P (bar-a)" << '\t' << hf_in.F.P << '\t' << hf_out.F.P << endl;
cout << "T (deg-C)" << '\t' << hf_in.F.T << '\t' << hf_out.F.T << endl;
cout << "h (kJ/kg)" << '\t' << hf_in.P.h << '\t' << hf_out.P.h << endl;

cout << "Qk (MW): " << par.vctp("Qk")[nk] << endl;
cout << "DH HX duty (MW): " << hf_in.F.M * (hf_in.P.h - hf_out.P.h) * 1e-3 << endl;

P_bleed.push_back(hf_in.F.P); M_bleed.push_back(hf_in.F.M);
}
par.vct_fp("P_bleed", P_bleed);
par.vct_fp("M_bleed", M_bleed);

}


void rankine_cycle(object &par){

cout << "---------------------------------------------------- " << endl;
Expand All @@ -229,6 +321,7 @@ void rankine_cycle(object &par){
bfw = flow("bfw", "water"); bfw.F.T = 105.0; bfw.F.P = par.fp("P_stm"); bfw.P.h = hTWater(bfw.F.T); bfw.P.Tsat = TSatWater(bfw.F.P); double Tsat = bfw.P.Tsat;
sat_cond = flow("sat_cond", "water"); sat_cond.F.T = Tsat-5.0; sat_cond.F.P = par.fp("P_stm"); sat_cond.calculate_flow_properties("PT");
sat_stm = flow("sat_stm", "water"); sat_stm.F.P = par.fp("P_stm"); sat_stm.F.T = Tsat+5.0; sat_stm.calculate_flow_properties("PT");

steam = flow("steam", "water"); steam.F.P = par.fp("P_stm"); steam.F.T = par.fp("T_stm"); steam.P.h = hPTSupSteam(steam.F.P,steam.F.T);
steam.F.M = 1e-3*par.fp("Q_stm")/(steam.P.h-bfw.P.h);
steam_out = flow("cond", "water");
Expand All @@ -250,3 +343,5 @@ void rankine_cycle(object &par){
}




Loading