import java.util.*;
//***********************************************************************************
//* Class for Van der Pohl ODE */
//***********************************************************************************

public class VanDerPohlFunction extends OdesFunction {
      
      private static final double Pi2=2*Math.PI;
      
/** the default value of the initial value of x */
 
      
      VanDerPohlFunction(int n) {
            super(n);
            x0=new double[n];
            x0[0]=0.;
            x0[1]=0.2;
            x0[2]=0.1;
            x0[3]=0.5;
            dt=0.2;
            trans=100.;
            ghostTime=100.;
            poincareSection=3.14;
            title="Van Der Pohl Oscillator";
            nParameters=3;
            aDefault=new double[nParameters];
            aDefault[0]=0.32;
            aDefault[1]=0.2;
            aDefault[2]=1.05;
            a=new double[nParameters];  
            wrapZ=true;
            wrapZValue=Pi2;                    
            
      }      
      
//***********************************************************************************
/** Sets the eqiation 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 Van der Pohl equation
* @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 compoent vector giving derivatives of dependent variables
*/
//*********************************************************************       
      public double[] derivs(double[] x, double t){
           double rhs[] = new double[nVariables];
           rhs[0]=1.;
           rhs[1]=x[2];
           rhs[2]=a[1]*(1-x[1]*x[1])*x[2]-x[1]+a[0]*Math.cos(x[3]);
           rhs[3]=a[2];
           return rhs;
      }

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