void FunctionalResponseGB::update() { if (egestionRatio < 0. || egestionRatio >= 1.) { QString msg("Illegal value for egestionRatio (%1)"); throw Exception(msg.arg(egestionRatio)); } // Compute total supply (i.e., total kill) totalDemand = costOnRespiration ? (demand + respiration)/(1-conversionCost) : demand/(1-conversionCost) + respiration; totalDemand /= (1. - egestionRatio); totalSupply = GBFuncResp(totalDemand, apparency*resourceDensity); // Allocate total supply supply = totalSupply; egestion = supply*egestionRatio; supply -= egestion; supply -= costOnRespiration ? respiration/(1-conversionCost) : respiration; if (supply < 0.) { sdRatio = 0.; if (truncateSupply) supply = 0.; } else { sdRatio = divBounded(supply, demand, 1.); TestNum::snapToZero(sdRatio); } // Update host-parasitoid variables if (supply > 0) { attacksPerHost = resourceDensity > 0. ? supply/resourceDensity : 0.; propHostsAttacked = 1. - exp(-attacksPerHost); numHostsAttacked = resourceDensity*propHostsAttacked; } else { attacksPerHost = propHostsAttacked = numHostsAttacked = 0.; } }
void FunctionalResponseGB::update() { if (egestionRatio < 0. || egestionRatio >= 1.) { QString msg("Illegal value for egestionRatio (%1)"); throw Exception(msg.arg(egestionRatio)); } totalDemand = (demand + respiration)/(1. - egestionRatio); totalSupply = GBFuncResp(totalDemand, apparancy*resourceDensity); if (totalSupply > resourceDensity) totalSupply = resourceDensity; double netSupply = totalSupply*(1. - egestionRatio); egestion = totalSupply*egestionRatio; if (netSupply <= respiration) { supply = sdRatio = 0; } else { supply = netSupply - respiration; sdRatio = divBounded(supply, demand, 1.); TestNum::snapToZero(sdRatio); } // Update host-parasitoid variables attacksPerHost = resourceDensity > 0. ? supply/resourceDensity : 0.; propHostsAttacked = 1. - exp(-attacksPerHost); numHostsAttacked = resourceDensity*propHostsAttacked; }