# Project resource using semichemostat model

Source:`R/resource_semichemostat.R`

`resource_semichemostat.Rd`

If you set your resource dynamics to use this function then the time evolution of the resource spectrum is described by a semi-chemostat equation $$\frac{\partial N_R(w,t)}{\partial t} = r_R(w) \Big[ c_R (w) - N_R(w,t) \Big] - \mu_R(w, t) N_R(w,t)$$

## Usage

```
resource_semichemostat(
params,
n,
n_pp,
n_other,
rates,
t,
dt,
resource_rate,
resource_capacity,
...
)
balance_resource_semichemostat(params, resource_rate, resource_capacity)
```

## Arguments

- params
A MizerParams object

- n
A matrix of species abundances (species x size)

- n_pp
A vector of the resource abundance by size

- n_other
A list with the abundances of other components

- rates
A list of rates as returned by

`mizerRates()`

- t
The current time

- dt
Time step

- resource_rate
Resource replenishment rate

- resource_capacity
Resource carrying capacity

- ...
Unused

## Details

Here \(r_R(w)\) is the resource regeneration rate and \(c_R(w)\) is the
carrying capacity in the absence of predation. These parameters are changed
with `setResource()`

. The mortality \(\mu_R(w, t)\) is
due to predation by consumers and is calculate with `getResourceMort()`

.

This function uses the analytic solution of the above equation to calculate
the resource abundance at time `t + dt`

from all abundances and rates at time
`t`

, keeping the mortality fixed during the timestep.

To set your model to use semichemostat dynamics for the resource you do

```
<- setResource(params,
params resource_dynamics = "resource_semichemostat",
resource_level = 0.5)
```

where you should replace `params`

with the name of the variable holding your
MizerParams object. You can of course choose any value between 0 and 1 for
the resource level.

The `balance_resource_semichemostat()`

function is called by `setResource()`

to determine the values of the resource parameters that are needed to make
the replenishment rate at each size equal the consumption rate at that size,
as calculated by `getResourceMort()`

. It should be called with only one of
`resource_rate`

or `resource_capacity`

should and will return a named list
with the values for both.

## See also

Other resource dynamics:
`resource_constant()`

,
`resource_logistic()`