Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Biology Extra IA

Possible Ideas
- Magnetotactic Bacteria
- Impact of magnetic fields on insects
- The effects of removing Cane Toads
- Biological methods of plant protection.
- Evolution of Invertebrate symmetry/Asymmetry
- Simulating community ecology with computer models
- Natural Selection modelled with a computer simulation
- The maths behind population Curves
- Evolutionary Game theory with its links to computer science

Code
from numpy import *
from pyqtgraph import PlotWidget, plot
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QIcon, QPixmap
import math

class Ui_MainWindow(object):
global rvalue
global pvalue
global kvalue

def prey(self):
self.graphicsView.clear()
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 18, 19, 20, 21, 22, 23]
b = sin(a)
c = sin(a)+1

predator = [4.742, 3.258, 1.955, 1.153, 1.048, 1.666, 2.855,


4.325, 5.715, 6.685, 6.990, 6.577, 5.525, 4.100, 2.650, 1.531,
1.016, 1.232, 2.126, 3.520, 4.973, 6.204, 6.906, 7.001]
prey = [1.376, 1.624, 1.854, 1.974, 1.992, 1.889, 1.691,
1.446, 1.214, 1.053, 1.001, 1.071, 1.246, 1.483, 1.725, 1.912,
1.997, 1.961, 1.812, 1.602, 1.350, 1.133, 1.017, 1.015]

line2 = self.graphicsView.plot(a, predator, pen='g',


symbol='x', symbolPen='g', symbolBrush=0.2, name='green')
line3 = self.graphicsView.plot(a, prey, pen='r', symbol='x',
symbolPen='r', symbolBrush=0.2, name='red')

def generate_graph(self):
pValue = int(self.tempSlider.value())
kvalue = int(self.litterSlider.value())
Shay Brokensha - 2022
rvalue = int(self.foodSlider.value())
rValue = rvalue/100
kValue = kvalue/100
#rValue = -rVAlue
self.graphicsView.clear()

a = rValue*(kValue/(1+(2.7)**(-0+5)))+pValue
b = rValue*(kValue/(1+(2.7)**(-1+5)))+pValue
c = rValue*(kValue/(1+(2.7)**(-2+5)))+pValue
d = rValue*(kValue/(1+(2.7)**(-3+5)))+pValue
e = rValue*(kValue/(1+(2.7)**(-4+5)))+pValue
f = rValue*(kValue/(1+(2.7)**(-5+5)))+pValue
g = rValue*(kValue/(1+(2.7)**(-6+5)))+pValue
h = rValue*(kValue/(1+(2.7)**(-7+5)))+pValue
i = rValue*(kValue/(1+(2.7)**(-8+5)))+pValue
j = rValue*(kValue/(1+(2.7)**(-9+5)))+pValue
k = rValue*(kValue/(1+(2.7)**(-10+5)))+pValue
l = rValue*(kValue/(1+(2.7)**(-11+5)))+pValue
m = rValue*(kValue/(1+(2.7)**(-12+5)))+pValue
n = rValue*(kValue/(1+(2.7)**(-13+5)))+pValue
o = rValue*(kValue/(1+(2.7)**(-14+5)))+pValue
p = rValue*(kValue/(1+(2.7)**(-15+5)))+pValue
q = rValue*(kValue/(1+(2.7)**(-16+5)))+pValue
r = rValue*(kValue/(1+(2.7)**(-17+5)))+pValue
s = rValue*(kValue/(1+(2.7)**(-18+5)))+pValue
t = rValue*(kValue/(1+(2.7)**(-19+5)))+pValue
u = rValue*(kValue/(1+(2.7)**(-20+5)))+pValue

y = [a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r,
s, t, u]
x = range(0, 21)
line1 = self.graphicsView.plot(x, y, pen='g', symbol='x',
symbolPen='g', symbolBrush=0.2, name='green')

# self.graphWidget = pg.PlotWidget()

# # self.setCentralWidget(self.graphWidget)
# # # self.graphWidget.setGeometry(QtCore.QRect(490,
100, 471, 450))
# # hour = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# # temperature = [30, 32, 34, 32, 33, 31, 29, 32, 35,
45]
# # # plot data: x, y values
# # self.graphWidget.plot(hour, temperature)

