//***********************************************************************************
//* Class for Lorenz ODE */
//***********************************************************************************

public class LorenzFunction extends OdesFunction {
      
      LorenzFunction(int n) {
            super(n);
            x0=new double[n];
            x0[0]=0.;
            x0[1]=2.;
            x0[2]=5.;
            x0[3]=20.;
            dt=0.01;
            trans=10.;
            ghostTime=10.;
            poincareSection=31;
            title="Lorenz Model";
            nParameters=3;
            aDefault=new double[nParameters];
            aDefault[0]=28;
            aDefault[1]=2.667;
            aDefault[2]=10.;
            a=new double[nParameters];          
            
      }      
      
//***********************************************************************************
/** Sets the equation paramters 
* @param paramters the array of input paramters
*/
//***********************************************************************************      
      public void setParameters(double[] parameters) {
            for(int i=0; i<nParameters;i++) a[i]=parameters[i];
      }

//*********************************************************************
/**
* Returns RHS of differential equations for Lorenz model
* @param x[] vector of current value of dependent variables
* @param n number of dependent variables in array x[]
* @param t current value of independent variable
* @return n component vector giving derivatives of dependent variables
*/
//*********************************************************************       
      public double[] derivs(double[] x, double t){
           double rhs[] = new double[nVariables];
           rhs[0]=1.;
           rhs[1]=a[2]*(x[2]-x[1]);
           rhs[2]=a[0]*x[1]-x[2]-x[1]*x[3];
           rhs[3]=-a[1]*(x[3]-x[1]*x[2]);
           return rhs;
      }

     
//***********************************************************************************
/** Returns the number of parameters defining the map
* @return number of parameters
*/
//***********************************************************************************
     public int getNParameters() {
            return nParameters;
     } 
                  
}
