diff --git a/submodels/bioCHP_plant/CREDITS.md b/submodels/bioCHP_plant/CREDITS.md new file mode 100644 index 0000000..af4d869 --- /dev/null +++ b/submodels/bioCHP_plant/CREDITS.md @@ -0,0 +1,9 @@ +bioCHP plant model. + +author: Gonzalo del Alamo. + +github user: gonzalodelalamo + +e-mail: gonzalo.alamo@sintef.no + +Tf: +47 93002014. diff --git a/submodels/bioCHP_plant/Cost.h b/submodels/bioCHP_plant/Cost.h index d8b998e..f95b7a6 100644 --- a/submodels/bioCHP_plant/Cost.h +++ b/submodels/bioCHP_plant/Cost.h @@ -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; } diff --git a/submodels/bioCHP_plant/Flows_library/feedstock_characterization.h b/submodels/bioCHP_plant/Flows_library/feedstock_characterization.h index 3ae3ae0..0032e3d 100644 --- a/submodels/bioCHP_plant/Flows_library/feedstock_characterization.h +++ b/submodels/bioCHP_plant/Flows_library/feedstock_characterization.h @@ -1,5 +1,5 @@ #include -#include +//#include void Heating_Value(flow &feed); diff --git a/submodels/bioCHP_plant/Flows_library/flow_calculations.h b/submodels/bioCHP_plant/Flows_library/flow_calculations.h index 23f5d6d..7748bd8 100644 --- a/submodels/bioCHP_plant/Flows_library/flow_calculations.h +++ b/submodels/bioCHP_plant/Flows_library/flow_calculations.h @@ -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 1e-10) {F.Ht = F.N * P.ht;} - if(F.N == 0) {F.Ht = (F.M/P.MW) * P.ht;} -} - diff --git a/submodels/bioCHP_plant/Flows_library/flow_definitions.h b/submodels/bioCHP_plant/Flows_library/flow_definitions.h index c8f5fae..910602f 100644 --- a/submodels/bioCHP_plant/Flows_library/flow_definitions.h +++ b/submodels/bioCHP_plant/Flows_library/flow_definitions.h @@ -1,3 +1,4 @@ + #include #include #include @@ -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 @@ -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; + + } + diff --git a/submodels/bioCHP_plant/Parameters.h b/submodels/bioCHP_plant/Parameters.h index dc67dad..d39fd6c 100644 --- a/submodels/bioCHP_plant/Parameters.h +++ b/submodels/bioCHP_plant/Parameters.h @@ -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 str; vector num; @@ -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 vctp(string symb); string sp(string symb); @@ -82,6 +83,7 @@ string get_parameter_value(vector &par, string sys_type, string sys_d } } if( found == false ) { return "null"; } + return "null"; } @@ -152,9 +154,14 @@ void get_parameters( vector &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 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(); } @@ -227,7 +234,8 @@ vector fp_vct(vector &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 sp_vct(vector &par, string sys_type, string sys_def, string data_id){ @@ -240,6 +248,7 @@ vector sp_vct(vector &par, string sys_type, string sys_def, s } } if( found == false ) { return vct; } + return vct; } void fval_p(vector &par, string data_def, string sys_type, string sys_def, string data_id, double val){ @@ -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; } diff --git a/submodels/bioCHP_plant/Processes_library/Rankine_cycle.h b/submodels/bioCHP_plant/Processes_library/Rankine_cycle.h index d76adfa..b576b77 100644 --- a/submodels/bioCHP_plant/Processes_library/Rankine_cycle.h +++ b/submodels/bioCHP_plant/Processes_library/Rankine_cycle.h @@ -1,4 +1,5 @@ + struct steam_turbine_parameters { public: @@ -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; @@ -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 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 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 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 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 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; @@ -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"); @@ -250,3 +343,5 @@ void rankine_cycle(object &par){ } + + diff --git a/submodels/bioCHP_plant/Processes_library/bioCHP_plant.h b/submodels/bioCHP_plant/Processes_library/bioCHP_plant.h index 85814cc..64e8f3b 100644 --- a/submodels/bioCHP_plant/Processes_library/bioCHP_plant.h +++ b/submodels/bioCHP_plant/Processes_library/bioCHP_plant.h @@ -1,20 +1,13 @@ +void get_feedstock(vector &f, object &plant){ -void feedstock_characterization(vector &feedstock, object &plant){ + double LHV = 0.0;for(int nf = 0; nf < plant.svct("fuel_def").size(); nf++){ + f.push_back( flow("feed", plant.svct("fuel_def")[nf] ) ); + f[nf].F.T = 25.0; + f[nf].F.P = 1.01325; + LHV += f[nf].P.LHV * plant.vctp("Yj")[nf]; + } - feedstock.push_back( flow("feed", plant.sp("fuel_def") ) ); - - feedstock[0].F.Hf = plant.fp("boiler_power_in_MW"); - feedstock[0].F.T = 25.0; - feedstock[0].F.P = 1.01325; - feedstock[0].F.M = feedstock[0].F.Hf / feedstock[0].P.LHV; - - plant.fval_p("M_fuel", feedstock[0].F.M); - plant.fval_p("Hf_fuel", feedstock[0].F.Hf); - - plant.c.push_back(object("consumable",feedstock[0].def,"Database/Consumables_database")); - int feed = plant.ic("consumable",feedstock[0].def); - plant.c[feed].fval_p("Q_annual", plant.fp("M_fuel") * 3.6 * 8000); - material_cost(plant.c[feed]); + plant.fval_p("LHV_f", LHV); } @@ -28,35 +21,88 @@ void bioCHP_plant_model(object &bioCHP){ object rankine("process", "Rankine_cycle", "bioCHP_inputs"); object scrubber("process", "flue_gas_cleaning", "bioCHP_inputs"); - vector feed; feedstock_characterization(feed, bioCHP); + vector feed; get_feedstock(feed, bioCHP); - flow flue_gas, bottom_ash, fly_ash, dh_in, dh_out; - boiler.fval_p("M_fuel", bioCHP.fp("M_fuel")); + flow flue_gas, bottom_ash, fly_ash, dh_in, dh_out; vector comb_air; - solid_fuel_boiler(feed, flue_gas, bottom_ash, fly_ash, boiler); rankine.fval_p("P_stm", bioCHP.fp("P_stm")); rankine.fval_p("T_stm", bioCHP.fp("T_stm")); + rankine.vct_fp("Qk", bioCHP.vctp("Qk")); + rankine.vct_fp("Tk_in", bioCHP.vctp("Tk_in")); + rankine.vct_fp("Tk_out", bioCHP.vctp("Tk_out")); + + if( bioCHP.bp("W_el") ){ + + cout << "bioCHP PLANT calculation using W_el: " << endl; + + double Hf = bioCHP.fp("W_el")/0.2; for(int nk = 0; nk < bioCHP.vctp("Qk").size(); nk++){ Hf += bioCHP.vctp("Qk")[nk]; } Hf = Hf/0.9; + + double ratio = 0.0; + + double Mf = Hf/bioCHP.fp("LHV_f"); + + cout << "initial Hf: " << Hf << endl; + cout << "initial Mf: " << Mf << endl; + + for(int nf = 0; nf < feed.size(); nf++){ + feed[nf].F.M = bioCHP.vctp("Yj")[nf] * Mf; + feed[nf].F.Hf = feed[nf].F.M * feed[nf].P.LHV; + } + + object r = rankine; + object b = boiler; + + solid_fuel_boiler(feed, comb_air, flue_gas, bottom_ash, fly_ash, b); + r.fval_p("Q_stm", b.fp("Q_out")); + rankine_cycle(r); + Hf = Hf * bioCHP.fp("W_el")/r.fp("W_el"); + + cout << "Final Hf: " << Hf << endl; + + bioCHP.fval_p("Hf", Hf); + + } + + + bioCHP.fval_p("M_fuel", bioCHP.fp("Hf")/bioCHP.fp("LHV_f")); + + for(int nf = 0; nf < feed.size(); nf++){ + feed[nf].F.M = bioCHP.vctp("Yj")[nf] * bioCHP.fp("M_fuel"); + feed[nf].F.Hf = feed[nf].F.M * feed[nf].P.LHV; + } + + boiler.fval_p("M_fuel", bioCHP.fp("M_fuel")); + + solid_fuel_boiler(feed, comb_air, flue_gas, bottom_ash, fly_ash, boiler); + rankine.fval_p("Q_stm", boiler.fp("Q_out")); - rankine.fval_p("Q_dh", bioCHP.fp("heat_demand_MW")); - //rankine.fval_p("Q_dh", boiler.fp("Q_out")*bioCHP.fp("heat_power_ratio")); rankine_cycle(rankine); - //NOx_reduction_model(comb_fg, denox_fg, cons, par); + scrubber.fval_p("M_fuel", bioCHP.fp("M_fuel")); + dry_scrubber_model(flue_gas, flue_gas, scrubber); bioCHP.c.push_back(boiler); bioCHP.c.push_back(rankine); bioCHP.c.push_back(scrubber); + for(int nf = 0; nf < feed.size(); nf++){ + bioCHP.fval_p("output-Mj", feed[nf].F.M); + bioCHP.fval_p("output-Hfj", feed[nf].F.Hf); + bioCHP.c.push_back(object("consumable",feed[nf].def,"Database/Consumables_database")); + int f = bioCHP.ic("consumable",feed[nf].def); + bioCHP.c[f].fval_p("Q_annual", feed[nf].F.M * 3.6 * 8000); + material_cost(bioCHP.c[f]); + + } + bioCHP.fval_p("output-Biomass_mass_input_(t/h)", bioCHP.fp("M_fuel")*3.6); - bioCHP.fval_p("output-Biomass_energy_input_(MW)", bioCHP.fp("Hf_fuel")); + bioCHP.fval_p("output-Biomass_energy_input_(MW)", bioCHP.fp("Hf")); bioCHP.fval_p("output-Heat_production_(MW)", bioCHP.fp("heat_demand_MW")); bioCHP.fval_p("output-Electricity_production_(MW)", rankine.fp("W_el")); cost(bioCHP); } - - diff --git a/submodels/bioCHP_plant/Processes_library/combustion.h b/submodels/bioCHP_plant/Processes_library/combustion.h index d318840..dc87970 100644 --- a/submodels/bioCHP_plant/Processes_library/combustion.h +++ b/submodels/bioCHP_plant/Processes_library/combustion.h @@ -98,13 +98,20 @@ void solid_fuel_boiler(vector &fuel, vector &comb_air, flow &flue_ga vector air; vector fg; vector ba; vector fa; - for( int n = 0; n < fuel.size(); n++) - { + if(air.size() == 0){ - air.push_back(flow(comb.sp("oxidant_def"))); - fg.push_back(flow("flue_gas", "flue_gas")); - ba.push_back(flow("bottom_ash", "ash")); - fa.push_back(flow("fly_ash", "ash")); + for( int n = 0; n < fuel.size(); n++){ + + air.push_back(flow(comb.sp("oxidant_def"))); + fg.push_back(flow("flue_gas", "flue_gas")); + ba.push_back(flow("bottom_ash", "ash")); + fa.push_back(flow("fly_ash", "ash")); + + } + + } + + for( int n = 0; n < fuel.size(); n++){ int C = index_species(fuel[n].i, "C"); int H = index_species(fuel[n].i, "H"); @@ -153,7 +160,9 @@ void solid_fuel_boiler(vector &fuel, vector &comb_air, flow &flue_ga double comb_Hf = 0; for( int n = 0; n < fuel.size(); n++){ - if ( n == 0 ) {comb_air.push_back(air[n]); flue_gas = fg[n]; bottom_ash = ba[n]; fly_ash = fa[n]; } + if ( n == 0 ) { + if(comb_air.size() == 0){ comb_air.push_back(air[n]);} + flue_gas = fg[n]; bottom_ash = ba[n]; fly_ash = fa[n]; } if ( n > 0 ) { comb_air[0].mix_flows(comb_air[0], air[n]); bottom_ash.mix_flows(bottom_ash, ba[n]); @@ -167,10 +176,24 @@ void solid_fuel_boiler(vector &fuel, vector &comb_air, flow &flue_ga comb.fval_p("Q_loss", flue_gas.F.Ht * comb.fp("q_loss")); comb.fval_p("Q_out", comb.fp("Hf")*1e6 + comb_air[0].F.Ht - flue_gas.F.Ht - bottom_ash.F.Ht - comb.fp("Q_loss")); + object boiler("equipment","biomass_stoker_boiler_power"); + boiler.fval_p("S", comb.fp("M_fuel")*3.6); + equipment_cost(boiler); + boiler.fval_p("W_el", comb.fp("M_fuel")*3.6*boiler.fp("w_el")); + comb.c.push_back(boiler); + + object prep("equipment","biomass_storage&feeding"); + prep.fval_p("S", comb.fp("M_fuel")*3.6); + equipment_cost(prep); + comb.c.push_back(prep); + cout << "-------------" << endl; cout << "Mass balance" << endl; cout << "------------" << endl; - cout << "fuel M: " << fuel[0].F.M << endl; + cout << "fuel M (kg/s): " << comb.fp("M_fuel") << endl; + for(int nf = 0; nf < fuel.size(); nf++){ + cout << '\t' << fuel[nf].def << " (kg/s): " << fuel[nf].F.M << endl; + } cout << "flue gas M: " << flue_gas.F.M << endl; cout << "comb air M: " << comb_air[0].F.M << endl; cout << "bottom ash M: " << bottom_ash.F.M << endl; @@ -179,31 +202,17 @@ void solid_fuel_boiler(vector &fuel, vector &comb_air, flow &flue_ga cout << "-------------" << endl; cout << "energy balance" << endl; cout << "-------------" << endl; - cout << "comb Hf (MW): " << comb.fp("Hf") << endl; + cout << "Fuel Hf (MW): " << comb.fp("Hf") << endl; + for(int nf = 0; nf < fuel.size(); nf++){ + cout << '\t'<< fuel[nf].def << " (MW): " << fuel[nf].F.Hf << endl; + } + cout << "Q_out: (W) " << comb.fp("Q_out") << endl; cout << "Q_loss: (W) " << comb.fp("Q_loss") << endl; - cout << "H_air: (W) " << comb_air[0].F.Ht << endl; + cout << "H_air: (W) " << comb_air[0].F.Ht << endl; cout << "H_fg: (W) " << flue_gas.F.Ht << endl; cout << "H_ba: (W) " << bottom_ash.F.Ht << endl; cout << "H_fa: (W) " << fly_ash.F.Ht << endl; - object boiler("equipment","biomass_stoker_boiler_power"); - boiler.fval_p("S", comb.fp("M_fuel")*3.6); - equipment_cost(boiler); - boiler.fval_p("W_el", comb.fp("M_fuel")*3.6*boiler.fp("w_el")); - comb.c.push_back(boiler); - - object prep("equipment","biomass_storage&feeding"); - prep.fval_p("S", comb.fp("M_fuel")*3.6); - equipment_cost(prep); - comb.c.push_back(prep); - } -void solid_fuel_boiler(vector &feed, flow &flue_gas, flow &bottom_ash, flow &fly_ash, object &boiler){ - - vector comb_air; - - solid_fuel_boiler(feed, comb_air, flue_gas, bottom_ash, fly_ash, boiler); - -} diff --git a/submodels/bioCHP_plant/README.md b/submodels/bioCHP_plant/README.md new file mode 100644 index 0000000..0f176a4 --- /dev/null +++ b/submodels/bioCHP_plant/README.md @@ -0,0 +1,14 @@ +# bioCHP plant model + +`bioCHP_plant` is a c++ module within `EnergyModelsHeat` with functionality to model mass and energy flows, investment cost and operational cost of a combined heat and power production plant using biomass as feedstock. + +## Model test + +The bioCHP plant model can be tested separately using the c++ files bioCHP_function_test_[number].cpp in the main directory: + - bioCHP_function_test_1.cpp: single biomass feedstock with specified electric power production and no heat demand + - bioCHP_function_test_2.cpp: multiple biomass feedstock with specified electric power production and no heat demands + - bioCHP_function_test_3.cpp: multiple biomass feedstock with specified electric power production and several heat demand + +## Project Funding + +The development of `EnergyModelsHeat` was funded by the European Union’s Horizon Europe research and innovation programme in the project [iDesignRES](https://idesignres.eu/) under grant agreement [101095849](https://doi.org/10.3030/101095849). diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Library_Water_Correlations.h b/submodels/bioCHP_plant/Thermodynamic_library/Library_Water_Correlations.h index 747a3ab..7f84943 100644 --- a/submodels/bioCHP_plant/Thermodynamic_library/Library_Water_Correlations.h +++ b/submodels/bioCHP_plant/Thermodynamic_library/Library_Water_Correlations.h @@ -177,6 +177,7 @@ if (P >= 60 && P < 100) { G / pow(P,3) + U / pow(H,3) + i / (P * pow(H,2)) + j / (pow(P,2) * H); } + return -1; } double TPhSupSteam(double P, double H) @@ -266,6 +267,9 @@ if(P >= 60 && P < 100) { f * log(P) * log(H) + G * pow(log(P), 3) + U * pow(log(H),3) + i * log(P) * pow(log(H),2) + j * pow(log(P), 2) * log(H) - 273.17; } + + return -1; + } double hPTSupSteam(double P, double Temp) @@ -357,7 +361,7 @@ if (P >= 6 && P < 10) { return A + B * P + C / T + D * pow(P,2) + E / pow(T, 2) + f * P / T + G * pow(P,3) + H / pow(T, 3) + i * P / pow(T, 2) + j * pow(P,2) / T; } - + return -1; } @@ -454,6 +458,7 @@ if (P < 10) { return A + B * P + C / T + D * pow(P,2) + E / pow(T, 2) + f * P / T + G * pow(P,3) + H / pow(T, 3) + i * P / pow(T, 2) + j * pow(P,2) / T; } + return -1; } double sPWater(double P) diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Ar b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Ar deleted file mode 100644 index 129dc98..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Ar +++ /dev/null @@ -1,29 +0,0 @@ -Compound: Ar -Property: cp -Dependence: temperature -Validity: 298 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.786 2.825911e-7 -21.64191 1.092131e-8 -44.61371 -6.19735 179.999 0 - -Compound: Ar -Property: h -Dependence: temperature -Validity: 298 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.786 2.825911e-7 -21.64191 1.092131e-8 -44.61371 -6.19735 179.999 0 - -Compound: Ar -Property: s -Dependence: temperature -Validity: 298 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.786 2.825911e-7 -21.64191 1.092131e-8 -44.61371 -6.19735 179.999 0 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO deleted file mode 100644 index 7f93702..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO +++ /dev/null @@ -1,59 +0,0 @@ -Compound: CO2 -Property: cp -Dependence: temperature -Validity: 298 1300 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 25.56759 6.096130 4.054656 -2.671301 0.131021 -118.0089 227.3665 -110.5271 - -Compound: CO2 -Property: cp -Dependence: temperature -Validity: 1300 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.15070 1.300095 -0.205921 0.013550 -3.282780 -127.8375 231.7120 -110.5271 - -Compound: CO2 -Property: h -Dependence: temperature -Validity: 298 1300 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 25.56759 6.096130 4.054656 -2.671301 0.131021 -118.0089 227.3665 -110.5271 - -Compound: CO2 -Property: h -Dependence: temperature -Validity: 1300 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.15070 1.300095 -0.205921 0.013550 -3.282780 -127.8375 231.7120 -110.5271 - -Compound: CO2 -Property: s -Dependence: temperature -Validity: 298 1300 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 25.56759 6.096130 4.054656 -2.671301 0.131021 -118.0089 227.3665 -110.5271 - -Compound: CO2 -Property: s -Dependence: temperature -Validity: 1300 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.15070 1.300095 -0.205921 0.013550 -3.282780 -127.8375 231.7120 -110.5271 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO2 deleted file mode 100644 index e665dc6..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/CO2 +++ /dev/null @@ -1,60 +0,0 @@ -Compound: CO2 -Property: cp -Dependence: temperature -Validity: 298 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 24.99735 55.18696 -33.69137 7.948387 -0.136638 -403.6075 228.2431 -393.5224 - -Compound: CO2 -Property: cp -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 58.16639 2.720074 -0.492289 0.038844 -6.447293 -425.9186 263.6125 -393.5224 - -Compound: CO2 -Property: h -Dependence: temperature -Validity: 298 1200 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 24.99735 55.18696 -33.69137 7.948387 -0.136638 -403.6075 228.2431 -393.5224 - -Compound: CO2 -Property: h -Dependence: temperature -Validity: 1200 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 58.16639 2.720074 -0.492289 0.038844 -6.447293 -425.9186 263.6125 -393.5224 - -Compound: CO2 -Property: s -Dependence: temperature -Validity: 298 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 24.99735 55.18696 -33.69137 7.948387 -0.136638 -403.6075 228.2431 -393.5224 - -Compound: CO2 -Property: s -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 58.16639 2.720074 -0.492289 0.038844 -6.447293 -425.9186 263.6125 -393.5224 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Gases b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Gases deleted file mode 100644 index 2287dc9..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/Gases +++ /dev/null @@ -1,50 +0,0 @@ -Compound: NaOH -Property: cp -Dependence: temperature -Validity: 298.0 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: cp -Dependence: temperature -Validity: 572.0 596.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 86.02304 0.0 0.0 0.0 0.0 -448.8512 169.6281 -425.9312 - -Compound: NaOH -Property: h -Dependence: temperature -Validity: 298.0 1000 -Unit: kJ/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: s -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: rho -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: constant -Constants: A -Values: 1.8e3 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2 deleted file mode 100644 index 8572534..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2 +++ /dev/null @@ -1,89 +0,0 @@ -Compound: H2 -Property: cp -Dependence: temperature -Validity: 298 1000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 33.066178 -11.363417 11.432816 -2.772874 -0.158558 -9.980797 172.707974 0.0 - -Compound: H2 -Property: cp -Dependence: temperature -Validity: 1000 2500 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 18.563083 12.257357 -2.859786 0.268238 1.97799 -1.147438 156.288133 0.0 - -Compound: H2 -Property: cp -Dependence: temperature -Validity: 2500 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 43.41356 -4.293079 1.272428 -0.096876 -20.533862 -38.515158 162.081354 0.0 - -Compound: H2 -Property: h -Dependence: temperature -Validity: 298 1000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 33.066178 -11.363417 11.432816 -2.772874 -0.158558 -9.980797 172.707974 0.0 - -Compound: H2 -Property: h -Dependence: temperature -Validity: 1000 2500 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 18.563083 12.257357 -2.859786 0.268238 1.97799 -1.147438 156.288133 0.0 - -Compound: H2 -Property: h -Dependence: temperature -Validity: 2500 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 43.41356 -4.293079 1.272428 -0.096876 -20.533862 -38.515158 162.081354 0.0 - -Compound: H2 -Property: s -Dependence: temperature -Validity: 298 1000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 33.066178 -11.363417 11.432816 -2.772874 -0.158558 -9.980797 172.707974 0.0 - -Compound: H2 -Property: s -Dependence: temperature -Validity: 1000 2500 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 18.563083 12.257357 -2.859786 0.268238 1.97799 -1.147438 156.288133 0.0 - -Compound: H2 -Property: s -Dependence: temperature -Validity: 2500 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 43.41356 -4.293079 1.272428 -0.096876 -20.533862 -38.515158 162.081354 0.0 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2O b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2O deleted file mode 100644 index cf46727..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/H2O +++ /dev/null @@ -1,71 +0,0 @@ -Compound: H2O -Property: cp -Dependence: temperature -Validity: 200 1700 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.092 6.832514 6.793435 -2.53448 0.082139 -250.881 223.3967 -241.8264 - -Compound: H2O -Property: cp -Dependence: temperature -Validity: 1700 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 41.96426 8.622053 -1.49978 0.098119 -11.15764 -272.1797 219.7809 -241.8264 - -Compound: H2O -Property: h -Dependence: temperature -Validity: 200 1700 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.092 6.832514 6.793435 -2.53448 0.082139 -250.881 223.3967 -241.8264 - -Compound: H2O -Property: h -Dependence: temperature -Validity: 1700 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 41.96426 8.622053 -1.49978 0.098119 -11.15764 -272.1797 219.7809 -241.8264 - -Compound: H2O -Property: s -Dependence: temperature -Validity: 200 1700 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.092 6.832514 6.793435 -2.53448 0.082139 -250.881 223.3967 -241.8264 - -Compound: H2O -Property: s -Dependence: temperature -Validity: 1700 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 41.96426 8.622053 -1.49978 0.098119 -11.15764 -272.1797 219.7809 -241.8264 - -Compound: methanol -Property: Tsat -MW: 32.04 -Dependence: pressure -Validity: 1.83235 79.461 -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 4.6543 1435.264 -64.848 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/K2CO3 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/K2CO3 deleted file mode 100644 index db8aa7d..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/K2CO3 +++ /dev/null @@ -1,44 +0,0 @@ -Compound: K2CO3 -Property: cp -MW: 98.00 -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 97.08093 94.22326 -2.053291 0.709644 -0.947860 -1186.499 239.5834 -1150.182 - -Compound: K2CO3 -Property: h -MW: 98.00 -Dependence: temperature -Validity: 298.0 1200.0 -Unit: kJ/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 97.08093 94.22326 -2.053291 0.709644 -0.947860 -1186.499 239.5834 -1150.182 - -Compound: K2CO3 -Property: s -MW: 98.00 -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 97.08093 94.22326 -2.053291 0.709644 -0.947860 -1186.499 239.5834 -1150.182 - -Compound: K2CO3 -Property: rho -MW: 98.00 -Dependence: temperature -Validity: 298.0 1200.0 -Unit: kg/m3 -Data: model -Model: constant -Constants: A -Values: 2.43e3 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/N2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/N2 deleted file mode 100644 index fffc16b..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/N2 +++ /dev/null @@ -1,89 +0,0 @@ -Compound: N2 -Property: cp -Dependence: temperature -Validity: 100 500 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 28.98641 1.853978 -9.647459 16.63537 0.000117 -8.671914 226.4168 0.0 - -Compound: N2 -Property: cp -Dependence: temperature -Validity: 500 2000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 19.50583 19.88705 -8.598535 1.369784 0.527601 -4.935202 212.39 0.0 - -Compound: N2 -Property: cp -Dependence: temperature -Validity: 2000 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.51872 1.128728 -0.196103 0.014662 -4.55376 -18.97091 224.981 0.0 - -Compound: N2 -Property: h -Dependence: temperature -Validity: 100 500 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 28.98641 1.853978 -9.647459 16.63537 0.000117 -8.671914 226.4168 0 - -Compound: N2 -Property: h -Dependence: temperature -Validity: 500 2000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 19.50583 19.88705 -8.598535 1.369784 0.527601 -4.935202 212.39 0 - -Compound: N2 -Property: h -Dependence: temperature -Validity: 2000 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.51872 1.128728 -0.196103 0.014662 -4.55376 -18.97091 224.981 0 - -Compound: N2 -Property: s -Dependence: temperature -Validity: 100 500 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 28.98641 1.853978 -9.647459 16.63537 0.000117 -8.671914 226.4168 0 - -Compound: N2 -Property: s -Dependence: temperature -Validity: 500 2000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 19.50583 19.88705 -8.598535 1.369784 0.527601 -4.935202 212.39 0 - -Compound: N2 -Property: s -Dependence: temperature -Validity: 2000 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 35.51872 1.128728 -0.196103 0.014662 -4.55376 -18.97091 224.981 0 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NO2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NO2 deleted file mode 100644 index 009125a..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NO2 +++ /dev/null @@ -1,59 +0,0 @@ -Compound: NO2 -Property: cp -Dependence: temperature -Validity: 200 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 16.10857 75.89525 -54.38740 14.30777 0.239423 26.17464 240.5386 33.09504 - -Compound: NO2 -Property: cp -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 56.82541 0.738053 -0.144721 0.009777 -5.459911 2.846456 290.5056 33.09502 - -Compound: NO2 -Property: h -Dependence: temperature -Validity: 200 1200 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 16.10857 75.89525 -54.38740 14.30777 0.239423 26.17464 240.5386 33.09504 - -Compound: NO2 -Property: h -Dependence: temperature -Validity: 1200 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 56.82541 0.738053 -0.144721 0.009777 -5.459911 2.846456 290.5056 33.09502 - -Compound: NO2 -Property: s -Dependence: temperature -Validity: 200 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 16.10857 75.89525 -54.38740 14.30777 0.239423 26.17464 240.5386 33.09504 - -Compound: NO2 -Property: s -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 56.82541 0.738053 -0.144721 0.009777 -5.459911 2.846456 290.5056 33.09502 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NaOH b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NaOH deleted file mode 100644 index 2287dc9..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/NaOH +++ /dev/null @@ -1,50 +0,0 @@ -Compound: NaOH -Property: cp -Dependence: temperature -Validity: 298.0 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: cp -Dependence: temperature -Validity: 572.0 596.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 86.02304 0.0 0.0 0.0 0.0 -448.8512 169.6281 -425.9312 - -Compound: NaOH -Property: h -Dependence: temperature -Validity: 298.0 1000 -Unit: kJ/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: s -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 419.4837 1717.754 2953.573 -1597.221 -6.046884 -517.8662 933.0738 -425.9312 - -Compound: NaOH -Property: rho -Dependence: temperature -Validity: 298.0 1200.0 -Unit: J/molK -Data: model -Model: constant -Constants: A -Values: 1.8e3 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/O2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/O2 deleted file mode 100644 index 079a17d..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/O2 +++ /dev/null @@ -1,89 +0,0 @@ -Compound: O2 -Property: cp -Dependence: temperature -Validity: 100 700 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 31.32234 -20.23531 57.86644 -36.50624 -0.007374 -8.903471 246.7945 0.0 - -Compound: O2 -Property: cp -Dependence: temperature -Validity: 700 2000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.03235 8.772972 -3.988133 0.788313 -0.741599 -11.32468 236.1663 0.0 - -Compound: O2 -Property: cp -Dependence: temperature -Validity: 2000 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.91111 10.72071 -2.020498 0.146449 9.245722 5.337651 237.6185 0.0 - -Compound: O2 -Property: h -Dependence: temperature -Validity: 100 700 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 31.32234 -20.23531 57.86644 -36.50624 -0.007374 -8.903471 246.7945 0.0 - -Compound: O2 -Property: h -Dependence: temperature -Validity: 700 2000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.03235 8.772972 -3.988133 0.788313 -0.741599 -11.32468 236.1663 0 - -Compound: O2 -Property: h -Dependence: temperature -Validity: 2000 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.91111 10.72071 -2.020498 0.146449 9.245722 5.337651 237.6185 0 - -Compound: O2 -Property: s -Dependence: temperature -Validity: 100 700 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 31.32234 -20.23531 57.86644 -36.50624 -0.007374 -8.903471 246.7945 0.0 - -Compound: O2 -Property: s -Dependence: temperature -Validity: 700 2000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 30.03235 8.772972 -3.988133 0.788313 -0.741599 -11.32468 236.1663 0 - -Compound: O2 -Property: s -Dependence: temperature -Validity: 2000 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 20.91111 10.72071 -2.020498 0.146449 9.245722 5.337651 237.6185 0 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/SO2 b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/SO2 deleted file mode 100644 index b92cd2b..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/SO2 +++ /dev/null @@ -1,59 +0,0 @@ -Compound: SO2 -Property: cp -Dependence: temperature -Validity: 200 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 21.43049 74.35094 -57.75217 16.35534 0.086731 -305.7688 254.8872 -296.8422 - -Compound: SO2 -Property: cp -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 57.48188 1.009328 -0.07629 0.005174 -4.045401 -324.414 302.7798 -296.8422 - -Compound: SO2 -Property: h -Dependence: temperature -Validity: 200 1200 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 21.43049 74.35094 -57.75217 16.35534 0.086731 -305.7688 254.8872 -296.8422 - -Compound: SO2 -Property: h -Dependence: temperature -Validity: 1200 6000 -Unit: J/mol -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 57.48188 1.009328 -0.07629 0.005174 -4.045401 -324.414 302.7798 -296.8422 - -Compound: SO2 -Property: s -Dependence: temperature -Validity: 200 1200 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 21.43049 74.35094 -57.75217 16.35534 0.086731 -305.7688 254.8872 -296.8422 - -Compound: SO2 -Property: s -Dependence: temperature -Validity: 1200 6000 -Unit: J/molK -Data: model -Model: Shomate -Constants: A B C D E F G H -Values: 57.48188 1.009328 -0.07629 0.005174 -4.045401 -324.414 302.7798 -296.8422 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetic_acid b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetic_acid deleted file mode 100644 index 66bb81f..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetic_acid +++ /dev/null @@ -1,61 +0,0 @@ -Compound: acetic_acid -Property: cpliq -MW: 60.052 -Dependence: temperature -Validity: 289.691 580.0 -Unit: J/kmolK -Data: model -Model: TDEliq -Extrapolation: yes -Constants: C1 C2 C3 C4 B Tc -Values: 182617.6 -992.636 3.586276 -0.003622026 6808.338 592.9978 - -Compound: acetic_acid -Property: cpideal -MW: 60.052 -Dependence: temperature -Validity: 50 1500 -Unit: J/kmolK -Data: model -Model: AlyLee -Extrapolation: no -Constants: A B C D E -Values: 39924.63 135839.5 1208.064 64252.96 542.473 - -Compound: acetic_acid -Property: Tsat -MW: 60.052 -Dependence: pressure -Validity: -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 4.68206 1642.54 -39.764 - -Compound: acetic_acid -Property: Psat -MW: 60.052 -Dependence: temperature -Validity: -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 4.68206 1642.54 -39.764 - -Compound: acetic_acid -Property: Hvap -MW: 60.052 -Dependence: temperature -Validity: 298.0 392.0 -Unit: kJ/mol -Data: model -Model: Majer1985 -Extrapolation: yes -Constants: A alpha beta Tc -Values: 22.84 0.0184 -0.0454 592.7 - - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetone b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetone deleted file mode 100644 index d57ae2d..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/acetone +++ /dev/null @@ -1,55 +0,0 @@ -Compound: Acetone -Property: Hvap -Dependence: temperature -Validity: 251.0 505.0 -Unit: J/mol -Data: model -Model: PPDS12 -Extrapolation: yes -Constants: A B C D E Tc R -Values: 6.6492 6.1047 -1.9357 -1.1091 7.573 508.1 - -Compound: Acetone -Property: cpideal -Dependence: temperature -Validity: 200.0 1500.0 -Unit: J/kmolK -Data: model -Model: AlyLee -Extrapolation: no -Constants: A B C D E -Values: 56784.82 162251.3 1572.387 93640.73 720.0944 - -Compound: Acetone -Property: cpliq -Dependence: temperature -Validity: 178.16 497.9042 -Unit: J/kmolK -Data: model -Model: TDEliquid -Extrapolation: yes -Constants: C1 C2 C3 C4 B Tc -Values: 199551.1 -960.4159 3.14242 -0.002830175 3833.658 508.0655 - -Compound: Acetone -Property: Tsat -Dependence: pressure -Validity: 0.0432875 45.9985 -Unit: K -Data: model -Model: Antoine -Extrapolation: yes -Constants: A B C -Values: 4.42448 1312.253 -32.445 - -Compound: Acetone -Property: Psat -Dependence: temperature -Validity: 259.16 507.60 -Unit: bar -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 4.42448 1312.253 -32.445 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/formic_acid b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/formic_acid deleted file mode 100644 index 114c108..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/formic_acid +++ /dev/null @@ -1,73 +0,0 @@ -Compound: formic_acid -Property: cpideal -MW: 43.03 -Dependence: temperature -Validity: 50.0 1500.0 -Unit: J/kmolK -Data: model -Model: AlyLee -Extrapolation: no -Constants: A B C D E -Values: 33282.79 76477.8 1177.72 31762.81 532.6783 - -Compound: formic_acid -Property: cpliq -MW: 43.03 -Dependence: temperature -Validity: -Unit: J/kmolK -Data: model -Model: ThermoML -Extrapolation: yes -Constants: C1 C2 C3 C4 C5 -Values: 145446 -411.7134 0.8670977 0.0 0.0 - -Compound: formic_acid -Property: Tsat -MW: 43.03 -Dependence: pressure -Validity: -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 2.00121 515.0 -139.408 - -Compound: formic_acid -Property: Psat -MW: 43.03 -Dependence: temperature -Validity: 273.7 307.4 -Unit: bar -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 2.00121 515.0 -139.408 - -Compound: formic_acid -Property: Psat -MW: 43.03 -Dependence: temperature -Validity: 281.44 587.961 -Unit: Pa -Data: model -Model: Wagner25 -Extrapolation: yes -Constants: C1 C2 C3 C4 lPc Tc -Values: -12.52877 4.291676 7.415085 -18.62419 16.45771 587.961 - -Compound: formic_acid -Property: Hvap -MW: 43.03 -Dependence: temperature -Validity: 298.1444 497.5181 -Unit: J/kmol -Data: model -Model: TDEWatson -Extrapolation: yes -Constants: C1 C2 C3 C4 Tc -Values: 17.1444 3.219126 -8.15176 5.369517 587.961 - - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/furfural b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/furfural deleted file mode 100644 index 802b10b..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/furfural +++ /dev/null @@ -1,60 +0,0 @@ -Compound: Furfural -Property: cpideal -MW: 96.06 -Dependence: temperature -Validity: 298.0 1000.0 -Unit: J/kmolK -Data: model -Model: AlyLee -Extrapolation: no -Constants: A B C D E -Values: 65056.39 183957.0 1421.119 145585.2 673.0352 - -Compound: Furfural -Property: cpliq -MW: 96.06 -Dependence: temperature -Validity: 234.84 656.6 -Unit: J/kmolK -Data: model -Model: TDEliq -Extrapolation: yes -Constants: C1 C2 C3 C4 B Tc -Values: 327634.2 -1550.202 4.183647 -0.003283608 5816.994 670.0 - -Compound: Furfural -Property: Tsat -MW: 96.06 -Dependence: Pressure -Validity: -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 4.09355 1430.133 -84.449 - -Compound: Furfural -Property: Psat -MW: 96.06 -Dependence: temperature -Validity: 234.84 670.0 -Unit: Pa -Data: model -Model: Wagner25 -Extrapolation: yes -Constants: C1 C2 C3 C4 lPc Tc -Values: -11.9086 11.33736 -11.43733 1.415875 15.61272 670.0 - -Compound: Furfural -Property: Hvap -MW: 96.06 -Dependence: temperature -Validity: 234.84 670 -Unit: J/kmol -Data: model -Model: TDEWatson -Extrapolation: yes -Constants: C1 C2 C3 C4 Tc -Values: 17.76321 -0.8968546 2.924581 -1.864477 670.0 - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/methanol b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/methanol deleted file mode 100644 index 0f58c22..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/methanol +++ /dev/null @@ -1,71 +0,0 @@ -Compound: methanol -Property: Hvap -MW: 32.04 -Dependence: temperature -Validity: 248.0 512.0 -Unit: J/mol -Data: model -Model: PPDS12 -Extrapolation: yes -Constants: A B C D E Tc R -Values: 9.3995 0.14881 9.537 -14.192 30.769 512.6 0.008314 - -Compound: methanol -Property: cpliq -MW: 32.04 -Dependence: temperature -Validity: 175.53 348.15 -Unit: J/kmolK -Data: model -Model: ThermoML -Extrapolation: yes -Constants: C1 C2 C3 C4 -Values: 72254.92 113.9303 -1.512782 0.005428005 - -Compound: methanol -Property: cpideal -MW: 32.04 -Dependence: temperature -Validity: 50.0 3000.0 -Unit: J/kmolK -Data: model -Model: AlyLee -Extrapolation: no -Constants: A B C D E -Values: 34250.55 90234.34 1324.078 26923.2 471.5034 - -Compound: methanol -Property: Psat -MW: 32.04 -Dependence: temperature -Validity: 175.53 512.6795 -Unit: Pa -Data: model -Model: Wagner25 -Extrapolation: yes -Constants: C1 C2 C3 C4 lPc Tc -Values: -8.381618 0.7496107 -2.324033 -0.7894569 15.889 512.6795 - -Compound: methanol -Property: Tsat -MW: 32.04 -Dependence: pressure -Validity: 1.83235 79.461 -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 5.15853 1569.613 -34.846 - -Compound: methanol -Property: Tsat -MW: 32.04 -Dependence: pressure -Validity: 0.0984005 2.06009 -Unit: K -Data: model -Model: Antoine -Extrapolation: no -Constants: A B C -Values: 5.20409 1581.341 -33.50 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/sulfuric_acid b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/sulfuric_acid deleted file mode 100644 index 4a6d269..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Properties/sulfuric_acid +++ /dev/null @@ -1,25 +0,0 @@ -Compound: sulfuric_acid -Property: Hvap -MW: 98.079 -Dependence: temperature -Validity: 280.0 578.0 -Unit: J/kmol -Data: model -Model: TDEWatson -Extrapolation: yes -Constants: C1 C2 C3 C4 Tc -Values: 18.31483 0.2043291 0.7654368 -0.5781372 578.0 - -Compound: sulfuric_acid -Property: Psat -MW: 98.079 -Dependence: temperature -Validity: 283.54 578.0 -Unit: Pa -Data: model -Model: Wagner25 -Extrapolation: yes -Constants: C1 C2 C3 C4 lPc Tc -Values: -11.07472 4.297288 -9.025746 -5.164637 15.74584 - - diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Species_thermofile_list b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Species_thermofile_list deleted file mode 100644 index 6e961b3..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/Species_thermofile_list +++ /dev/null @@ -1,31 +0,0 @@ -Compound: acetic_acid -Composition: C2H4O2 -File: Thermodynamic_library/Thermodynamic_database/Properties/acetic_acid - -Compound: acetone -Composition: C3H6O -File: Thermodynamic_library/Thermodynamic_database/Properties/acetone - -Compound: formic_acid -Composition: CH2O2 -File: Thermodynamic_library/Thermodynamic_database/Properties/formic_acid - -Compound: furfural -Composition: C5H4O2 -File: Thermodynamic_library/Thermodynamic_database/Properties/furfural - -Compound: methanol -Composition: CH4O -File: Thermodynamic_library/Thermodynamic_database/Properties/methanol - -Compound: sulfuric_acid -Composition: H2SO4 -File: Thermodynamic_library/Thermodynamic_database/Properties/sulfuric_acid - -Compound: O2 -Composition: O2 -File: Thermodynamic_library/Thermodynamic_database/Properties/O2 - -Compound: N2 -Composition: N2 -File: Thermodynamic_library/Thermodynamic_database/Properties/O2 diff --git a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/thermodata.h b/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/thermodata.h deleted file mode 100644 index 4901e5d..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/Thermodynamic_database/thermodata.h +++ /dev/null @@ -1,652 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -//Function declarations: -void upper_case(string &str); -void upper_case(string &str1, string &str2); -void upper_case(string &str1, string &str2, string &str3); - -//thermo data from input file -//properties tables are given at a constant pressure level, and provide the property as a function of temperature -//Exhaustive data tables should be used for high accuracy! - -struct list_data{ - double cons;//Constant independent property (pressure or temperature) - vector var;//variable independent property (pressure or temperature) - vector P;//Dependent property -}; - -struct model_data{ - string model_type; - vector constant_list; - vector constant_values; -}; - -struct thermo_data{ - string id, property_type, data_type, function_dependence, unit; - double MW; - double min = -1e4; - double max = 1e4; //Validity (minimum and maximum limits) - list_data lData; //if data list is used - model_data mData; //if model list is used -}; - -/********************************************************************************************************/ -/************************************FUNCTION EXTRACT THERMODATA*****************************************/ -/********************************************************************************************************/ -//Information: extracts all the property data from a given input file: - -void extract_thermo_data(vector &thermo, string input_file){ - ifstream td_file; - td_file.open(input_file); - if( !td_file.good() ) {cout << "input file not found " << endl; return;} - - thermo_data td; string line_txt, txt, str; double Temp, Prop; bool prop_set_found = false, compound_type_found = false; - - while (!td_file.eof()){ - if(!compound_type_found) {getline(td_file, line_txt);} - stringstream sst(line_txt); getline(sst, txt, ' '); - //convert to upper_case to avoid case sensitivity: - upper_case(txt); - if( txt == "COMPOUND:" || txt == "COMPOUND"){ - getline(sst, td.id, ' '); - upper_case(td.id); - prop_set_found = false; - while( prop_set_found == false ){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - if (txt == "PROPERTY:" || txt == "PROPERTY"){ - getline(sst,td.property_type,' '); - upper_case(td.property_type); - } - //Specifies whether the data are provided using either a list or a model. - else if (txt == "DATA:" || txt == "DATA"){ - getline(sst,td.data_type,' '); - upper_case(td.data_type); - } - else if (txt == "UNIT:" || txt == "UNIT"){ - getline(sst,td.unit,' '); - upper_case(td.unit); - } - else if (txt == "MW:"){ - getline(sst,str, ' '); - td.MW = atof(str.c_str()); - } - //Valid interval: - else if (txt == "VALIDITY:" || txt == "VALIDITY"){ - vector validity; - double min, max; - while(getline(sst, str,' ')){ - validity.push_back(atof(str.c_str())); - } - if (validity.size()>0){ - min = validity[0]; - max = validity[0]; - for(int i=0;i temp){ - min = temp; - } - else if (max < temp){ - max = temp; - } - } - td.min = min; td.max = max; - } - } - //Check whether the property is dependent on temperature or pressure: - else if (txt == "DEPENDENCE:" || txt == "DEPENDENCE"){ - getline(sst,td.function_dependence,' '); - upper_case(td.function_dependence); - } - //Deals with properties given in list form: - else if (td.data_type == "LIST"){ - //Check at which isobar or isotherm the property remains valid - if (txt == "CONSPROP:" || txt == "CONSTANT PROPERTY:" || txt == "ISOBAR:" ||txt == "ISOTERM"){ - getline(sst,str, ' '); - td.lData.cons = atof(str.c_str()); - } - //Independent property: - else if (txt == "VAR:" || txt == "VARIABLE:" || txt == "VARIABLE") { - while(getline(sst, str, ' ')){ td.lData.var.push_back(atof(str.c_str()));} - } - //Dependendent property: - else if (txt == "PROP:" || txt == "PROPERTY:" || txt == "PROPERTY"){ - while(getline(sst, str, ' ')){ td.lData.P.push_back(atof(str.c_str()));} - } - //If non of the above are read, we have moved on to the next element - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt == "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); - //Delete vector for next entry: - td.lData.var.clear(); td.lData.P.clear(); td.min = -1e4; td.max = 1e4; td.lData.cons = 0.0; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - } - } - //Deals with properties given in model form: - else if (td.data_type == "MODEL"){ - if (txt == "MODEL:" || txt == "MODEL"){ - getline(sst, td.mData.model_type, ' '); - upper_case(td.mData.model_type); - } - else if (txt == "CONSTANTS:" || txt == "CONSTANTS" ){ - while(getline(sst, str, ' ')){ td.mData.constant_list.push_back(str);} - } - else if (txt == "VALUES:" || txt == "VALUES"){ - while(getline(sst, str, ' ')) - { - td.mData.constant_values.push_back(atof(str.c_str())); - } - } - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt == "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); - //Delete vector for next entry: - td.mData.constant_list.clear(); td.mData.constant_values.clear(); td.min = -1e4; td.max = 1e4; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - td.mData.model_type ="VOID"; - } - } - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt != "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); td.min = -1e4; td.max = 1e4; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - //clear the vectors: - if (td.data_type == "LIST"){ - td.lData.var.clear(); td.lData.P.clear(); - } - else if (td.data_type == "MODEL"){ - td.mData.constant_list.clear(); td.mData.constant_values.clear(); - } - } - } - } - } - td_file.close(); -} - - -/********************************************************************************************************/ -/*************************************FUNCTION EXTRACT PROPERTY******************************************/ -/********************************************************************************************************/ -//Information: extracts only the property data needed from a given input file: - -bool extract_property(thermo_data &thermo, string property, double P, double T, double S, string input_file){ - //Convert to upper case: - upper_case(property); - - - ifstream td_file; - td_file.open(input_file); - if( !td_file.good() ) {cout << "input file not found " << endl; return false;} - - thermo_data td; string line_txt, txt, str; double Temp, Prop; bool prop_set_found = false; bool property_found= false; - - while (!td_file.eof() && !property_found){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - //convert to upper_case to avoid case sensitivity: - upper_case(txt); - if( txt == "PROPERTY:" || txt == "PROPERTY"){ - getline(sst, td.property_type, ' '); - upper_case(td.property_type); - if(td.property_type == property){ - while(prop_set_found == false){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - //Specifies whether the data are provided using either a list or a model. - if (txt == "DATA:" || txt == "DATA"){ - getline(sst,td.data_type,' '); - upper_case(td.data_type); - } - else if (txt == "UNIT:" || txt == "UNIT"){ - getline(sst,td.unit,' '); - upper_case(td.unit); - } - else if (txt == "MW:" || txt == "MW"){ - getline(sst,str, ' '); - td.MW = atof(str.c_str()); - } - //Check whether the property is dependent on temperature or pressure: - else if (txt == "DEPENDENCE:" || txt == "DEPENDENCE"){ - getline(sst,td.function_dependence,' '); - upper_case(td.function_dependence); - } - //Valid interval: - else if (txt == "VALIDITY:" || txt == "VALIDITY"){ - vector validity; - double min, max; - while(getline(sst, str,' ')){ - validity.push_back(atof(str.c_str())); - } - if (validity.size()>0){ - min = validity[0]; - max = validity[0]; - for(int i=0;i temp){ - min = temp; - } - else if (max < temp){ - max = temp; - } - } - td.min = min; td.max = max; - } - } - //Deals with properties given in list form: - else if (td.data_type == "LIST"){ - //Check at which isobar or isotherm the property remains valid - if (txt == "CONSPROP:" || txt == "CONSTANT PROPERTY:" || txt == "ISOBAR:" ||txt == "ISOTERM"){ - getline(sst,str, ' '); - td.lData.cons = atof(str.c_str()); - } - //Independent property: - else if (txt == "VAR:" || txt == "VARIABLE:" || txt == "VARIABLE") { - while(getline(sst, str, ' ')){ td.lData.var.push_back(atof(str.c_str()));} - } - //Dependendent property: - else if (txt == "PROP:" || txt == "PROPERTY:" || txt == "PROPERTY"){ - while(getline(sst, str, ' ')){ td.lData.P.push_back(atof(str.c_str()));} - } - //If non of the above are read, we have moved on to the next element - else{ - prop_set_found = true; - if (td.function_dependence == "TEMPERATURE"){ - if(T>=td.min && T<=td.max){ - thermo =td; - property_found = true; - } - } - else if (td.function_dependence == "PRESSURE"){ - if(P>=td.min && P<=td.max){ - thermo =td; - property_found = true; - } - } - else if (td.function_dependence == "ENTROPY"){ - if(S>=td.min && S<=td.max){ - thermo =td; - property_found = true; - } - } - } - } - //Deals with properties given in model form: - else if (td.data_type == "MODEL"){ - if (txt == "MODEL:" || txt == "MODEL"){ - getline(sst, td.mData.model_type, ' '); - upper_case(td.mData.model_type); - } - else if (txt == "CONSTANTS:" || txt == "CONSTANTS" ){ - while(getline(sst, str, ' ')){ td.mData.constant_list.push_back(str);} - } - else if (txt == "VALUES:" || txt == "VALUES"){ - while(getline(sst, str, ' ')) - { - td.mData.constant_values.push_back(atof(str.c_str())); - } - } - else{ - prop_set_found = true; - if (td.function_dependence == "TEMPERATURE"){ - if(T>=td.min && T<=td.max){ - thermo =td; - property_found = true; - } - } - else if (td.function_dependence == "PRESSURE"){ - if(P>=td.min && P<=td.max){ - thermo =td; - property_found = true; - } - } - else if (td.function_dependence == "ENTROPY"){ - if(S>=td.min && S<=td.max){ - thermo =td; - property_found = true; - } - } - } - } - else{ - prop_set_found = true; - } - } - } - } - } - td_file.close(); - return property_found; -} - - -/********************************************************************************************************/ -/**********************************FUNCTION GET SPECIES THERMODATA***************************************/ -/********************************************************************************************************/ -//Information: Retrieves all the Thermodata for a given species - - -void get_species_thermo_data(vector &thermo, - string species_id, - string database_file = "Thermodynamic_library/Thermodynamic_database/Species_thermofile_list"){ - ifstream data_file; - data_file.open(database_file); - if( !data_file.good() ) {cout << "input file not found " << endl; return;} - string line_txt, txt, id, composition, path; - bool path_found = false; - bool species_found = false; - //convert species_id to upper case: - upper_case(species_id); - - while (!data_file.eof() && !path_found){ - getline(data_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - if (txt == "COMPOUND:" || txt == "COMPOUND"){ - getline(sst, id, ' '); - //Convert to upper case only: - upper_case(id); - } - else if (txt == "COMPOSITION:" || txt == "COMPOSITION"){ - getline(sst, composition, ' '); - //Convert to upper case only: - upper_case(composition); - } - else if (txt == "FILE:" || txt == "FILE"){ - //only extract the path if we have the correct species: - if (id == species_id || composition == species_id){ - getline(sst, path, ' '); - path_found = true; - } - } - } - //Close file: - data_file.close(); - //Error if species cannot be found - if (path_found == false){ - cout<<"Error: Species "< &thermo, string id, string property_type){ - //Upper case used to make the search case insensitive: - upper_case(id, property_type); - for (int n = 0; n &thermo, string id, string property_type, string function_dependence, double atVal){ - //Use upper case to make the search case insensitive: - upper_case(id, property_type, function_dependence); - for (int n = 0; n= thermo[n].min && atVal<= thermo[n].max){ - return n; - } - } - } - cout << '\n'<< "Error: Property for species: "<< id<< '\n'; - cout <<" as a function of "< &thermo, string id, string property_type, double T, double P){ - //Use upper case to make the search case insensitive: - upper_case(id, property_type); - for (int n = 0; n= thermo[n].min && T<= thermo[n].max){ - return n; - } - } - else if (thermo[n].function_dependence == "PRESSURE"){ - if (P >= thermo[n].min && P<= thermo[n].max){ - return n; - } - } - } - } - cout << '\n'<< "Error: Property for species: "<< id<< '\n'; - cout <<" for temperature: "<= prev && indVar < cur){ - exit = true; - }else{ - prev = cur; - prev_prop = cur_prop; - i++; - } - } - //update values for interpolation: - prev = list.var[i-1]; cur = list.var[i]; prev_prop = list.P[i-1]; cur_prop = list.P[i]; - - return prev_prop + ((cur_prop-prev_prop)/(cur-prev))*(indVar - prev); -} - -/********************************************************************************************************/ -/************************************************PRINT***************************************************/ -/********************************************************************************************************/ -//Output functions: -void print_list_data(list_data &list){ - cout<<'\n'<< "Constant property: "<< list.cons< &td){ - if (td.size() == 0){ - cout<<"No property data exist!"< #include #include -#include #include #include #include -#include "thermodynamics.h" +#include "species_thermodynamics.h" #include "Library_Water_Correlations.h" +/* +#include +#include "thermodynamics.h" #include "thermodata.h" #include "conversion.h" #include "thermo_property_models.h" - +*/ diff --git a/submodels/bioCHP_plant/Thermodynamic_library/conversion.h b/submodels/bioCHP_plant/Thermodynamic_library/conversion.h deleted file mode 100644 index 48719a2..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/conversion.h +++ /dev/null @@ -1,261 +0,0 @@ -using namespace std; -void unit_conversion(double &value, thermo_data model, string unit){ - if (unit == "DEFAULT" || model.unit == unit){ - return; - } - else if (model.unit == "K" || model.unit == "KELVIN"){ - if (unit == "K" || model.unit == "KELVIN"){ - return; - } - else if (unit == "C" || unit == "CELSIUS" || "DEGC"){ - value -= 273.15; - return; - } - else { - cout<<"Caution: Unsupported output unit "< +#include +#include +#include + +using namespace std; + +double shomate(string property, double tK, double A, double B, double C, double D, double E, double F, double G, double Hf298){ + + // properties + // cp = heat capacity (J/mol*K) = A + B * t + C * t2 + D * t3 + E / t2 + // h - H°298.15 = standard enthalpy (kJ/mol) = A*t + B*t2/2 + C*t3/3 + D*t4/4 - E/t + F - Hf298 + // s = standard entropy (J/mol*K) = A * Ln(t) + B * t + C * t2 / 2 + D * t3 / 3 - E / (2 * t2) + G + + if(property == "cp"){ return A+B*pow(tK,1)+C*pow(tK,2)+D*pow(tK,3)+E/pow(tK,2);} + if(property == "h"){ return A*pow(tK,1)+B*pow(tK,2)/2.0+C*pow(tK,3)/3.0+D*pow(tK,4)/4.0-E/tK+F-Hf298;} + if(property == "hf"){ return Hf298;} + if(property == "s"){ return A*log(tK)+B*pow(tK,1)+C*pow(tK,2)/2.0+D*pow(tK,3)/3.0-E/(2.0*pow(tK,2.0))+G;} + + return -1; + +} + +double thermodynamic_property(string species, string property, double TK, double P, string unit){ + + double tK = TK/1000.0; + + if (species == "CO2"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.2){ + A = 24.99735; B = 55.18696; C = -33.69137; D = 7.948387; E = -0.136638; F = -403.6075; G = 228.2431; Hf298 = -393.5224; + } + if (tK > 1.2){ + A = 58.16639; B = 2.720074; C = -0.492289; D = 0.038844; E = -6.447293; F = -425.9186; G = 263.6125; Hf298 = -393.5224; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "CO"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.3){ + A = 25.56759; B = 6.09613; C = 4.054656; D = -2.671301; E = 0.131021; F = -118.0089; G = 227.3665; Hf298 = -110.5271; + } + if (tK > 1.3){ + A = 35.1507; B = 1.300095; C = -0.205921; D = 0.01355; E = -3.28278; F = -127.8375; G = 231.712; Hf298 = -110.5271; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "H2O"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.7){ + A = 30.092; B = 6.832514; C = 6.793435; D = -2.53448; E = 0.082139; F = -250.881; G = 223.3967; Hf298 = -241.8264; + } + if (tK > 1.7){ + A = 41.96426; B = 8.622053; C = -1.499781; D = 0.098119; E = -11.15764; F = -272.1797; G = 219.7809; Hf298 = -241.8264; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "H2"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.5){ + A = 33.1078; B = -11.508; C = 11.6093; D = -2.8444; E = -0.159665; F = -9.991971; G = 172.788; Hf298 = 0.0; + } + if (tK > 1.5){ + A = 34.1434; B = 0.503927; C = 0.372036; D = -0.038599; E = -8.074761; F = -21.2188; G = 162.093; Hf298 = 0.0; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "CH4"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.3){ + A = -0.703029; B = 108.4773; C = -42.52157; D = 5.862788; E = 0.678565; F = -76.84376; G = 158.7163; Hf298 = -74.8731; + } + if (tK > 1.3){ + A = 85.81217; B = 11.26467; C = -2.114146; D = 0.13819; E = -26.42221; F = -153.5327; G = 224.4143; Hf298 = -74.8731; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "N2"){ + double A, B, C, D, E, F, G, Hf298; + A = 26.092; B = 8.218801; C = -1.976141; D = 0.159274; E = 0.044434; F = -7.98923; G = 221.02; Hf298 = 0.0; + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "O2"){ + double A, B, C, D, E, F, G, Hf298; + A = 29.659; B = 6.137261; C = -1.186521; D = 0.09578; E = -0.219663; F = -9.861391; G = 237.948; Hf298 = 0.0; + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "SO2"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.2){ + A = 21.43049; B = 74.35094; C = -57.75217; D = 16.35534; E = 0.086731; F = -305.7688; G = 254.8872; Hf298 = -296.8422; + } + if (tK > 1.2){ + A = 57.48188; B = 1.009328; C = -0.07629; D = 0.005174; E = -4.045401; F = -324.414; G = 302.7798; Hf298 = -296.8422; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "SO3"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.2){ + A = 24.02503; B = 119.4607; C = -94.38686; D = 26.96237; E = -0.117517; F = -407.8526; G = 253.5186; Hf298 = -395.7654; + } + if (tK > 1.2){ + A = 81.99008; B = 0.622236; C = -0.12244; D = 0.008294; E = -6.703688; F = -437.659; G = 330.9264; Hf298 = -395.7654; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "HCl"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.2){ + A = 32.12392; B = -13.45805; C = 19.86852; D = -6.853936; E = -0.049672; F = -101.6206; G = 228.6866; Hf298 = -92.31201; + } + if (tK > 1.2){ + A = 31.91923; B = 3.203184; C = -0.541539; D = 0.035925; E = -3.438525; F = -108.015; G = 218.2768; Hf298 = -92.31201; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "Cl2"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.0){ + A = 33.0506; B = 12.2294; C = -12.0651; D = 4.38533; E = -0.159494; F = -10.8348; G = 259.029; Hf298 = 0.0; + } + if (tK > 1.0 && tK <= 3.0){ + A = 42.6773; B = -5.00957; C = 1.904621; D = -0.165641; E = -2.098481; F = -17.2898; G = 269.84; Hf298 = 0.0; + } + if (tK > 3.0){ + A = -42.5535; B = 41.6857; C = -7.12683; D = 0.387839; E = 101.144; F = 132.764; G = 264.786; Hf298 = 0.0; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "NH3"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.4){ + A = 19.99563; B = 49.77119; C = -15.37599; D = 1.921168; E = 0.189174; F = -53.30667; G = 203.8591; Hf298 = -45.89806; + } + if (tK > 1.4){ + A = 52.02427; B = 18.48801; C = -3.765128; D = 0.248541; E = -12.45799; F = -85.53895; G = 223.8022; Hf298 = -45.89806; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "NO2"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.2){ + A = 16.10857; B = 75.89525; C = -54.3874; D = 14.30777; E = 0.239423; F = 26.17464; G = 240.5386; Hf298 = 33.09502; + } + if (tK > 1.2){ + A = 56.82541; B = 0.738053; C = -0.144721; D = 0.009777; E = -5.459911; F = 2.846456; G = 290.5056; Hf298 = 33.09502; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + else if (species == "N2O4"){ + double A, B, C, D, E, F, G, Hf298; + if (tK <= 1.0){ + A = 34.05274; B = 191.9845; C = -151.0575; D = 44.3935; E = -0.158949; F = -8.893428; G = 293.7724; Hf298 = 9.078988; + } + if (tK > 1.0){ + A = 128.622; B = 2.524345; C = -0.520883; D = 0.03663; E = -11.55704; F = -59.22619; G = 417.0444; Hf298 = 9.078988; + } + return shomate(property, tK, A, B, C, D, E, F, G, Hf298); + } + + return -1; +} diff --git a/submodels/bioCHP_plant/Thermodynamic_library/thermo_property_models.h b/submodels/bioCHP_plant/Thermodynamic_library/thermo_property_models.h deleted file mode 100644 index 7f10d97..0000000 --- a/submodels/bioCHP_plant/Thermodynamic_library/thermo_property_models.h +++ /dev/null @@ -1,616 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -//#include "thermodata.h" -//#include "conversion.h" - -using namespace std; - -//declarations: -double Antoine(thermo_data model, double T, double P, string unit); -double Majer1985(thermo_data model, double T, double P, string unit); -double PPDS12(thermo_data model, double T, double P, string unit); -double DIPPR107(thermo_data model, double T, double P, string unit); -double TDEliquid(thermo_data model, double T, double P, string unit); -double Shomate(thermo_data model, double T, double P, string unit); -double Constant(thermo_data model, double T, double P, string unit); -double Wagner25(thermo_data model, double T, double P, string unit); -double TDEWatson(thermo_data model, double T, double P, string unit); -double ThermoML(thermo_data model, double T, double P, string unit); - - -double thermodynamic_property(string species_id, string property_id, double T, double P, string unit = "DEFAULT"){ - //Initializations: - thermo_data data; - bool property_found; - double propVal = 0.0; //return value - - //Convert the unit string to upper case: - upper_case(unit); - property_found = get_property_data(data, species_id, property_id, T, P); - - //DEBUG: - //print_thermo_data(data); - //END DEBUG - - //If property data doesn't exist in the list: - if (!property_found){ - //cout<< '\n'<<"Error: Property list/model cannot be found in list!"<Tmax){//extrapolation at the upper bound (lnp) - double T1, T2; //extrapolation variables: - T1 = Tmax; T2 = T1 - 1.0;//sample at two points for extrapolation - - double Tr1 = T1/Tc; double Tr2 = T2/Tc; - double lPsat1 = lPc + (C1*(1-Tr1) + C2*pow(1-Tr1,1.5) + C3*pow(1-Tr1,2.5) + C4*pow(1-Tr1,5))/Tr1; - double lPsat2 = lPc + (C1*(1-Tr2) + C2*pow(1-Tr2,1.5) + C3*pow(1-Tr2,2.5) + C4*pow(1-Tr2,5))/Tr2; - - double lPsat = lPsat1 + ((lPsat1-lPsat2)*(T-T1)/(T1-T2)); - Psat = exp(lPsat); - } - else{ - double Tr = T/Tc; - double lPsat = lPc + (C1*(1-Tr) + C2*pow(1-Tr,1.5) + C3*pow(1-Tr,2.5) + C4*pow(1-Tr,5))/Tr; - Psat = exp(lPsat); - } - //unit conversion: - unit_conversion(Psat, model, unit); - - return Psat; - -} - -//Heat of evaporation using the publication by Majer and Svoboda, 1985 -double Majer1985(thermo_data model, double T, double P, string unit){ - //Declare constants for the process: - double A, alpha, beta, Tc; - for(int i = 0; iTc){//Set Hvap to 0 above critical temperature - HVap = 0.0; - } - else if (TTmax){ - double T1 = Tmax; double T2 = Tmax - 1.0; - double Tr1 = T1/Tc; double Tr2 = T2/Tc; - double lgHVap1 = C1 + C2*log(1-Tr1) + C3*Tr1*log(1-Tr1) + C4*pow(Tr1,2)*log(1-Tr1); - double lgHVap2 = C1 + C2*log(1-Tr2) + C3*Tr2*log(1-Tr2) + C4*pow(Tr2,2)*log(1-Tr2); - - double HVap1 = exp(lgHVap1); double HVap2 = exp(lgHVap2); - //Extrapolation: - HVap = HVap1 + ((HVap1-HVap2)*(T-T1)/(T1-T2)); - } - else{ - double Tr = T/Tc; - double lgHVap = 0.0; - lgHVap = C1 + C2*log(1-Tr) + C3*Tr*log(1-Tr) + C4*pow(Tr,2)*log(1-Tr); - - HVap = exp(lgHVap); - } - //unit conversion: - unit_conversion(HVap, model, unit); - return HVap; -} - -//PPDS12 function: -//From DDB -double PPDS12(thermo_data model, double T, double P, string unit){ - double Tmin = model.min; double Tmax = model.max; - //Declare constants for the process: - double A, B, C, D, E, Tc, R; - for(int i = 0; iTc){//Hvap = 0.0 above critical temperature - Hvap = 0.0; - } - else if(T>Tmax){//Extrapolation at the upper bound - double T1 = Tmax; double T2 =T1-1.0; - double Tr1, Tr2, Hvap1, Hvap2; - Tr1 = 1-T1/Tc; Tr2 = 1-T2/Tc; - Hvap1 = R*Tc*(A*pow(Tr1,1.0/3.0)+B*pow(Tr1,2.0/3.0)+C*Tr1+D*pow(Tr1,2)+E*pow(Tr1,6)); - Hvap2 = R*Tc*(A*pow(Tr2,1.0/3.0)+B*pow(Tr2,2.0/3.0)+C*Tr2+D*pow(Tr2,2)+E*pow(Tr2,6)); - Hvap = Hvap1 + ((Hvap1-Hvap2)*(T-T1)/(T1-T2)); - } - else{ - //reduced temperature: - double Tr = 1-T/Tc; - Hvap = R*Tc*(A*pow(Tr,1.0/3.0)+B*pow(Tr,2.0/3.0)+C*Tr+D*pow(Tr,2)+E*pow(Tr,6)); - } - //unit conversion: - unit_conversion(Hvap, model, unit); - - return Hvap; -} - -//Ideal gas constant heat capacity: -//Formula from Aly and Lee 1981 (DIPPR107) -double DIPPR107(thermo_data model, double T, double P, string unit){ - //Declare constants for the process: - double A, B, C, D, E; - for(int i = 0; iTmax){ - double T1 = Tmin; double T2 = Tmin + 1.0; - double t1 = 1-T1/Tc; double t2 = 1-T2/Tc; - double cpliq1 = B/t1 + C1 + C2*T1 + C3*pow(T1,2) + C4*pow(T1,3); - double cpliq2 = B/t2 + C1 + C2*T2 + C3*pow(T2,2) + C4*pow(T2,3); - - cpliq = cpliq1 + ((cpliq1-cpliq2)*(T-T1)/(T1-T2)); - } - else { - double t = 1-T/Tc; - cpliq = B/t + C1 + C2*T + C3*pow(T,2) + C4*pow(T,3); - } - //unit converter: - unit_conversion(cpliq, model, unit); - - return cpliq; -} - -//Saturated liquid heat capacity at constant pressure: -double ThermoML(thermo_data model, double T, double P, string unit){ - double Tmin = model.min; double Tmax = model.max; - //Declare constants for the process: - double C1, C2, C3, C4, C5, Tc; - for(int i = 0; iTmax){ - double T1 = Tmax; double T2 = Tmax-1.0; - double cpliq1 = C1 + C2*T1 + C3*pow(T1,2) + C4*pow(T1,3) + C5*pow(T1,4); - double cpliq2 = C1 + C2*T2 + C3*pow(T2,2) + C4*pow(T2,3) + C5*pow(T2,4); - cpliq = cpliq1 + ((cpliq1-cpliq2)*(T-T1)/(T1-T2)); - } - else{ - cpliq = C1 + C2*T + C3*pow(T,2) + C4*pow(T,3) + C5*pow(T,4); - } - //unit conversion: - unit_conversion(cpliq, model, unit); - return cpliq; -} - -double Shomate(thermo_data model, double T, double P, string unit){ - //Declare constants for the process: - double A, B, C, D, E, F, G, H; - for(int i = 0; i -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -//Function declarations: -void upper_case(string &str); -void upper_case(string &str1, string &str2); -void upper_case(string &str1, string &str2, string &str3); - -//thermo data from input file -//properties tables are given at a constant pressure level, and provide the property as a function of temperature -//Exhaustive data tables should be used for high accuracy! - -struct list_data{ - double cons;//Constant independent property (pressure or temperature) - vector var;//variable independent property (pressure or temperature) - vector P;//Dependent property -}; - -struct model_data{ - string model_type; - vector constant_list; - vector constant_values; -}; - -struct thermo_data{ - string id, property_type, data_type, function_dependence, unit; - bool extrapolate = false; - double MW; - double min = -1e4; - double max = 1e4; //Validity (minimum and maximum limits) - list_data lData; //if data list is used - model_data mData; //if model list is used -}; - -/********************************************************************************************************/ -/************************************FUNCTION EXTRACT THERMODATA*****************************************/ -/********************************************************************************************************/ -//Information: extracts all the property data from a given input file: - -void extract_thermo_data(vector &thermo, string input_file){ - ifstream td_file; - td_file.open(input_file); - if( !td_file.good() ) {cout << "input file not found " << endl; return;} - - thermo_data td; string line_txt, txt, str; double Temp, Prop; bool prop_set_found = false, compound_type_found = false; - - while (!td_file.eof()){ - if(!compound_type_found) {getline(td_file, line_txt);} - stringstream sst(line_txt); getline(sst, txt, ' '); - //convert to upper_case to avoid case sensitivity: - upper_case(txt); - if( txt == "COMPOUND:" || txt == "COMPOUND"){ - getline(sst, td.id, ' '); - upper_case(td.id); - prop_set_found = false; - while( prop_set_found == false ){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - if (txt == "PROPERTY:" || txt == "PROPERTY"){ - getline(sst,td.property_type,' '); - upper_case(td.property_type); - } - //Specifies whether the data are provided using either a list or a model. - else if (txt == "DATA:" || txt == "DATA"){ - getline(sst,td.data_type,' '); - upper_case(td.data_type); - } - else if (txt == "EXTRAPOLATION:" || txt == "EXTRAPOLATION"){ - getline(sst, str, ' '); - upper_case(str); - if (str == "YES"){ - td.extrapolate = true; - } - else{ - td.extrapolate = false; - } - } - else if (txt == "UNIT:" || txt == "UNIT"){ - getline(sst,td.unit,' '); - upper_case(td.unit); - } - else if (txt == "MW:"){ - getline(sst,str, ' '); - td.MW = atof(str.c_str()); - } - //Valid interval: - else if (txt == "VALIDITY:" || txt == "VALIDITY"){ - vector validity; - double min, max; - while(getline(sst, str,' ')){ - validity.push_back(atof(str.c_str())); - } - if (validity.size()>0){ - min = validity[0]; - max = validity[0]; - for(int i=0;i temp){ - min = temp; - } - else if (max < temp){ - max = temp; - } - } - td.min = min; td.max = max; - } - } - //Check whether the property is dependent on temperature or pressure: - else if (txt == "DEPENDENCE:" || txt == "DEPENDENCE"){ - getline(sst,td.function_dependence,' '); - upper_case(td.function_dependence); - } - //Deals with properties given in list form: - else if (td.data_type == "LIST"){ - //Check at which isobar or isotherm the property remains valid - if (txt == "CONSPROP:" || txt == "CONSTANT PROPERTY:" || txt == "ISOBAR:" ||txt == "ISOTERM"){ - getline(sst,str, ' '); - td.lData.cons = atof(str.c_str()); - } - //Independent property: - else if (txt == "VAR:" || txt == "VARIABLE:" || txt == "VARIABLE") { - while(getline(sst, str, ' ')){ td.lData.var.push_back(atof(str.c_str()));} - } - //Dependendent property: - else if (txt == "PROP:" || txt == "PROPERTY:" || txt == "PROPERTY"){ - while(getline(sst, str, ' ')){ td.lData.P.push_back(atof(str.c_str()));} - } - //If non of the above are read, we have moved on to the next element - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt == "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); - //Delete vector for next entry: - td.lData.var.clear(); td.lData.P.clear(); td.min = -1e4; td.max = 1e4; td.extrapolate = false; td.lData.cons = 0.0; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - } - } - //Deals with properties given in model form: - else if (td.data_type == "MODEL"){ - if (txt == "MODEL:" || txt == "MODEL"){ - getline(sst, td.mData.model_type, ' '); - upper_case(td.mData.model_type); - } - else if (txt == "CONSTANTS:" || txt == "CONSTANTS" ){ - while(getline(sst, str, ' ')){ td.mData.constant_list.push_back(str);} - } - else if (txt == "VALUES:" || txt == "VALUES"){ - while(getline(sst, str, ' ')) - { - td.mData.constant_values.push_back(atof(str.c_str())); - } - } - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt == "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); - //Delete vector for next entry: - td.mData.constant_list.clear(); td.mData.constant_values.clear(); td.min = -1e4; td.max = 1e4; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - td.mData.model_type ="VOID"; td.extrapolate = false; - } - } - else{ - prop_set_found = true; - if( txt == "COMPOUND:" || txt != "COMPOUND") {compound_type_found = true;} - if( txt != "COMPOUND:" || txt != "COMPOUND") {compound_type_found = false;} - thermo.push_back(td); td.min = -1e4; td.max = 1e4; td.extrapolate = false; - td.data_type = "VOID"; td.property_type = "VOID"; td.id="VOID"; td.function_dependence = "VOID"; - //clear the vectors: - if (td.data_type == "LIST"){ - td.lData.var.clear(); td.lData.P.clear(); - } - else if (td.data_type == "MODEL"){ - td.mData.constant_list.clear(); td.mData.constant_values.clear(); - } - } - } - } - } - td_file.close(); -} - - -/********************************************************************************************************/ -/*************************************FUNCTION EXTRACT PROPERTY******************************************/ -/********************************************************************************************************/ -//Information: extracts only the property data needed from a given input file: - -bool extract_property(thermo_data &thermo, string property, double T, double P, string input_file){ - //Convert to upper case: - upper_case(property); - - ifstream td_file; - td_file.open(input_file); - if( !td_file.good() ) {cout << "input file not found " << endl; return false;} - - thermo_data td; string line_txt, txt, str; double Temp, Prop; bool prop_set_found = false; bool property_found= false; - - while (!td_file.eof() && !property_found){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - //convert to upper_case to avoid case sensitivity: - upper_case(txt); - if( txt == "PROPERTY:" || txt == "PROPERTY"){ - getline(sst, td.property_type, ' '); - upper_case(td.property_type); - if(td.property_type == property){ - prop_set_found = false; - while(prop_set_found == false){ - getline(td_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - //Specifies whether the data are provided using either a list or a model. - if (txt == "DATA:" || txt == "DATA"){ - getline(sst,td.data_type,' '); - upper_case(td.data_type); - } - else if (txt == "UNIT:" || txt == "UNIT"){ - getline(sst,td.unit,' '); - upper_case(td.unit); - } - else if (txt == "EXTRAPOLATION:" || txt == "EXTRAPOLATION"){ - getline(sst, str, ' '); - upper_case(str); - - if (str == "YES"){ - td.extrapolate = true; - } - else{ - td.extrapolate = false; - } - } - else if (txt == "MW:" || txt == "MW"){ - getline(sst,str, ' '); - td.MW = atof(str.c_str()); - } - //Check whether the property is dependent on temperature or pressure: - else if (txt == "DEPENDENCE:" || txt == "DEPENDENCE"){ - getline(sst,td.function_dependence,' '); - upper_case(td.function_dependence); - } - //Valid interval: - else if (txt == "VALIDITY:" || txt == "VALIDITY"){ - td.min = -1e4; td.max = 1e4; - vector validity; - double min, max; - while(getline(sst, str,' ')){ - validity.push_back(atof(str.c_str())); - } - if (validity.size()>0){ - min = validity[0]; - max = validity[0]; - for(int i=0;i temp){ - min = temp; - } - else if (max < temp){ - max = temp; - } - } - td.min = min; td.max = max; - } - } - //Deals with properties given in list form: - else if (td.data_type == "LIST"){ - //Check at which isobar or isotherm the property remains valid - if (txt == "CONSPROP:" || txt == "CONSTANT PROPERTY:" || txt == "ISOBAR:" ||txt == "ISOTERM"){ - getline(sst,str, ' '); - td.lData.cons = atof(str.c_str()); - } - //Independent property: - else if (txt == "VAR:" || txt == "VARIABLE:" || txt == "VARIABLE") { - while(getline(sst, str, ' ')){ td.lData.var.push_back(atof(str.c_str()));} - } - //Dependendent property: - else if (txt == "PROP:" || txt == "PROPERTY:" || txt == "PROPERTY"){ - while(getline(sst, str, ' ')){ td.lData.P.push_back(atof(str.c_str()));} - } - //If non of the above are read, we have moved on to the next element - else{ - prop_set_found = true; - if (td.function_dependence == "TEMPERATURE"){ - if(T>=td.min && T<=td.max){ - thermo =td; - property_found = true; - } - else if (td.extrapolate){//list can be extrapolated - thermo = td; - property_found = true; - } - } - else if (td.function_dependence == "PRESSURE"){ - if(P>=td.min && P<=td.max){ - thermo = td; - property_found = true; - } - else if (td.extrapolate){//list can be extrapolated - thermo = td; - property_found = true; - } - } - } - } - //Deals with properties given in model form: - else if (td.data_type == "MODEL"){ - if (txt == "MODEL:" || txt == "MODEL"){ - getline(sst, td.mData.model_type, ' '); - upper_case(td.mData.model_type); - } - else if (txt == "CONSTANTS:" || txt == "CONSTANTS" ){ - while(getline(sst, str, ' ')){ td.mData.constant_list.push_back(str);} - } - else if (txt == "VALUES:" || txt == "VALUES"){ - while(getline(sst, str, ' ')) - { - td.mData.constant_values.push_back(atof(str.c_str())); - } - } - else{ - prop_set_found = true; - if (td.function_dependence == "TEMPERATURE"){ - if(T>=td.min && T<=td.max){ - thermo =td; - property_found = true; - } - else if (td.extrapolate){//model can be extrapolated - thermo = td; - property_found = true; - } - } - else if (td.function_dependence == "PRESSURE"){ - if(P>=td.min && P<=td.max){ - thermo =td; - property_found = true; - } - else if (td.extrapolate){//model can be extrapolated - thermo = td; - property_found = true; - } - } - } - } - else{ - prop_set_found = true; - } - } - } - } - } - td_file.close(); - return property_found; -} - - -/********************************************************************************************************/ -/**********************************FUNCTION GET SPECIES THERMODATA***************************************/ -/********************************************************************************************************/ -//Information: Retrieves all the Thermodata for a given species - - -void get_species_thermo_data(vector &thermo, string species_id, string database_file = "Thermodynamic_library/Thermodynamic_database/Species_thermofile_list"){ - ifstream data_file; - data_file.open(database_file); - if( !data_file.good() ) {cout << "input file not found " << endl; return;} - string line_txt, txt, id, composition, path; - bool path_found = false; - bool species_found = false; - //convert species_id to upper case: - upper_case(species_id); - - while (!data_file.eof() && !path_found){ - getline(data_file, line_txt); - stringstream sst(line_txt); getline(sst, txt, ' '); - upper_case(txt); - if (txt == "COMPOUND:" || txt == "COMPOUND"){ - getline(sst, id, ' '); - //Convert to upper case only: - upper_case(id); - } - else if (txt == "COMPOSITION:" || txt == "COMPOSITION"){ - getline(sst, composition, ' '); - //Convert to upper case only: - upper_case(composition); - } - else if (txt == "FILE:" || txt == "FILE"){ - //only extract the path if we have the correct species: - if (id == species_id || composition == species_id){ - getline(sst, path, ' '); - path_found = true; - } - } - } - //Close file: - data_file.close(); - //Error if species cannot be found - if (path_found == false){ - cout<<"Error: Species "< &thermo, string id, string property_type){ - //Upper case used to make the search case insensitive: - upper_case(id, property_type); - for (int n = 0; n &thermo, string id, string property_type, string function_dependence, double atVal){ - //Use upper case to make the search case insensitive: - upper_case(id, property_type, function_dependence); - for (int n = 0; n= thermo[n].min && atVal<= thermo[n].max){ - return n; - } - } - } - cout << '\n'<< "Error: Property for species: "<< id<< '\n'; - cout <<" as a function of "< &thermo, string id, string property_type, double T, double P){ - //Use upper case to make the search case insensitive: - upper_case(id, property_type); - for (int n = 0; n= thermo[n].min && T<= thermo[n].max){ - return n; - } - } - else if (thermo[n].function_dependence == "PRESSURE"){ - if (P >= thermo[n].min && P<= thermo[n].max){ - return n; - } - } - } - } - cout << '\n'<< "Error: Property for species: "<< id<< '\n'; - cout <<" for temperature: "<= prev && indVar < cur){ - exit = true; - }else{ - prev = cur; - prev_prop = cur_prop; - i++; - } - } - //update values for interpolation: - prev = list.var[i-1]; cur = list.var[i]; prev_prop = list.P[i-1]; cur_prop = list.P[i]; - - return prev_prop + ((cur_prop-prev_prop)/(cur-prev))*(indVar - prev); -} - -/********************************************************************************************************/ -/************************************************PRINT***************************************************/ -/********************************************************************************************************/ -//Output functions: -void print_list_data(list_data &list){ - cout<<'\n'<< "Constant property: "<< list.cons< &td){ - if (td.size() == 0){ - cout<<"No property data exist!"< -#include -#include -#include -#include - -using namespace std; - -//Function headers: -double wCwO(string CellerO, double H, double wH, double wS, double wCl, double wN, double wAske, double wH2O); -double NedreBrennverdi(double wC, double wH, double wO, double wS, double wN, double wH2O); -double SGas(string Comp, double TC); -double HGas(string Comp, double TC); -double CpGas(string Comp, double TC, double TC1 = 0.0); -void GasData(string Comp, double &T, double &A, double &B, double &C, double &D, double &E, double &f, double &G, double &H, double &Hf298); -double AcidVaporDewPoint(string Comp, double xHCl, double xsO2, double xH2O, double P); -double THGasMix(double H, double xCO2, double xH2O, double xO2, double xN2, double xCO = 0.0, double xH2 = 0.0); -double HGasMix(double T, double xCO2, double xH2O, double xO2, double xN2, double xCO = 0.0, double xH2 = 0.0); -double HfGas_Mix(double xO2, double xN2, double xCO2, double xH2O, double xH2, double xCO, double xCH4, double xC2H4, double xC2H2, double xC2H6, double xC3, double xC4, double xC5, double xC6, double xC7, double xC8, double xC9, double xC10); -double hPWater(double P); -double hTWater(double T); -double TSatWater(double P); -double PSatWater(double T); -double sPhSupSteam(double P, double H); -double TPhSupSteam(double P, double H); -double hPsSupSteam(double P, double S); -double hPTSupSteam(double P, double Temp); -double sPTSupSteam(double P, double T_in); -double dT_sPTSupSteam(double P, double T); -double sPSatSteam(double P); -double sPWater(double P); -double sTWater(double T); -double hPSatSteam(double P); -double HTSteam(double T); -double vTWater(double T); -double vTSteam(double T); -double HVapH2O(double T); -double CpVann(double T); -double cp(string Comp, double T, double T2 = 9999.0); -double cpRGASS(string Comp, double T, double T1 = 9999.0, int kg = 0); -double cpMix(double xCO2, double xO2, double xH2O, double xN2, double T, double T1 = 9999.0); -double PvH2O(double T); -double TSatH2O(double P); -double gas_visc_lucas(double T, string Comp); -double gas_visc(double T, string Comp); -double G_Mix_visc(double T, double xO2, double xCO, double xH2, double xCO2, double xH2O, double xN2); -double gas_lambda(double T, string Comp); - -// Bibliotek med korrelasjoner for fysikalske data -// HGasMix Beregner entalpi [kJ/Nm3] av røykgass sfa. temperatur [C] -// HVapH2O Fordampningsvarme for vann [kJ/kg] sfa. temperatur [C] -// gas_lambda Termisk konduktivitet i gass [W/(m K)] sfa temperatur [C] -// G_Mix_visc Viskositet [Pa s] for en gassblanding sfa. temperaturen T [C] -// gas_visc Viskositet for komponenter [Pa s] sfa. temperatur [C] - -double wESt(string CHO, double Qar, double wS, double wCl, double wN, double wAske, double wH2O){ - // Empirisk korrelasjon for wC, wH og wO som funksjon av input parametrene over. - // Basert på - double k; - double kC, kH, kO, kS, kN, kH2O, kA; - kC = 34.1; kH = 102; kO = -9.85; kS = 19.1; kN = 0.0; kH2O = -2.5; kA = 0.0; - //kC = 34.8; kH = 93.9; kO = -10.8; kS = 10.5; kN = 6.3; kH2O = -2.45; kA=0.0; // Ref. Christensen, T. (1998) - //kC = 34.1; kH = 110.4; kO = -12.0; kS = 6.86; kN = -12.0; kA = -1.53; //Milne's formulae (from Phyllis) - //kC = 34.91; kH = 97.67; kO = -10.34; kS = 10.05; kN = 0.0; kA = -2.11; // Review artikkel - - double Qdaf, wC, wH, wO; - - //Qdaf = Qar / ((1 - wH2O) * (1 - wAske)) - //Qar = (kC*wC+kH*wH+kS*wS+kN*wN+kO*wO)*(1-wH2O) + kH2O*wH2O = Qdaf*(1-wH2O)+kH2O*wH2O - - Qdaf = (Qar - kH2O * wH2O) / (1 - wH2O); //korrigert 27.03.03 - wC = (0.01727 * Qdaf + 0.1583); - k = (Qar - kH2O * wH2O) / (1 - wH2O); - wH = (k - (kC * wC + kS * wS + kN * wN + kA * wAske) - kO * (1 - wC - wN - wS - wCl - wAske)) / (kH - kO); - wO = 1 - (wC + wH + wS + wN + wCl + wAske); - - if (CHO == "C"){ - return wC; - } - else if (CHO == "H"){ - return wH; - } - else{ - return wO; - } -} - - -double wCwO(string CellerO, double H, double wH, double wS, double wCl, double wN, double wAske, double wH2O){ - double k, x, y, wA; - double kC, kH, kO, kS, kN, kH2O, kA; - kC = 34.1; kH = 102.0; kO = -9.85; kS = 19.1; kN = 0.0; kH2O = -2.5; - //kC = 34.8; kH = 93.9; kO = -10.8; kS = 10.5; kN = 6.3; kH2O = -2.45; //Ref. Christensen, T. (1998) - //kC = 34.1; kH = 110.4; kO = -12.0; kS = 6.86; kN = -12.0; kA = -1.53; //Milne's formulae (from Phyllis) - - wA = wAske + wS + wCl + wN; - k = (H - kH2O * wH2O) / (1 - wH2O) - kH * wH - kS * wS - kN * wN; - y = (12 / 16) * (kC * (1 - wA) - k * (1 + wH / (1 - wA - wH))) / (-kO * (1 - wA) + k * (1 + wH / (1 - wA - wH))); - x = (12 + 16 * y) * wH / (1 - wA - wH); - - if (CellerO == "C"){ - return 12 / (12 + x + 16 * y) * (1 - wA); - } - else{ - return 16 * y / (12 + x + 16 * y) * (1 - wA); - } -} - - -double NedreBrennverdi(double wC, double wH, double wO, double wS, double wN, double wH2O){ - //Beregning av nedre brennverdi [MJ/kg] - //Forutsetning: Brensel: 20C, Forbrenningsluft inn: 20C, røykgass ut ved 100oC (ikke kondensert). - - //ToP - 4.8.2000 - - double kC, kH, kO, kS, kN, kH2O, kA; - kC = 34.1; kH = 102; kO = -9.85; kS = 19.1; kN = 0; kH2O = -2.5; kA = 0.0; - //kC = 34.8; kH = 93.9; kO = -10.8; kS = 10.5; kN = 6.3; kH2O = -2.45; kA = 0.0; // Ref. Christensen, T. (1998) - //kC = 34.1; kH = 110.4; kO = -12; kS = 6.86; kN = -12; kH2O = -2.442; kA = -1.53; // Milne's formulae (from Phyllis) - if (wH2O > 1) wH2O = wH2O / 100; //forutsetter vektfraksjon i input - if (wC + wH + wO + wS + wN > 1.0001) { - wC = wC / 100; wH = wH / 100; wO = wO / 100; wS = wS / 100; wN = wN / 100; - } - - return (kC * wC + kH * wH + kS * wS + kN * wN + kO * wO) * (1 - wH2O) + kH2O * wH2O; // Ref. Christensen (1998) -} - - -double SGas(string Comp, double TC){ - //Standard entropy S^o [J/(mol K)] - //Comp {se rutinen GasData for definerte komponenter} - //TC - temperatur [C] - - //ToP - 16.3.00 - double T = (TC + 273.15) / 1000; - - double A, B, C, D, E, f, G, H, Hf298; - - //COME BACK TO THIS: (must be a void function with addresses!) - GasData(Comp, T, A, B, C, D, E, f, G, H, Hf298); - - return A * log(T) + B * T + C * (pow(T,2)) / 2 + D * (pow(T,3)) / 3 - E / (2 * pow(T,2)) + G; -} - - -double HGas(string Comp, double TC){ - //Standard entalpi [kJ/mol] - //Comp {se rutinen GasData for definerte komponenter} - //TC - temperatur [C] - - //ToP - 16.3.00 - double T = (TC + 273.15) / 1000; - //double T = (TC + 273.15); - double A, B, C, D, E, f, G, H, Hf298; - GasData(Comp, T, A, B, C, D, E, f, G, H, Hf298); - double R = 8.314; - - return R*(A * T + B * pow(T,2) / 2 + C * pow(T,3) / 3 + D * pow(T,4) / 4 - E / T + f); -} - -void GasNASAData(string Species, double &Tn, double &a1, double &a2, double &a3, double &a4, double &a5, double &a6, double &a7) -{ -// Cp° = A + B * t + C * t2 + D * t3 + E / t2 -// H° - H°298.15= A*t + B*t2/2 + C*t3/3 + D*t4/4 - E/t + F - fH°f,298 -// S° = A * Ln(t) + B * t + C * t2 / 2 + D * t3 / 3 - E / (2 * t2) + G -// Cp = heat capacity (J/mol*K) -// H° = standard enthalpy (kJ/mol) -// S° = standard entropy (J/mol*K) - -if( Species == "O2") { -if( Tn > 1000 ){ a1 = 3.28253784; a2 = 0.00148308754; a3 = -0.000000757966669; a4 = 2.09470555E-10; a5 = -2.16717794E-14; a6 = -1088.45772; a7 = 5.45323129;} -if( Tn <= 1000 ){ a1 = 3.78245636; a2 = -0.00299673416; a3 = 0.00000984730201; a4 = -9.68129509E-09; a5 = 3.24372837E-12; a6 = -1063.94356; a7 = 3.65767573;} -} -if( Species == "N2") { -if( Tn > 1000 ){ a1 = 3.28253784; a2 = 0.00148308754; a3 = -0.000000757966669; a4 = 2.09470555E-10; a5 = -2.16717794E-14; a6 = -1088.45772; a7 = 5.45323129;} -if( Tn <= 1000 ){ a1 = 3.298677; a2 = 0.0014082404; a3 = -0.000003963222; a4 = 0.000000005641515; a5 = -2.444854E-12; a6 = -1020.8999; a7 = 3.950372;} -} -if( Species == "H2O") { -if( Tn > 1000 ){ a1 = 3.03399249; a2 = 0.00217691804; a3 = -0.000000164072518; a4 = -9.7041987E-11; a5 = 1.68200992E-14; a6 = -30004.2971; a7 = 4.9667701;} -if( Tn <= 1000 ){ a1 = 4.19864056; a2 = -0.0020364341; a3 = 0.00000652040211; a4 = -5.48797062E-09; a5 = 1.77197817E-12; a6 = -30293.7267; a7 = -0.849032208;} -} -if( Species == "CO2") { -if( Tn > 1000 ){ a1 = 3.85746029; a2 = 0.00441437026; a3 = -0.00000221481404; a4 = 5.23490188E-10; a5 = -4.72084164E-14; a6 = -48759.166; a7 = 2.27163806;} -if( Tn <= 1000 ){ a1 = 2.35677352; a2 = 0.00898459677; a3 = -0.00000712356269; a4 = 2.45919022E-09; a5 = -1.43699548E-13; a6 = -48371.9697; a7 = 9.90105222;} -} -if( Species == "CO") { -if( Tn > 1000 ){ a1 = 2.71518561; a2 = 0.00206252743; a3 = -0.000000998825771; a4 = 2.30053008E-10; a5 = -2.03647716E-14; a6 = -14151.8724; a7 = 7.81868772;} -if( Tn <= 1000 ){ a1 = 3.57953347; a2 = -0.00061035368; a3 = 0.00000101681433; a4 = 9.07005884E-10; a5 = -9.04424499E-13; a6 = -14344.086; a7 = 3.50840928;} -} -if( Species == "H2") { -if( Tn > 1000 ){ a1 = 3.3372792; a2 = -0.0000494024731; a3 = 0.000000499456778; a4 = -1.79566394E-10; a5 = 2.00255376E-14; a6 = -950.158922; a7 = -3.20502331;} -if( Tn <= 1000 ){ a1 = 2.34433112; a2 = 0.00798052075; a3 = -0.000019478151; a4 = 2.01572094E-08; a5 = -7.37611761E-12; a6 = -917.935173; a7 = 0.683010238;} -} -} - -double HGas_j(string Comp, double TC){ - - double T = (TC + 273.15); - double a1, a2, a3, a4, a5, a6, a7; - double R = 8.314; - GasNASAData(Comp, T, a1, a2, a3, a4, a5, a6, a7); - - return R * T * (a1 + a2 * T / 2 + a3 * pow(T,2) / 3 + a4 * pow(T,3) / 4 + a5 * pow(T,4) / 5 + a6 / T); -} - - -double CpGas(string Comp, double TC, double TC1){ - //Spesifikk varmekapasitet [J/(mol K)] - //Comp {se rutinen GasData for definerte komponenter} - //TC - temperatur [C] - //TC1 - valgfri temperatur [C]. Dersom gitt beregnes midlere varmekap. mellom TC og TC1. - - //ToP - 16.3.00 - double T = (TC + 273.15) / 1000; - double T1 = (TC1 + 273.15) / 1000; - - double A, B, C, D, E, f, G, H, Hf298; - GasData(Comp, T, A, B, C, D, E, f, G, H, Hf298); - double R = 8.314; - - if (TC1 == 0){ - return A + B * T + C * pow(T,2) + D * pow(T,3) + E / pow(T,2); - } - else{ - return (A * (T1 - T) + B / 2 * (pow(T1,2) - pow(T,2)) + C / 3 * (pow(T1,3) - pow(T,3)) + D / 4 * (pow(T1,4) - pow(T,4)) - E * (1 / T1 - 1 / T)) / (T1 - T); - } -} - - -void GasData(string Comp, double &T, double &A, double &B, double &C, double &D, double &E, double &f, double &G, double &H, double &Hf298){ - //Korrelasjoner for termokjemiske data for enkeltkomponenter - //hentet fra NIST Chemistry WebBook : http://webbook.nist.gov/chemistry/ - //Cp° = A + B * t + C * t2 + D * t3 + E / t2 - //H° - H°298.15= A*t + B*t2/2 + C*t3/3 + D*t4/4 - E/t + F - fH°f,298 - //S° = A * Ln(t) + B * t + C * t2 / 2 + D * t3 / 3 - E / (2 * t2) + G - //Cp = heat capacity (J/mol*K) - //H° = standard enthalpy (kJ/mol) - //Print fH°298.15 = enthalpy; of; formation; at; 298.15K (kJ / mol) - //S° = standard entropy (J/mol*K) - //t = temperature(K) / 1000# - - //Gyldig temperaturområde er fra 298 til 6000K - - //ToP 19.3.00 - if (Comp == "CO2"){ - if (T <= 1.2){ - A = 24.99735; B = 55.18696; C = -33.69137; D = 7.948387; E = -0.136638; f = -403.6075; G = 228.2431; Hf298 = -393.5224; - } - if (T > 1.2){ - A = 58.16639; B = 2.720074; C = -0.492289; D = 0.038844; E = -6.447293; f = -425.9186; G = 263.6125; Hf298 = -393.5224; - } - } - else if (Comp == "CO"){ - if (T <= 1.3){ - A = 25.56759; B = 6.09613; C = 4.054656; D = -2.671301; E = 0.131021; f = -118.0089; G = 227.3665; Hf298 = -110.5271; - } - if (T > 1.3){ - A = 35.1507; B = 1.300095; C = -0.205921; D = 0.01355; E = -3.28278; f = -127.8375; G = 231.712; Hf298 = -110.5271; - } - } - else if (Comp == "H2O"){ - if (T <= 1.7){ - A = 30.092; B = 6.832514; C = 6.793435; D = -2.53448; E = 0.082139; f = -250.881; G = 223.3967; Hf298 = -241.8264; - } - if (T > 1.7){ - A = 41.96426; B = 8.622053; C = -1.499781; D = 0.098119; E = -11.15764; f = -272.1797; G = 219.7809; Hf298 = -241.8264; - } - } - else if (Comp == "H2"){ - if (T <= 1.5){ - A = 33.1078; B = -11.508; C = 11.6093; D = -2.8444; E = -0.159665; f = -9.991971; G = 172.788; Hf298 = 0.0; - } - if (T > 1.5){ - A = 34.1434; B = 0.503927; C = 0.372036; D = -0.038599; E = -8.074761; f = -21.2188; G = 162.093; Hf298 = 0.0; - } - } - else if (Comp == "CH4"){ - if (T <= 1.3){ - A = -0.703029; B = 108.4773; C = -42.52157; D = 5.862788; E = 0.678565; f = -76.84376; G = 158.7163; Hf298 = -74.8731; - } - if (T > 1.3){ - A = 85.81217; B = 11.26467; C = -2.114146; D = 0.13819; E = -26.42221; f = -153.5327; G = 224.4143; Hf298 = -74.8731; - } - } - else if (Comp == "N2"){ - A = 26.092; B = 8.218801; C = -1.976141; D = 0.159274; E = 0.044434; f = -7.98923; G = 221.02; Hf298 = 0.0; - } - else if (Comp == "O2"){ - A = 29.659; B = 6.137261; C = -1.186521; D = 0.09578; E = -0.219663; f = -9.861391; G = 237.948; Hf298 = 0.0; - } - else if (Comp == "SO2"){ - if (T <= 1.2){ - A = 21.43049; B = 74.35094; C = -57.75217; D = 16.35534; E = 0.086731; f = -305.7688; G = 254.8872; Hf298 = -296.8422; - } - if (T > 1.2){ - A = 57.48188; B = 1.009328; C = -0.07629; D = 0.005174; E = -4.045401; f = -324.414; G = 302.7798; Hf298 = -296.8422; - } - } - else if (Comp == "SO3"){ - if (T <= 1.2){ - A = 24.02503; B = 119.4607; C = -94.38686; D = 26.96237; E = -0.117517; f = -407.8526; G = 253.5186; Hf298 = -395.7654; - } - if (T > 1.2){ - A = 81.99008; B = 0.622236; C = -0.12244; D = 0.008294; E = -6.703688; f = -437.659; G = 330.9264; Hf298 = -395.7654; - } - } - else if (Comp == "HCl"){ - if (T <= 1.2){ - A = 32.12392; B = -13.45805; C = 19.86852; D = -6.853936; E = -0.049672; f = -101.6206; G = 228.6866; Hf298 = -92.31201; - } - if (T > 1.2){ - A = 31.91923; B = 3.203184; C = -0.541539; D = 0.035925; E = -3.438525; f = -108.015; G = 218.2768; Hf298 = -92.31201; - } - } - else if (Comp == "Cl2"){ - if (T <= 1.0){ - A = 33.0506; B = 12.2294; C = -12.0651; D = 4.38533; E = -0.159494; f = -10.8348; G = 259.029; Hf298 = 0.0; - } - if (T > 1.0 && T <= 3.0){ - A = 42.6773; B = -5.00957; C = 1.904621; D = -0.165641; E = -2.098481; f = -17.2898; G = 269.84; Hf298 = 0.0; - } - if (T > 3.0){ - A = -42.5535; B = 41.6857; C = -7.12683; D = 0.387839; E = 101.144; f = 132.764; G = 264.786; Hf298 = 0.0; - } - } - else if (Comp == "NH3"){ - if (T <= 1.4){ - A = 19.99563; B = 49.77119; C = -15.37599; D = 1.921168; E = 0.189174; f = -53.30667; G = 203.8591; Hf298 = -45.89806; - } - if (T > 1.4){ - A = 52.02427; B = 18.48801; C = -3.765128; D = 0.248541; E = -12.45799; f = -85.53895; G = 223.8022; Hf298 = -45.89806; - } - } - else if (Comp == "NO2"){ - if (T <= 1.2){ - A = 16.10857; B = 75.89525; C = -54.3874; D = 14.30777; E = 0.239423; f = 26.17464; G = 240.5386; Hf298 = 33.09502; - } - if (T > 1.2){ - A = 56.82541; B = 0.738053; C = -0.144721; D = 0.009777; E = -5.459911; f = 2.846456; G = 290.5056; Hf298 = 33.09502; - } - } - else if (Comp == "N2O4"){ - if (T <= 1.0){ - A = 34.05274; B = 191.9845; C = -151.0575; D = 44.3935; E = -0.158949; f = -8.893428; G = 293.7724; Hf298 = 9.078988; - } - if (T > 1.0){ - A = 128.622; B = 2.524345; C = -0.520883; D = 0.03663; E = -11.55704; f = -59.22619; G = 417.0444; Hf298 = 9.078988; - } - } -} - - -double AcidVaporDewPoint(string Comp, double xHCl, double xsO2, double xH2O, double P){ - //Beregner syreduggpunkt [C] for HCl (Comp="HCl") eller H2SO4 - //xHCl, xSO2, xH2O - molfraksjon av hendholdsvis HCl, SO2 og H2O i røykgassen - //P - trykk [atma] - - //Basert på korrelasjon fra http://pages.hotbot.com/books/vganapathy/corros.html - //Torbjørn Pettersen 11.5.99 - P = P * 760; // atm -> mmHg - double pHCl, pH2SO4, pH2O, THCl, TH2SO4; - pHCl = xHCl * P; - pH2O = xH2O * P; - pH2SO4 = xsO2 * 0.02 * (64 / 80) * P; - THCl = 1000 / (3.7368 - 0.1591 * log(pH2O) - 0.326 * log(pHCl) + 0.00269 * log(pH2O) * log(pHCl)); - TH2SO4 = 1000 / (2.276 - 0.0294 * log(pH2O) - 0.0858 * log(pH2SO4) + 0.0062 * log(pH2O) * log(pH2SO4)); - - if (Comp == "HCl"){ - return THCl; - } - else{ - return TH2SO4; - } - -} - - -double THGasMix(double H, double xCO2, double xH2O, double xO2, double xN2, double xCO, double xH2){ - //Beregner temperatur [C] for en gassblanding med CO2, H2O,O2 og N2 - //med entalpi H [kJ/Nm3], hvor H beregnes fra HGasMix(T,...) - //Torbjørn Pettersen, 13.5.99 - //ToP, 23.4.00 (mulighet for å regne på primærkammergass med CO og H2) - double T, f, dfdx, dT; - static double Tn; - dT = 1.0; - (Tn == 0.0) ? Tn = 1000.0:Tn=Tn; //start estimat - - int nIt = 0; - - while (abs(Tn - T) > 0.05 && nIt < 5000){ - T = Tn; - f = H - HGasMix(T, xCO2, xH2O, xO2, xN2, xCO, xH2); - dfdx = ((H - HGasMix(T + dT, xCO2, xH2O, xO2, xN2, xCO, xH2)) - f) / dT; - Tn = 0.5 * Tn + 0.5 * (T - f / dfdx); - nIt++; - } - if (nIt>=5000){ - cout <<"Error number of it exceeded in THGasMix"; - } - return Tn; -} - -double HGasMix(double T, double xCO2, double xH2O, double xO2, double xN2, double xCO, double xH2){ - //Entalpi for gass blanding med CO2, H2O, O2 og N2 [kJ/Nm3] - //T - temperatur [C] - //xCO2, xH2O, xO2, xN2 - molfraksjoner eller mol/tid eller Nm3/tid - - //Torbjørn Pettersen, 16.12.98 - //ToP, 23.4.00 (Nye Cp data og mulighet for å regne på primærkammergass) - double HCO2, HO2, HH2O, HN2, HCO, HH2, sumX; - if (T < -273 || T > 6000){ - cout << "Ugyldig temperatur"; - } - - //HN2 = -2.1282 + 1.2779 * T + 0.00010401 * pow(T,2); //Verdier benyttet i beregninger før 29.1.00 - //HO2 = -8.43 + 1.3597 * T + 0.00010443 * pow(T,2); //Gir ca 3% lavere Cp verdier enn CpRGASS - //HCO2 = -30.225 + 1.9576 * T + 0.00025049 * pow(T,2); //og er basert på at Cp er en linær funksjon av T. - //HH2O = -0.90662 + 1.4463 * T + 0.00024529 * pow(T,2); //(ToP, 29.1.00) - - //HN2 = cpRGASS("N2", 0, T) * T / 22.41; //Basert på cpRGASS - //HO2 = cpRGASS("O2", 0, T) * T / 22.41; //Korrigert 29.1.00 (ToP) - //HCO2 = cpRGASS("CO2", 0, T) * T / 22.41; - //HH2O = cpRGASS("H2O", 0, T) * T / 22.41; - - //HN2 = CpGas("N2", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - //HO2 = CpGas("O2", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - //HCO2 = CpGas("CO2", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - //HH2O = CpGas("H2O", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - //HH2 = CpGas("H2", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - //HCO = CpGas("CO", 0, T) * T / 22.41; //J/mol / Nm3/kmol = kJ/Nm3 - - double T0 = 25.0; //La til entalpiberegning basert på HGas og T0 som referansetemperatur. - HN2 = (HGas("N2", T) - HGas("N2", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - HO2 = (HGas("O2", T) - HGas("O2", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - HCO2 = (HGas("CO2", T) - HGas("CO2", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - HCO = (HGas("CO", T) - HGas("CO", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - HH2 = (HGas("H2", T) - HGas("H2", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - HH2O = (HGas("H2O", T) - HGas("H2O", T0)) / 0.02241; // kJ/mol / Nm3/mol = kJ/Nm3 - - HN2 = (HGas_j("N2", T) - HGas_j("N2", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - HO2 = (HGas_j("O2", T) - HGas_j("O2", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - HCO2 = (HGas_j("CO2", T) - HGas_j("CO2", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - HCO = (HGas_j("CO", T) - HGas_j("CO", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - HH2 = (HGas_j("H2", T) - HGas_j("H2", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - HH2O = (HGas_j("H2O", T) - HGas_j("H2O", T0)) / 0.02241; // J/mol / Nm3/mol = J/Nm3 - - sumX = (xCO2 + xO2 + xH2O + xN2 + xCO + xH2); - return (xCO2 * HCO2 + xH2O * HH2O + xO2 * HO2 + xN2 * HN2 + xCO * HCO + xH2 * HH2) / sumX; -} - - -double HfGas_Mix(double xO2, double xN2, double xCO2, double xH2O, double xH2, double xCO, double xCH4, double xC2H4, double xC2H2, double xC2H6, double xC3, double xC4, double xC5, double xC6, double xC7, double xC8, double xC9, double xC10){ - - double Hf_O2, Hf_N2, hf_CO2, hf_H2O, hf_H2, hf_CO, HF_CH4, Hf_C2H4, Hf_C2H2, Hf_C2H6; - double Hf_C3, Hf_C4, Hf_C5, Hf_C6, Hf_C7, Hf_C8, Hf_C9, Hf_C10; - - // Hf in kJ / mol - - hf_CO = -26.42 * 4.18; hf_CO2 = -94.05 * 4.18; hf_H2O = -57.8 * 4.18; hf_H2 = 0; Hf_O2 = 0; Hf_N2 = 0; HF_CH4 = -17.83; - Hf_C2H4 = 52.459; Hf_C2H2 = 227.98; Hf_C2H6 = -83.77; HF_CH4 = -74.53; - Hf_C3 = -104.04; Hf_C4 = -211.53; Hf_C5 = -314.3; Hf_C6 = -361.06; Hf_C7 = -354.7; Hf_C8 = -359.6; Hf_C9 = -371.23; Hf_C10 = -395.39; - - double Hfgas=0.0; - Hfgas = -(xO2 * Hf_O2 + xN2 * Hf_N2 + xCO2 * hf_CO2 + xH2O * hf_H2O + xH2 * hf_H2 + xCO * hf_CO + xC2H4 * Hf_C2H4 + xC2H2 * Hf_C2H2 + xC2H6 * Hf_C2H6); - Hfgas = Hfgas - (xC3 * Hf_C3 + xC4 * Hf_C4 + xC5 * Hf_C5 + xC6 * Hf_C6 + xC7 * Hf_C7 + xC8 * Hf_C8 + xC9 * Hf_C9 + xC10 * Hf_C10); - - return Hfgas; -} - - -double gas_visc_lucas(double T, string Comp){ - // Beregn viskositet av komponenter i gass fase - // eta(T,C) - [Pa s] - // T - [C] - // C - {O2, N2, CO, CO2, H2O} - // Basert på korrelasjon fra "Properties of gases and liquids", - // Reid et al. - // Lucas metode: Slik metoden er implementert her er den ikke - // gyldig for komponentene hydrogen og helium. - // Parametre som inngår for hver komponent: - // Mw - molvekt [g/mol] - // Tc - kritisk temperatur [K] - // Pc - kritisk trykk [bar] - // Zc - kritisk kompressibilitet [-] - // dipm - dipolmoment [debey] - double Mw, TC, Pc, Zc, dipm; - double Tr, eps, ur, Fp0, Fq0; - - if (Comp == "H2O"){ - Mw = 18.015; //g/mol - TC = 647.3; //K - Pc = 221.2; //bar - Zc = 0.235; - dipm = 1.8; - } - else if (Comp == "O2"){ - Mw = 32.0; //g/mol - TC = 154.6; //K - Pc = 50.4; //bar - Zc = 0.288; - dipm = 0.0; - } - else if (Comp == "N2"){ - Mw = 28.0; //g/mol - TC = 126.2; //K - Pc = 33.9; //bar - Zc = 0.29; - dipm = 0.0; - } - else if (Comp == "CO"){ - dipm = 0.1; - Mw = 28.01; //g/mol - TC = 132.9; //K - Pc = 35.0; //bar - Zc = 0.295; - dipm = 0.1; - } - else if (Comp == "CO2"){ - Mw = 44.01; //g/mol - TC = 304.1; //K - Pc = 73.8; //bar - Zc = 0.274; - dipm = 0.0; - } - Tr = (273 + T) / TC; - - eps = 0.176 * pow((TC / (pow(Mw,3) * pow(Pc,4))),(1 / 6)); // [m2/(N s)] - - ur = 52.46 * pow(dipm,2) * Pc / pow(TC,2); - Fp0 = 1.0; - Fq0 = 1.0; - if (ur >= 0.022 && ur < 0.075){ - Fp0 = 1 + 30.55 * pow((0.292 - Zc),1.72); - } - else if (ur >= 0.075){ - Fp0 = 1 + 30.55 * pow((0.292 - Zc),1.72) * abs(0.96 + 0.1 * (Tr - 0.7)); - } - - return 0.0000001 * (0.807 * pow(Tr, 0.618) - 0.357 * exp(-0.449 * Tr) + 0.34 * exp(-4.058 * Tr) + 0.018) * Fp0 * Fq0 / eps; // [Pa*s] -} - -//THIS FUNCTION SEEMS INCOMPLETE!! -double gas_visc(double T, string Comp){ - // Beregner gass-viskositet av enkeltkomponenter [Pa s] som funksjon av - // T - temperatur [C] - // Comp - {O2, N2, CO, CO2, H2, H2O} - //Viskositet, kg/(m.s) (K & B, Tabell 45) - // Gunnar Nåvik - // Torbjørn Pettersen 1.5.99 (Re-implementert og sammenliknet md gas_visc_lucas). - vector A(6,0.0); - double my, Tk; - double dmydT=0.0, T0=0.0, dT=0.0; - Tk = T + 273; - if (Comp == "O2"){ - if(Tk <= 1273){ //TC<1000 oC - A[0] = 18.11; A[1] = 0.6632; A[2] = -0.0001879; - dmydT = 0.0; - } - else{ //lineær ekstrapolasjon over 1000 oC: - T0 = 1273; dT = Tk - T0; Tk = T0; - dmydT = A[1] + 2 * A[2] * T0; - } - my = (A[0] + A[1] * Tk + A[2] * pow(Tk,2) + dmydT * dT) * 0.0000001; - } - else if (Comp == "CO2"){ - A[0] = 25.45; A[1] = 0.4549; A[2] = -0.00008649; - my = (A[0] + A[1] * Tk + A[2] * pow(Tk,2)) * 0.0000001; //TC<1400 oC - } - else if (Comp == "CO"){ - A[0] = 32.28; A[1] = 0.4747; A[2] = -0.00009648; - my = (A[0] + A[1] * Tk + A[2] * pow(Tk,2)) * 0.0000001; //TC<1400 oC - } - else if (Comp == "H2O"){ - if(Tk <= 1273){ //TC<1000 oC - A[0] = -31.89; A[1] = 0.4145; A[2] = -0.000008272; - dmydT = 0.0; - } - else{ //lineær ekstrapolasjon over 1000 oC: - T0 = 1273; dT = Tk - T0; Tk = T0; - dmydT = A[1] + 2 * A[2] * T0; - } - my = (A[0] + A[1] * Tk + A[2] * pow(Tk,2) + dmydT * dT) * 0.0000001; - } - else if (Comp == "H2"){ - A[0] = 21.87; A[1] = 0.222; A[2] = -0.00003751; - my = (A[0] + A[1] * Tk + A[2] * pow(Tk,2)) * 0.0000001; //TC<1200 oC - } - else if (Comp == "N2"){ - A[0] = 30.43; A[1] = 0.4989; A[2] = -0.0001033; - my = (A[0] + A[1] * Tk + A[2] * pow(Tk, 2)) * 0.0000001; //TC<1200 oC - } - - return my; -} - - -double G_Mix_visc(double T, double xO2, double xCO, double xH2, double xCO2, double xH2O, double xN2){ - // Beregner viskositet for en gassblanding som funksjon av temperaturen T [C] - // og sammensetningen. - // Blanderegler fra Reid et al. - // Gunnar Nåvik - // Torbjørn Pettersen 1.5.99 (reimplementering) - vector x(6), U(6), Mw(6); - x[0] = xO2; U[0] = gas_visc_lucas(T, "O2"); Mw[0] = 32.0; - x[1] = xCO; U[1] = gas_visc_lucas(T, "CO"); Mw[1] = 28.0; - x[2] = xH2; U[2] = gas_visc(T, "H2"); Mw[2] = 2.0; - x[3] = xCO2; U[3] = gas_visc_lucas(T, "CO2"); Mw[3] = 44.0; - x[4] = xH2O; U[4] = gas_visc_lucas(T, "H2O"); Mw[4] = 18.0; - x[5] = xN2; U[5] = gas_visc_lucas(T, "N2"); Mw[5] = 28.0; - double fiij, fiji; - double sumi, sumj; - sumi = 0.0; - for (int i=0;i<6;i++){ - sumi += x[i]; //normaliser som molfraksjoner - } - - for (int i=0;i<6;i++){ - x[i]=x[i]/sumi; - } - - sumi = 0.0; - for (int i=0;i<6;i++){ - sumj = 0.0; - for (int j=0;j<6;j++){ - fiij = pow((1.0 + sqrt(U[i]/U[j]) * pow((Mw[j]/Mw[i]),0.25)),2) / sqrt(8*(1 + Mw[i] / Mw[j])); - sumj += x[j] * fiij; - } - sumi += x[i] * U[i] / sumj; - } - return sumi; //viskositet for blanding -} - - -double gas_lambda(double T, string Comp){ - // Termisk konduktivitet i gass fase [W/(m K)] sfa Temperatur [C] - // Comp - {O2, H2O, N2, CO, CO2} - // Basert på korrelasjoner fra Reid et al. - // Torbjørn Pettersen 2.5.99 - double A, B, C, D, Tmin, Tmax, T_; - - - if (Comp == "H2O"){ - A = 0.007341; B = -0.00001013; C = 0.0000001801; D = -0.000000000091; - Tmin = 273.0; // T>=Tmin [C] - Tmax = 1070.0; // T<=Tmax [C] - } - else if (Comp == "O2"){ - A = -0.0003273; B = 0.00009966; C = -0.00000003743; D = 0.000000000009732; - Tmin = 115.0; - Tmax = 1470.0; - } - else if (Comp == "N2"){ - A = 0.0003919; B = 0.00009816; C = -0.00000005067; D = 0.00000000001504; - Tmin = 115.0; - Tmax = 1470.0; - } - else if (Comp == "CO"){ - A = 0.0005067; B = 0.00009125; C = -0.00000003524; D = 0.000000000008199; - Tmin = 115.0; - Tmax = 1670.0; - } - else if (Comp == "CO2"){ - A = -0.007215; B = 0.00008015; C = 0.000000005477; D = -0.00000000001053; - Tmin = 185.0; - Tmax = 1670.0; - } - T_ = T + 273; // C -> K - if (T_ >= Tmin && T_ <= Tmax){ - return A + B * T_ + C * pow(T_, 2) + D * pow(T_, 3); - } - else{ - return 0; - } -} diff --git a/submodels/bioCHP_plant/bioCHP.cpp b/submodels/bioCHP_plant/bioCHP.cpp index 7eb6eeb..3e16bf3 100644 --- a/submodels/bioCHP_plant/bioCHP.cpp +++ b/submodels/bioCHP_plant/bioCHP.cpp @@ -5,13 +5,67 @@ #include "Cost.h" #include "Processes.h" +bool bioCHP_plant(vector fuel_def, vector Yj, double W_el, vector Qk, vector Tk_in, vector Tk_out, vector &Mj, double &C_inv, double &C_op){ -using namespace std; + // INPUTS + // feed_def: name of each biomass feedstock + // Yj: mass fraction of each biomass feedstock + // W_el: electric power output (MW_el) + // Qk: heat demand (MW) + // Tk_in: Return temperature for each heat demand (district heating) + // Tk_in: Supply temperature for each heat demand (district heating) -int main(){ + // OUTPUTS + // Mj: Required mass flow of each biomass feedstock + // C_inv: Investment cost + // C_op_var: Variable operating cost + // C_op_fix: Variable operating cost + + + // Check that all feedstock exist in the database + for(int nf = 0; nf < fuel_def.size(); nf++){ if( !find_flow(fuel_def[nf]) ){ + + for(int nff = 0; nff < fuel_def.size(); nff++){ Mj.push_back(0.0); } + C_inv = 0.0; + C_op = 0.0; + + return false; + + }} + + // Check specificatins of heat demands + if( Qk.size() != Tk_in.size() ){ cout << "number of specifications for Tk_in and Qk are different" << endl; return false; } + if( Qk.size() != Tk_out.size() ){ cout << "number of specifications for Tk_out and Qk are different" << endl; return false; } + if( Tk_in.size() != Tk_out.size() ){ cout << "number of specifications for Tk_in and Tk_out are different" << endl; return false; } + for(int nk = 0; nk < Tk_in.size(); nk++){ if( Tk_in[nk] > Tk_out[nk] ) { cout << "return temperature of heat demand no. " << nk << " is higher than supply temperature" << endl; return false; } } + + // Check that there is sufficient heat available from Rankine cycle + double sum_Qk = 0.0; for(int nk = 0; nk < Qk.size(); nk++){ sum_Qk = sum_Qk + Qk[nk]; } + if( sum_Qk > 0.5 * (W_el / 0.2) ){ + + cout << "there is not sufficient heat available from Rankine cycle to supply the specifiy heat demand" << endl; + cout << "Reducing proportionally the heat demands" << endl; + for(int nk = 0; nk < Qk.size(); nk++){ Qk[nk] = Qk[nk] * (0.5 * (W_el / 0.2)) / sum_Qk; } + } + + object bioCHP("plant", "bioCHP_PLANT", "bioCHP_function_inputs"); + bioCHP.vct_sp("fuel_def", fuel_def); + bioCHP.vct_fp("Yj", Yj); + bioCHP.fval_p("W_el", W_el); + bioCHP.vct_fp("Qk", Qk); + bioCHP.vct_fp("Tk_in", Tk_in); + bioCHP.vct_fp("Tk_out", Tk_out); - object bioCHP("plant", "bioCHP_PLANT", "bioCHP_inputs"); bioCHP_plant_model(bioCHP); + + Mj = bioCHP.vctp("Mj"); + C_inv = bioCHP.fp("C_inv") * 1e-6; + C_op = bioCHP.fp("C_op") * 1e-6; + export_output_parameters(bioCHP, "bioCHP_outputs"); + return true; + } + + diff --git a/submodels/bioCHP_plant/bioCHP.so b/submodels/bioCHP_plant/bioCHP.so new file mode 100644 index 0000000..d5967db Binary files /dev/null and b/submodels/bioCHP_plant/bioCHP.so differ diff --git a/submodels/bioCHP_plant/bioCHP_function_test_1.cpp b/submodels/bioCHP_plant/bioCHP_function_test_1.cpp new file mode 100644 index 0000000..606d471 --- /dev/null +++ b/submodels/bioCHP_plant/bioCHP_function_test_1.cpp @@ -0,0 +1,24 @@ +#include "bioCHP.cpp" + +using namespace std; + +int main(){ + + vector fuel_def = {"spruce_chips"}; + vector Yj = {1.0}; + double W_el = 300.0; + vector Qk = {}; + vector Tk_in = {}; + vector Tk_out = {}; + + vector Mj; double C_inv; double C_op; + + if( bioCHP_plant(fuel_def, Yj, W_el, Qk, Tk_in,Tk_out,Mj,C_inv,C_op) ){ + + for(int nj = 0; nj < Mj.size(); nj++){ cout << "M_"+fuel_def[nj]+" = " << Mj[nj] << endl;} + cout << "C_inv (M$) = " << C_inv << endl; + std::cout << "C_op (M$) = " << C_op << endl; + + } + else{ cout << "error" << endl; } +} diff --git a/submodels/bioCHP_plant/bioCHP_function_test_2.cpp b/submodels/bioCHP_plant/bioCHP_function_test_2.cpp new file mode 100644 index 0000000..7688444 --- /dev/null +++ b/submodels/bioCHP_plant/bioCHP_function_test_2.cpp @@ -0,0 +1,24 @@ +#include "bioCHP.cpp" + +using namespace std; + +int main(){ + + vector fuel_def = {"spruce_chips","spruce_T&B"}; + vector Yj = {0.5,0.5}; + double W_el = 300.0; + vector Qk = {}; + vector Tk_in = {}; + vector Tk_out = {}; + + vector Mj; double C_inv; double C_op; + + if( bioCHP_plant(fuel_def, Yj, W_el, Qk, Tk_in,Tk_out,Mj,C_inv,C_op) ){ + + for(int nj = 0; nj < Mj.size(); nj++){ cout << "M_"+fuel_def[nj]+" = " << Mj[nj] << endl;} + cout << "C_inv (M$) = " << C_inv << endl; + cout << "C_op (M$) = " << C_op << endl; + + } + else{ cout << "error" << endl; } +} diff --git a/submodels/bioCHP_plant/bioCHP_function_test_3.cpp b/submodels/bioCHP_plant/bioCHP_function_test_3.cpp new file mode 100644 index 0000000..7f43870 --- /dev/null +++ b/submodels/bioCHP_plant/bioCHP_function_test_3.cpp @@ -0,0 +1,24 @@ +#include "bioCHP.cpp" + +using namespace std; + +int main(){ + + vector fuel_def = {"spruce_chips","spruce_T&B"}; + vector Yj = {0.5,0.5}; + double W_el = 300.0; + vector Qk = {30.0, 40.0}; + vector Tk_in = {70.0, 70.0}; + vector Tk_out = {90.0, 90.0}; + + vector Mj; double C_inv; double C_op; + + if( bioCHP_plant(fuel_def, Yj, W_el, Qk, Tk_in,Tk_out,Mj,C_inv,C_op) ){ + + for(int nj = 0; nj < Mj.size(); nj++){ cout << "M_"+fuel_def[nj]+" = " << Mj[nj] << endl;} + cout << "C_inv (M$) = " << C_inv << endl; + cout << "C_op (M$) = " << C_op << endl; + + } + else{ cout << "error" << endl; } +} diff --git a/submodels/bioCHP_plant/bioCHP_inputs b/submodels/bioCHP_plant/bioCHP_inputs index 3000b67..75cf16f 100644 --- a/submodels/bioCHP_plant/bioCHP_inputs +++ b/submodels/bioCHP_plant/bioCHP_inputs @@ -1,8 +1,5 @@ plant bioCHP_PLANT -prop fuel_def SE-pellets_arbacore_spruce_stem prop fuel_diameter_m 0.05 -prop boiler_power_in_MW 1500 -prop heat_demand_MW 200 prop T_stm 450.0 prop P_stm 100.0 prop electricity_unit kWh @@ -20,7 +17,6 @@ prop f_cont 0.15 prop f_ins 0.01 prop f_adm 0.01 - system solid_fuel_boiler prop oxidant_def dry_air prop lambda 1.2 @@ -45,7 +41,6 @@ prop Po 0.032 prop mu_isent 0.65 prop P_cond 1.032 prop T_cond 25 -prop T_dh_in 70.0 -prop T_dh_out 90.0 END + diff --git a/submodels/bioCHP_plant/bioCHP_wrapper.cpp b/submodels/bioCHP_plant/bioCHP_wrapper.cpp new file mode 100644 index 0000000..51c57ea --- /dev/null +++ b/submodels/bioCHP_plant/bioCHP_wrapper.cpp @@ -0,0 +1,37 @@ +#include "bioCHP.cpp" +#include +#include +#include + +extern "C" { + bool bioCHP_plant_c( + const char** fuel_def, int fuel_count, + const double* Yj, int Yj_len, + double W_el, + const double* Qk, int Qk_len, + const double* Tk_in, int Tk_in_len, + const double* Tk_out, int Tk_out_len, + double* Mj, int Mj_len, + double* C_inv, + double* C_op + ) { + std::vector fuel_vec; + for (int i = 0; i < fuel_count; ++i) { + fuel_vec.emplace_back(fuel_def[i]); + } + + std::vector Yj_vec(Yj, Yj + Yj_len); + std::vector Qk_vec(Qk, Qk + Qk_len); + std::vector Tk_in_vec(Tk_in, Tk_in + Tk_in_len); + std::vector Tk_out_vec(Tk_out, Tk_out + Tk_out_len); + std::vector Mj_vec(Mj_len); + + bool result = bioCHP_plant(fuel_vec, Yj_vec, W_el, Qk_vec, Tk_in_vec, Tk_out_vec, Mj_vec, *C_inv, *C_op); + + for (int i = 0; i < Mj_len; ++i) { + Mj[i] = Mj_vec[i]; + } + + return result; + } +}