import java.util.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import javax.swing.*;

public class HT_xt_sonsuzduvarP
{
public static double T(double Ti,double T0,double alpha,double x,double t)
{double y=x/2/Math.sqrt(t*alpha); 
double T1=(Ti-T0)*Mathd.erf(y)+T0;
return T1;
}

public static void plot(double Ti,double T0,double alpha,double x,double t,double dt)
{ double dx=x/80;
  double a[][]=new double[2][80];

  a[0][0]=0.0;
  a[1][0]=T0;
  int i=1;
  for(double x1=dx;x1<=x;x1+=dx)
  {a[0][i]=x1;a[1][i]=Ti;i++;}
  Plot pp=new Plot(a);  
  for(double t1=dt;t1<=t;t1+=dt)
  { 
  i=1; 
  for(double x1=dx;x1<=x;x1+=dx)
  {a[0][i]=x1;a[1][i]=T(Ti,T0,alpha,x1,t1);i++;}
  System.out.println("t1="+t1);
  double xx[]=a[0];
  double yy[]=a[1];
  pp.addData(xx,yy);
  }
  pp.plot();
}
     public static void main (String args[])  
     { //fb f=new fb(); 
       double Ti,T0,x,t,alpha;
       Ti=Double.parseDouble(JOptionPane.showInputDialog(" t=0 daki duvar sıcaklığı Ti: "));
       T0=Double.parseDouble(JOptionPane.showInputDialog(" t>0 daki duvar yüzey sıcaklığı T0: "));
       t=Double.parseDouble(JOptionPane.showInputDialog(" zaman t: "));
       x=Double.parseDouble(JOptionPane.showInputDialog(" duvar yüzeyinden mesafe: "));
       alpha=Double.parseDouble(JOptionPane.showInputDialog(" alpha=ro/k/Cp: "));
       double dt=t/10;
       plot(Ti,T0,alpha,x,t,dt);
       //JOptionPane.showMessageDialog(null," T = "+T(Ti,T0,alpha,x,t),
       //"duvarda zamana bağlı ısı transferi  : ",JOptionPane.PLAIN_MESSAGE);
       //System.exit(0); 
     } 
}