Child of Algae

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)



"Algae is alive!"

Tagged by Reuven M. Lerner over 14 years ago

Child of model Algae preview imageAlgae
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.0beta4 • Viewed 503 times • Downloaded 32 times • Run 4 times
Download the 'Child of Algae' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


$Id: Algae.nlogo 37529 2008-01-03 20:38:02Z craig $


This is a model of a simplified aquatic ecosystem consisting of a column of water containing algae, light, and nutrients. There is more light at the top but more food at the bottom, so algae move up and down to balance their needs.


Algae need both light and nutrients (such as ammonia and phosphate) in order to grow. Although there is ample light near the lake surface, there are few nutrients. On the other hand, it is dark deep in the lake, but there is a lot of ammonia and phosphate down there. Some algae can move up and down in the water column to get both light and nutrients. These algae make dense substances using the energy from light in order to make them sink, and then burn up those dense substances in the dark at the deeper parts of the water column.

The algae move up and down in the water column based on how dense they are. The algae's density is something that changes continuously based on how much light they are able to get during the day. Density decreases some every turn because the algae use the dense substances to produce chemical energy. However, the algae can also use light energy to make the dense substances. The more light present, the denser they get. When they become denser than water, they move down. Deeper water gets less light, so the deeper algae goes, the less density it is able to add. When algae becomes less dense than water, it moves up towards the surface again. Also, as the seasons change, the length of the day changes, which changes how much light is present throughout the day.


The SETUP button prepares the ecosystem and the GO button runs the simulation.

The LIGHT-SPREADINESS slider changes how much the light penetrates the water. The higher the "spreadiness," the more light can reach down into the water. If the DAY-AND-NIGHT? switch is on, the DAY-LENGTH slider changes how much of each day has sunlight. If it is off, light does not change throughout the day. If the CHANGE-DAY-LENGTH? switch is on, DAY-LENGTH changes as GO is running, simulating the changes of the seasons. If it is off, DAY-LENGTH will only change manually.

The AVERAGE-HEIGHT plot shows a history of the average height of the algae over the past 24 hour period. The DAY-LENGTH plot show the history of the DAY-LENGTH slider. The ALGAE-DISTRIBUTION plot shows the current position of the algae. Lower algae appear farther to the right in the plot.


Notice how as the days get longer, the average height of the algae gets lower. Similarly, as the days get shorter, the average height of the algae gets higher. Also, the more the light penetrates the water, the lower the algae are on average.

The color of the patches indicate the light intensity at that depth in the water column - the more yellow, the more light is present.

Sometimes the algae clumps all together and sometimes the algae forms multiple clumps.


To get time to pass faster, use the speed slider.

Turn off DAY-AND-NIGHT? to see that the algae still go up and down when the sun is always shining.

