Farm Irrigation

No preview image

1 collaborator

Default-person Jaiveer Kothari (Author)

Tags

(This model has yet to be categorized with any tags)
Model group MAM-2016 | Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.0-M5 • Viewed 512 times • Downloaded 51 times • Run 0 times
Download the 'Farm Irrigation' modelDownload this modelEmbed this model

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


Comments and Questions

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

Click to Run Model

turtles-own
[
 pmin-water-content ; min water content of patch its on in order to live
 pmax-water-content ; max water content of patch its on in order to live
 cur-water-content ; current water content of turtle
]

patches-own
[
 pwater-content ; patche's water content
]

globals
[
  avg-cur-water-content ;avg water content of patches
  total-water-used-in-irrgn ;total water used in irrigation
  total-killed-from-excess-water ;number of plants killed from excess water
  total-killed-from-less-water ;number of plants killed from less water
  total-water-used-by-crops ; total water used by crop
  total-water-on-farm ; total water content of farm
  time ; time in the simulation. = number of ticks
  abs-rate
  abs-success
  efficiency ; outout measure
  crop-lifespan ; lifespan of current crop
]

to setup
  clear-all
  ;;maize
  if crop-type = "maize" [ ; if maize crop set maize properties
    create-turtles num-plants [
      set shape "plant"
      setxy random-xcor random-ycor
      set crop-lifespan 1300
      set pmin-water-content 100 + random 10
      set pmax-water-content 700 + random 100
      set cur-water-content 300 + random 50
      set color green
    ]
  ]

  ;;peppers
  if crop-type = "peppers" [ ; if pepper crop set pepper properties
    create-turtles num-plants [
      set shape "plant"
      setxy random-xcor random-ycor
      set crop-lifespan 1500
      set pmin-water-content 100 + random 10
      set pmax-water-content 600 + random 100
      set cur-water-content 300 + random 100
      set color blue
    ]
  ]

  ;; rice
  if crop-type = "rice" [ ;set rice properties
    create-turtles num-plants [
      set shape "plant"
      setxy random-xcor random-ycor
      set crop-lifespan 1200
      set pmin-water-content 150 + random 15
      set pmax-water-content 800 + random 100
      set cur-water-content 400 + random 100
      set color red
    ]
  ]
  set total-water-on-farm 0
  ask patches [ ;get total water on farm
    set pwater-content 180 + random 40
    set total-water-on-farm total-water-on-farm + pwater-content
    set pcolor (39.9 - pwater-content / 100 )
  ]
  get-avg-cur-water-content
  set abs-rate 3
  set abs-success 0
  set total-water-used-in-irrgn (sum [pwater-content] of patches)
  set total-killed-from-excess-water 0
  set total-killed-from-less-water 0
  set total-water-used-by-crops 0
  set time 0
  set efficiency 0 ;getter defined below
  set-arrangement
  reset-ticks
end 


;; set arrangment or formation of crops based on input

to set-arrangement
  if arrangement = "rows" [setup-rows]
  if arrangement = "evenspread" [setup-es]
end 

;; setup equally spaced rows

to setup-rows
  let num-rows 9 ; number of rows to create
  let total-turtles count turtles
  let x-spacing (max-pxcor - min-pxcor) / num-rows ;space between the rows

  ask turtles [
    foreach [0 1 2 3 4 5 6 7]
    [
      if who >= (? * total-turtles / (num-rows - 1)) and who < ((? + 1) * total-turtles / (num-rows - 1))[
        set xcor min-pxcor + x-spacing * (? + 1)
      ]

    ]
    set ycor (min-pycor + ((who mod (total-turtles / (num-rows - 1))) / (total-turtles / (num-rows - 1))) * max-pycor * 2)
  ]
end 

;; set up turtles equally spead out equispread arrangment

to setup-es
  let num-rows 24
  let total-turtles count turtles
  let x-spacing (max-pxcor - min-pxcor) / num-rows

  ask turtles [

    foreach [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22]
    [

      if who >= (? * total-turtles / (num-rows - 1)) and who < ((? + 1) * total-turtles / (num-rows - 1))[
        set xcor min-pxcor + x-spacing * (? + 1)
      ]

    ]
    set ycor (min-pycor + ((who mod (total-turtles / (num-rows - 1))) / (total-turtles / (num-rows - 1))) * max-pycor * 2)
  ]
end 

to go

  if count turtles <= 1 [ stop ] ; if all plants dead
  if time >= crop-lifespan [ stop ] ;life cycle of crop finished

  diffuse pwater-content 0.1
  check-water
  irrigate
  absorb-water
  use-water
  patches-lose-water
  evaporation
  recolor-patches
  get-avg-cur-water-content
  get-eff
  get-total-water-on-farm
  set time time + 1
  tick
end 

; patches lose water to earth

