/* this is for the model where parasites "eat" reserves */
void derivs (int *neq, double *t, double *y, double *ydot) {
  // fixed parameters whose values will not ever vary
  double eps = 0.00000000816536; // carbon content of algae from Meg's data
  double V = 30; // volume of the container
  double xi = 0.0018; // length-weight regression coefficient from Spencer
  double q = 3; // length-weight regression exponent from Spencer

  // foraging-dependent parameters
  double Fh = 12000; // half-saturation constant
  double Imax = 12162; // ingestion rate
  double g = 1.467; // size-dependence of ingestion
  double a = 3.2e-5; // spore coefficient
  double h = 3.57; // size -dependence of spore dependence

  // state variables
  double F = y[0]; // algal concentration
  double E = y[1]; // energy reserves
  double W = y[2]; // structural weight
  double Pi = y[3]; // immature parasites
  double Pm = y[4]; // mature parasites
  double L = pow(W, 1/3); // structural length
  double Lobs = pow(W/xi, 1/q); //observed length

  // ingestion
  double ing = Imax * F/(Fh+F) * pow(Lobs,g) * exp(-a * Pm/pow(Lobs,h));
  // mobilization
  double pc = E * (v/L + km) / (1 + K*E/W);

  // total number of state variables
  int Nout = 5;
  // which state variables do we want
  int nr[5] = {0, 1, 2, 3, 4};
  // array of initial values
  double ytau[5] = {0.0, 0.0, 0.0, 0.0, 0.0};

  double T = *t - tau;

  if (*t > tau) {
    lagvalue(T, nr, Nout, ytau);
  }

  // balance the equations
  ydot[0] = -ing;
  ydot[1] = rho*eps*V*ing - pc;
  ydot[2] = K*pc - km*W - aP*W*Pi;
  ydot[3] = eP*aP*W/(hP+W)*Pi - exp(-m*tau)*eP*aP*ytau[2]/(hP+ytau[2])*ytau[3] - m*Pi;
  ydot[4] = exp(-m*tau)*eP*aP*ytau[2]/(hP+ytau[2])*ytau[3];
}
예제 #2
0
/* Derivatives */
void derivs (int *neq, double *t, double *y, double *ydot,
             double *yout, int *ip) {

  if (ip[0] < 1) error("nout should be at least 1");

  int nr[1] = {0};            // which lags are needed?
                              // numbering starts from zero !
  double ytau[1] = {1.0};     // array; initialize with default values !
  double T = *t - tau;
  
  if (*t > tau) {
    lagvalue(T, nr, 1, ytau);
    //Rprintf("test %g %g %g \n", T, y[0], ytau[0]);
  }

  yout[0] = ytau[0];
  ydot[0] = k * ytau[0];

}