def pChanged(self):
global rvalue
global pvalue
global kvalue
pValue = str(self.tempSlider.value())
self.pNumLabel.setText(pValue)
Shay Brokensha - 2022
def kChanged(self):
global rvalue
global pvalue
global kvalue
kValue = str(self.litterSlider.value())
self.kNumLabel.setText(kValue)

def rChanged(self):
global rvalue
global pvalue
global kvalue
rValue = str(self.foodSlider.value())
self.rNumLabel.setText(rValue)

def setupUi(self, MainWindow):


#MainWindow.setWindowTitle("Hardest Coding Project I've Done
To Date")
global rvalue
global pvalue
global kvalue
MainWindow.setWindowTitle("Hardest Coding Project I've Done
To Date")
MainWindow.resize(980, 590)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.titleLabel = QtWidgets.QLabel(self.centralwidget)
self.titleLabel.setGeometry(QtCore.QRect(260, 20, 441, 40))
font = QtGui.QFont()
font.setPointSize(16)
self.titleLabel.setFont(font)
self.titleLabel.setObjectName("titleLabel")
self.litterSlider = QtWidgets.QSlider(self.centralwidget)
self.litterSlider.setGeometry(QtCore.QRect(230, 165, 160,
22))
self.litterSlider.setMinimum(1)
self.litterSlider.setMaximum(700)
self.litterSlider.setOrientation(QtCore.Qt.Horizontal)

self.litterSlider.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.litterSlider.setTickInterval(1000)
self.litterSlider.setObjectName("litterSlider")
self.tempSlider = QtWidgets.QSlider(self.centralwidget)
self.tempSlider.setGeometry(QtCore.QRect(230, 105, 160, 22))
self.tempSlider.setMinimum(1)
self.tempSlider.setMaximum(10)
self.tempSlider.setOrientation(QtCore.Qt.Horizontal)
self.tempSlider.setInvertedControls(False)

self.tempSlider.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.tempSlider.setTickInterval(200)
self.tempSlider.setObjectName("tempSlider")
self.foodSlider = QtWidgets.QSlider(self.centralwidget)
self.foodSlider.setGeometry(QtCore.QRect(230, 225, 160, 22))
self.foodSlider.setMinimum(0)
Shay Brokensha - 2022
self.foodSlider.setMaximum(200)
self.foodSlider.setSingleStep(5)
self.foodSlider.setOrientation(QtCore.Qt.Horizontal)

self.foodSlider.setTickPosition(QtWidgets.QSlider.TicksAbove)
self.foodSlider.setTickInterval(10)
self.foodSlider.setObjectName("foodSlider")
self.shayLabel = QtWidgets.QLabel(self.centralwidget)
self.shayLabel.setGeometry(QtCore.QRect(20, 520, 191, 16))
self.shayLabel.setObjectName("shayLabel")
self.pLabel = QtWidgets.QLabel(self.centralwidget)
self.pLabel.setGeometry(QtCore.QRect(20, 100, 211, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.pLabel.setFont(font)
self.pLabel.setObjectName("pLabel")
self.kLabel = QtWidgets.QLabel(self.centralwidget)
self.kLabel.setGeometry(QtCore.QRect(20, 160, 191, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.kLabel.setFont(font)
self.kLabel.setObjectName("kLabel")
self.rLabel = QtWidgets.QLabel(self.centralwidget)
self.rLabel.setGeometry(QtCore.QRect(20, 220, 181, 31))
font = QtGui.QFont()
font.setPointSize(12)
self.rLabel.setFont(font)
self.rLabel.setObjectName("rLabel")
self.graphButton = QtWidgets.QPushButton(self.centralwidget,
clicked=lambda: self.generate_graph())
self.graphButton.setGeometry(QtCore.QRect(230, 450, 200,
41))
font = QtGui.QFont()
font.setPointSize(13)
self.graphButton.setFont(font)
self.graphButton.setObjectName("graphButton")

self.preyButton = QtWidgets.QPushButton(self.centralwidget,
clicked=lambda: self.prey())
self.preyButton.setGeometry(QtCore.QRect(230, 510, 200, 41))
font = QtGui.QFont()
font.setPointSize(13)
self.preyButton.setFont(font)
self.preyButton.setObjectName("preyButton")

self.pNumLabel = QtWidgets.QLabel(self.centralwidget)
self.pNumLabel.setGeometry(QtCore.QRect(410, 100, 40, 30))
font = QtGui.QFont()
font.setPointSize(11)
self.pNumLabel.setFont(font)
self.pNumLabel.setObjectName("pNumLabel")
self.kNumLabel = QtWidgets.QLabel(self.centralwidget)
self.kNumLabel.setGeometry(QtCore.QRect(410, 160, 50, 30))
font = QtGui.QFont()
font.setPointSize(11)
Shay Brokensha - 2022
self.kNumLabel.setFont(font)
self.kNumLabel.setObjectName("kNumLabel")
self.rNumLabel = QtWidgets.QLabel(self.centralwidget)
self.rNumLabel.setGeometry(QtCore.QRect(410, 220, 40, 30))
font = QtGui.QFont()
font.setPointSize(11)
self.rNumLabel.setFont(font)
self.rNumLabel.setObjectName("rNumLabel")
self.graphicsView = PlotWidget(self.centralwidget)
self.graphicsView.setGeometry(QtCore.QRect(490, 100, 471,
450))
self.graphicsView.setObjectName("graphicsView")
self.image = QtWidgets.QLabel(self.centralwidget)
self.image.setGeometry(QtCore.QRect(80, 300, 321, 131))
self.image.setText("")
self.image.setObjectName("image")
pixmap = QPixmap('equation.gif')
self.image.setPixmap(pixmap)

MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)

self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)

self.tempSlider.valueChanged.connect(self.pChanged)
self.litterSlider.valueChanged.connect(self.kChanged)
self.foodSlider.valueChanged.connect(self.rChanged)

def retranslateUi(self, MainWindow):


_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow",
"MainWindow"))
self.titleLabel.setText(_translate("MainWindow", "Modelling
the Sigmoid Growth Curve"))
self.shayLabel.setText(_translate("MainWindow", "Made By
Shay Brokensha - 2022"))
self.pLabel.setText(_translate("MainWindow", "Initial
Population (P)"))
self.kLabel.setText(_translate("MainWindow", "Carrying
Capacity (K)"))
self.rLabel.setText(_translate("MainWindow", "Rate Of
Increase (r)"))
self.graphButton.setText(_translate("MainWindow", "Graph!"))
self.preyButton.setText(_translate("MainWindow",
"Predator/Prey"))
self.pNumLabel.setText(_translate("MainWindow", "2"))
self.kNumLabel.setText(_translate("MainWindow", "1"))
self.rNumLabel.setText(_translate("MainWindow", "1"))

if __name__ == "__main__":
import sys
Shay Brokensha - 2022
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())

Background Research
1. What is Population Ecology?
- Deals with species populations.
- E.g., Emigration, immigration, mortality, and natality
- It can predict whether that specie will live (and thrive) in that particular habitat that
it is in
- A population is the number of organisms of the same species that live in a particular
geographic area at the same time, with the capability of interbreeding.
- The total number of individuals in a population is defined as population size.
- Population size of any given specie can fluctuate drastically depending on a range of
biotic and abiotic factors

2. Exponential Vs. Logistical Growth


Exponential Growth Logistic Growth
Shape J - Curve S - Curve
Factors Does not consider the Takes into account of
abundance of resources the number of
organisms the current
resources available can
support
Characteristics Does not have an upper Has an upper carrying
limit limit, often called the
carrying capacity
Phases Has 2 main phases: lag Has 4 main phases: log
phase and log phase phase, lag phase,
deceleration phase and
stationary phase
Real-Life Example When Bacteria is When an animal
preforming Mitosis rapidly reproduces
until all resources have
been used up and
carrying capacity is
reached
Shay Brokensha - 2022
Example Equation y=x
2
k
y=( (a +bx )
)
(1+ ( e ) )
Image

3. What Limits a Population?


- The factors that limit a population are called its limiting factors
- Some factors that can help limit a population include; disease, resources,
reproductive environments seasons
- As populations increase animals become more susceptible to diseases as the disease
can be passed on easier due to the close proximities the animals will be in. This is
part of the problem with farming cattle in vast numbers.
- Populations are also limited by food supply. If an organism can’t get the nutrients it
needs to survive then it will die (and not have the chance to reproduce).
- Some organisms have a certain set of conditions in order to reproduce. If there is
only a limited number of these locations then often not all organisms are able to
reproduce resulting in fewer organisms in the next generation
- After all these factors are taken into account the total number of individuals of a
population that can be sustained indefinitely in a particular ecosystem is call the
carrying capacity.

4. What is the Predator Prey Population Size Relationship?


- A predator is an animal the kills and eats other animals for food
- Prey is an organism that is killed by a predator for food
- When there is a low predator level, the prey population number peaks. Then the
Predator population increases as there are heaps of food for them. Then the Prey
population starts to dip again due to the vast number of predators feeding on them.
The Predators then don’t have enough food and start to die off
- The prey spikes are always the bigger peaks and the same troughs as the predator
- The predators population is always delayed to the preys
- If the populations of either prey or predator’s varies too much then it can send the
other one out of whack too.

5. How does the computer simulation work?


I managed to code the simulation using PyCharm (a program which allows you to
code in a variety of coding languages) with Python (a coding language). After that I
Shay Brokensha - 2022
was able to use a variety of modules (third party software which allows you to
communicate/accomplish things not possible by just using python itself) to start
building a desktop application. Then I hoped on a website called Desmos
(www.desmos.com/calculator) which is a website that is a graphing calculator. Using
this I was then able to work out a bunch of quadratic formulas which would model
what I was trying to accomplish. Then after a lot of trial and error as well as help
from Stack Overflow (a coding forum where you can ‘Google’ your errors) I was then
able to get the simulation working where it would take the users inputs and
construct a graph on the right modelling this.

Definitions
- Reproductive potential
- Limiting factors
- Emigration
- Natality
- Predation
- Carrying capacity

Term Definition
Reproductive The Reproductive potential is the relative capacity of the
Potential population to reproduce under optimal conditions
Limiting Factors Any factor that directly affects a habitats carrying
capacity when its quantity is changed
Emigration The act of leaving one’s own habitat
Natality The birth rate within a competition
Predation A biological interaction where one organism (the
predator), eats another organism (the prey)
Carrying The number of organisms which can survive with the
Capacity available number of resources within an ecosystem

Shay Brokensha - 2022


Population Dynamics and Trends in Ecosystems
My Topic
The topic I have chosen involves modelling animal populations
with computer simulations. I have a love for both computers and
maths. Hence when I was given the assignment and saw on the task
sheet that you could make a game instead of a model I instantly
though I had to code something. Initially I was planning on
converting a biology topic into a game. While I had many ideas for
this, not one of them would be both fun to play and educational.
Hence, I pivoted towards a simulation. By moving towards a
simulation, I was able to consider my love for maths and with a bit
of hard work come up with a simulation that models any particular
specie’s population. In this I was able to model both, logistical
growth as well as the predator/prey relationship on population size.
By accomplishing this I both learnt about carrying capacity of an
environment, logistical vs. exponential growth and why it is not
always achievable as well as a variety of other things.

Personal Relationship
When I first was shown how the population dynamics of a
predator/prey relationship worked I was captivated with how both
the populations can vary in magnitude and remain stable with
killing out one or the other. I believe this factor was what made me
make a simulation about population trends.

Background Information
While my topic is very broad and covers a range of different
disciplines, only a few prerequisites need to be learnt to fully
understand it.
Predator Prey
A Predator Prey relationship is the relationship shared
between both predator and prey. A predator is known as an
animal that eats prey. And the prey is the creature being
eaten. Given this scenario certain patterns emerge between
the two species.
Carrying Capacity
The carrying capacity is known as the number of organisms
an ecosystem can sustain long-term.
Shay Brokensha - 2022
Quadratics
Quadratics is a field of maths in which an equation can be
made and then graphed given a particular shape.

Communication Medium
As said above I really have a love for both programming and maths
hence I was willing to combine all three topics together to
accomplish the simulation. While choosing the topic I also
considered building a model, however I couldn’t think of an
interactive fun way I could build a model on population trends. I
also don’t think that a collection would have been the best idea
either with the key question being; what would I collect?
I really like the idea of a PowerPoint. As mentioned, several times
I have a knack for computers and could put one together without
much struggle. Again, I thought about a video and a poster
however I thought that I didn’t want to go to the hassle of writing,
filming and then editing a video, hence I chose a PowerPoint

References

1%2F2 %28sin%28x %CF%80 - %CF%80%2F2%29 %2B 1%29 - Wolfram|Alpha.

(n.d.). Www.wolframalpha.com. Retrieved July 5, 2022, from

https://www.wolframalpha.com/input?i=1%2F2+%28sin%28x+%CF%80+-+

%CF%80%2F2%29+%2B+1%29&assumption=%22ClashPrefs%22+-%3E+

%7B%22Math%22%7D

BD Editors. (2016, December 21). Population. Biology Dictionary.

https://biologydictionary.net/population/

Evolutionary game theory. (2022, June 29). Wikipedia.

https://en.wikipedia.org/wiki/Evolutionary_game_theory#:~:text=Evolutionar

y%20game%20theory%20encompasses%20Darwinian%20evolution%2C

%20including%20competition

Lakna. (2019, December 13). What is the Difference Between Biotic Potential and

Reproductive Potential. Pediaa.com. https://pediaa.com/what-is-the-

Shay Brokensha - 2022


difference-between-biotic-potential-and-reproductive-potential/#:~:text=The

%20reproductive%20potential%20is%20the%20relative%20capacity%20of

Moore, J., & Moore, R. (2006). Evolution 101. Greenwood Press.

Predator and prey populations - Ecosystems - National 5 Biology Revision. (n.d.).

BBC Bitesize. https://www.bbc.co.uk/bitesize/guides/z2vjrwx/revision/2

python 3.x - TypeError: unsupported operand type(s) for ^: “float” and “int.” (n.d.).

Stack Overflow. Retrieved July 5, 2022, from

https://stackoverflow.com/questions/66701388/typeerror-unsupported-

operand-types-for-float-and-int

Python, R. (n.d.). SimPy: Simulating Real-World Processes With Python – Real

Python. Realpython.com. Retrieved July 6, 2022, from

https://realpython.com/simpy-simulating-with-python/#:~:text=%20To

%20recap%2C%20here%20are%20the%20three%20steps

sigmoid. (n.d.). Desmos. Retrieved July 5, 2022, from

https://www.desmos.com/calculator/kn9tpwdan5

Sigmoid (mod). (n.d.). Desmos. Retrieved July 5, 2022, from

https://www.desmos.com/calculator/5cljvgire7

signal processing - Adjustable Sigmoid Curve (S-Curve) from $(0,0)$ to $ (1,1)$.


(n.d.). Mathematics Stack Exchange. Retrieved July 5, 2022, from

https://math.stackexchange.com/questions/459872/adjustable-sigmoid-curve-

s-curve-from-0-0-to-1-1

Stearns, S. C., & Hoekstra, R. F. (2005). Evolution : an introduction. Oxford

University Press.

Trading 101 | How to Use Game Theory to Your Advantage in Business. (n.d.).

Trading 101. Retrieved July 6, 2022, from

https://www.trading101.com/blog/how-to-use-game-theory-to-your-

advantage-in-business#:~:text=The%20most%20common%20example%20of

%20game%20theory%20usage

Shay Brokensha - 2022


Transformations Of Linear Functions (video lessons, examples and solutions). (n.d.).

Www.onlinemathlearning.com.

https://www.onlinemathlearning.com/transformation-linear-functions.html

Wikipedia Contributors. (2019, June 29). Kin selection. Wikipedia; Wikimedia

Foundation. https://en.wikipedia.org/wiki/Kin_selection

Journal
STUDENT NAME Shay Brokensha

PROJECT TITLE Population Dynamics and Trends in Ecosystems

TOTAL RESEARCH HOURS 12

Date Research/Activity/Action/Outcome Hours spent

6/14/2022 Today I was first informed about the competition. I instantly read 0.5
the competition manual and guidelines. I then set to work
shortlisting a bunch of possible research ideas.

6/16/2022 Today I was researching my chosen research question. As I am 0.5


Shay Brokensha - 2022
planning to complete an electronic simulation / model I was
planning what software I should use to code this model.

6/17/2022 Today I found the ideal software which I was going to use 0.5
(Python). I then started researching and doing some background
research so I can start planning the coding aspect

6/20/2022 Today I was able to find a module to use to code the simulation. I 0.5
then started looking up some tutorials to aid in my learning of
this new module.

6/21/2022 Again, today I was just doing some background research to put 2.5
on my poster and for my essay. I then started coding the
simulation.

7/21/2022 Today I fixed some bugs in my program and then added to it a bit 2
more

7/19/2022 Today I fixed some more bugs and was then able to code some 1
more.

7/14/2022 More Coding :) 2

7/16/2022 Today I decided to change things up and work on my essay 1


instead

7/19/2022 Today I finished the simulation and then formatted everything 1


for my PowerPoint

7/20/2022 Today I finished the PowerPoint 0.5

Shay Brokensha - 2022

You might also like