Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Annotation of /trunk/gadget/growermemberfunctions.cc
[mareframe] / trunk / gadget / growermemberfunctions.cc Repository:
ViewVC logotype

Annotation of /trunk/gadget/growermemberfunctions.cc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (view) (download)

1 : agomez 1 #include "grower.h"
2 :     #include "mathfunc.h"
3 :     #include "errorhandler.h"
4 :     #include "global.h"
5 :    
6 :     //Uses the length increase in interpLengthGrowth and mean weight change in
7 :     //interpWeightGrowth to calculate lgrowth and wgrowth.
8 :     void Grower::implementGrowth(int area, const PopInfoVector& NumberInArea,
9 :     const LengthGroupDivision* const Lengths) {
10 :    
11 :     int lgroup, j, inarea = this->areaNum(area);
12 :     double meanw, tmppart3, tmpweight;
13 :     double tmpMult = growthcalc->getMult();
14 :     double tmpPower = growthcalc->getPower();
15 :     double tmpDl = 1.0 / Lengths->dl(); //JMB no need to check zero here
16 :    
17 :     for (lgroup = 0; lgroup < Lengths->numLengthGroups(); lgroup++) {
18 :     part3 = 1.0;
19 :     growth = interpLengthGrowth[inarea][lgroup] * tmpDl;
20 :     if (growth >= maxlengthgroupgrowth)
21 :     growth = double(maxlengthgroupgrowth) - 0.1;
22 :     if (growth < verysmall)
23 :     growth = 0.0;
24 :     alpha = beta * growth / (maxlengthgroupgrowth - growth);
25 :     for (j = 0; j < maxlengthgroupgrowth; j++)
26 :     part3 *= (alpha + beta + double(j));
27 :    
28 :     tmppart3 = 1.0 / part3;
29 :     part4[1] = alpha;
30 :     if (maxlengthgroupgrowth > 1)
31 :     for (j = 2; j <= maxlengthgroupgrowth; j++)
32 :     part4[j] = part4[j - 1] * (j - 1 + alpha);
33 :    
34 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
35 :     (*lgrowth[inarea])[j][lgroup] = part1[j] * part2[j] * tmppart3 * part4[j];
36 :    
37 :     switch (functionnumber) {
38 :     case 1:
39 :     case 2:
40 :     case 3:
41 :     case 4:
42 :     case 5:
43 :     case 6:
44 :     case 7:
45 :     case 9:
46 :     meanw = 0.0;
47 :     tmpweight = (NumberInArea[lgroup].W * tmpPower * Lengths->dl()) / Lengths->meanLength(lgroup);
48 :     for (j = 0; j <= maxlengthgroupgrowth; j++) {
49 :     (*wgrowth[inarea])[j][lgroup] = tmpweight * j;
50 :     meanw += (*wgrowth[inarea])[j][lgroup] * (*lgrowth[inarea])[j][lgroup];
51 :     }
52 :    
53 :     tmpweight = interpWeightGrowth[inarea][lgroup] - meanw;
54 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
55 :     (*wgrowth[inarea])[j][lgroup] += tmpweight;
56 :     break;
57 :     case 8:
58 :     case 10:
59 :     case 11:
60 :     if (lgroup != Lengths->numLengthGroups())
61 :     for (j = 1; j <= maxlengthgroupgrowth; j++)
62 :     (*wgrowth[inarea])[j][lgroup] = tmpMult * (pow(Lengths->meanLength(lgroup + j), tmpPower) - pow(Lengths->meanLength(lgroup), tmpPower));
63 :     break;
64 :     default:
65 :     handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);
66 :     break;
67 :     }
68 :     }
69 :     }
70 :    
71 :     //Uses only the length increase in interpLengthGrowth to calculate lgrowth.
72 :     void Grower::implementGrowth(int area, const LengthGroupDivision* const Lengths) {
73 :    
74 :     int lgroup, j, inarea = this->areaNum(area);
75 :     double tmppart3;
76 :     double tmpDl = 1.0 / Lengths->dl(); //JMB no need to check zero here
77 :    
78 :     for (lgroup = 0; lgroup < Lengths->numLengthGroups(); lgroup++) {
79 :     part3 = 1.0;
80 :     growth = interpLengthGrowth[inarea][lgroup] * tmpDl;
81 :     if (growth >= maxlengthgroupgrowth)
82 :     growth = double(maxlengthgroupgrowth) - 0.1;
83 :     if (growth < verysmall)
84 :     growth = 0.0;
85 :     alpha = beta * growth / (maxlengthgroupgrowth - growth);
86 :     for (j = 0; j < maxlengthgroupgrowth; j++)
87 :     part3 *= (alpha + beta + double(j));
88 :    
89 :     tmppart3 = 1.0 / part3;
90 :     part4[1] = alpha;
91 :     if (maxlengthgroupgrowth > 1)
92 :     for (j = 2; j <= maxlengthgroupgrowth; j++)
93 :     part4[j] = part4[j - 1] * (j - 1 + alpha);
94 :    
95 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
96 :     (*lgrowth[inarea])[j][lgroup] = part1[j] * part2[j] * tmppart3 * part4[j];
97 :     }
98 :     }

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge