# 明确问题在哪

• 将testField的改变值传递给变量（基本解决）
• 将压力曲线以什么样的形式表显示出来
• 界面设计太简陋，输出的压力值放在哪里，压力曲线放在哪里

``````public class OneDimension
{
static MyFrame frame;
/*
*This code is calculating for one dimension reservoir numerical simulation
*/
public double φ=0.25;           //孔隙度
double k=0.05;          //渗透率
double μ = 1;           //粘度μ
double con=0.0005;      //压缩系数 con
double rw=10;           //井筒半径 rw
double re=25000;        //供给边界半径 re
int Pe= 100;            //供给边界压力 Pe
int Pi=100;             //原始地层压力 Pi
double qv=173.611;      //定产量 q
int h = 500;            //油层厚度h
int n=30;           //网格数
int delta=30*86400; //两网格之间的时间差
int tmax=360*86400; //最大生产时间

double r[]=new double[31];
double a[]=new double[31];
double b[]=new double[31];
double c[]=new double[31];
double d[]=new double[31];
double p[]=new double[31];
double q[]=new double[31];

double u[]=new double[31];
double l[]=new double[31];
double detx=Math.log(re / rw)/n;
double xa[]=new double[30];
double xb[]=new double[30];
double xc[]=new double[30];
double xd[]=new double[30];
double m[]=new double[30];
double lamd[]=new double[30];

double dr[]=new double[30];
double pch[]=new double[31];
double pre[]=new double[31];

double x[]=new double[31];
double y[]=new double[31];

public  OneDimension()
{
for (int i=1;i<=29;i++)
{
m[i]=Math.exp(2*i*detx)*φ*μ*con*detx*detx*rw*rw/(k*delta);
lamd[i]=2+m[i];
}

for (int i=0;i<=29;i++)
{
pre[i]=100;
}

dr[0]=(qv*μ*detx)/(2*Math.PI*k*h);
xa[0]=0;
for(int i=1;i<=29;i++)
{
xa[i] = 1;
}
xb[0]=-1;
for (int i=1;i<=29; i++)
xb[i]=-lamd[i];
for (int i=0; i<=28; i++)
xc[i] = 1;

xc[29] = 0;

for (int i=1;i<=30;i++)
{
r[i] = Math.exp(i*detx ) *rw;
}
}

public double[] lu(double pa[], double pb[], double pc[], double pd[])
{
System. arraycopy(pa, 0, a, 1, pa.length);
System. arraycopy (pb, 0, b, 1, pb.length);
System. arraycopy(pc, 0, c, 1, pc.length);
System. arraycopy(pd, 0, d, 1, pd.length);

u [ 1 ] = b [1];
for ( int i = 2 ; i <= 30 ; i ++ )
{
l[i] = a[i]/(u[i - 1]);
u[i] = b[i] - l[i]*c[i-1];
}
y[1] = d[1];
for ( int i = 2 ;i <= 30 ; i ++ )
{
y[i]=d[i] - l[i]*y[i - 1];
}
x[30] = y[30] / (u[30]);
for ( int i = 29 ; i >= 1 ; i--)
{
x[i]=(y[i]-c[i]*x[i+1])/u[i];
}
return x;
}
public void compute()
{

for(int i=1;i<=29; i++)
dr[i]=-m[i]*pre[i];
for(int i=0; i<=28; i++)
xd[i]=dr[i];

xd[29]=dr[29]-Pe;
pch=lu(xa, xb, xc, xd);
System.arraycopy(pch,1,pre, 0,(pch.length-1));
pre[30] = 100 ;

}
public void print() {
for ( int i = 1 ;i <= 30 ;i++)

{
System.out.println(" pressure of the " + i +"th grid is "+pre[i]);
}
}

public void start()
{
for ( int t = 1 ; t <= 12 ;t ++ ) {
compute();
}
}

public static void main ( String[] args )
{
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
frame = new MyFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});

OneDimension test = new OneDimension();
test. start();
test. print();

}
}
``````