-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from pedro-andrade-inpe/master
Updates to TerraME 2.0 (DataFrame).
- Loading branch information
Showing
5 changed files
with
113 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
version = "0.3.1" | ||
version = "0.4" | ||
license = "GPL" | ||
package = "sci" | ||
title = "Scientific and Mathematical Functions" | ||
date = "9 May 2016" | ||
date = "6 Feb 2017" | ||
depends = "terrame (>= 2.0)" | ||
authors = "Gilberto Camara" | ||
contact = "[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
-- @example Predator-Prey Oscillations on the Kaibab Plateau. | ||
-- Ford, F. A. (1999). Modeling the environment: an introduction to system | ||
-- dynamics models of environmental systems. Island Press. | ||
|
||
import("sci") | ||
|
||
local deerKilledPerPredatorPerYear = Spline{ | ||
points = DataFrame{ | ||
x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100}, | ||
y = {0, 15, 25, 30, 35, 40, 45, 50, 55, 60, 60, 60} | ||
} | ||
} | ||
|
||
local deerNetBirthRate = Spline{ | ||
points = DataFrame{ | ||
x = { 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0}, | ||
y = {-0.4, -0.2, 0.0, 0.2, 0.4, 0.45, 0.5, 0.5} | ||
} | ||
} | ||
|
||
local predatorsNetBirthRate = Spline{ | ||
points = DataFrame{ | ||
x = { 0.00, 10.00, 20.00, 30.00, 40.00, 50.00, 60.00, 70.00, 80.00}, | ||
y = {-0.60, -0.45, -0.30, -0.15, 0.00, 0.15, 0.30, 0.40, 0.45} | ||
} | ||
} | ||
|
||
PredatorPreyFord = Model{ | ||
deer = 4000, -- population of deer | ||
predator = 46, -- number of predators, | ||
finalTime = 1932, | ||
init = function(model) | ||
model.prey = function(self) | ||
return self.deer / 80 | ||
end | ||
|
||
model.chart = Chart{ | ||
target = model, | ||
select = {"predator", "prey"}, | ||
title = "Predator and Prey Populations" | ||
} | ||
|
||
model.timer = Timer{ | ||
Event{start = 1901, action = function() | ||
local deer_density = model.deer / 800 | ||
local dkpppy = deerKilledPerPredatorPerYear:value(deer_density) | ||
|
||
local ffnm = 1 -- fraction forage need met | ||
|
||
model.deer = model.deer + model.deer * deerNetBirthRate:value(ffnm) - model.predator * dkpppy | ||
|
||
-- the density needs to be recomputed before updating the amount of predators | ||
deer_density = model.deer / 800 | ||
dkpppy = deerKilledPerPredatorPerYear:value(deer_density) | ||
model.predator = model.predator + model.predator * predatorsNetBirthRate:value(dkpppy) | ||
|
||
end}, | ||
Event{start = 1900, action = model.chart} | ||
} | ||
end | ||
} | ||
|
||
PredatorPreyFord:run() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters