2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
Assignment 1: Simulating Ecological Homeostasis Background: The Gaia Hypothesis & Daisy World
In the 1970s, James Lovelock and Lynn Margulis developed the Gaia Hypothesis. This is a highly controversial theory which proposes that the global ‘biosphere’ is self-regulating— that ecosystems work to maintain the conditions necessary life to persist on Earth. As a case in point to support his theory, Lovelock observed that the amount of heat arriving from our Sun has increased significantly since the origin of life, but that the tempera- ture of the planet has remained within the limits of hability throughout. How does this homeostasis (loosely translatable as ‘keeping things the same’) occur?
Lovelock argues that the homeostasis is a natural biproduct of complex ecosystems, but this is a very controversial claim, because it seems to contradict classic ideas of evolution being driven by selfish competition and ‘survival of the fittest.’ Lovelock’s theory suggests that instead of competing and ‘being selfish,’ diverse species come to some sort of agreement, whereby they’ll cooperate to make conditions beneficial for all life (and not just themselves). If you are interested to know more, the wikipedia page on the ‘Gaia Hypothesis’ provides some more information including links to further reading.
Debate concerning the Gaia Hypothesis continues today. A computational model known as ‘Daisy World’ has been developed to show how regulation of environmental conditions (such as the temperature of the planet) can happen. The model considers a planet populated by two different types of daisies, black ones and white ones. The black daisies increase the temperature (by a small amount) by absorbing sunlight, and the white ones reflect light back into space, decreasing the local temperature. In this assignment, we will develop a simplified version of Daisy World that only includes the white daisies.
As is common in developing computational models, we will make many simplifying assumptions. We will assume:
1. the daisies grow better at certain temperatures than others;
2. the temperature of the planet is the same everywhere;
3. daisies are the only relevant species that lives on the planet;
4. the carrying capacity (i. e. the number of daisies that are alive at equilibrium) is well approximated as a
function of temperature;
5. when there are no daisies around, it is still possible for a population to grow (we can imagine there are
always seeds in the ground).
Model
Our model will be a continuous-time dynamical system that is described by three differ- ential equations. Each equation describes the dynamics of one of the following variables.
— the normalized population density of daises. 1 means the planet is covered in the maximum possible density of daises and 0 means there are no daisies at all, etc.
– the temperature of the planet (this corresponds in our simplified model to the temperature everywhere)
– an external ‘perturbing’ force to the temperature. This can be conceived of as an increase in the radiation from the star that the planet is orbiting, or any other (combination) of factors that are modifying the planet’s temperature other than the presence of the daisies.
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 1/6
𝑝 𝑦
𝑛
2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
In this assignment, as you follow the instructions, you will build a computational model of this system. By the end of it hopefully you will have gained some insight into one way that biological-feedback can (at least in theory) stabilise environments as claimed by Lovelock and Margulis.
Step 1: Write a function that maps the temperature to the carrying capacity of the daisies.
In our equations, the carrying capacity is written . It describes the equilibrium population density, i. e. what the population density (n) would move toward if everything else were held constant. Assumption 4 tells us that we can is well approximated as some function of temperature ( ):
A typical response of a carrying capacity to an environmental feature such as temperature is a Gaussian function:
In this equation, there are three parameters ( , and ). specifies the height of the curve’s peak; specifies the position of the maximum; and specifies the standard deviation, i. e. the ‘width’ of the curve.
What values for these parameters should we use? is normalized, so the peak of the curve should be 1. Let us assume that the daisies grow best at a temperature of C. and that the standard deviation is 3.
Q1a. Write a Python function that takes y as an argument and returns n. In [1]:
Q1b. To confirm that your function is correct, plot it for suitable values of y.
FOR ALL PLOTS LABEL AXES AND PROVIDE TITLES OR POINTS WILL BE LOST!
In [3]:
Step 2: Describing how daisy density changes over time.
In our model, the population density ( ) changes as a function of the current population density ( ) and the current carrying capacity ( ):
We shall model as always approaching the carrying capacity, with a rate of this approach that is linearly proportional to the difference between the current population density and the carrying capacity. The scale of the response (i. e., the slope of the line), .
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 2/6
𝑛𝑛
𝑏 𝑎𝑐𝑏𝑎
)𝑘,𝑛(𝑔= 𝑡𝑑 𝑛𝑑
𝑜52
𝑛
) 2𝑐2 −(pxe⋅𝑎=)𝑦(𝑓=𝑘 2)𝑏 − 𝑦(
5.0 = 𝑠
𝑐
)𝑦(𝑓 = 𝑘 𝑦𝑘
𝑘
𝑘
𝑛
…ereh seog rewsna b1Q ##
…ereh seog rewsna a1Q ##
2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
Q2a. Write down (in math notation, not code) the differential equation that captures what has just been described above. If it is not clear to you how to do this, think about what a graph of this function should look like. Use pencil and paper to think this through.
Double click on the word ANSWER below, to edit the markdown. Your answer here should sit between the two sets of
to be displayed as latex math. When you’ve written an equation, to see it rendered as math, run the cell (I hit control-enter to do so).
The basics of latex math in markdown can be found here: https://www.latex-tutorial.com/tutorials/amsmath/ (https://www.latex-tutorial.com/tutorials/amsmath/)
Q2b. Translate the above mathematical equation into a Python function that takes two arguments (n and k) and returns the rate at which n changes. In other words, fill in the following blank.
In [ ]:
Q2c. To confirm that your function is working how it should be, plot for an appropriate range of values of n, with k = 0.5.
In [ ]:
Q2d. Super-impose on the same plot g ( n, k ) when k is fixed to one or two other values (you pick the values). In [ ]:
Q2e. In a sentence or two, describe why the above plots confirm that this function is working correctly. DON’T FORGET TO LABEL YOUR PLOTS.
Type Markdown and LaTeX:
Step 3: Describing how temperature changes over time.
The temperature changes at a rate proportional to the sum of (1) the influence of every-thing other than the daisies, which is captured by the variable , and (2) the influence of the daisies. The influence of the daisies will be linearly proportional to their density, giving us the following differential equation,
dndt(n,k):
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 3/6
)𝑘 ,𝑛(𝑔
𝑅𝐸𝑊𝑆𝑁𝐴 = )𝑘,𝑛(𝑔 = 𝑡𝑑 𝑛𝑑
𝑝
2𝛼
…ereh seog rewsna d2Q ##
…ereh seog rewsna c2Q ##
… nruter
fed
…ereh seog rewsna b2Q ##
2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
where is a constant that describes the amount of influence that the daisies have. We’ll assign this parameter a value of , which can be interpreted as saying that when the daisies are at their maximum possible density, they bring the global temperature down by 10 degrees.
Q3. Translate the above Equation into a Python function as you did with the differential equation for . In [7]:
Step 4: Non-daisy influence
Let us imagine that the radiation of the sun is increasing at an increasing rate. This can be described using the following differential equation, where is a constant representing the rate of that increase and represents the amount of time that has passed since the start of the simulation.
Q4. Translate this differential Equation into a Python function as you have done with the differential equations for and .
In [9]:
At this point you should have four Python functions:
def k(…):
“””returns carrying capacity”””
…
def dndt(…):
“””returns rate of change of population density “””
…
def dydt(…):
“””returns rate of temperature change”””
…
def dpdt(…):
“””returns rate of change of non-daisy infl. upon temperature”””
….
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 4/6
𝑡
2.0 = 𝑞
𝑛
𝑡𝑞=)𝑡(h= 𝑡𝑑 𝑝𝑑
𝑛𝑟+𝑝= 𝑡𝑑 𝑦𝑑
…ereh seog rewsna 4Q ##
…ereh seog rewsna 3Q ##
01− = 𝑟 𝑟
𝑦𝑛
2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
Q5. Write a trajectory function that uses these functions to simulate a trajectory from the initial condition that is passed in as an argument.
Your function should use the Euler integration we have learned about in class, and must NOT use an existing library (e.g. scipy) to solve the integration. The functions signature should look like this, where the final argument (‘dur’) indicates the duration of the trajectory to simulate.
def trajectory(init_n, init_y, init_c, dur) :
…
Tips:
Experiment to pick an appropriate time step value.
Be careful to pass time (and not the time step or the iteration count) to dpdt().
Make your code as clear and understandable as you can to improve chances of getting partial credit.
In [ ]:
Step 6: Plotting results and interpretation
Simulate a trajectory that starts with and that runs for 45 time units.
Q6a. On a labelled figure, plot a time-series that shows how the population density changes over the course of the simulation.
In [ ]:
Q6b. On a separate labelled figure, plot a time-series that shows how the temperature changes over the course of the simulation.
In [ ]:
Q6c. Superimposed on the same figure as Q6b, plot a time-series that shows how the temperature would have changed if the daisies had no influence upon temperature. Label which line is which using a legend.
In [ ]:
Q7. Interpret the results. What has happened? What are the striking features about the trajectories? What affects them? What conclusion(s) can we draw from the simulation? Write a short paragraph summarizing your interpretation.
trajectory(init_n, init_y, init_c, dur) :
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 5/6
0 = 0𝑝 = 0𝑦 = 0𝑛
5Q rewsna ot siht etelpmoC ##
…
fed
2020/3/28 Assessment 1 — Daisyworld – Jupyter Notebook
In [ ]:
localhost:8888/notebooks/Downloads/Assessment 1 — Daisyworld.ipynb 6/6