当前位置: 技术问答>java相关
朋友门,继续我们的讨论。这次我更新了源程序及出错提示,请看:(再线等待)
来源: 互联网 发布时间:2015-06-05
本文导语: //:Csc.java //computing the sedimenting tank; import java.io.*; import Geshan.*; interface Index1{ double velocity=0.2;//设计流量时的水平流速,米/秒 double time=50;//最大设计流量时,污水在池内的停留时间,秒 double maxQ=Index.kTota...
//:Csc.java
//computing the sedimenting tank;
import java.io.*;
import Geshan.*;
interface Index1{
double velocity=0.2;//设计流量时的水平流速,米/秒
double time=50;//最大设计流量时,污水在池内的停留时间,秒
double maxQ=Index.kTotal*20000.0/86400;//最大流量
double h2=1;//设计有效水深,米
double day=2;//计算沉砂斗体积时,按2天的沉砂量计,天
double x1=3;//城市污水沉沙量,立方米/十万立方米
double a1=0.5;//沉砂斗下底宽,米
double alpha=55;//沉砂斗壁与水平面的倾角,度
double n=4;//沉砂斗的个数
double minQ=20000.0/86400/3;
double po=0.06;//沉砂斗外侧的坡度
// double h3=0.7;沉砂斗的高度,米
}
public class Csc {
double L1=Index1.velocity*Index1.time;//水流部分长度,米
double A=Index1.maxQ/Index1.velocity;//水流断面积,平方米
double B=A/Index1.h2;//池总宽度,米
double V=86400*Index1.maxQ*Index1.day*Index1.x1/(100000*Index.kTotal);
//沉砂斗容积,立方米
double v=V/Index1.n;//每个沉砂斗的容积,立方米
double h3pie=0.0;
double rr=root(0.0,10.0,0.001,h3pie);
double a=2*h3pie/Math.tan(Index1.alpha*Math.PI/180)+Index1.a1;
//沉砂斗上口宽,米
double h3=h3pie+Index1.po*(L1-Index1.n/2*a)/2;//沉砂室总高,米
double H=Index1.h2+Index1.h2+h3;//沉砂池总高,米
double minV=Index1.minQ/(B/2*Index1.h2);
double f(double x,double x1,double x2){
return x1-(x2-x)*Math.tan(55*Math.PI/180)/12*(2*Math.pow(x2,2)+
2*x2*x+2*Math.pow(x,2));
}
double root(double y1,double y2,double y3,double y4){
double s1=f(y1,v,Index1.a1);
y4=(y1+y2)/2;
while (Math.abs(y2-y1)>y3){
double y5=0;
double y6=0;
double s2=f(y4,v,Index1.a1);
if(s2+1.0==1.0){
return y4;
}
if (s1*s2>0){
y5=y4;
}
else{
y6=y4;
}
y4=(y5+y6)/2;
}
}
public static void main(String[] args){
Csc csc=new Csc();
try {
DataOutputStream out2 =
new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream("Data.txt")));
out2.writeDouble(L1);
out2.writeDouble(A);
out2.writeDouble(B);
out2.writeDouble(V);
out2.writeDouble(h3pie);
out2.writeDouble(a);
out2.writeDouble(h3);
out2.writeDouble(H);
out2.writeDouble(minV);
out2.writeDouble(Index.kTotal);
out2.close();
DataInputStream in5 =
new DataInputStream(
new BufferedInputStream(
new FileInputStream("Data.txt")));
// Must use DataInputStream for data:
System.out.println("L="+in5.readDouble());
System.out.println("A="+in5.readDouble());
System.out.println("B="+in5.readDouble());
System.out.println("V="+in5.readDouble());
System.out.println("h3pie="+in5.readDouble());
System.out.println("a="+in5.readDouble());
System.out.println("h3="+in5.readDouble());
System.out.println("H="+in5.readDouble());
System.out.println("minV"+in5.readDouble());
System.out.println("kTotal="+in5.readDouble());
} catch(EOFException e) {
System.out.println("End of stream");
}catch(FileNotFoundException e) {
System.out.println("File Not Found");
}
catch(IOException e) {
System.out.println("IO Error");
}
}
}///:~
都是同一类型的错误:
仅举一例:
Csc.java:75:non-static variable L1 cannot be referenced from a static context
out2.writeDouble(L1);
//computing the sedimenting tank;
import java.io.*;
import Geshan.*;
interface Index1{
double velocity=0.2;//设计流量时的水平流速,米/秒
double time=50;//最大设计流量时,污水在池内的停留时间,秒
double maxQ=Index.kTotal*20000.0/86400;//最大流量
double h2=1;//设计有效水深,米
double day=2;//计算沉砂斗体积时,按2天的沉砂量计,天
double x1=3;//城市污水沉沙量,立方米/十万立方米
double a1=0.5;//沉砂斗下底宽,米
double alpha=55;//沉砂斗壁与水平面的倾角,度
double n=4;//沉砂斗的个数
double minQ=20000.0/86400/3;
double po=0.06;//沉砂斗外侧的坡度
// double h3=0.7;沉砂斗的高度,米
}
public class Csc {
double L1=Index1.velocity*Index1.time;//水流部分长度,米
double A=Index1.maxQ/Index1.velocity;//水流断面积,平方米
double B=A/Index1.h2;//池总宽度,米
double V=86400*Index1.maxQ*Index1.day*Index1.x1/(100000*Index.kTotal);
//沉砂斗容积,立方米
double v=V/Index1.n;//每个沉砂斗的容积,立方米
double h3pie=0.0;
double rr=root(0.0,10.0,0.001,h3pie);
double a=2*h3pie/Math.tan(Index1.alpha*Math.PI/180)+Index1.a1;
//沉砂斗上口宽,米
double h3=h3pie+Index1.po*(L1-Index1.n/2*a)/2;//沉砂室总高,米
double H=Index1.h2+Index1.h2+h3;//沉砂池总高,米
double minV=Index1.minQ/(B/2*Index1.h2);
double f(double x,double x1,double x2){
return x1-(x2-x)*Math.tan(55*Math.PI/180)/12*(2*Math.pow(x2,2)+
2*x2*x+2*Math.pow(x,2));
}
double root(double y1,double y2,double y3,double y4){
double s1=f(y1,v,Index1.a1);
y4=(y1+y2)/2;
while (Math.abs(y2-y1)>y3){
double y5=0;
double y6=0;
double s2=f(y4,v,Index1.a1);
if(s2+1.0==1.0){
return y4;
}
if (s1*s2>0){
y5=y4;
}
else{
y6=y4;
}
y4=(y5+y6)/2;
}
}
public static void main(String[] args){
Csc csc=new Csc();
try {
DataOutputStream out2 =
new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream("Data.txt")));
out2.writeDouble(L1);
out2.writeDouble(A);
out2.writeDouble(B);
out2.writeDouble(V);
out2.writeDouble(h3pie);
out2.writeDouble(a);
out2.writeDouble(h3);
out2.writeDouble(H);
out2.writeDouble(minV);
out2.writeDouble(Index.kTotal);
out2.close();
DataInputStream in5 =
new DataInputStream(
new BufferedInputStream(
new FileInputStream("Data.txt")));
// Must use DataInputStream for data:
System.out.println("L="+in5.readDouble());
System.out.println("A="+in5.readDouble());
System.out.println("B="+in5.readDouble());
System.out.println("V="+in5.readDouble());
System.out.println("h3pie="+in5.readDouble());
System.out.println("a="+in5.readDouble());
System.out.println("h3="+in5.readDouble());
System.out.println("H="+in5.readDouble());
System.out.println("minV"+in5.readDouble());
System.out.println("kTotal="+in5.readDouble());
} catch(EOFException e) {
System.out.println("End of stream");
}catch(FileNotFoundException e) {
System.out.println("File Not Found");
}
catch(IOException e) {
System.out.println("IO Error");
}
}
}///:~
都是同一类型的错误:
仅举一例:
Csc.java:75:non-static variable L1 cannot be referenced from a static context
out2.writeDouble(L1);
|
L1必须设置为static
or out2.writeDouble(csc.L1);
or out2.writeDouble(csc.L1);