本篇教程由作者设定未经允许禁止转载。
注意:本教程已经弃用,原因是作者打算重构程序,消除硬编码限制,并且使用Java的图形化界面
设某种油蒸馏出的产物为A:石脑油 B:轻燃油 C:重燃油
可知裂解过程中A,B,C三者可以互相转化,但是,绝对不可能出现油越裂越多的情况,因为这跟产物有限矛盾,如果油总量越裂越多,那么烯烃和烷烃的产物几乎无限,这显然不可能,同时证明产物的级数是收敛的。
容易证明最终趋向于完全裂解的产物情况与三种油裂解的先后顺序无关,而且,每种油不能自己一次裂解后产出自己。
根据实际裂解的情况,可以列出下列表达式,其中pi为跟裂解方式有关的常数,容易知道,每种油有6种裂解方法。从而列出:
(根据裂解顺序:重燃油-轻燃油-石脑油)
A(n)=A(n)+C(n)*p1
B(n)=B(n)+C(n)*p2
C(n+1)=0;
A(n)=A(n)+B(n)*p3
C(n+1)=C(n+1)+B(n)*p4
B(n+1)=0;
B(n+1)=B(n+1)+A(n)*p5
C(n+1)=C(n+1)+A(n)*p6
显然,很相似数学上的高斯赛德尔迭代方法。但是实际上,手算很不适合,因为迭代步骤较多,而且计算较麻烦,这里采用计算机编程求解,保证裂解到最后三种油量<10^-7
实际上,相比gtnhwiki中nxer大佬给出的矩阵分析法(个人是真的看了好久才弄明白),本方法可能更适合数学基础水平较差的读者,以及想要求出所有7*6*6*7*4=7056种裂解方式的玩家。(因为不可能把所有情况手算列出来计算)
代码中额外考虑了炼油气的贡献,以及炼油气和重燃油只蒸馏的情况。
适用于计算任意产物最大时的搭配。代码计算所得的结果是1000mB某种油裂解的产物量,单位:mB。
适用于2.2.3版本的追求某最大产物和裂解方式表格:
产物 | 重燃油裂化方式 | 轻燃油裂化方式 | 石脑油裂化方式 | 炼油气裂化方式 |
甲烷 | 中氢 | 重氢 | 重氢 | 重氢 |
乙烷 | 中氢 | 重氢 | 重氢 | 直接蒸馏 |
丙烷 | 中氢 | 中氢 | 中氢 | 直接蒸馏 |
丁烷 | 中氢 | 轻氢 | 轻氢 | 直接蒸馏 |
辛烷 | 轻氢 | 轻氢 | 轻氢 | 轻氢 |
氦气 | 重氢 | 重氢 | 轻蒸 | 重氢 |
甲苯 | 直接蒸馏 | 轻蒸 | 轻蒸 | 重蒸 |
苯 | 重蒸 | 中蒸 | 轻蒸 | 轻蒸 |
乙烯 | 中氢 | 轻氢 | 重蒸 | 重蒸 |
丙烯 | 中氢 | 轻蒸 | 中蒸 | 轻蒸 |
丁烯 | 重蒸 | 轻蒸 | 轻蒸 | 重蒸 |
丁二烯 | 中氢 | 轻蒸 | 轻蒸 | 重蒸 |
苯酚 | 直接蒸馏 | 轻蒸 | 轻蒸 | 重氢 |
这里给出遍历全部情况后求出最大值的求解的C++代码:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define InvalidValueException -1
using namespace std;
class oil{
private:
int TypeInInt;
string TypeInString;
double HeavyOilAmount;
double LightOilAmount;
double NaphthaAmount;
double GasAmount;
public:
void GetOilTypeAndAmount(int type){//获取原油是那种,1是BC原油,2是GT轻油,3是GT原油,4是GT重油,5是GT极重油
switch(type){
case 1:
TypeInInt=1;
TypeInString="BCOil";
HeavyOilAmount=4500;
LightOilAmount=15000;
NaphthaAmount=6000;
GasAmount=18000;
break;
case 2:
TypeInInt=2;
TypeInString="GTLightOil";
HeavyOilAmount=1000;
LightOilAmount=2000;
NaphthaAmount=3000;
GasAmount=24000;
break;
case 3:
TypeInInt=3;
TypeInString="GTOil";
HeavyOilAmount=1500;
LightOilAmount=7500;
NaphthaAmount=22500;
GasAmount=9000;
break;
case 4:
TypeInInt=4;
TypeInString="GTHeavyOil";
HeavyOilAmount=37500;
LightOilAmount=6750;
NaphthaAmount=2250;
GasAmount=9000;
break;
case 5:
TypeInInt=5;
TypeInString="GTExtraHeavyOil";
HeavyOilAmount=56250;
LightOilAmount=10125;
NaphthaAmount=3375;
GasAmount=13500;
break;
default:
break;
}
}
void OutPutData(){//输出数据用来检验
cout<<"原油类型号:"<<this->TypeInInt<<endl;
cout<<"原油类型:"<<this->TypeInString<<endl;
printf("产出重燃油总量:%lf,产出轻燃油总量:%lf,产出石脑油总量:%lf,产出炼油气总量:%lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
}
double GetHeavyOilAmount(){
return this->HeavyOilAmount;
}
double GetLightOilAmount(){
return this->LightOilAmount;
}
double GetNaphthaAmount(){
return this->NaphthaAmount;
}
double GetGasAmount(){
return this->GasAmount;
}
void Initialization(){
this->GasAmount=0;
this->HeavyOilAmount=0;
this->NaphthaAmount=0;
this->LightOilAmount=0;
this->TypeInInt=-1;
this->TypeInString="";
}
};
class All{
private:
double HeavyOilAmount;
double LightOilAmount;
double NaphthaAmount;
double GasAmount;
int GetFuel;//为0时,不生产高十六,为1时,生产柴油,为2时,生产高十六
int HeavyOilCrackedType;//重燃油裂化方式
// 0:直接蒸馏 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int LightOilCrackedType;//轻燃油裂化方式
// 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int NaphthaCrackedType;//石脑油裂化方式
// 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int GasCrackedType;//炼油气裂化方式
// 0:直接蒸馏 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
//定义嵌套类Product用来存储产物
public:
class Product{
friend class All;
private:
double methane;//甲烷
double ethane;//乙烷
double propane;//丙烷
double butane;//丁烷
double octane;
double helium;//氦气
double toluene;//甲苯
double benzene;//苯
double vinyl;//乙烯
double acrylic;//丙烯
double butene;//丁烯
double butadiene;//丁二烯
double phenol;//苯酚
double TinyCarbonDust;//小撮碳粉
double Fuel;//柴油
double CetaneBoostedDiesel;//高十六
public:
void Initialization(){
this->methane=0;
this->ethane=0;
this->propane=0;
this->butane=0;
this->helium=0;
this->toluene=0;
this->benzene=0;
this->vinyl=0;
this->acrylic=0;
this->butene=0;
this->butadiene=0;
this->TinyCarbonDust=0;
this->phenol=0;
this->octane=0;
this->Fuel=0;
this->CetaneBoostedDiesel=0;
}
void OutPutInformation(){//输出内部内容
//cout<<"甲烷产量:"<<this->methane<<endl;
printf("甲烷产量:%lf\n",this->methane/(double)15);
//cout<<"乙烷产量:"<<this->ethane<<endl;
printf("乙烷产量:%lf\n",this->ethane/(double)15);
//cout<<"丙烷产量:"<<this->propane<<endl;
printf("丙烷产量:%lf\n",this->propane/(double)15);
//cout<<"丁烷产量:"<<this->butane<<endl;
printf("丁烷产量:%lf\n",this->butane/(double)15);
//cout<<"氦气产量:"<<this->helium<<endl;
printf("辛烷产量:%lf\n",this->octane/(double)15);
printf("氦气产量:%lf\n",this->helium/(double)15);
//cout<<"甲苯产量:"<<this->toluene<<endl;
printf("甲苯产量:%lf\n",this->toluene/(double)15);
//cout<<"苯产量:"<<this->benzene<<endl;
printf("苯产量:%lf\n",this->benzene/(double)15);
//cout<<"乙烯产量:"<<this->vinyl<<endl;
printf("乙烯产量:%lf\n",this->vinyl/(double)15);
//cout<<"丙烯产量:"<<this->acrylic<<endl;
printf("丙烯产量:%lf\n",this->acrylic/(double)15);
//cout<<"丁烯产量:"<<this->butene<<endl;
printf("丁烯产量:%lf\n",this->butene/(double)15);
//cout<<"丁二烯产量:"<<this->butadiene<<endl;
printf("丁二烯产量:%lf\n",this->butadiene/(double)15);
//cout<<"小撮碳粉产量:"<<this->TinyCarbonDust<<endl;
printf("苯酚产量:%lf\n",this->phenol/(double)15);
printf("小撮碳粉产量:%lf\n",TinyCarbonDust/(double)15);
printf("柴油产量:%lf\n",this->Fuel/(double)15);
printf("高十六产量:%lf\n",this->CetaneBoostedDiesel/(double)15);
}
void MethaneAdd(double num){
this->methane=this->methane+num;
}
double GetMethaneAmount(){
return this->methane;
}
void EthaneAdd(double num){
this->ethane=this->ethane+num;
}
double GetEthaneAmount(){
return this->ethane;
}
void PropaneAdd(double num){
this->propane=this->propane+num;
}
double GetPropaneAmount(){
return this->propane;
}
void ButaneAdd(double num){
this->butane=this->butane+num;
}
double GetButaneAmount(){
return this->butane;
}
void HeliumAdd(double num){
this->helium=this->helium+num;
}
double GetHeliumAmount(){
return this->helium;
}
void TolueneAdd(double num){
this->toluene=this->toluene+num;
}
double GetTolueneAmount(){
return this->toluene;
}
void BenezeAdd(double num){
this->benzene=this->benzene+num;
}
double GetBenezeAmount(){
return this->benzene;
}
void VinylAdd(double num){
this->vinyl=this->vinyl+num;
}
double GetVinylAmount(){
return this->vinyl;
}
void AcrylicAdd(double num){
this->acrylic=this->acrylic+num;
}
double GetAcrylicAmount(){
return this->acrylic;
}
void ButeneAdd(double num){
this->butene=this->butene+num;
}
double GetButeneAmount(){
return this->butene;
}
void ButadieneAdd(double num){
this->butadiene=this->butadiene+num;
}
double GetButadieneAmount(){
return this->butadiene;
}
void TinyCarbonDustAdd(double num){
this->TinyCarbonDust=this->TinyCarbonDust+num;
}
double GetTinyCarbonDustAmount(){
return this->TinyCarbonDust;
}
void PhenolAdd(double num){
this->phenol=this->phenol+num;
}
double GetPhenolAmount(){
return this->phenol;
}
void OctaneAdd(double num){
this->octane=this->octane+num;
}
double GetOctaneAmount(){
return this->octane;
}
void FuelAdd(double num){
this->Fuel=this->Fuel+num;
}
double GetFuelAmount(){
return this->Fuel;
}
void CetaneBoostedDieselAdd(double num){
this->CetaneBoostedDiesel=this->CetaneBoostedDiesel+num;
}
double GetCetaneBoostedDieselAmount(){
return this->CetaneBoostedDiesel;
}
};
public:
Product Products;
void HeavyOilCrack(){//裂化后蒸馏重燃油
switch(this->HeavyOilCrackedType){
case 0://直接蒸馏重燃油
Products.BenezeAdd(0.4*this->HeavyOilAmount);
Products.TolueneAdd(0.4*this->HeavyOilAmount);
Products.PhenolAdd(0.25*this->HeavyOilAmount);
this->HeavyOilAmount=0;
break;
case 1://轻度氢气裂化重燃油
Products.MethaneAdd(0.075*this->HeavyOilAmount);
Products.EthaneAdd(0.075*this->HeavyOilAmount);
Products.PropaneAdd(0.1*this->HeavyOilAmount);
Products.ButaneAdd(0.1*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.6;
this->NaphthaAmount=this->NaphthaAmount+0.1*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 2://中度氢气裂化重燃油
Products.MethaneAdd(0.1*this->HeavyOilAmount);
Products.EthaneAdd(0.1*this->HeavyOilAmount);
Products.PropaneAdd(0.15*this->HeavyOilAmount);
Products.ButaneAdd(0.15*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.4;
this->NaphthaAmount=this->NaphthaAmount+0.4*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 3://重度氢气裂化重燃油
Products.MethaneAdd(0.175*this->HeavyOilAmount);
Products.EthaneAdd(0.175*this->HeavyOilAmount);
Products.PropaneAdd(0.3*this->HeavyOilAmount);
Products.ButaneAdd(0.3*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.2;
this->NaphthaAmount=this->NaphthaAmount+0.25*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 4://轻度蒸汽裂化重燃油
Products.TolueneAdd(0.025*this->HeavyOilAmount);
Products.BenezeAdd(0.125*this->HeavyOilAmount);
Products.ButeneAdd(0.025*this->HeavyOilAmount);
Products.ButadieneAdd(0.015*this->HeavyOilAmount);
Products.PropaneAdd(0.003*this->HeavyOilAmount);
Products.AcrylicAdd(0.03*this->HeavyOilAmount);
Products.EthaneAdd(0.005*this->HeavyOilAmount);
Products.VinylAdd(0.05*this->HeavyOilAmount);
Products.MethaneAdd(0.05*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.001*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.3;
this->NaphthaAmount=this->NaphthaAmount+0.05*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 5://中度蒸汽裂化重燃油
Products.TolueneAdd(0.04*this->HeavyOilAmount);
Products.BenezeAdd(0.2*this->HeavyOilAmount);
Products.ButeneAdd(0.04*this->HeavyOilAmount);
Products.ButadieneAdd(0.025*this->HeavyOilAmount);
Products.PropaneAdd(0.005*this->HeavyOilAmount);
Products.AcrylicAdd(0.05*this->HeavyOilAmount);
Products.EthaneAdd(0.007*this->HeavyOilAmount);
Products.VinylAdd(0.075*this->HeavyOilAmount);
Products.MethaneAdd(0.075*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.002*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.2;
this->NaphthaAmount=this->NaphthaAmount+0.2*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 6://重度蒸汽裂化重燃油
Products.TolueneAdd(0.08*this->HeavyOilAmount);
Products.BenezeAdd(0.4*this->HeavyOilAmount);
Products.ButeneAdd(0.08*this->HeavyOilAmount);
Products.ButadieneAdd(0.05*this->HeavyOilAmount);
Products.PropaneAdd(0.01*this->HeavyOilAmount);
Products.AcrylicAdd(0.1*this->HeavyOilAmount);
Products.EthaneAdd(0.015*this->HeavyOilAmount);
Products.VinylAdd(0.15*this->HeavyOilAmount);
Products.MethaneAdd(0.15*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.003*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.1;
this->NaphthaAmount=this->NaphthaAmount+0.125*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case -1://不裂化
break;
}
}
void LightOilCrack(){//裂化后蒸馏轻燃油
switch(this->LightOilCrackedType){
case 1://轻度氢气裂化轻燃油
Products.OctaneAdd(0.1*this->LightOilAmount);
Products.ButaneAdd(0.15*this->LightOilAmount);
Products.PropaneAdd(0.2*this->LightOilAmount);
Products.EthaneAdd(0.125*this->LightOilAmount);
Products.MethaneAdd(0.125*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.8*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 2://中度氢气裂化轻燃油
Products.OctaneAdd(0.05*this->LightOilAmount);
Products.ButaneAdd(0.2*this->LightOilAmount);
Products.PropaneAdd(1.1*this->LightOilAmount);
Products.EthaneAdd(0.4*this->LightOilAmount);
Products.MethaneAdd(0.4*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.5*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 3://重度氢气裂化轻燃油
Products.OctaneAdd(0.02*this->LightOilAmount);
Products.ButaneAdd(0.125*this->LightOilAmount);
Products.PropaneAdd(0.125*this->LightOilAmount);
Products.EthaneAdd(1.5*this->LightOilAmount);
Products.MethaneAdd(1.5*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.2*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 4://轻度蒸汽裂化轻燃油
Products.TolueneAdd(0.04*this->LightOilAmount);
Products.BenezeAdd(0.2*this->LightOilAmount);
Products.ButeneAdd(0.075*this->LightOilAmount);
Products.ButadieneAdd(0.06*this->LightOilAmount);
Products.PropaneAdd(0.02*this->LightOilAmount);
Products.AcrylicAdd(0.15*this->LightOilAmount);
Products.EthaneAdd(0.01*this->LightOilAmount);
Products.VinylAdd(0.05*this->LightOilAmount);
Products.MethaneAdd(0.05*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.001*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.15*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.4*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 5://中度蒸汽裂化轻燃油
Products.TolueneAdd(0.05*this->LightOilAmount);
Products.BenezeAdd(0.3*this->LightOilAmount);
Products.ButeneAdd(0.09*this->LightOilAmount);
Products.ButadieneAdd(0.075*this->LightOilAmount);
Products.PropaneAdd(0.035*this->LightOilAmount);
Products.AcrylicAdd(0.2*this->LightOilAmount);
Products.EthaneAdd(0.03*this->LightOilAmount);
Products.VinylAdd(0.15*this->LightOilAmount);
Products.MethaneAdd(0.15*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.002*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.1*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.25*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 6://重度蒸汽裂化轻燃油
Products.TolueneAdd(0.03*this->LightOilAmount);
Products.BenezeAdd(0.15*this->LightOilAmount);
Products.ButeneAdd(0.065*this->LightOilAmount);
Products.ButadieneAdd(0.05*this->LightOilAmount);
Products.PropaneAdd(0.05*this->LightOilAmount);
Products.AcrylicAdd(0.25*this->LightOilAmount);
Products.EthaneAdd(0.05*this->LightOilAmount);
Products.VinylAdd(0.25*this->LightOilAmount);
Products.MethaneAdd(0.25*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.003*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.05*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.1*this->LightOilAmount;
this->LightOilAmount=0;
break;
case -1:
break;
}
}
void NaphthaCrack(){//裂化后蒸馏石脑油
switch(this->NaphthaCrackedType){
case 1://轻度氢气裂化石脑油
Products.ButaneAdd(0.8*this->NaphthaAmount);
Products.PropaneAdd(0.3*this->NaphthaAmount);
Products.EthaneAdd(0.25*this->NaphthaAmount);
Products.MethaneAdd(0.25*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 2://中度氢气裂化石脑油
Products.ButaneAdd(0.2*this->NaphthaAmount);
Products.PropaneAdd(1.1*this->NaphthaAmount);
Products.EthaneAdd(0.4*this->NaphthaAmount);
Products.MethaneAdd(0.4*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 3://重度氢气裂化石脑油
Products.ButaneAdd(0.125*this->NaphthaAmount);
Products.PropaneAdd(0.125*this->NaphthaAmount);
Products.EthaneAdd(1.5*this->NaphthaAmount);
Products.MethaneAdd(1.5*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 4://轻度蒸汽裂化石脑油
Products.TolueneAdd(0.04*this->NaphthaAmount);
Products.BenezeAdd(0.15*this->NaphthaAmount);
Products.ButeneAdd(0.08*this->NaphthaAmount);
Products.ButadieneAdd(0.15*this->NaphthaAmount);
Products.PropaneAdd(0.015*this->NaphthaAmount);
Products.AcrylicAdd(0.2*this->NaphthaAmount);
Products.EthaneAdd(0.035*this->NaphthaAmount);
Products.VinylAdd(0.2*this->NaphthaAmount);
Products.MethaneAdd(0.2*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.001*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.15;
this->HeavyOilAmount=this->HeavyOilAmount+0.075*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case 5://中度蒸汽裂化石脑油
Products.TolueneAdd(0.03*this->NaphthaAmount);
Products.BenezeAdd(0.125*this->NaphthaAmount);
Products.ButeneAdd(0.065*this->NaphthaAmount);
Products.ButadieneAdd(0.1*this->NaphthaAmount);
Products.PropaneAdd(0.03*this->NaphthaAmount);
Products.AcrylicAdd(0.4*this->NaphthaAmount);
Products.EthaneAdd(0.05*this->NaphthaAmount);
Products.VinylAdd(0.35*this->NaphthaAmount);
Products.MethaneAdd(0.35*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.002*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.1;
this->HeavyOilAmount=this->HeavyOilAmount+0.05*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case 6://重度蒸汽裂化石脑油
Products.TolueneAdd(0.02*this->NaphthaAmount);
Products.BenezeAdd(0.1*this->NaphthaAmount);
Products.ButeneAdd(0.05*this->NaphthaAmount);
Products.ButadieneAdd(0.05*this->NaphthaAmount);
Products.PropaneAdd(0.015*this->NaphthaAmount);
Products.AcrylicAdd(0.3*this->NaphthaAmount);
Products.EthaneAdd(0.065*this->NaphthaAmount);
Products.VinylAdd(0.5*this->NaphthaAmount);
Products.MethaneAdd(0.5*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.003*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.05;
this->HeavyOilAmount=this->HeavyOilAmount+0.025*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case -1:
break;
}
}
void GasCrack(){//裂化后蒸馏炼油气
switch(this->GasCrackedType){
case 0:
Products.ButaneAdd(0.06*this->GasAmount);
Products.PropaneAdd(0.07*this->GasAmount);
Products.EthaneAdd(0.1*this->GasAmount);
Products.MethaneAdd(0.75*this->GasAmount);
Products.HeliumAdd(0.02*this->GasAmount);
this->GasAmount=0;
break;
case 1:
Products.HeliumAdd(0.1*this->GasAmount);
Products.MethaneAdd(1.3*this->GasAmount);
this->GasAmount=0;
break;
case 2:
Products.HeliumAdd(0.15*this->GasAmount);
Products.MethaneAdd(1.4*this->GasAmount);
this->GasAmount=0;
break;
case 3:
Products.HeliumAdd(0.2*this->GasAmount);
Products.MethaneAdd(1.5*this->GasAmount);
this->GasAmount=0;
break;
case 4:
Products.HeliumAdd(0.05*this->GasAmount);
Products.MethaneAdd(0.5*this->GasAmount);
Products.VinylAdd(0.1*this->GasAmount);
Products.EthaneAdd(0.01*this->GasAmount);
Products.AcrylicAdd(0.05*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case 5:
Products.HeliumAdd(0.07*this->GasAmount);
Products.MethaneAdd(0.6*this->GasAmount);
Products.VinylAdd(0.2*this->GasAmount);
Products.EthaneAdd(0.05*this->GasAmount);
Products.AcrylicAdd(0.01*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case 6:
Products.HeliumAdd(0.01*this->GasAmount);
Products.MethaneAdd(0.7*this->GasAmount);
Products.VinylAdd(0.3*this->GasAmount);
Products.EthaneAdd(0.01*this->GasAmount);
Products.AcrylicAdd(0.01*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case -1:
break;
}
}
void Initialization(){//初始化数据
HeavyOilAmount=0;
LightOilAmount=0;
NaphthaAmount=0;
GasAmount=0;
HeavyOilCrackedType=-1;
LightOilCrackedType=-1;
NaphthaCrackedType=-1;
GasCrackedType=-1;
this->Products.Initialization();
GetFuel=0;
}
void GetCrackedType(int H,int L,int N,int G){//获取裂化的方式
HeavyOilCrackedType=H;
LightOilCrackedType=L;
NaphthaCrackedType=N;
GasCrackedType=G;
}
void ReceivedData(oil Oil){//从oil类中获取油的数目
this->NaphthaAmount=Oil.GetNaphthaAmount();
this->HeavyOilAmount=Oil.GetHeavyOilAmount();
this->GasAmount=Oil.GetGasAmount();
this->LightOilAmount=Oil.GetLightOilAmount();
}
void OutputData(){//输出内部数据信息
printf("重燃油量:%lf,轻燃油量:%lf,石脑油量:%lf,炼油气量:%lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
this->Products.OutPutInformation();
}
void Crack(){
while((this->HeavyOilAmount>1e-7&&this->HeavyOilCrackedType!=-1)||(this->LightOilAmount>1e-7&&this->LightOilCrackedType!=-1)||(this->NaphthaAmount>1e-7&&this->NaphthaCrackedType!=-1)||(this->GasAmount>1e-7&&this->GasCrackedType!=-1)){
this->HeavyOilCrack();
this->LightOilCrack();
this->NaphthaCrack();
this->GasCrack();
//printf("%lf %lf %lf %lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
}
}
void MakeFuel(){
if(this->GetFuel==1||this->GetFuel==2){
if(this->LightOilAmount>=5*this->HeavyOilAmount){
this->LightOilAmount=this->LightOilAmount-5*this->HeavyOilAmount;
Products.FuelAdd(this->HeavyOilAmount*6);
this->HeavyOilAmount=0;
}else if(this->LightOilAmount<5*this->HeavyOilAmount){
this->HeavyOilAmount=this->HeavyOilAmount-this->LightOilAmount/5;
Products.FuelAdd(this->LightOilAmount*1.2);
this->LightOilAmount=0;
}
}else if(this->GetFuel==0){
//donothing;
}
}
void IfGetFuel(int c){
this->GetFuel=c;
}
void MakeCetaneBoostedDiesel(){
if(this->GetFuel==2){
//先判断乙烯够不够用,如果不够用,不合成高十六
if(Products.vinyl>=0.01*Products.Fuel){//乙烯过量
Products.vinyl=Products.vinyl-Products.Fuel/(double)100;
Products.CetaneBoostedDiesel=Products.Fuel;
Products.Fuel=0;
}else if(Products.vinyl<0.01*Products.Fuel){
Products.CetaneBoostedDiesel=Products.vinyl*100;
Products.Fuel=Products.Fuel-100*Products.vinyl;
Products.vinyl=0;
}
}else{
//donothing
}
}
double GetHeavyOil(){
return this->HeavyOilAmount;
}
double GetLightOil(){
return this->LightOilAmount;
}
double GetNaphtha(){
return this->NaphthaAmount;
}
double GetGas(){
return this->GasAmount;
}
double GetProductAcrylic(){
return this->Products.GetAcrylicAmount();
}
double GetProductBeneze(){
return this->Products.GetBenezeAmount();
}
double GetProductButadiene(){
return this->Products.GetButadieneAmount();
}
double GetProductButane(){
return this->Products.GetButaneAmount();
}
double GetProductButene(){
return this->Products.GetButeneAmount();
}
double GetProductCetaneBoostedDiesel(){
return this->Products.GetCetaneBoostedDieselAmount();
}
double GetProductEthane(){
return this->Products.GetEthaneAmount();
}
double GetProductFuel(){
return this->Products.GetFuelAmount();
}
double GetProductHelium(){
return this->Products.GetHeliumAmount();
}
double GetProductMethane(){
return this->Products.GetMethaneAmount();
}
double GetProductOctane(){
return this->Products.GetOctaneAmount();
}
double GetProductPhenol(){
return this->Products.GetPhenolAmount();
}
double GetProductPropane(){
return this->Products.GetPropaneAmount();
}
double GetProductTinyCarbonDust(){
return this->Products.GetTinyCarbonDustAmount();
}
double GetProductToluene(){
return this->Products.GetTolueneAmount();
}
double GetProductVinyl(){
return this->Products.GetVinylAmount();
}
};
class Outputs{
public:
int OilType;
//double HeavyOilAmount;
//double LightOilAmount;
//double NaphthaAmount;
//double GasAmount;
int HeavyOilCrackedType;
int LightOilCrackedType;
int NaphthaCrackedType;
int GasCrackedType;
double methane;//甲烷
double ethane;//乙烷
double propane;//丙烷
double butane;//丁烷
double octane;//辛烷
double helium;//氦气
double toluene;//甲苯
double benzene;//苯
double vinyl;//乙烯
double acrylic;//丙烯
double butene;//丁烯
double butadiene;//丁二烯
double phenol;//苯酚
double TinyCarbonDust;//小撮碳粉
double Fuel;//柴油
double CetaneBoostedDiesel;//高十六
void OutputData(){
switch(this->OilType){
case 1:cout<<"BC原油"<<endl;break;
case 2:cout<<"GT轻油"<<endl;break;
case 3:cout<<"GT原油"<<endl;break;
case 4:cout<<"GT重油"<<endl;break;
case 5:cout<<"GT极重油"<<endl;break;
}
switch(this->HeavyOilCrackedType){
case 0:cout<<"重燃油直接蒸馏"<<endl;break;
case 1:cout<<"重燃油轻氢裂化"<<endl;break;
case 2:cout<<"重燃油中氢裂化"<<endl;break;
case 3:cout<<"重燃油重氢裂化"<<endl;break;
case 4:cout<<"重燃油轻蒸裂化"<<endl;break;
case 5:cout<<"重燃油中蒸裂化"<<endl;break;
case 6:cout<<"重燃油重蒸裂化"<<endl;break;
}
switch(this->LightOilCrackedType){
case 1:cout<<"轻燃油轻氢裂化"<<endl;break;
case 2:cout<<"轻燃油中氢裂化"<<endl;break;
case 3:cout<<"轻燃油重氢裂化"<<endl;break;
case 4:cout<<"轻燃油轻蒸裂化"<<endl;break;
case 5:cout<<"轻燃油中蒸裂化"<<endl;break;
case 6:cout<<"轻燃油重蒸裂化"<<endl;break;
}
switch(this->NaphthaCrackedType){
case 1:cout<<"石脑油轻氢裂化"<<endl;break;
case 2:cout<<"石脑油中氢裂化"<<endl;break;
case 3:cout<<"石脑油重氢裂化"<<endl;break;
case 4:cout<<"石脑油轻蒸裂化"<<endl;break;
case 5:cout<<"石脑油中蒸裂化"<<endl;break;
case 6:cout<<"石脑油重蒸裂化"<<endl;break;
}
switch(this->GasCrackedType){
case 0:cout<<"炼油气直接蒸馏"<<endl;break;
case 1:cout<<"炼油气轻氢裂化"<<endl;break;
case 2:cout<<"炼油气中氢裂化"<<endl;break;
case 3:cout<<"炼油气重氢裂化"<<endl;break;
case 4:cout<<"炼油气轻蒸裂化"<<endl;break;
case 5:cout<<"炼油气中蒸裂化"<<endl;break;
case 6:cout<<"炼油气重蒸裂化"<<endl;break;
}
printf("甲烷产量:%lf\n",this->methane/double(15));
printf("乙烷产量:%lf\n",this->ethane/double(15));
printf("丙烷产量:%lf\n",this->propane/double(15));
printf("丁烷产量:%lf\n",this->butane/double(15));
printf("辛烷产量:%lf\n",this->octane/double(15));
printf("氦气产量:%lf\n",this->helium/double(15));
printf("甲苯产量:%lf\n",this->toluene/double(15));
printf("苯产量:%lf\n",this->benzene/double(15));
printf("乙烯产量:%lf\n",this->vinyl/double(15));
printf("丙烯产量:%lf\n",this->acrylic/double(15));
printf("丁烯产量:%lf\n",this->butene/double(15));
printf("丁二烯产量:%lf\n",this->butadiene/double(15));
printf("苯酚产量:%lf\n",this->phenol/double(15));
printf("小撮碳粉产量:%lf\n",this->TinyCarbonDust/double(15));
printf("柴油产量:%lf\n",this->Fuel/double(15));
printf("高十六产量:%lf\n",this->CetaneBoostedDiesel/double(15));
}
};
int MethaneCompare(const void *a ,const void *b) {
return (*(Outputs*)b).methane-(*(Outputs*)a).methane;
}
int EthaneCompare(const void *a,const void *b){
return (*(Outputs*)b).ethane-(*(Outputs*)a).ethane;
}
int PropaneCompare(const void *a,const void *b){
return (*(Outputs*)b).propane-(*(Outputs*)a).propane;
}
int ButaneCompare(const void *a,const void *b){
return (*(Outputs*)b).butane-(*(Outputs*)a).butane;
}
int OctaneCompare(const void *a,const void *b){
return (*(Outputs*)b).octane-(*(Outputs*)a).octane;
}
int HeliumCompare(const void *a,const void *b){
return (*(Outputs*)b).helium-(*(Outputs*)a).helium;
}
int BenzeneCompare(const void *a,const void *b){
return (*(Outputs*)b).benzene-(*(Outputs*)a).benzene;
}
int TolueneCompare(const void *a,const void *b){
return (*(Outputs*)b).toluene-(*(Outputs*)a).toluene;
}
int VinylCompare(const void *a,const void *b){
return (*(Outputs*)b).vinyl-(*(Outputs*)a).vinyl;
}
int AcrylicCompare(const void *a,const void *b){
return (*(Outputs*)b).acrylic-(*(Outputs*)a).acrylic;
}
int ButeneCompare(const void *a,const void *b){
return (*(Outputs*)b).butene-(*(Outputs*)a).butene;
}
int ButadieneCompare(const void *a,const void *b){
return (*(Outputs*)b).butadiene-(*(Outputs*)a).butadiene;
}
int PhenolCompare(const void *a,const void *b){
return (*(Outputs*)b).phenol-(*(Outputs*)a).phenol;
}
int TinyCarbonDustCompare(const void *a,const void *b){
return (*(Outputs*)b).TinyCarbonDust-(*(Outputs*)a).TinyCarbonDust;
}
int FuelCompare(const void *a,const void *b){
return (*(Outputs*)b).Fuel-(*(Outputs*)a).Fuel;
}
int CetaneBoostedDieselCompare(const void *a,const void *b){
return (*(Outputs*)b).CetaneBoostedDiesel-(*(Outputs*)a).CetaneBoostedDiesel;
}
int main(){
Outputs OutPutData[1764];
int MakeFuel=0;
cout<<"是否考虑制作柴油,若考虑则输入1,否则输入0"<<endl;
scanf("%d",&MakeFuel);
int cnt=0;
oil Oil;
All Calc;
for(int a=1;a<=5;a++){
cnt=0;
for(int b=0;b<=6;b++){
for(int c=1;c<=6;c++){
for(int d=1;d<=6;d++){
for(int e=0;e<=6;e++){
Oil.Initialization();
Oil.GetOilTypeAndAmount(a);
Calc.Initialization();
Calc.ReceivedData(Oil);
Calc.GetCrackedType(b,c,d,e);
Calc.IfGetFuel(MakeFuel);
Calc.MakeFuel();
Calc.Crack();
//Calc.OutputData();
OutPutData[cnt].OilType=a;
//OutPutData[cnt].HeavyOilAmount=Calc.GetHeavyOil();
//OutPutData[cnt].LightOilAmount=Calc.GetLightOil();
//OutPutData[cnt].NaphthaAmount=Calc.GetNaphtha();
//OutPutData[cnt].GasAmount=Calc.GetGas();
OutPutData[cnt].HeavyOilCrackedType=b;
OutPutData[cnt].LightOilCrackedType=c;
OutPutData[cnt].NaphthaCrackedType=d;
OutPutData[cnt].GasCrackedType=e;
OutPutData[cnt].methane=Calc.GetProductMethane();
OutPutData[cnt].ethane=Calc.GetProductEthane();
OutPutData[cnt].propane=Calc.GetProductPropane();
OutPutData[cnt].butane=Calc.GetProductButane();
OutPutData[cnt].octane=Calc.GetProductOctane();
OutPutData[cnt].helium=Calc.GetProductHelium();//氦气
OutPutData[cnt].toluene=Calc.GetProductToluene();//甲苯
OutPutData[cnt].benzene=Calc.GetProductBeneze();//苯
OutPutData[cnt].vinyl=Calc.GetProductVinyl();//乙烯
OutPutData[cnt].acrylic=Calc.GetProductAcrylic();//丙烯
OutPutData[cnt].butene=Calc.GetProductButene();//丁烯
OutPutData[cnt].butadiene=Calc.GetProductButadiene();//丁二烯
OutPutData[cnt].phenol=Calc.GetProductPhenol();//苯酚
OutPutData[cnt].TinyCarbonDust=Calc.GetProductTinyCarbonDust();//小撮碳粉
OutPutData[cnt].Fuel=Calc.GetProductFuel();//柴油
OutPutData[cnt].CetaneBoostedDiesel=Calc.GetProductCetaneBoostedDiesel();
//OutputStruct(OutPutData[cnt]);
//return 0;
cnt++;
}
}
}
}
qsort(OutPutData,1764,sizeof(Outputs),MethaneCompare);
printf("原油情况为%d时,最大输出的甲烷及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),EthaneCompare);
printf("原油情况为%d时,最大输出的乙烷及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),PropaneCompare);
printf("原油情况为%d时,最大输出的丙烷及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),ButaneCompare);
printf("原油情况为%d时,最大输出的丁烷及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),OctaneCompare);
printf("原油情况为%d时,最大输出的辛烷及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),HeliumCompare);
printf("原油情况为%d时,最大输出的氦气及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),TolueneCompare);
printf("原油情况为%d时,最大输出的甲苯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),BenzeneCompare);
printf("原油情况为%d时,最大输出的苯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),VinylCompare);
printf("原油情况为%d时,最大输出的乙烯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),AcrylicCompare);
printf("原油情况为%d时,最大输出的丙烯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),ButeneCompare);
printf("原油情况为%d时,最大输出的丁烯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),ButadieneCompare);
printf("原油情况为%d时,最大输出的丁二烯及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
qsort(OutPutData,1764,sizeof(Outputs),PhenolCompare);
printf("原油情况为%d时,最大输出的苯酚及所用裂解方式为:\n",a);
OutPutData[0].OutputData();
}
system("pause");
return 0;
}
现给出想要任意搭配裂化方式的人,用于编程求解的C++源代码:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#define InvalidValueException -1
using namespace std;
class oil{
private:
int TypeInInt;
string TypeInString;
double HeavyOilAmount;
double LightOilAmount;
double NaphthaAmount;
double GasAmount;
public:
void GetOilTypeAndAmount(int type){//获取原油是那种,1是BC原油,2是GT轻油,3是GT原油,4是GT重油,5是GT极重油
switch(type){
case 1:
TypeInInt=1;
TypeInString="BCOil";
HeavyOilAmount=4500;
LightOilAmount=15000;
NaphthaAmount=6000;
GasAmount=18000;
break;
case 2:
TypeInInt=2;
TypeInString="GTLightOil";
HeavyOilAmount=1000;
LightOilAmount=2000;
NaphthaAmount=3000;
GasAmount=24000;
break;
case 3:
TypeInInt=3;
TypeInString="GTOil";
HeavyOilAmount=1500;
LightOilAmount=7500;
NaphthaAmount=22500;
GasAmount=9000;
break;
case 4:
TypeInInt=4;
TypeInString="GTHeavyOil";
HeavyOilAmount=37500;
LightOilAmount=6750;
NaphthaAmount=2250;
GasAmount=9000;
break;
case 5:
TypeInInt=5;
TypeInString="GTExtraHeavyOil";
HeavyOilAmount=56250;
LightOilAmount=10125;
NaphthaAmount=3375;
GasAmount=13500;
break;
default:
break;
}
}
void OutPutData(){//输出数据用来检验
cout<<"原油类型号:"<<this->TypeInInt<<endl;
cout<<"原油类型:"<<this->TypeInString<<endl;
printf("产出重燃油总量:%lf,产出轻燃油总量:%lf,产出石脑油总量:%lf,产出炼油气总量:%lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
}
double GetHeavyOilAmount(){
return this->HeavyOilAmount;
}
double GetLightOilAmount(){
return this->LightOilAmount;
}
double GetNaphthaAmount(){
return this->NaphthaAmount;
}
double GetGasAmount(){
return this->GasAmount;
}
void Initialization(){
this->GasAmount=0;
this->HeavyOilAmount=0;
this->NaphthaAmount=0;
this->LightOilAmount=0;
this->TypeInInt=-1;
this->TypeInString="";
}
};
class All{
private:
double HeavyOilAmount;
double LightOilAmount;
double NaphthaAmount;
double GasAmount;
int GetFuel;//为0时,不生产高十六,为1时,生产柴油,为2时,生产高十六
int HeavyOilCrackedType;//重燃油裂化方式
// 0:直接蒸馏 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int LightOilCrackedType;//轻燃油裂化方式
// 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int NaphthaCrackedType;//石脑油裂化方式
// 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
int GasCrackedType;//炼油气裂化方式
// 0:直接蒸馏 1:轻度氢气 2:中度氢气 3:重度氢气 4:轻度蒸汽 5:中度蒸汽 6:重度蒸汽
//定义嵌套类Product用来存储产物
public:
class Product{
friend class All;
private:
double methane;//甲烷
double ethane;//乙烷
double propane;//丙烷
double butane;//丁烷
double octane;
double helium;//氦气
double toluene;//甲苯
double benzene;//苯
double vinyl;//乙烯
double acrylic;//丙烯
double butene;//丁烯
double butadiene;//丁二烯
double phenol;//苯酚
double TinyCarbonDust;//小撮碳粉
double Fuel;//柴油
double CetaneBoostedDiesel;//高十六
public:
void Initialization(){
this->methane=0;
this->ethane=0;
this->propane=0;
this->butane=0;
this->helium=0;
this->toluene=0;
this->benzene=0;
this->vinyl=0;
this->acrylic=0;
this->butene=0;
this->butadiene=0;
this->TinyCarbonDust=0;
this->phenol=0;
this->octane=0;
this->Fuel=0;
this->CetaneBoostedDiesel=0;
}
void OutPutInformation(){//输出内部内容
//cout<<"甲烷产量:"<<this->methane<<endl;
printf("甲烷产量:%lf\n",this->methane/(double)15);
//cout<<"乙烷产量:"<<this->ethane<<endl;
printf("乙烷产量:%lf\n",this->ethane/(double)15);
//cout<<"丙烷产量:"<<this->propane<<endl;
printf("丙烷产量:%lf\n",this->propane/(double)15);
//cout<<"丁烷产量:"<<this->butane<<endl;
printf("丁烷产量:%lf\n",this->butane/(double)15);
//cout<<"氦气产量:"<<this->helium<<endl;
printf("辛烷产量:%lf\n",this->octane/(double)15);
printf("氦气产量:%lf\n",this->helium/(double)15);
//cout<<"甲苯产量:"<<this->toluene<<endl;
printf("甲苯产量:%lf\n",this->toluene/(double)15);
//cout<<"苯产量:"<<this->benzene<<endl;
printf("苯产量:%lf\n",this->benzene/(double)15);
//cout<<"乙烯产量:"<<this->vinyl<<endl;
printf("乙烯产量:%lf\n",this->vinyl/(double)15);
//cout<<"丙烯产量:"<<this->acrylic<<endl;
printf("丙烯产量:%lf\n",this->acrylic/(double)15);
//cout<<"丁烯产量:"<<this->butene<<endl;
printf("丁烯产量:%lf\n",this->butene/(double)15);
//cout<<"丁二烯产量:"<<this->butadiene<<endl;
printf("丁二烯产量:%lf\n",this->butadiene/(double)15);
//cout<<"小撮碳粉产量:"<<this->TinyCarbonDust<<endl;
printf("苯酚产量:%lf\n",this->phenol/(double)15);
printf("小撮碳粉产量:%lf\n",TinyCarbonDust/(double)15);
printf("柴油产量:%lf\n",this->Fuel/(double)15);
printf("高十六产量:%lf\n",this->CetaneBoostedDiesel/(double)15);
}
void MethaneAdd(double num){
this->methane=this->methane+num;
}
void EthaneAdd(double num){
this->ethane=this->ethane+num;
}
void PropaneAdd(double num){
this->propane=this->propane+num;
}
void ButaneAdd(double num){
this->butane=this->butane+num;
}
void HeliumAdd(double num){
this->helium=this->helium+num;
}
void TolueneAdd(double num){
this->toluene=this->toluene+num;
}
void BenezeAdd(double num){
this->benzene=this->benzene+num;
}
void VinylAdd(double num){
this->vinyl=this->vinyl+num;
}
void AcrylicAdd(double num){
this->acrylic=this->acrylic+num;
}
void ButeneAdd(double num){
this->butene=this->butene+num;
}
void ButadieneAdd(double num){
this->butadiene=this->butadiene+num;
}
void TinyCarbonDustAdd(double num){
this->TinyCarbonDust=this->TinyCarbonDust+num;
}
void PhenolAdd(double num){
this->phenol=this->phenol+num;
}
void OctaneAdd(double num){
this->octane=this->octane+num;
}
void FuelAdd(double num){
this->Fuel=this->Fuel+num;
}
void CetaneBoostedDieselAdd(double num){
this->CetaneBoostedDiesel=this->CetaneBoostedDiesel+num;
}
};
public:
Product Products;
void HeavyOilCrack(){//裂化后蒸馏重燃油
switch(this->HeavyOilCrackedType){
case 0://直接蒸馏重燃油
Products.BenezeAdd(0.4*this->HeavyOilAmount);
Products.TolueneAdd(0.4*this->HeavyOilAmount);
Products.PhenolAdd(0.25*this->HeavyOilAmount);
this->HeavyOilAmount=0;
break;
case 1://轻度氢气裂化重燃油
Products.MethaneAdd(0.075*this->HeavyOilAmount);
Products.EthaneAdd(0.075*this->HeavyOilAmount);
Products.PropaneAdd(0.1*this->HeavyOilAmount);
Products.ButaneAdd(0.1*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.6;
this->NaphthaAmount=this->NaphthaAmount+0.1*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 2://中度氢气裂化重燃油
Products.MethaneAdd(0.1*this->HeavyOilAmount);
Products.EthaneAdd(0.1*this->HeavyOilAmount);
Products.PropaneAdd(0.15*this->HeavyOilAmount);
Products.ButaneAdd(0.15*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.4;
this->NaphthaAmount=this->NaphthaAmount+0.4*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 3://重度氢气裂化重燃油
Products.MethaneAdd(0.175*this->HeavyOilAmount);
Products.EthaneAdd(0.175*this->HeavyOilAmount);
Products.PropaneAdd(0.3*this->HeavyOilAmount);
Products.ButaneAdd(0.3*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.2;
this->NaphthaAmount=this->NaphthaAmount+0.25*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 4://轻度蒸汽裂化重燃油
Products.TolueneAdd(0.025*this->HeavyOilAmount);
Products.BenezeAdd(0.125*this->HeavyOilAmount);
Products.ButeneAdd(0.025*this->HeavyOilAmount);
Products.ButadieneAdd(0.015*this->HeavyOilAmount);
Products.PropaneAdd(0.003*this->HeavyOilAmount);
Products.AcrylicAdd(0.03*this->HeavyOilAmount);
Products.EthaneAdd(0.005*this->HeavyOilAmount);
Products.VinylAdd(0.05*this->HeavyOilAmount);
Products.MethaneAdd(0.05*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.001*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.3;
this->NaphthaAmount=this->NaphthaAmount+0.05*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 5://中度蒸汽裂化重燃油
Products.TolueneAdd(0.04*this->HeavyOilAmount);
Products.BenezeAdd(0.2*this->HeavyOilAmount);
Products.ButeneAdd(0.04*this->HeavyOilAmount);
Products.ButadieneAdd(0.025*this->HeavyOilAmount);
Products.PropaneAdd(0.005*this->HeavyOilAmount);
Products.AcrylicAdd(0.05*this->HeavyOilAmount);
Products.EthaneAdd(0.007*this->HeavyOilAmount);
Products.VinylAdd(0.075*this->HeavyOilAmount);
Products.MethaneAdd(0.075*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.002*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.2;
this->NaphthaAmount=this->NaphthaAmount+0.2*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case 6://重度蒸汽裂化重燃油
Products.TolueneAdd(0.08*this->HeavyOilAmount);
Products.BenezeAdd(0.4*this->HeavyOilAmount);
Products.ButeneAdd(0.08*this->HeavyOilAmount);
Products.ButadieneAdd(0.05*this->HeavyOilAmount);
Products.PropaneAdd(0.01*this->HeavyOilAmount);
Products.AcrylicAdd(0.1*this->HeavyOilAmount);
Products.EthaneAdd(0.015*this->HeavyOilAmount);
Products.VinylAdd(0.15*this->HeavyOilAmount);
Products.MethaneAdd(0.15*this->HeavyOilAmount);
Products.TinyCarbonDustAdd(0.003*this->HeavyOilAmount);
this->LightOilAmount=this->LightOilAmount+this->HeavyOilAmount*0.1;
this->NaphthaAmount=this->NaphthaAmount+0.125*this->HeavyOilAmount;
this->HeavyOilAmount=0;
break;
case -1://不裂化
break;
}
}
void LightOilCrack(){//裂化后蒸馏轻燃油
switch(this->LightOilCrackedType){
case 1://轻度氢气裂化轻燃油
Products.OctaneAdd(0.1*this->LightOilAmount);
Products.ButaneAdd(0.15*this->LightOilAmount);
Products.PropaneAdd(0.2*this->LightOilAmount);
Products.EthaneAdd(0.125*this->LightOilAmount);
Products.MethaneAdd(0.125*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.8*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 2://中度氢气裂化轻燃油
Products.OctaneAdd(0.05*this->LightOilAmount);
Products.ButaneAdd(0.2*this->LightOilAmount);
Products.PropaneAdd(1.1*this->LightOilAmount);
Products.EthaneAdd(0.4*this->LightOilAmount);
Products.MethaneAdd(0.4*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.5*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 3://重度氢气裂化轻燃油
Products.OctaneAdd(0.02*this->LightOilAmount);
Products.ButaneAdd(0.125*this->LightOilAmount);
Products.PropaneAdd(0.125*this->LightOilAmount);
Products.EthaneAdd(1.5*this->LightOilAmount);
Products.MethaneAdd(1.5*this->LightOilAmount);
this->NaphthaAmount=this->NaphthaAmount+0.2*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 4://轻度蒸汽裂化轻燃油
Products.TolueneAdd(0.04*this->LightOilAmount);
Products.BenezeAdd(0.2*this->LightOilAmount);
Products.ButeneAdd(0.075*this->LightOilAmount);
Products.ButadieneAdd(0.06*this->LightOilAmount);
Products.PropaneAdd(0.02*this->LightOilAmount);
Products.AcrylicAdd(0.15*this->LightOilAmount);
Products.EthaneAdd(0.01*this->LightOilAmount);
Products.VinylAdd(0.05*this->LightOilAmount);
Products.MethaneAdd(0.05*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.001*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.15*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.4*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 5://中度蒸汽裂化轻燃油
Products.TolueneAdd(0.05*this->LightOilAmount);
Products.BenezeAdd(0.3*this->LightOilAmount);
Products.ButeneAdd(0.09*this->LightOilAmount);
Products.ButadieneAdd(0.075*this->LightOilAmount);
Products.PropaneAdd(0.035*this->LightOilAmount);
Products.AcrylicAdd(0.2*this->LightOilAmount);
Products.EthaneAdd(0.03*this->LightOilAmount);
Products.VinylAdd(0.15*this->LightOilAmount);
Products.MethaneAdd(0.15*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.002*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.1*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.25*this->LightOilAmount;
this->LightOilAmount=0;
break;
case 6://重度蒸汽裂化轻燃油
Products.TolueneAdd(0.03*this->LightOilAmount);
Products.BenezeAdd(0.15*this->LightOilAmount);
Products.ButeneAdd(0.065*this->LightOilAmount);
Products.ButadieneAdd(0.05*this->LightOilAmount);
Products.PropaneAdd(0.05*this->LightOilAmount);
Products.AcrylicAdd(0.25*this->LightOilAmount);
Products.EthaneAdd(0.05*this->LightOilAmount);
Products.VinylAdd(0.25*this->LightOilAmount);
Products.MethaneAdd(0.25*this->LightOilAmount);
Products.TinyCarbonDustAdd(0.003*this->LightOilAmount);
this->HeavyOilAmount=this->HeavyOilAmount+0.05*this->LightOilAmount;
this->NaphthaAmount=this->NaphthaAmount+0.1*this->LightOilAmount;
this->LightOilAmount=0;
break;
case -1:
break;
}
}
void NaphthaCrack(){//裂化后蒸馏石脑油
switch(this->NaphthaCrackedType){
case 1://轻度氢气裂化石脑油
Products.ButaneAdd(0.8*this->NaphthaAmount);
Products.PropaneAdd(0.3*this->NaphthaAmount);
Products.EthaneAdd(0.25*this->NaphthaAmount);
Products.MethaneAdd(0.25*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 2://中度氢气裂化石脑油
Products.ButaneAdd(0.2*this->NaphthaAmount);
Products.PropaneAdd(1.1*this->NaphthaAmount);
Products.EthaneAdd(0.4*this->NaphthaAmount);
Products.MethaneAdd(0.4*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 3://重度氢气裂化石脑油
Products.ButaneAdd(0.125*this->NaphthaAmount);
Products.PropaneAdd(0.125*this->NaphthaAmount);
Products.EthaneAdd(1.5*this->NaphthaAmount);
Products.MethaneAdd(1.5*this->NaphthaAmount);
this->NaphthaAmount=0;
break;
case 4://轻度蒸汽裂化石脑油
Products.TolueneAdd(0.04*this->NaphthaAmount);
Products.BenezeAdd(0.15*this->NaphthaAmount);
Products.ButeneAdd(0.08*this->NaphthaAmount);
Products.ButadieneAdd(0.15*this->NaphthaAmount);
Products.PropaneAdd(0.015*this->NaphthaAmount);
Products.AcrylicAdd(0.2*this->NaphthaAmount);
Products.EthaneAdd(0.035*this->NaphthaAmount);
Products.VinylAdd(0.2*this->NaphthaAmount);
Products.MethaneAdd(0.2*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.001*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.15;
this->HeavyOilAmount=this->HeavyOilAmount+0.075*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case 5://中度蒸汽裂化石脑油
Products.TolueneAdd(0.03*this->NaphthaAmount);
Products.BenezeAdd(0.125*this->NaphthaAmount);
Products.ButeneAdd(0.065*this->NaphthaAmount);
Products.ButadieneAdd(0.1*this->NaphthaAmount);
Products.PropaneAdd(0.03*this->NaphthaAmount);
Products.AcrylicAdd(0.4*this->NaphthaAmount);
Products.EthaneAdd(0.05*this->NaphthaAmount);
Products.VinylAdd(0.35*this->NaphthaAmount);
Products.MethaneAdd(0.35*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.002*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.1;
this->HeavyOilAmount=this->HeavyOilAmount+0.05*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case 6://重度蒸汽裂化石脑油
Products.TolueneAdd(0.02*this->NaphthaAmount);
Products.BenezeAdd(0.1*this->NaphthaAmount);
Products.ButeneAdd(0.05*this->NaphthaAmount);
Products.ButadieneAdd(0.05*this->NaphthaAmount);
Products.PropaneAdd(0.015*this->NaphthaAmount);
Products.AcrylicAdd(0.3*this->NaphthaAmount);
Products.EthaneAdd(0.065*this->NaphthaAmount);
Products.VinylAdd(0.5*this->NaphthaAmount);
Products.MethaneAdd(0.5*this->NaphthaAmount);
Products.TinyCarbonDustAdd(0.003*this->NaphthaAmount);
this->LightOilAmount=this->LightOilAmount+this->NaphthaAmount*0.05;
this->HeavyOilAmount=this->HeavyOilAmount+0.025*this->NaphthaAmount;
this->NaphthaAmount=0;
break;
case -1:
break;
}
}
void GasCrack(){//裂化后蒸馏炼油气
switch(this->GasCrackedType){
case 0:
Products.ButaneAdd(0.06*this->GasAmount);
Products.PropaneAdd(0.07*this->GasAmount);
Products.EthaneAdd(0.1*this->GasAmount);
Products.MethaneAdd(0.75*this->GasAmount);
Products.HeliumAdd(0.02*this->GasAmount);
this->GasAmount=0;
break;
case 1:
Products.HeliumAdd(0.1*this->GasAmount);
Products.MethaneAdd(1.3*this->GasAmount);
this->GasAmount=0;
break;
case 2:
Products.HeliumAdd(0.15*this->GasAmount);
Products.MethaneAdd(1.4*this->GasAmount);
this->GasAmount=0;
break;
case 3:
Products.HeliumAdd(0.2*this->GasAmount);
Products.MethaneAdd(1.5*this->GasAmount);
this->GasAmount=0;
break;
case 4:
Products.HeliumAdd(0.05*this->GasAmount);
Products.MethaneAdd(0.5*this->GasAmount);
Products.VinylAdd(0.1*this->GasAmount);
Products.EthaneAdd(0.01*this->GasAmount);
Products.AcrylicAdd(0.05*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case 5:
Products.HeliumAdd(0.07*this->GasAmount);
Products.MethaneAdd(0.6*this->GasAmount);
Products.VinylAdd(0.2*this->GasAmount);
Products.EthaneAdd(0.05*this->GasAmount);
Products.AcrylicAdd(0.01*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case 6:
Products.HeliumAdd(0.01*this->GasAmount);
Products.MethaneAdd(0.7*this->GasAmount);
Products.VinylAdd(0.3*this->GasAmount);
Products.EthaneAdd(0.01*this->GasAmount);
Products.AcrylicAdd(0.01*this->GasAmount);
Products.TinyCarbonDustAdd(0.001*this->GasAmount);
this->GasAmount=0;
break;
case -1:
break;
}
}
void Initialization(){//初始化数据
HeavyOilAmount=0;
LightOilAmount=0;
NaphthaAmount=0;
GasAmount=0;
HeavyOilCrackedType=-1;
LightOilCrackedType=-1;
NaphthaCrackedType=-1;
GasCrackedType=-1;
this->Products.Initialization();
GetFuel=0;
}
void GetCrackedType(int H,int L,int N,int G){//获取裂化的方式
HeavyOilCrackedType=H;
LightOilCrackedType=L;
NaphthaCrackedType=N;
GasCrackedType=G;
}
void ReceivedData(oil Oil){//从oil类中获取油的数目
this->NaphthaAmount=Oil.GetNaphthaAmount();
this->HeavyOilAmount=Oil.GetHeavyOilAmount();
this->GasAmount=Oil.GetGasAmount();
this->LightOilAmount=Oil.GetLightOilAmount();
}
void OutputData(){//输出内部数据信息
printf("重燃油量:%lf,轻燃油量:%lf,石脑油量:%lf,炼油气量:%lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
this->Products.OutPutInformation();
}
void Crack(){
while((this->HeavyOilAmount>1e-7&&this->HeavyOilCrackedType!=-1)||(this->LightOilAmount>1e-7&&this->LightOilCrackedType!=-1)||(this->NaphthaAmount>1e-7&&this->NaphthaCrackedType!=-1)||(this->GasAmount>1e-7&&this->GasCrackedType!=-1)){
this->HeavyOilCrack();
this->LightOilCrack();
this->NaphthaCrack();
this->GasCrack();
//printf("%lf %lf %lf %lf\n",this->HeavyOilAmount,this->LightOilAmount,this->NaphthaAmount,this->GasAmount);
}
}
void MakeFuel(){
if(this->GetFuel==1||this->GetFuel==2||this->GetFuel==3){
if(this->LightOilAmount>=5*this->HeavyOilAmount){
this->LightOilAmount=this->LightOilAmount-5*this->HeavyOilAmount;
Products.FuelAdd(this->HeavyOilAmount*6);
this->HeavyOilAmount=0;
}else if(this->LightOilAmount<5*this->HeavyOilAmount){
this->HeavyOilAmount=this->HeavyOilAmount-this->LightOilAmount/5;
Products.FuelAdd(this->LightOilAmount*1.2);
this->LightOilAmount=0;
}
}else if(this->GetFuel==0){
//donothing;
}
}
void IfGetFuel(int c){
this->GetFuel=c;
}
void MakeCetaneBoostedDiesel(){
if(this->GetFuel==2){
//先判断乙烯够不够用,如果不够用,不合成高十六
if(Products.vinyl>=0.01*Products.Fuel){//乙烯过量
Products.vinyl=Products.vinyl-Products.Fuel/(double)100;
Products.CetaneBoostedDiesel=Products.Fuel;
Products.Fuel=0;
}else if(Products.vinyl<0.01*Products.Fuel){
Products.CetaneBoostedDiesel=Products.vinyl*100;
Products.Fuel=Products.Fuel-100*Products.vinyl;
Products.vinyl=0;
}
}else if(this->GetFuel==3){
Products.CetaneBoostedDiesel=Products.Fuel;
Products.Fuel=0;
}else{
//donothing
}
}
};
int main(){
int judge=0;
oil Oil;
All Calc;
cout<<"此程序用于计算15000mB的各种油的石化产物情况。"<<endl;
while(true){
cout<<"输入1启动运算程序,输入0结束运算程序"<<endl;
scanf("%d",&judge);
if(judge==1){
Oil.Initialization();
int InputType=0;
cout<<"请输入油的类别:"<<endl;
cout<<"1为BC原油,2为GT轻油,3为GT原油,4为GT重油,5为GT极重油"<<endl;
cout<<"输入例子:"<<endl;
cout<<"1"<<endl;
cout<<"这个例子代表选择计算15B的BC原油的石化产物情况"<<endl;
try{
scanf("%d",&InputType);
if(InputType<1||InputType>5){
throw InvalidValueException;
}
Oil.GetOilTypeAndAmount(InputType);
//Oil.OutPutData();
//后期需要注释掉上面的代码
}catch(int Exception){
if(Exception==InvalidValueException){
cout<<"输入的数据不能小于0或者大于5"<<endl;
continue;
}
}
Calc.Initialization();
Calc.ReceivedData(Oil);
//Calc.GetCrackedType(5,4,4,0);
cout<<"请输入是否制作柴油类燃料,如果制作高十六且不使用乙烯,输入3,如果制作高十六且使用乙烯,输入2,如果制作柴油,输入1,否则输入0"<<endl;
int c;
scanf("%d",&c);
Calc.IfGetFuel(c);
cout<<"请输入裂化的方式(按照重燃油-轻燃油-石脑油-炼油气 的顺序):"<<endl;
cout<<"从1到6,分别对应轻氢,中氢,重氢,轻蒸汽,中蒸汽,重蒸汽,-1对应该产物不裂解,此外对于重燃油和炼油气,0代表直接蒸馏"<<endl;
cout<<"输入例子:"<<endl;
cout<<"0 1 1 0"<<endl;
cout<<"这个例子代表,重燃油和炼油气直接蒸馏,轻燃油和石脑油选择轻氢裂化"<<endl;
int type1,type2,type3,type4;
try{
scanf("%d %d %d %d",&type1,&type2,&type3,&type4);
if(type1<-1||type1>6||type2<-1||type2>6||type3<-1||type3>6||type4<-1||type4>6||type2==0||type3==0){
throw InvalidValueException;
}
}catch(int Exception){
if(Exception==InvalidValueException){
cout<<"输入的裂化方式有误!"<<endl;
continue;
}
}
Calc.MakeFuel();
Calc.GetCrackedType(type1,type2,type3,type4);
Calc.Crack();
Calc.MakeCetaneBoostedDiesel();
cout<<"每1000mB该原油的彻底裂解产物和燃料产物为(单位:mB):"<<endl;
Calc.OutputData();
}else if(judge==0){
break;
}
}
return 0;
}