예제 #1
0
int Rossler::Jacobian (long int N, DenseMat J, realtype t, N_Vector x, N_Vector fy, 
			  void *jac_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) {
#endif
#ifdef CVODE26
int Rossler::Jacobian (int N, realtype t, N_Vector x, N_Vector fy, DlsMat J, 
			  void *jac_data, N_Vector tmp1, N_Vector tmp2, N_Vector tmp3) {
#endif
  realtype a, b, c;
  realtype x1, x2, x3;
  Parameters * parameters;
  
  x1 = Ith (x, 0);
  x2 = Ith (x, 1);
  x3 = Ith (x, 2);
  
  parameters = (Parameters *) jac_data;
  a = parameters->At(0);
  b = parameters->At(1);
  c = parameters->At(2);
  
  IJth (J, 0, 0) =  0.0;
  IJth (J, 0, 1) = -1.0;
  IJth (J, 0, 2) = -1.0;
  IJth (J, 1, 0) =  1.0;
  IJth (J, 1, 1) =  a;
  IJth (J, 1, 2) =  0.0;
  IJth (J, 2, 0) =  x3;
  IJth (J, 2, 1) =  0.0;
  IJth (J, 2, 2) =  x1-c;
  
  return CV_SUCCESS;
}
예제 #2
0
void Rossler::EventsConstraints (realtype t, N_Vector x, int * constraints, void * data) {
  realtype a, b, c;
  realtype x1, x2, x3;
  realtype ris[3], xdot[3];
  Parameters * parameters;
  
  x1 = Ith (x, 0);
  x2 = Ith (x, 1);
  x3 = Ith (x, 2);
 
  parameters = (Parameters *) data;
  a = parameters->At(0);
  b = parameters->At(1);
  c = parameters->At(2);

  RHS(t,x,xderiv,data);
  for(int i=0; i<GetDimension(); i++)
    xdot[i] = Ith(xderiv,i);
  
  ris[0] = - xdot[1] - xdot[2];
  ris[1] = xdot[0] + a*xdot[1];
  ris[2] = xdot[0]*x3 + xdot[2]*(x1-c);
	
  for(int i=0; i<GetNumberOfEvents(); i++)
    constraints[i] = (ris[i] < 0 ? 1 : 0);
}
예제 #3
0
int Rossler::RHS (realtype t, N_Vector x, N_Vector xdot, void * data) {
  realtype x1, x2, x3;
  realtype a, b, c;
  Parameters * parameters;
  
  parameters = (Parameters *) data;
  a = parameters->At(0);
  b = parameters->At(1);
  c = parameters->At(2);
  
  x1 = Ith (x, 0);
  x2 = Ith (x, 1);
  x3 = Ith (x, 2);
  
  Ith (xdot, 0) = - x2 - x3;
  Ith (xdot, 1) = x1 + a*x2;
  Ith (xdot, 2) = b + x3*(x1 - c);
  
  return CV_SUCCESS;
}
예제 #4
0
int PLL::Events (realtype t, N_Vector X, realtype * event, void * data) {
#ifndef WITHPHIERR
  realtype x, y, r, w;
  Parameters * parameters = (Parameters *) data;
  
  x = Ith (X, 0);
  y = Ith (X, 1);
  r = Ith (X, 2);
  w = Ith (X, 3);
  
  fREF = parameters->At(0);
  T = 1.0/fREF;
  R1 = parameters->At(1);
  omega0 = 2*pi*parameters->At(2);
  Vdd = parameters->At(3);
  rho0 = parameters->At(4);
  rhoap = parameters->At(5);
  k0 = parameters->At(6);
  Krho = parameters->At(7);
  Kap = parameters->At(8);
  alpha = parameters->At(9);
  KVCOa = parameters->At(10);
  KVCOb = parameters->At(11);
  KVCOc = parameters->At(12);
  tuning_coeff = parameters->At(13);
  
  // rising edge of the clock
  event[0] = t - n*T;
  // extrema of x
  realtype gamma = sqrt(x*x+y*y);
  realtype vtune = w/tuning_coeff;
  event[1] = ((rho0+Krho*vtune)/gamma - 1)*k0*x - ((1-alpha)*Kap*(gamma-rhoap) + 1 + alpha*vtune*(KVCOa + KVCOb*vtune + KVCOc*vtune*vtune))*omega0*y;
  // reset
  event[2] = t - (treset+tau_d+dt);
#endif
  return CV_SUCCESS;
}