-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_ue0.R
80 lines (69 loc) · 2.66 KB
/
get_ue0.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#' get_ue0
#'
#' gets initial scaled reserve.
#' Obtains the initial scaled reserve for eggs given the scaled reserve density at birth.
#' Specification of length at birth as third input by-passes its computation, so if you want to specify an initial value for this quantity, you should use get_lb directly.
#'
#' @param p 1 or 3 -vector with parameters g, k_J/ k_M, v_H^b, see get_lb
#' @param eb optional scalar with scaled reserbe density at birth (default: eb = 1)
#' @param lb0 optional scalar with scaled length at birth (default: lb is optained from get_lb)
#'
#' @return [uE0, lb, info] scaled with scaled reserve at t=0: $U_E^0 g^2 k_M^3/ v^2$ with $U_E^0 = M_E^0/ \{J_{EAm}\}$; lb: scalar with scaled length at birth; info: indicator equals 1 if successful, 0 otherwise
#' @export
#'
#' @examples
#' g = 6; k = 6; kap = .8; uHb = .001; vHb = uHb/ (1 - kap);
#' par = c(g, k, vHb);
get_ue0=function(p, eb = 1, lb0 = NA){
# created at 2007/07/27 by Bas Kooijman; modified 2010/05/02
## Syntax
# [uE0, lb, info] = <../get_ue0.m *get_ue0*>(p, eb, lb0)
## Description
# Obtains the initial scaled reserve given the scaled reserve density at birth.
# Function get_ue0 does so for eggs, get_ue0_foetus for foetuses.
# Specification of length at birth as third input by-passes its computation,
# so if you want to specify an initial value for this quantity, you should use get_lb directly.
#
# Input
#
# * p: 1 or 3 -vector with parameters g, k_J/ k_M, v_H^b, see get_lb
# * eb: optional scalar with scaled reserbe density at birth
# (default: eb = 1)
# * lb0: optional scalar with scaled length at birth
# (default: lb is optained from get_lb)
#
# Output
#
# * uE0: scaled with scaled reserve at t=0: $U_E^0 g^2 k_M^3/ v^2$
# with $U_E^0 = M_E^0/ \{J_{EAm}\}$
# * lb: scalar with scaled length at birth
# * info: indicator equals 1 if successful, 0 otherwise
## Remarks
# See <get_ue0_foetus.html *get_ue0_foetus*> for foetal development.
# See <initial_scaled_reserve.html *initial_scaled_reserve*>, for a non-dimensionless scaling.
## Example of use
# see <../mydata_ue0.m *mydata_ue0*>
# if (!exists('eb')) {
# eb = 1 # maximum value as juvenile
# }
if (is.na(lb0)){
if (length(p) < 3) {
print('not enough input parameters, see get_lb \n');
uE0 = NA
lb = NA
info = 0
}
lbinfo = get_lb(p, eb)
lb=lbinfo[1]
info=lbinfo[2]
} else {
lb = lb0
info = 1
}
# unpack p
g = p[1] # energy investment ratio
xb = g/ (eb + g)
uE0 = (3 * g/ (3 * g * xb^(1/ 3)/ lb - beta0(0, xb)))^3
#print(paste("uE0", uE0))
return(c(uE0 = unname(uE0), lb = unname(lb), info = unname(info)))
}