second
This commit is contained in:
parent
5f7fcb96ed
commit
01204dfa2f
34 changed files with 1498 additions and 0 deletions
23
ecology/metabolism.js
Normal file
23
ecology/metabolism.js
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import {KELVIN_OFFSET, clamp} from './units.js';
|
||||
|
||||
const B0 = Object.freeze({ectotherm: 42, endotherm: 310}); // kJ d^-1 at 1 kg, simulator calibration
|
||||
const ACTIVATION_EV = 0.65;
|
||||
const BOLTZMANN_EV = 8.617333262e-5;
|
||||
|
||||
export function ectothermTemperatureMultiplier(temperatureC,referenceC=20){
|
||||
const t=clamp(temperatureC+KELVIN_OFFSET,180,350),ref=referenceC+KELVIN_OFFSET;
|
||||
return Math.exp((-ACTIVATION_EV/BOLTZMANN_EV)*(1/t-1/ref));
|
||||
}
|
||||
export function basalMetabolismKJPerDay(massKg,temperatureC,physiology='ectotherm'){
|
||||
const mass=Math.max(1e-4,massKg),temp=physiology==='ectotherm'?ectothermTemperatureMultiplier(temperatureC):1;
|
||||
return B0[physiology] * Math.pow(mass,.75) * temp;
|
||||
}
|
||||
export function starvationHazardPerDay(energyFraction){
|
||||
if(energyFraction>=.18)return 0;
|
||||
return 0.018 + 0.34*Math.pow((.18-Math.max(0,energyFraction))/.18,2);
|
||||
}
|
||||
export function thermalHazardPerDay(temperatureC,preferredC,toleranceC,physiology='ectotherm'){
|
||||
const excess=Math.max(0,Math.abs(temperatureC-preferredC)-Math.max(1,toleranceC));
|
||||
if(!excess)return 0;
|
||||
return (physiology==='endotherm'?.00025:.0008)*excess*excess;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue