//======================================================
// Numerical Analysis package in java
// example to show differential equation solution
// Runge-Kutta 6 method with multible differential equations
// Dr. Turhan Coban
// =====================================================
// dy1/dx=f(x,y1,y2,..,yn)
// dy2/dx=f(x,y1,y2,..,yn)
// ......
// dyn/dx=f(x,y1,y2,..,yn)
// Pendulum problem

import java.io.*;

class fm1 extends f_xi
{

 double func(double x[],int x_ref)
 {
   //  Josephson Junctions equation 
   double A=0.9045;
   double r=0.5;
   double to=0.47;
   double a=0;
   if(x_ref==1) a= A*Math.sin(to*x[0])-r*x[2]-Math.sin(x[1]);
   else if(x_ref==0) a= x[2];
   return a;
 }
}

class NA101E
{

public static void main(String args[]) throws IOException
{
fm1 b3=new fm1();
  double y[]=new double[2];
  y[0]=0.0;
  y[1]=0.0; 
  //solution of the differential system : 
  double xi[]=new double[20];
  double fi[]=new double[20];
  double a[][];
  a=NA93.RK6(b3,0.0,1200.0,y,4800000);
  //Text.print(Text.T(a));
  Plot pp=new Plot(a[1],a[2]);
  pp.setXlabel("u");
  pp.setYlabel("v");
  pp.setPlabel("Josephson Junctions equation ");
  pp.plot();
 }
}