How does having lots of LIGHT-SPREADINESS and a small DAY-LENGTH compare to having little LIGHT-SPREADINESS and a big DAY-LENGTH? (It'll help to turn off CHANGE-DAY-LENGTH?.)


Even though algae need both light and nutrients, this simple model only considers the role of light. Add a nutrient gradient in the water column. The floor could contain nutrients and the algae might contribute to the gradient when they die.

When real algae are healthy, they grow new algae. Also, when they run out of food, they die. Add these rules to the model.


In the SPREAD-LIGHT procedure, the water patches grab light from the patch directly above them. Note the use of the FOREACH and SORT primitives to ensure that the patches are asked in the desired order.

In order to display all of the elements of the control strip above it, the 2D View needs to be of a certain minimum width, so world-width is larger than it needs to be. The necessary patches are stored as patch agentsets in the AIR, WATER, and GROUND global variables and the SETUP-ENVIRONMENT procedure "gets rid" of the unnecessary patches:

| ask patches with [pxcor != 0] [

| set pcolor gray + 1.75

| ]


This model is based on a preliminary model developed by Allan Konopka at the 2004 NetLogo Workshop at Northwestern University.

Thanks to Josh Unterman for his work on this model.

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [
  ;;; some patch agentsets to make things easier to read

patches-own [ light ]

breed [ algae an-algae ]

algae-own [ ballast ]


to setup

to setup-globals
  set algae-height-list []
  set air patches with [ pxcor = 0 and pycor = max-pycor ]
  set water patches with [ pxcor = 0 and abs pycor != max-pycor ]
  set ground patches with [ pxcor = 0 and pycor = min-pycor ]

to setup-environment
  ask air [ set light 1 ]
  ask ground [ set light 0 ]
  ask water [ set light 0 ]
  ask patches with [ pxcor != 0 ] [
    set pcolor gray + 1.75

to recolor-environment
  ask air [
    if day-and-night? [
      ifelse daytime? [
        set pcolor yellow + 3
      ] [
        set pcolor black
  ask ground [
    set pcolor brown
  ask water [
    ifelse light > 0 [
      ;; make water with more light brighter yellow
      set pcolor yellow - 4 + light * 7
    ] [
      ;; make deeper water darker so things are prettier
      set pcolor blue - 2 - 0.1 * distance one-of air

to setup-algae
  set-default-shape algae "algae"
  create-algae 50 [
    set ballast 0.3 + random-float 0.4
    set heading 0
    set color one-of [red yellow lime sky]
    setxy 0 [pycor] of one-of water
    ;; spread the algae throughout the water patches
    setxy xcor - 0.2 + random-float 0.4
          ycor - 0.5 + random-float 1


to go
  if not any? algae [ stop ]
  ;; 24 hour days
  let day ticks / 24
  ;; assume all months are the same length
  let month day / 10
  ;; day length cycles up and down based on the time of year
  if change-day-length? [
    set day-length 12 + 4 * sin ( month * 180 / 12 )

to step
  if day-and-night? [
  ask algae [
    change-ballast light
  ask algae [

to change-ballast [ light-present ] ; algae procedure
  ;; algae lose some ballast per hour (but don't get less than 0)
  set ballast max list 0 (ballast - 0.1)
  ;; the amount of new ballast depends on how much light and has some randomness
  let new-ballast light-present - random-float 0.05
  ;; ballast can't be greater than 1
  set ballast min list 1 ballast + new-ballast

to move ; algae procedure
  ;; if ballast is empty, amount-to-move is 1
  ;; if ballast is full, amount-to-move is -1
  ;; ballast stays between 0 (empty) and 1 (full)
  let amount-to-move (1 - (2 * ballast))
  if amount-to-move > 0 [
    ;; algae don't go into the air
    let distance-to-air (max-pycor - 0.5 - ycor)
    set amount-to-move min list distance-to-air amount-to-move
  fd amount-to-move
  ;; algae die if on the bottom
  if member? patch-here ground [ die ]

to spread-light
  ifelse daytime? [
    ask air [ set light 1 ]
    ask water [ set light 0 ]
    ;; we sort the water patches top to bottom and then ask them in turn
    ;; to grab some light from above
    foreach sort water [
      ask ? [
        let light-gained light-spreadiness * [light] of patch-at 0 1
        set light light + light-gained
  ] [
    ask air [ set light 0 ]
    ask water [ set light 0 ]

to-report daytime?
  report ticks mod 24 < day-length


to update-plots
  let current-algae-height mean [ycor] of algae
  set algae-height-list fput current-algae-height algae-height-list

  ;; let things go for a bit before starting the plotting
  if ticks > 100 [

to do-plotting
  set algae-height-list sublist algae-height-list 0 24

  set-current-plot "average height"
  set-current-plot-pen "average height"
  plot mean algae-height-list

  set-current-plot "day length"
  set-current-plot-pen "day length"
  plot day-length

  set-current-plot "algae distribution"
  histogram [ ycor ] of algae

There are 2 versions of this model.

Uploaded by When Description Download
Uri Wilensky about 14 years ago How about them algae? Download this version
Uri Wilensky about 14 years ago How about them algae? Download this version

Attached files

No files

Parent: Algae

This model does not have any descendants.

Graph of models related to 'Child of Algae'