void StageAndPhase::update() { // std::cout << qPrintable(id().label()) << " StageAndPhase::update() A\n"; if (inflow.size() != phaseK) { QString msg("inflow's size (phaseK=%1) does not match the size of the recipient (phaseK=%2)"); throw Exception(msg.arg(inflow.size()).arg(phaseK), this); } if (phaseInflow.size() != k) { QString msg("phaseInflow's size (k=%1) does not match the size of the recipient (k=%2)"); throw Exception(msg.arg(phaseInflow.size()).arg(k), this); } applyInstantMortality(); increment(inflowPending, inflow); latestInflow = inflow; inflowTotal += accum(inflow); increment(phaseInflowPending, phaseInflow); latestPhaseInflow = phaseInflow; phaseInflowTotal += accum(phaseInflow); // It remains to consider cases, when only one time step is zero if (TestNum::eqZero(timeStep) || TestNum::eqZero(phaseTimeStep)) { sum = dd->content() + accum(inflowPending) + accum(phaseInflowPending); outflow.fill(0.); phaseOutflow.fill(0.); growth = 0.; return; } DistributedDelay2D::UpdateParameters p; p.dt1 = timeStep; p.dt2 = phaseTimeStep; p.inflow1 = &inflowPending; p.inflow2 = &phaseInflowPending; dd->update(p); inflowPending.fill(0.); phaseInflowPending.fill(0.); sum = dd->content(); outflow = dd->state().outflow1; phaseOutflow = dd->state().outflow2; outflowTotal += accum(outflow); phaseOutflowTotal += accum(phaseOutflow); growth = dd->state().growthRate; // std::cout << qPrintable(id().label()) << " StageAndPhase::update() Z\n"; }
void SeedBank::update() { //QMessageBox::information(0, "Test", QString::number(density)); applyInstantMortality(); addInflow(); int dayOfYear = calendar->pullVariable<int>("dayOfYear"); dailyEmergenceRatioPotential = lookupEmergence(dayOfYear); cropEffectOnEmergence = calcCropEffectOnEmergence(); dailyEmergenceRatio = dailyEmergenceRatioPotential*cropEffectOnEmergence; dailyEmergenceDensity = dailyEmergenceRatio*density; density -= dailyEmergenceDensity; density *= dailySurvivalRate; if (dayOfYear == 1) { totalEmergenceRatio = dailyEmergenceRatio; totalEmergenceDensity = dailyEmergenceDensity; } else { totalEmergenceRatio += dailyEmergenceRatio; totalEmergenceDensity += dailyEmergenceDensity; } total = density + dormant; //QMessageBox::information(0, "Test", QString::number(density)); }