Subversion Repositories public iLand

Rev

Rev 277 | Rev 280 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 277 Rev 278
Line 91... Line 91...
91
        ++current;
91
        ++current;
92
    }
92
    }
93
    ++last; // last points now to the first dead tree
93
    ++last; // last points now to the first dead tree
94
94
95
    // free ressources
95
    // free ressources
96
    mTrees.erase(last, mTrees.end());
-
 
97
    if (mTrees.capacity()>100) {
-
 
98
        if (mTrees.count() / double(mTrees.capacity()) < 0.2) {
-
 
99
            int target_size = mTrees.count()*2;
-
 
100
            qDebug() << "reduce size from "<<mTrees.capacity() << "to" << target_size;
-
 
101
            mTrees.reserve(qMax(target_size, 100));
-
 
-
 
96
    if (last!=mTrees.end()) {
-
 
97
        mTrees.erase(last, mTrees.end());
-
 
98
        if (mTrees.capacity()>100) {
-
 
99
            if (mTrees.count() / double(mTrees.capacity()) < 0.2) {
-
 
100
                int target_size = mTrees.count()*2;
-
 
101
                qDebug() << "reduce size from "<<mTrees.capacity() << "to" << target_size;
-
 
102
                mTrees.reserve(qMax(target_size, 100));
-
 
103
            }
102
        }
104
        }
103
    }
105
    }
104
}
106
}
105
107
106
void ResourceUnit::newYear()
108
void ResourceUnit::newYear()
Line 109... Line 111...
109
    mAggregatedLA = 0.;
111
    mAggregatedLA = 0.;
110
    mAggregatedLR = 0.;
112
    mAggregatedLR = 0.;
111
    mEffectiveArea = 0.;
113
    mEffectiveArea = 0.;
112
    mPixelCount = mStockedPixelCount = 0;
114
    mPixelCount = mStockedPixelCount = 0;
113
    // clear statistics global and per species...
115
    // clear statistics global and per species...
114
}
-
 
115
-
 
-
 
116
    ResourceUnitSpecies *i;
-
 
117
    QVector<ResourceUnitSpecies>::iterator iend = mRUSpecies.end();
-
 
118
    mStatistics.clear();
-
 
119
    for (i=mRUSpecies.begin(); i!=iend; ++i) {
-
 
120
        i->statistics().clear();
-
 
121
        i->statisticsDead().clear();
-
 
122
        i->statisticsMgmt().clear();
-
 
123
    }
116
124
-
 
125
}
117
126
118
/** production() is the "stand-level" part of the biomass production (3PG).
127
/** production() is the "stand-level" part of the biomass production (3PG).
119
    - The amount of radiation intercepted by the stand is calculated
128
    - The amount of radiation intercepted by the stand is calculated
120
    - The 3PG production for each species and ressource unit is invoked  */
129
    - The 3PG production for each species and ressource unit is invoked  */
121
void ResourceUnit::production()
130
void ResourceUnit::production()
122
{
131
{
123
132
124
    if (mAggregatedWLA==0 || mPixelCount==0) {
133
    if (mAggregatedWLA==0 || mPixelCount==0) {
125
        // nothing to do...
134
        // nothing to do...
126
        mStatistics.clear();
-
 
127
        return;
135
        return;
128
    }
136
    }
129
137
130
    // the pixel counters are filled during the height-grid-calculations
138
    // the pixel counters are filled during the height-grid-calculations
131
    mStockedArea = 100. * mStockedPixelCount; // m2 (1 height grid pixel = 10x10m)
139
    mStockedArea = 100. * mStockedPixelCount; // m2 (1 height grid pixel = 10x10m)
Line 154... Line 162...
154
    DebugTimer tw("water:run");
162
    DebugTimer tw("water:run");
155
    mWater->run();
163
    mWater->run();
156
    }
164
    }
157
165
158
    // invoke species specific calculation (3PG)
166
    // invoke species specific calculation (3PG)
159
    //QVector<ResourceUnitSpecies>::iterator i;
-
 
160
    ResourceUnitSpecies *i;
167
    ResourceUnitSpecies *i;
161
    QVector<ResourceUnitSpecies>::iterator iend = mRUSpecies.end();
168
    QVector<ResourceUnitSpecies>::iterator iend = mRUSpecies.end();
162
    mStatistics.clear();
-
 
-
 
169
163
    for (i=mRUSpecies.begin(); i!=iend; ++i) {
170
    for (i=mRUSpecies.begin(); i!=iend; ++i) {
164
        i->calculate();
171
        i->calculate();
165
        i->statistics().clear();
-
 
166
        i->statisticsDead().clear();
-
 
167
        qDebug() << "species" << (*i).species()->id() << "raw_gpp_m2" << i->prod3PG().GPPperArea();
172
        qDebug() << "species" << (*i).species()->id() << "raw_gpp_m2" << i->prod3PG().GPPperArea();
168
    }
173
    }
169
}
174
}
170
175
171
void ResourceUnit::calculateInterceptedArea()
176
void ResourceUnit::calculateInterceptedArea()
Line 183... Line 188...
183
{
188
{
184
    // calculate statistics for all tree species of the ressource unit
189
    // calculate statistics for all tree species of the ressource unit
185
    int c = mRUSpecies.count();
190
    int c = mRUSpecies.count();
186
    for (int i=0;i<c; i++) {
191
    for (int i=0;i<c; i++) {
187
        mRUSpecies[i].statisticsDead().calculate(); // calculate the dead trees
192
        mRUSpecies[i].statisticsDead().calculate(); // calculate the dead trees
188
        mRUSpecies[i].updateGWL(); // get sum od dead trees
-
 
-
 
193
        mRUSpecies[i].statisticsMgmt().calculate(); // stats of removed trees
-
 
194
        mRUSpecies[i].updateGWL(); // get sum of dead trees (died + removed)
189
        mRUSpecies[i].statistics().calculate(); // calculate the living (and add removed volume to gwl)
195
        mRUSpecies[i].statistics().calculate(); // calculate the living (and add removed volume to gwl)
190
        mStatistics.add(mRUSpecies[i].statistics());
196
        mStatistics.add(mRUSpecies[i].statistics());
191
    }
197
    }
192
    mStatistics.calculate(); // aggreagte on stand level
198
    mStatistics.calculate(); // aggreagte on stand level
193
}
199
}
Line 198... Line 204...
198
    // clear statistics (ru-level and ru-species level)
204
    // clear statistics (ru-level and ru-species level)
199
    mStatistics.clear();
205
    mStatistics.clear();
200
    for (int i=0;i<mRUSpecies.count();i++) {
206
    for (int i=0;i<mRUSpecies.count();i++) {
201
        mRUSpecies[i].statistics().clear();
207
        mRUSpecies[i].statistics().clear();
202
        mRUSpecies[i].statisticsDead().clear();
208
        mRUSpecies[i].statisticsDead().clear();
-
 
209
        mRUSpecies[i].statisticsMgmt().clear();
203
    }
210
    }
204
211
205
    // add all trees to the statistics objects of the species
212
    // add all trees to the statistics objects of the species
206
    foreach(const Tree &t, mTrees) {
213
    foreach(const Tree &t, mTrees) {
207
        if (!t.isDead())
214
        if (!t.isDead())