to patches-lose-water ;; patch procedure
  if soil-type = "sand" [
    ask patches [
      set pwater-content pwater-content - 0.3
    ]
  ]
  if soil-type = "loam" [
    ask patches [
      set pwater-content pwater-content - 0.2
    ]
  ]
  if soil-type = "clay" [
    ask patches [
      set pwater-content pwater-content - 0.1
    ]
  ]
  recolor-patches
end 

; check water at turtles patch. die accordingly

to check-water ;; turtle procedure
  ;; check if there is too much water on the turtle's patch
  ask turtles [
    let flag 0
    let y pmax-water-content
    ask patch-here [
      if pwater-content > y [
        set flag 1
      ]
    ]
    if flag = 1[
      set total-killed-from-excess-water total-killed-from-excess-water + 1

      die
    ]

  ]

  ;; check if too little water for turtle
  ask turtles [
    let flag 0
    let x pmin-water-content
    ask patch-here [
      if pwater-content < x [
        set flag 1
      ]
    ]
    if flag = 1[
      set total-killed-from-less-water total-killed-from-less-water + 1
      die
    ]
  ]
end 

; turtles use the water they absorb

to use-water ;; turtle procedure
  ask turtles [
    set cur-water-content cur-water-content - abs-rate
  ]
end 


; absorb water from soil

to absorb-water ;; turtle procedure
  ask turtles[
    set abs-success 0
    let abss 0
    ask patch-here[
      if pwater-content > abs-rate [

        set pwater-content pwater-content - abs-rate

        set abss 1
        ]
      set abs-success 1
      ]
    if abss = 1 [

      set cur-water-content cur-water-content + abs-rate
      set total-water-used-by-crops total-water-used-by-crops + abs-rate
    ]
    set abs-success 0
    set abss 0

  ]
end 

to evaporation ;; patch procedure
  ask patches [
    ifelse pwater-content >= evaporation-rate [
      set pwater-content pwater-content - evaporation-rate
    ]
    [
      set pwater-content 0
    ]
  ]
end 

to irrigate
  if periodic [
    ;;; repeat the irrigation
    if ticks mod period = 0 [
      if irrigation-type = "drip" [drip-irrigation]
      if irrigation-type = "surface" [surf-irrigation]
      if irrigation-type = "channel" [channel-irrigation]
    ]
  ]
end 

;; surface irrigation. add water to every patch

to surf-irrigation ;; patch procedure
  ;;; add water to every patch
  ask patches [
    set pwater-content pwater-content + irrigation-per-patch
    set total-water-used-in-irrgn total-water-used-in-irrgn + irrigation-per-patch
  ]
  recolor-patches
end 

;; add water to those patches with turtles on them

to drip-irrigation ;; patch procedure
  ask patches [
    if count turtles-here > 0 [
      set pwater-content pwater-content + irrigation-per-patch
      set total-water-used-in-irrgn total-water-used-in-irrgn + irrigation-per-patch
    ]
  ]
   recolor-patches
end 

;; add water in vertical lines

to channel-irrigation ;; patch procedure

  ask patches [
    let x-spacing (max-pxcor - min-pxcor) / 7 ;;9 channels

    if member? pxcor [0 4 7 11 14 -4 -7 -11 -14]
    [
      set pwater-content pwater-content + irrigation-per-patch
      set total-water-used-in-irrgn total-water-used-in-irrgn + irrigation-per-patch
    ]
  ]
   recolor-patches
end 

; calcualtes the irrigation efficiency

to get-eff
  set efficiency (total-water-used-by-crops / total-water-used-in-irrgn) * 100
end 

;total water on farm is sum of pwaterc-content of patches

to get-total-water-on-farm
  set total-water-on-farm (sum [pwater-content] of patches)
end 

;; scale the patch colors from light to dark brown based on water content

to recolor-patches ;; patch procedure
  ask patches [
    set pcolor (39.9 - pwater-content / 100 )
  ]
end 

;getter function

to get-avg-cur-water-content
  if count turtles > 0 [
    set avg-cur-water-content (mean [cur-water-content] of turtles)
  ]
end 

There are 6 versions of this model.

Uploaded by When Description Download
Jaiveer Kothari over 8 years ago Final Project Latest Version Download this version
Jaiveer Kothari over 8 years ago Final Project Download this version
Jaiveer Kothari over 8 years ago version 4 Download this version
Jaiveer Kothari over 8 years ago version 3 Download this version
Jaiveer Kothari over 8 years ago Version 2 Download this version
Jaiveer Kothari over 8 years ago Initial upload Download this version

Attached files

File Type Description Last updated
JaiveerKothari-FinalProjectReport.pdf pdf Final Report over 8 years ago, by Jaiveer Kothari Download

This model does not have any ancestors.

This model does not have any descendants.