资源描述:
《基于Java程序的化工热力学饱和蒸汽压——安托因方程的计算及应用》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、例题参考书:《化工热力学》,陈光进等。【例2-2】用vanderWaals方程和等面积原理估算对比温度Tr=T/Tc=0.95时甲烷的饱和蒸汽压和液体及饱和蒸汽的摩尔体积。实验值:3.55MPa;计算值:3.40MPa【例】计算氨在303K的饱和蒸汽压。百度值:;1.09MPa计算值:1.17MPa程序:importorg.apache.poi.hssf.usermodel.HSSFWorkbook;importorg.apache.poi.hssf.usermodel.HSSFSheet;impor
2、torg.apache.poi.hssf.usermodel.HSSFRow;importorg.apache.poi.hssf.usermodel.HSSFCell;importjava.io.FileInputStream;importjava.util.Scanner;publicclassps{publicstaticStringfileToBeRead="H:/java/physicalpropertydata.xls";publicstaticvoidmain(Stringargs[]){
3、Scannersz=newScanner(System.in);doublet,pc,tc,w,x,z;double[]h=newdouble[5],y=newdouble[4],f=newdouble[300],f1=newdouble[300],ps=newdouble[300];inti,j,k;System.out.println("pleaseinputyourchoiceofsubstance");k=sz.nextInt();System.out.println("pleaseinput
4、thetemperatureofthesystem(K)");t=sz.nextDouble();try{HSSFWorkbookworkbook=newHSSFWorkbook(newFileInputStream(fileToBeRead));for(j=0;j<4;j++){HSSFSheetsheet=workbook.getSheetAt(0);HSSFRowrow=sheet.getRow(k);HSSFCellcell=row.getCell((short)j);if(j==0)Syst
5、em.out.println("Theparametersof"+cell.getStringCellValue()+"areasfollows:");elsey[j-1]=cell.getNumericCellValue();}}catch(Exceptione){System.out.println("已运行Outputexcel():"+e);}tc=y[0];pc=y[1];w=y[2];pc=pc*100000;System.out.println("tc="+tc+"K,pc="+pc/M
6、ath.pow(10,6)+"MPa,w="+w);try{HSSFWorkbookworkbook=newHSSFWorkbook(newFileInputStream("H:/java/saturatedvaporpressureparameters.xls"));for(j=0;j<5;j++){HSSFSheetsheet=workbook.getSheetAt(0);HSSFRowrow=sheet.getRow(k);HSSFCellcell=row.getCell(j+1);h[j]=c
7、ell.getNumericCellValue();}}catch(Exceptione){System.out.println("已运行Outputexcel():"+e);}switch((int)h[4]){case1:{x=1-t/tc;ps[0]=Math.exp(1/(1-x)*(h[0]*x+h[1]*Math.pow(x,1.5)+h[2]*Math.pow(x,3)+h[3]*Math.pow(x,6))+Math.log(pc));System.out.println("satur
8、atedvaporpressurecalculatedbyantoineequation="+String.format("%.2f",ps[0]/Math.pow(10,6))+"MPa");break;}case2:{System.out.println("pleaseinputtheinitialpressureofthesystem(MPa)");z=sz.nextDouble();ps[0]=z*10;i=0;do{f[i]=Math.log(