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 4 - (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 : ulcessvp 2 double pow_L; double aux;
18 :     int numLenGr = Lengths->numLengthGroups();;
19 :    
20 :     switch (functionnumber) {
21 :     case 1:
22 :     case 2:
23 :     case 3:
24 :     case 4:
25 :     case 5:
26 :     case 6:
27 :     case 7:
28 :     case 9: break;
29 :     case 8:
30 :     case 10:
31 :     case 11:
32 :     if (vector_OK == 0)
33 :     {
34 :     meanlength_vectorPow = Lengths->meanlengthvecPow_initilize(maxlengthgroupgrowth,tmpPower);
35 :     vector_OK = 1;
36 :     }
37 :     break;
38 :     default: break;
39 :     }
40 :    
41 :    
42 :     for (lgroup = 0; lgroup < numLenGr; lgroup++) {
43 :    
44 : agomez 1 part3 = 1.0;
45 :     growth = interpLengthGrowth[inarea][lgroup] * tmpDl;
46 :     if (growth >= maxlengthgroupgrowth)
47 :     growth = double(maxlengthgroupgrowth) - 0.1;
48 :     if (growth < verysmall)
49 :     growth = 0.0;
50 :     alpha = beta * growth / (maxlengthgroupgrowth - growth);
51 :     for (j = 0; j < maxlengthgroupgrowth; j++)
52 :     part3 *= (alpha + beta + double(j));
53 :    
54 :     tmppart3 = 1.0 / part3;
55 :     part4[1] = alpha;
56 :     if (maxlengthgroupgrowth > 1)
57 :     for (j = 2; j <= maxlengthgroupgrowth; j++)
58 :     part4[j] = part4[j - 1] * (j - 1 + alpha);
59 :    
60 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
61 : ulcessvp 4 (*lgrowth)[j][lgroup] = part1[j] * part2[j] * tmppart3 * part4[j];
62 : agomez 1
63 :     switch (functionnumber) {
64 :     case 1:
65 :     case 2:
66 :     case 3:
67 :     case 4:
68 :     case 5:
69 :     case 6:
70 :     case 7:
71 :     case 9:
72 :     meanw = 0.0;
73 :     tmpweight = (NumberInArea[lgroup].W * tmpPower * Lengths->dl()) / Lengths->meanLength(lgroup);
74 :     for (j = 0; j <= maxlengthgroupgrowth; j++) {
75 : ulcessvp 4 (*wgrowth)[j][lgroup] = tmpweight * j;
76 :     meanw += (*wgrowth)[j][lgroup] * (*lgrowth)[j][lgroup];
77 : agomez 1 }
78 :    
79 :     tmpweight = interpWeightGrowth[inarea][lgroup] - meanw;
80 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
81 : ulcessvp 2 {
82 : ulcessvp 4 aux = (*wgrowth)[j][lgroup];
83 :     (*wgrowth)[j][lgroup] = aux + tmpweight;
84 : ulcessvp 2 }
85 : agomez 1 break;
86 :     case 8:
87 :     case 10:
88 :     case 11:
89 : ulcessvp 2 pow_L = meanlength_vectorPow[lgroup];
90 : ulcessvp 4 if (lgroup != numLenGr) //FIXME for (lgroup = 0; ¿¿¿lgroup < numLenGr????; lgroup++)
91 : agomez 1 for (j = 1; j <= maxlengthgroupgrowth; j++)
92 : ulcessvp 4 (*wgrowth)[j][lgroup] = tmpMult * (meanlength_vectorPow[lgroup + j] - pow_L);
93 : agomez 1 break;
94 :     default:
95 :     handle.logMessage(LOGFAIL, "Error in grower - unrecognised growth function", functionnumber);
96 :     break;
97 :     }
98 :     }
99 :     }
100 :    
101 :     //Uses only the length increase in interpLengthGrowth to calculate lgrowth.
102 :     void Grower::implementGrowth(int area, const LengthGroupDivision* const Lengths) {
103 :    
104 :     int lgroup, j, inarea = this->areaNum(area);
105 :     double tmppart3;
106 :     double tmpDl = 1.0 / Lengths->dl(); //JMB no need to check zero here
107 :    
108 :     for (lgroup = 0; lgroup < Lengths->numLengthGroups(); lgroup++) {
109 :     part3 = 1.0;
110 :     growth = interpLengthGrowth[inarea][lgroup] * tmpDl;
111 :     if (growth >= maxlengthgroupgrowth)
112 :     growth = double(maxlengthgroupgrowth) - 0.1;
113 :     if (growth < verysmall)
114 :     growth = 0.0;
115 :     alpha = beta * growth / (maxlengthgroupgrowth - growth);
116 :     for (j = 0; j < maxlengthgroupgrowth; j++)
117 :     part3 *= (alpha + beta + double(j));
118 :    
119 :     tmppart3 = 1.0 / part3;
120 :     part4[1] = alpha;
121 :     if (maxlengthgroupgrowth > 1)
122 :     for (j = 2; j <= maxlengthgroupgrowth; j++)
123 :     part4[j] = part4[j - 1] * (j - 1 + alpha);
124 :    
125 :     for (j = 0; j <= maxlengthgroupgrowth; j++)
126 : ulcessvp 4 (lgrowth[inarea])[j][lgroup] = part1[j] * part2[j] * tmppart3 * part4[j];
127 : agomez 1 }
128 :     }

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

Powered By FusionForge