Gets the resource supply rates of each resource, given the current resource concentrations.
get_ressupply(ressupply_obj, resources, params)
A vector of rates of change of resource concentrations, of the same length as resources
.
This function is normally only for internal use, but is exported to aid users in debugging their created rescomp_ressupply
objects.
# Two resources, A and B, with constant supply of A, and A spontaneously converting to B
ressupply <- ressupply_custom(
function(resources, params) {
conversion <- params$conversion * resources[1]
return(c(params$supply - conversion, conversion))
},
resnum = 2
)
get_ressupply(ressupply, c(10, 20), list(supply = 3, conversion = 0.2))
#> [1] 1 2
try(get_ressupply(ressupply, c(10, 20, 30), list(supply = 3, conversion = 0.2)))
#> Error in get_ressupply(ressupply, c(10, 20, 30), list(supply = 3, conversion = 0.2)) :
#> `func` of `ressupply_custom` must return a vector matching expected
#> length.
#> ✖ It returned a vector with length 2.
#> ℹ Expected length was 3 (i.e. `resnum`).