diff --git a/log/Dam-chart-1.bmp b/log/Dam-chart-1.bmp new file mode 100644 index 0000000..dd3ddef Binary files /dev/null and b/log/Dam-chart-1.bmp differ diff --git a/log/Dam-chart-2.bmp b/log/Dam-chart-2.bmp new file mode 100644 index 0000000..bceef4a Binary files /dev/null and b/log/Dam-chart-2.bmp differ diff --git a/lua/.terrametmp_DeI4D/Coffee-chart-1.bmp b/lua/.terrametmp_DeI4D/Coffee-chart-1.bmp new file mode 100644 index 0000000..be486ea Binary files /dev/null and b/lua/.terrametmp_DeI4D/Coffee-chart-1.bmp differ diff --git a/lua/.terrametmp_DeI4D/Daisyworld-chart-1.bmp b/lua/.terrametmp_DeI4D/Daisyworld-chart-1.bmp new file mode 100644 index 0000000..473084d Binary files /dev/null and b/lua/.terrametmp_DeI4D/Daisyworld-chart-1.bmp differ diff --git a/lua/.terrametmp_DeI4D/Daisyworld-chart-2.bmp b/lua/.terrametmp_DeI4D/Daisyworld-chart-2.bmp new file mode 100644 index 0000000..5f806b2 Binary files /dev/null and b/lua/.terrametmp_DeI4D/Daisyworld-chart-2.bmp differ diff --git a/lua/.terrametmp_DeI4D/Daisyworld-chart-3.bmp b/lua/.terrametmp_DeI4D/Daisyworld-chart-3.bmp new file mode 100644 index 0000000..e8ba5dc Binary files /dev/null and b/lua/.terrametmp_DeI4D/Daisyworld-chart-3.bmp differ diff --git a/lua/.terrametmp_DeI4D/Daisyworld-chart-4.bmp b/lua/.terrametmp_DeI4D/Daisyworld-chart-4.bmp new file mode 100644 index 0000000..dd79fb4 Binary files /dev/null and b/lua/.terrametmp_DeI4D/Daisyworld-chart-4.bmp differ diff --git a/lua/.terrametmp_DeI4D/Dam-chart-1.bmp b/lua/.terrametmp_DeI4D/Dam-chart-1.bmp new file mode 100644 index 0000000..dd3ddef Binary files /dev/null and b/lua/.terrametmp_DeI4D/Dam-chart-1.bmp differ diff --git a/lua/.terrametmp_DeI4D/Lorenz-chart-2.bmp b/lua/.terrametmp_DeI4D/Lorenz-chart-2.bmp new file mode 100644 index 0000000..bafd782 Binary files /dev/null and b/lua/.terrametmp_DeI4D/Lorenz-chart-2.bmp differ diff --git a/lua/.terrametmp_DeI4D/SIR-chart-1.bmp b/lua/.terrametmp_DeI4D/SIR-chart-1.bmp new file mode 100644 index 0000000..14d5969 Binary files /dev/null and b/lua/.terrametmp_DeI4D/SIR-chart-1.bmp differ diff --git a/lua/.terrametmp_DeI4D/SIR-chart-2.bmp b/lua/.terrametmp_DeI4D/SIR-chart-2.bmp new file mode 100644 index 0000000..f1524d3 Binary files /dev/null and b/lua/.terrametmp_DeI4D/SIR-chart-2.bmp differ diff --git a/lua/.terrametmp_DeI4D/Yeast-chart-1.bmp b/lua/.terrametmp_DeI4D/Yeast-chart-1.bmp new file mode 100644 index 0000000..462e161 Binary files /dev/null and b/lua/.terrametmp_DeI4D/Yeast-chart-1.bmp differ diff --git a/lua/.terrametmp_DeI4D/chaotic-growth.png b/lua/.terrametmp_DeI4D/chaotic-growth.png new file mode 100644 index 0000000..9bd9b0b Binary files /dev/null and b/lua/.terrametmp_DeI4D/chaotic-growth.png differ diff --git a/lua/.terrametmp_DeI4D/examples-coffee-scenarios-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-coffee-scenarios-chart-1-end.png new file mode 100644 index 0000000..955eaf1 Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-coffee-scenarios-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/examples-infection-scenarios-1-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-infection-scenarios-1-chart-1-end.png new file mode 100644 index 0000000..b0f5027 Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-infection-scenarios-1-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/examples-infection-scenarios-2-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-infection-scenarios-2-chart-1-end.png new file mode 100644 index 0000000..79409ba Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-infection-scenarios-2-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/examples-infection-scenarios-3-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-infection-scenarios-3-chart-1-end.png new file mode 100644 index 0000000..ffc77b2 Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-infection-scenarios-3-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/examples-population-scenarios-1-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-population-scenarios-1-chart-1-end.png new file mode 100644 index 0000000..2fbb34e Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-population-scenarios-1-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/examples-population-scenarios-2-chart-1-end.png b/lua/.terrametmp_DeI4D/examples-population-scenarios-2-chart-1-end.png new file mode 100644 index 0000000..01f3449 Binary files /dev/null and b/lua/.terrametmp_DeI4D/examples-population-scenarios-2-chart-1-end.png differ diff --git a/lua/.terrametmp_DeI4D/monolake-1.png b/lua/.terrametmp_DeI4D/monolake-1.png new file mode 100644 index 0000000..5ad3c01 Binary files /dev/null and b/lua/.terrametmp_DeI4D/monolake-1.png differ diff --git a/lua/.terrametmp_DeI4D/monolake-2.png b/lua/.terrametmp_DeI4D/monolake-2.png new file mode 100644 index 0000000..fc59ee1 Binary files /dev/null and b/lua/.terrametmp_DeI4D/monolake-2.png differ diff --git a/lua/.terrametmp_DeI4D/population-growth.png b/lua/.terrametmp_DeI4D/population-growth.png new file mode 100644 index 0000000..1dba29b Binary files /dev/null and b/lua/.terrametmp_DeI4D/population-growth.png differ diff --git a/lua/.terrametmp_DeI4D/predator-prey-1.png b/lua/.terrametmp_DeI4D/predator-prey-1.png new file mode 100644 index 0000000..f288182 Binary files /dev/null and b/lua/.terrametmp_DeI4D/predator-prey-1.png differ diff --git a/lua/.terrametmp_DeI4D/tub-2.png b/lua/.terrametmp_DeI4D/tub-2.png new file mode 100644 index 0000000..29e0b41 Binary files /dev/null and b/lua/.terrametmp_DeI4D/tub-2.png differ diff --git a/lua/.terrametmp_DeI4D/tub.png b/lua/.terrametmp_DeI4D/tub.png new file mode 100644 index 0000000..b19633b Binary files /dev/null and b/lua/.terrametmp_DeI4D/tub.png differ diff --git a/lua/.terrametmp_DxwSv/Daisyworld-chart-2.bmp b/lua/.terrametmp_DxwSv/Daisyworld-chart-2.bmp new file mode 100644 index 0000000..5f806b2 Binary files /dev/null and b/lua/.terrametmp_DxwSv/Daisyworld-chart-2.bmp differ diff --git a/lua/.terrametmp_DxwSv/Daisyworld-chart-3.bmp b/lua/.terrametmp_DxwSv/Daisyworld-chart-3.bmp new file mode 100644 index 0000000..e8ba5dc Binary files /dev/null and b/lua/.terrametmp_DxwSv/Daisyworld-chart-3.bmp differ diff --git a/lua/.terrametmp_DxwSv/Daisyworld-chart-4.bmp b/lua/.terrametmp_DxwSv/Daisyworld-chart-4.bmp new file mode 100644 index 0000000..dd79fb4 Binary files /dev/null and b/lua/.terrametmp_DxwSv/Daisyworld-chart-4.bmp differ diff --git a/lua/.terrametmp_DxwSv/Lorenz-chart-1.bmp b/lua/.terrametmp_DxwSv/Lorenz-chart-1.bmp new file mode 100644 index 0000000..f43c6f4 Binary files /dev/null and b/lua/.terrametmp_DxwSv/Lorenz-chart-1.bmp differ diff --git a/lua/.terrametmp_DxwSv/Lorenz-chart-2.bmp b/lua/.terrametmp_DxwSv/Lorenz-chart-2.bmp new file mode 100644 index 0000000..bafd782 Binary files /dev/null and b/lua/.terrametmp_DxwSv/Lorenz-chart-2.bmp differ diff --git a/lua/.terrametmp_DxwSv/SIR-chart-1.bmp b/lua/.terrametmp_DxwSv/SIR-chart-1.bmp new file mode 100644 index 0000000..14d5969 Binary files /dev/null and b/lua/.terrametmp_DxwSv/SIR-chart-1.bmp differ diff --git a/lua/.terrametmp_DxwSv/SIR-chart-2.bmp b/lua/.terrametmp_DxwSv/SIR-chart-2.bmp new file mode 100644 index 0000000..f1524d3 Binary files /dev/null and b/lua/.terrametmp_DxwSv/SIR-chart-2.bmp differ diff --git a/lua/.terrametmp_DxwSv/Yeast-chart-1.bmp b/lua/.terrametmp_DxwSv/Yeast-chart-1.bmp new file mode 100644 index 0000000..462e161 Binary files /dev/null and b/lua/.terrametmp_DxwSv/Yeast-chart-1.bmp differ diff --git a/lua/.terrametmp_DxwSv/examples-coffee-scenarios-chart-1-end.png b/lua/.terrametmp_DxwSv/examples-coffee-scenarios-chart-1-end.png new file mode 100644 index 0000000..955eaf1 Binary files /dev/null and b/lua/.terrametmp_DxwSv/examples-coffee-scenarios-chart-1-end.png differ diff --git a/lua/.terrametmp_DxwSv/examples-infection-scenarios-1-chart-1-end.png b/lua/.terrametmp_DxwSv/examples-infection-scenarios-1-chart-1-end.png new file mode 100644 index 0000000..b0f5027 Binary files /dev/null and b/lua/.terrametmp_DxwSv/examples-infection-scenarios-1-chart-1-end.png differ diff --git a/lua/.terrametmp_DxwSv/examples-population-scenarios-2-chart-1-end.png b/lua/.terrametmp_DxwSv/examples-population-scenarios-2-chart-1-end.png new file mode 100644 index 0000000..01f3449 Binary files /dev/null and b/lua/.terrametmp_DxwSv/examples-population-scenarios-2-chart-1-end.png differ diff --git a/lua/.terrametmp_DxwSv/homeostasis.png b/lua/.terrametmp_DxwSv/homeostasis.png new file mode 100644 index 0000000..a3831f3 Binary files /dev/null and b/lua/.terrametmp_DxwSv/homeostasis.png differ diff --git a/lua/.terrametmp_DxwSv/limited-growth.png b/lua/.terrametmp_DxwSv/limited-growth.png new file mode 100644 index 0000000..82dbbec Binary files /dev/null and b/lua/.terrametmp_DxwSv/limited-growth.png differ diff --git a/lua/.terrametmp_DxwSv/monolake-1.png b/lua/.terrametmp_DxwSv/monolake-1.png new file mode 100644 index 0000000..5ad3c01 Binary files /dev/null and b/lua/.terrametmp_DxwSv/monolake-1.png differ diff --git a/lua/.terrametmp_DxwSv/monolake-2.png b/lua/.terrametmp_DxwSv/monolake-2.png new file mode 100644 index 0000000..fc59ee1 Binary files /dev/null and b/lua/.terrametmp_DxwSv/monolake-2.png differ diff --git a/lua/.terrametmp_DxwSv/population-growth.png b/lua/.terrametmp_DxwSv/population-growth.png new file mode 100644 index 0000000..1dba29b Binary files /dev/null and b/lua/.terrametmp_DxwSv/population-growth.png differ diff --git a/lua/.terrametmp_DxwSv/predator-prey-1.png b/lua/.terrametmp_DxwSv/predator-prey-1.png new file mode 100644 index 0000000..f288182 Binary files /dev/null and b/lua/.terrametmp_DxwSv/predator-prey-1.png differ diff --git a/lua/.terrametmp_DxwSv/tub-2.png b/lua/.terrametmp_DxwSv/tub-2.png new file mode 100644 index 0000000..29e0b41 Binary files /dev/null and b/lua/.terrametmp_DxwSv/tub-2.png differ diff --git a/lua/.terrametmp_DxwSv/tub.png b/lua/.terrametmp_DxwSv/tub.png new file mode 100644 index 0000000..b19633b Binary files /dev/null and b/lua/.terrametmp_DxwSv/tub.png differ diff --git a/lua/.terrametmp_GtFj1/Coffee-chart-1.bmp b/lua/.terrametmp_GtFj1/Coffee-chart-1.bmp new file mode 100644 index 0000000..be486ea Binary files /dev/null and b/lua/.terrametmp_GtFj1/Coffee-chart-1.bmp differ diff --git a/lua/.terrametmp_GtFj1/Daisyworld-chart-1.bmp b/lua/.terrametmp_GtFj1/Daisyworld-chart-1.bmp new file mode 100644 index 0000000..473084d Binary files /dev/null and b/lua/.terrametmp_GtFj1/Daisyworld-chart-1.bmp differ diff --git a/lua/.terrametmp_GtFj1/Daisyworld-chart-2.bmp b/lua/.terrametmp_GtFj1/Daisyworld-chart-2.bmp new file mode 100644 index 0000000..5f806b2 Binary files /dev/null and b/lua/.terrametmp_GtFj1/Daisyworld-chart-2.bmp differ diff --git a/lua/.terrametmp_GtFj1/chaotic-growth.png b/lua/.terrametmp_GtFj1/chaotic-growth.png new file mode 100644 index 0000000..9bd9b0b Binary files /dev/null and b/lua/.terrametmp_GtFj1/chaotic-growth.png differ diff --git a/lua/.terrametmp_MtwRP/Coffee-chart-1.bmp b/lua/.terrametmp_MtwRP/Coffee-chart-1.bmp new file mode 100644 index 0000000..be486ea Binary files /dev/null and b/lua/.terrametmp_MtwRP/Coffee-chart-1.bmp differ diff --git a/lua/.terrametmp_MtwRP/Daisyworld-chart-1.bmp b/lua/.terrametmp_MtwRP/Daisyworld-chart-1.bmp new file mode 100644 index 0000000..473084d Binary files /dev/null and b/lua/.terrametmp_MtwRP/Daisyworld-chart-1.bmp differ diff --git a/lua/.terrametmp_MtwRP/Daisyworld-chart-2.bmp b/lua/.terrametmp_MtwRP/Daisyworld-chart-2.bmp new file mode 100644 index 0000000..5f806b2 Binary files /dev/null and b/lua/.terrametmp_MtwRP/Daisyworld-chart-2.bmp differ diff --git a/lua/.terrametmp_MtwRP/Daisyworld-chart-3.bmp b/lua/.terrametmp_MtwRP/Daisyworld-chart-3.bmp new file mode 100644 index 0000000..e8ba5dc Binary files /dev/null and b/lua/.terrametmp_MtwRP/Daisyworld-chart-3.bmp differ diff --git a/lua/.terrametmp_MtwRP/Daisyworld-chart-4.bmp b/lua/.terrametmp_MtwRP/Daisyworld-chart-4.bmp new file mode 100644 index 0000000..dd79fb4 Binary files /dev/null and b/lua/.terrametmp_MtwRP/Daisyworld-chart-4.bmp differ diff --git a/lua/.terrametmp_MtwRP/examples-infection-scenarios-3-chart-1-end.png b/lua/.terrametmp_MtwRP/examples-infection-scenarios-3-chart-1-end.png new file mode 100644 index 0000000..ffc77b2 Binary files /dev/null and b/lua/.terrametmp_MtwRP/examples-infection-scenarios-3-chart-1-end.png differ diff --git a/lua/.terrametmp_MtwRP/examples-population-scenarios-1-chart-1-end.png b/lua/.terrametmp_MtwRP/examples-population-scenarios-1-chart-1-end.png new file mode 100644 index 0000000..2fbb34e Binary files /dev/null and b/lua/.terrametmp_MtwRP/examples-population-scenarios-1-chart-1-end.png differ diff --git a/lua/.terrametmp_MtwRP/examples-population-scenarios-2-chart-1-end.png b/lua/.terrametmp_MtwRP/examples-population-scenarios-2-chart-1-end.png new file mode 100644 index 0000000..01f3449 Binary files /dev/null and b/lua/.terrametmp_MtwRP/examples-population-scenarios-2-chart-1-end.png differ diff --git a/lua/.terrametmp_MtwRP/homeostasis.png b/lua/.terrametmp_MtwRP/homeostasis.png new file mode 100644 index 0000000..a3831f3 Binary files /dev/null and b/lua/.terrametmp_MtwRP/homeostasis.png differ diff --git a/lua/.terrametmp_MtwRP/limited-growth.png b/lua/.terrametmp_MtwRP/limited-growth.png new file mode 100644 index 0000000..82dbbec Binary files /dev/null and b/lua/.terrametmp_MtwRP/limited-growth.png differ diff --git a/lua/.terrametmp_MtwRP/monolake-2.png b/lua/.terrametmp_MtwRP/monolake-2.png new file mode 100644 index 0000000..fc59ee1 Binary files /dev/null and b/lua/.terrametmp_MtwRP/monolake-2.png differ diff --git a/lua/.terrametmp_MtwRP/population-growth.png b/lua/.terrametmp_MtwRP/population-growth.png new file mode 100644 index 0000000..1dba29b Binary files /dev/null and b/lua/.terrametmp_MtwRP/population-growth.png differ diff --git a/lua/.terrametmp_MtwRP/predator-prey-1.png b/lua/.terrametmp_MtwRP/predator-prey-1.png new file mode 100644 index 0000000..f288182 Binary files /dev/null and b/lua/.terrametmp_MtwRP/predator-prey-1.png differ diff --git a/lua/.terrametmp_MtwRP/predator-prey-2.png b/lua/.terrametmp_MtwRP/predator-prey-2.png new file mode 100644 index 0000000..f3b48bf Binary files /dev/null and b/lua/.terrametmp_MtwRP/predator-prey-2.png differ diff --git a/lua/Dam.lua b/lua/Dam.lua new file mode 100644 index 0000000..2f3ff13 --- /dev/null +++ b/lua/Dam.lua @@ -0,0 +1,67 @@ +--- A water in the dam model. +-- @arg data.water The initial stock of water measured in m³. The initial value is 5,000,000,000. +-- @arg data.inFlow1 The flow of water into the dam each first season. The default is 2e9. +-- @arg data.inFlow2 The flow of water into the dam each second season. The default is 2e9. +-- @arg data.population The total amount of inhabitants. The default value is 1e5. +-- @arg data.consumePerPerson The total amount of water per inhabitant. The default value is 10. +-- @arg data.currentYear Year 1995. +-- @arg data.kWh2cubicMeters The total amount of kWh produced by cubic meters. The default value is 100. +-- @arg data.growth The comsumption amount of kWh produced by cubic meters. The default value is 100. +-- @arg data.countYear The flag in which defines whether count or not the years . The default value is false. +-- @arg data.changedYear The year in which water values change. The default value is 1970. +-- @arg data.finalTime The final time of the simulation in months. The default value is 1000. +Dam = Model{ + water = 5e9, + inFlow1 = 2e9, + inFlow2 = 1.5e9, + population = 1e5, + consumePerPerson = 10, + kWh2cubicMeters = 100, + growth = 0.05, + countYear = false, + changedYear= 1970, + currentYear = 1950, + finalTime = 1000, + execute = function(self) -- each time step + local outFlow = self.population * self.consumePerPerson * self.kWh2cubicMeters -- update outflow + self.water = self.water - outFlow -- update water + --local abc = 5 + + if self.water <= 0 then -- water amount less than zero + self.water = 0 + --print(self.timer:getTime()) + elseif self.water > 5e9 then-- water amount more than dam capacity + self.water = 5e9 + end + if (self.countYear == true) then + if (self.timer:getTime()%12 == 0) then -- every each year increments current year + self.currentYear = self.currentYear + 1 + if (self.currentYear == self.changedYear) then -- when changedYear equal to currentYear + self.inFlow1 = self.inFlow1/2 + self.inFlow2 = self.inFlow2/2 + end + end + end + end, + init = function (self) + self.chart = Chart{ + target = self, + select = "water" + } + + self.timer = Timer{ + Event{action = self, priority = 'high'}, + Event{period = 12, action = function() + self.water = self.water + self.inFlow1 -- first season in first semester + end}, + Event{start = 7, period = 12, action = function() + self.water = self.water + self.inFlow2 -- second season in second semester + end}, + Event{start = 12, period = 12, action = function() + self.consumePerPerson = self.consumePerPerson*(1 + self.growth) -- every year add 5% + end}, + Event{action = self.chart} + } + end +} + diff --git a/tests/Dam.lua b/tests/Dam.lua new file mode 100644 index 0000000..f23d7fa --- /dev/null +++ b/tests/Dam.lua @@ -0,0 +1,18 @@ +-- Test file for Dam.lua +-- Author: Gilberto Camara and Pedro R. Andrade + +return{ + Dam = function(unitTest) + local model = Dam{} + + model:run() + + unitTest:assertSnapshot(model.chart, "Dam-chart-1.bmp",0.15) + + model = Dam{countYear = true} + + model:run() + unitTest:assertSnapshot(model.chart, "Dam-chart-2.bmp",0.12) + end, +} +