Devon crab model 3

No preview image

This model is seeking new collaborators — would you please help?

2 collaborators

Paul_hart_july_2020 Paul Hart (Author)
Default-person Morgane Amelot (Team member)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 6.2.2 • Viewed 131 times • Downloaded 15 times • Run 0 times
Download the 'Devon crab model 3' modelDownload this modelEmbed this model

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


Info tab cannot be displayed because of an encoding error

Comments and Questions

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

Click to Run Model

globals [ year years day temperature stdeviation hibernation temperature-data SST-temperature-data SSTtemperature list1 incubationtemp  multiplier
  list2 list3 list4 list5 list6 list7 list8 list9 list10 list11 list12 list13 list14 list15 list16 list17 list18 list19 list20 list21 list22 list23 list24 list25 list26 list27 list28 list29 list30 list31
  list32 list33 list34 list35 list36 list37 list38 list39 list40 list41 list42 list43 list44 list45 list46 list47 list48 list49 list50 list51 list52 list53 list54 list55 list56 list57 list58
  list59 list60 catch1 catch2 catch3 catch4 catch5 catch6 catch7 catch8 catch9 catch10 catch11 catch12 catch13 catch14 catch15 catch16 catch17 catch18 catch19 catch20  catch21 catch22
  catch23 catch24 catch25 catch26 catch27 catch28 catch29 catch30 catch31 catch32 catch33 catch34 catch35 catch36 catch37 catch38 catch39 catch40 catch41 catch42 catch43 catch44 catch45 catch46
  catch47 catch48 catch49 catch50 catch51 catch52 catch53 catch54 catch55 catch56 catch57 catch58 catch59 catch60 totalcatch1 totalcatch2 totalcatch3 totalcatch listparentstockyear parentstockS
  parentstockM parentstockL listparentstockS listparentstockM listparentstockL totalcrabs totalcrabs1 totalcrabs2 totalcrabs3 catchtotal
  parentstock1 parentstock2 parentstock3 parentstock123  newrecruits recruits11 recruits12 recruits13  samples  area1 area2 area3 area4 area5 area6 area7 area8 area9 area10 area11 area12 area13 area14 area15
area16 area17 area18 area19 area20 newrecruits1 newrecruits2 newrecruits3 newrecruits1S newrecruits2S newrecruits3S ]
patches-own [ substrate  pots  vessel depth catchability1 catchability2 catchability3 catchS catchM catchL available-patches available-patches2 available-patches3 best-patch best-patch2 best-patch3 ]
turtles-own [ natmortality   ]
breed [ crabs1 crab1 ]
breed [ crabs2 crab2 ]
breed [ crabs3 crab3 ]
crabs1-own [ crabcatch1 ]
crabs2-own [ crabcatch2 ]
crabs3-own [ crabcatch3 ]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  set year year + 1
  set samples 1
  setup-patches  ;; uses information in Co-ords IPA + pots + vessels + sed2 + depth.txt to create the modelled environment.
  setup-crabshapes
  setup-crab-pots  ;; assigns vessel number to the patch locaion of the pots for each vessel.
  setup-lists
  set-up-population-total-lists
  setup-output-file
  setup-spawningstock-output-file
  setup-temp-profile
  setup-SST-profile
  sum-area
  reset-ticks
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to go

  if ticks = 366 [ set year year + 1 ]
  if ticks = 366 [ set samples 1 ]
  if ticks = 366 [ reset-ticks ]
  if year > maxyears [ stop ]
  burying-temperature ;; using the input daily temperature record assigns a value to the temperature at which the crab begins to hibernate.
  move-turtles
  naturalmortality
  immigration
  count-spawningstock
  crab-catch
  if round ( ticks / sampling-interval ) = samples and year > 5 [ sum-catches ]
  if ticks = 0 and year >= 6 [ incubation-temperature ]
 tick
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-patches; read from a file the colour code for each patch to creat the IPA areas, the number of pots in each patch and the
  ;; vessel owning those pots plus information on water depth and bottom type
  file-open "Co-ords IPA + pots + vessels + sed2 + depth.txt"
  while [not file-at-end?]
  [
    let next-X file-read
    let next-Y file-read
    let next-color file-read
    ask patch next-X next-Y [set pcolor next-color]
    ask patch next-X next-Y [set pots file-read]
    ask patch next-X next-Y [set vessel file-read]
    ask patch next-X next-Y [set substrate file-read
      if substrate = 1 [ let proportion random 100
        if proportion < 30 [ set substrate random 9 ] ]
    ask patch next-X next-Y [ set depth file-read ]
 ]]
  file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-crabshapes  ;; this procedure populates the sea area with the three sizes of crab. Crabs are assigned to patches at random.
  ;; If they are placed on a patch which represent land, they die.

  set-default-shape crabs1 "crab1"
  create-crabs1 18000  ;; create the smallest crabs, then initialize their variables
  [
    set color 27
    set size 1  ;; smallest size class
    setxy  random-pxcor random-pycor
    if pcolor = 67 [ die ]
    ]

  set-default-shape crabs2 "crab2"
  create-crabs2 7500  ;; create the medium crabs, then initialize their variables
  [
    set color 26
    set size 1.5  ;; medium size class
    setxy  random-pxcor random-pycor
    if pcolor = 67 [ die ]

  ]
  set-default-shape crabs3 "crab3"
  create-crabs3 4500  ;; create the largest crabs, then initialize their variables
  [
    set color 25
    set size 2  ;; largest size class
    setxy  random-pxcor random-pycor
    if pcolor = 67 [ die ]
     ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-crab-pots  ;; this subroutine places crab pots where each vessel fishes.
      ask patches [ if pots != 0
     [ set plabel-color 15 set plabel vessel ]
    ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-lists  ;; these lists are used to store the catches of each vessel.
  ask patches with [ vessel != 0 ] [
  if vessel = 1 [ set list1  [ 1 ] ]
    if vessel = 2 [ set list2  [ 2 ] ]
    if vessel = 3 [ set list3  [ 3 ] ]
    if vessel = 4 [ set list4  [ 4 ] ]
    if vessel = 5 [ set list5  [ 5 ] ]
    if vessel = 6 [ set list6  [ 6 ] ]
    if vessel = 7 [ set list7  [ 7 ] ]
    if vessel = 8 [ set list8  [ 8 ] ]
    if vessel = 9 [ set list9  [ 9 ] ]
    if vessel = 10 [ set list10  [ 10 ] ]
    if vessel = 11 [ set list11  [ 11 ] ]
    if vessel = 12 [ set list12  [ 12 ] ]
    if vessel = 13 [ set list13  [ 13 ] ]
    if vessel = 14 [ set list14  [ 14 ] ]
    if vessel = 15 [ set list15  [ 15 ] ]
    if vessel = 16 [ set list16  [ 16 ] ]
    if vessel = 17 [ set list17  [ 17 ] ]
    if vessel = 18 [ set list18  [ 18 ] ]
    if vessel = 19 [ set list19  [ 19 ] ]
    if vessel = 20 [ set list20  [ 20 ] ]

    if vessel = 1 [ set list21  [ 1 ] ]
    if vessel = 2 [ set list22  [ 2 ] ]
    if vessel = 3 [ set list23  [ 3 ] ]
    if vessel = 4 [ set list24  [ 4 ] ]
    if vessel = 5 [ set list25  [ 5 ] ]
    if vessel = 6 [ set list26  [ 6 ] ]
    if vessel = 7 [ set list27  [ 7 ] ]
    if vessel = 8 [ set list28  [ 8 ] ]
    if vessel = 9 [ set list29  [ 9 ] ]
    if vessel = 10 [ set list30  [ 10 ] ]
    if vessel = 11 [ set list31  [ 11 ] ]
    if vessel = 12 [ set list32  [ 12 ] ]
    if vessel = 13 [ set list33  [ 13 ] ]
    if vessel = 14 [ set list34  [ 14 ] ]
    if vessel = 15 [ set list35  [ 15 ] ]
    if vessel = 16 [ set list36  [ 16 ] ]
    if vessel = 17 [ set list37  [ 17 ] ]
    if vessel = 18 [ set list38  [ 18 ] ]
    if vessel = 19 [ set list39  [ 19 ] ]
    if vessel = 20 [ set list40  [ 20 ] ]

    if vessel = 1 [ set list41  [ 1 ] ]
    if vessel = 2 [ set list42  [ 2 ] ]
    if vessel = 3 [ set list43  [ 3 ] ]
    if vessel = 4 [ set list44  [ 4 ] ]
    if vessel = 5 [ set list45  [ 5 ] ]
    if vessel = 6 [ set list46  [ 6 ] ]
    if vessel = 7 [ set list47  [ 7 ] ]
    if vessel = 8 [ set list48  [ 8 ] ]
    if vessel = 9 [ set list49  [ 9 ] ]
    if vessel = 10 [ set list50  [ 10 ] ]
    if vessel = 11 [ set list51  [ 11 ] ]
    if vessel = 12 [ set list52  [ 12 ] ]
    if vessel = 13 [ set list53  [ 13 ] ]
    if vessel = 14 [ set list54  [ 14 ] ]
    if vessel = 15 [ set list55  [ 15 ] ]
    if vessel = 16 [ set list56  [ 16 ] ]
    if vessel = 17 [ set list57  [ 17 ] ]
    if vessel = 18 [ set list58  [ 18 ] ]
    if vessel = 19 [ set list59  [ 19 ] ]
    if vessel = 20 [ set list60  [ 20 ] ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to set-up-population-total-lists ;; this subroutine sets up the list that will contain the parent stock of crabs used in the recruitment function.

  set listparentstockS [ ]
  set listparentstockM [ ]
  set listparentstockL [ ]
  set listparentstockyear [ ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-output-file

; this sub-routine sets up the file that will store the output from the model. Output is for catch by size and in total and by vessel,
  ;; the numbers of crabs by size, the sample number and the number of patches covered by each vessel.

  if (file-exists? "Catches_per_vessel_per_day v11.csv")
  [
    carefully
    [ file-delete "Catches_per_vessel_per_day v11.csv" ]
    [ print error-message ]
  ]

  file-open "Catches_per_vessel_per_day v11.csv"
  file-type "Year,"
  file-type "Sample,"
  file-type "Catchability1,"
  file-type "Catchability2,"
  file-type "Catchability3,"
  file-type "Catch small,"
  file-type "Catch medium,"
  file-type "Catch large,"
  file-type "Total catch,"
  file-type "Total N,"
  file-type "Total N small,"
  file-type "Total N medium,"
  file-type "Total N large,"
  file-type "Vessel,"
  file-print "Pot coverage"
  file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-spawningstock-output-file

  ; this sub-routine sets up the file that will store the number of crabs in the spawning stock and the resulting recruitment.

  if (file-exists? "Spawning_stock_size_v11.csv")
  [
    carefully
    [ file-delete "Spawning_stock_size_v11.csv" ]
    [ print error-message ]
  ]

  file-open "Spawning_stock_size_v11.csv"
  file-type "Year,"
  file-type "Spawning stock small,"
  file-type "Spawning stock medium,"
  file-type "Spawning stock large,"
  file-type "Total Spawning stock,"
  file-type "Recruits size 1E,"
  file-type "Recruits size 2E,"
  file-type "Recruits size 3E,"
  file-type "Recruits size 1S,"
  File-type "Recruits size 2S,"
  file-type "Recruits size 3S,"
  file-type "Total recruits1,"
  file-type "Total recruits2,"
  file-print "Total recruits3"
  file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-temp-profile ;; this subroutine reads the daily sea surface temperature taken off Slapton, South Devon, UK

  set temperature-data [ ]

   file-open "Slapton temps daily mean + st dev.txt"
    while [ not file-at-end? ] [
   set temperature-data sentence temperature-data (list (list file-read file-read file-read))
    ]
  file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to setup-SST-profile ;; this subroutine reads the mean sea surface temperature for the first 100 days of each year off Plymouth, Devon, UK and is used in the recruitment function.

    set SST-temperature-data [ ]

   file-open "SST Plymouth 95-14 M & SD.txt"
    while [ not file-at-end? ] [
   set SST-temperature-data sentence SST-temperature-data (list (list file-read file-read file-read))
    ]
  file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to sum-area  ;; so that catch per unit area can be calculated, this routine sums the area occupied by the pots of each vessel

   ask patches with [ vessel != 0 ] [



    if vessel = 1 [ set area1 area1 + 1 ]
    if vessel = 2 [ set area2 area2 + 1 ]
    if vessel = 3 [ set area3 area3 + 1 ]
    if vessel = 4 [ set area4 area4 + 1 ]
    if vessel = 5 [ set area5 area5 + 1 ]
    if vessel = 6 [ set area6 area6 + 1 ]
    if vessel = 7 [ set area7 area7 + 1 ]
    if vessel = 8 [ set area8 area8 + 1 ]
    if vessel = 9 [ set area9 area9 + 1 ]
    if vessel = 10 [ set area10 area10 + 1 ]
    if vessel = 11 [ set area11 area11 + 1 ]
    if vessel = 12 [ set area12 area12 + 1 ]
    if vessel = 13 [ set area13 area13 + 1 ]
    if vessel = 14 [ set area14 area14 + 1 ]
    if vessel = 15 [ set area15 area15 + 1 ]
    if vessel = 16 [ set area16 area16 + 1 ]
    if vessel = 17 [ set area17 area17 + 1 ]
    if vessel = 18 [ set area18 area18 + 1 ]
    if vessel = 19 [ set area19 area19 + 1 ]
    if vessel = 20 [ set area20 area20 + 1 ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to count-spawningstock  ;; this procedure counts how many crabs are alive at day 330 and adds them to give a total. These numbers form the basis for calculating recruitment.
  if ticks = 330  [
     set parentstock1 count crabs1
     set parentstock2 count crabs2
     set parentstock3 count crabs3
     set listparentstockS lput parentstock1 listparentstockS
     set listparentstockM lput parentstock2 listparentstockM
     set listparentstockL lput parentstock3 listparentstockL

     set parentstock123 parentstock1 + parentstock2 + parentstock3
     set listparentstockyear lput parentstock123 listparentstockyear
  ]
  if ticks = 330 [
  file-open "Spawning_stock_size_v11.csv"
  file-type (word year ",")
  file-type (word parentstock1 ",")
  file-type (word parentstock2 ",")
  file-type (word parentstock3 ",")
  file-type (word parentstock123 ",")
  file-type (word newrecruits1 ",")
  file-type (word newrecruits2 ",")
  file-type (word newrecruits3 ",")
  file-type (word newrecruits1S ",")
  file-type (word newrecruits2S ",")
  file-type (word newrecruits3S ",")
  file-type (word (newrecruits1 + newrecruits1S) "," )
  file-type (word (newrecruits2 + newrecruits2S) "," )
  file-print (word (newrecruits3 + newrecruits3S) )
  file-close
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to burying-temperature  ;; this section looks up the temperature for the day and adds some variation to the mean to give the realised temperature for the day.
  ;; This determines whether the crab continues to move or to stop moving and bury.
   if ( is-list? temperature-data )
  [ foreach temperature-data [ ?1 -> if first ?1 = ticks - 5 [ set day first ?1 set temperature item 1 ?1 set stdeviation last ?1 ]
  set hibernation random-normal temperature stdeviation ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to move-turtles; this procedure moves the crabs using the three criteria of choice - depth, substrate type and smallest number of other crabs.

  ask crabs1 [
    if pcolor = 67
    [ die ]; if a crab encounters land it dies.

    ifelse hibernation > hibernation-temperature ;; As long as the sea temp is greater than the temperature at which crabs hibernate, the crab keeps moving west.
    [

       let potential-destinations ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1)  patch-here )
        ;the line above selects the five patches north & south, NW, West and SW of the patch the subject crab is on
      set available-patches potential-destinations with [ depth < 3 and substrate != 1 ]

      ifelse  any? available-patches
     [
        set best-patch min-one-of available-patches [ count turtles-here ] ;; If there are patches satisfying depth and substrate requirements, then the crab chooses the patch in that subset with
                                                                           ;; the lowest number of crabs
        move-to best-patch                                                 ;; The crab then moves to that patch
      ]
     [
        move-to min-one-of potential-destinations [ count turtles-here ]   ;; If there are no available patches with the desired characterisitcs then the crab moves to the patch
        ;; in the set with the lowest number of crabs

     ]


    ]

    ; if a crab moves to a patch with a hard substrate when the temperature is below the hibernation temperature and is supposed to bury
    ; it moves to a new patch with the lowest number of crabs. If substrate is not equal to 1 (rock) then it stays where it is.
     [
      ifelse substrate = 1 [
        let potential-destinations ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1) )
        move-to min-one-of potential-destinations [ count turtles-here ]
      ]
      [
      move-to patch-here
      ]
    ]
    ]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ask crabs2 [
    if pcolor = 67
    [ die ]; if a crab encounters land it dies.

    ifelse hibernation > hibernation-temperature  [ ;; if the temperature is below the value set on the slider, the crabs are assumed to be buried and not moving. They can stil die.
        ; First identify potential neighbor destination patches
       let potential-destinations2 ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1)  patch-here )
        ;the line above selects the five patches north & south, NW, West and SW of the patch the subject crab is on
      set available-patches2 potential-destinations2 with [  depth < 4  and  substrate != 1 ]
       ifelse  any? available-patches2
     [
        set best-patch2 min-one-of available-patches2 [ count turtles-here ]
        move-to best-patch2
     ]
     [
        move-to min-one-of potential-destinations2 [ count turtles-here ]

     ]
    ]
        [
      ifelse substrate = 1 [
        let potential-destinations2 ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1) )
        move-to min-one-of potential-destinations2 [ count turtles-here ]
      ]
      [
        move-to patch-here
      ]
    ]
]

 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      ask crabs3 [
    if pcolor = 67
    [ die ]; if a crab encounters land it dies.

    ifelse hibernation > hibernation-temperature
    [
      ;; if the temperature is below the value set on the slider, the crabs are assumed to be buried and not moving. They can stil die.
        ; First identify potential neighbor destination patches

       let potential-destinations3 ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1)  patch-here )
        ;the line above selects the five patches north & south, NW, West and SW of the patch the subject crab is on

       set available-patches3 potential-destinations3 with [ depth > 4 and substrate != 1 ]

       ifelse  any? available-patches3
     [
        set best-patch3 min-one-of available-patches3 [ count turtles-here ]
        move-to best-patch3
     ]
     [
        move-to min-one-of potential-destinations3 [ count turtles-here ]
     ]

      ]
        [
      ifelse substrate = 1
      [
        let potential-destinations3 ( patch-set patch (pxcor - 1) (pycor + 1)  patch (pxcor - 1) pycor  patch (pxcor - 1) (pycor - 1) patch pxcor (pycor + 1) patch pxcor (pycor - 1) )
        move-to min-one-of potential-destinations3 [ count turtles-here ]
      ]
      [
        move-to patch-here
      ]
    ]

  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to naturalmortality ;; this applies the natural daily mortality rate read from the slider

  ask turtles [
       let mortality random-float .001
       if mortality < m [ die ]  ; this is the natural mortality rate per day
       if pxcor = 0 [ die ]; when crabs get to westerly or southerly edge of the area they die which represents them exiting the area modelled.
       if pycor = 0 [ die ]

  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to incubation-temperature  ;; this section looks up the SST temperature off Plymouth for the year and adds some variation to the mean to give the realised temperature for the year.
   if ( is-list? SST-temperature-data )
  [ foreach SST-temperature-data [ ?1 -> if first ?1 = year - 5 [ set SSTtemperature item 1 ?1 set stdeviation last ?1 ]
  set incubationtemp random-normal SSTtemperature stdeviation ]
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to immigration  ;; this procedure calculates daily recruitment rates for the three crab sizes. The rates are a function of spawning stock size,and the average temperature
                ;; of the first 100 days of the year class's life. Data from off Plymouth is used as this is downstream of where the crabs eventually move to benthic living.
                ;; In version MR1 RF2 the recruitment is calculated as a function of temperature alone.

    if hibernation > hibernation-temperature
  [
    ifelse year >= 6 [

     set-default-shape crabs1 "crab1"
     set recruits11 item (year - 6) listparentstockyear
    set multiplier ( 0.1 * incubationtemp ) ;; the factor by which recruits are multiplied to give immigration rates per day is a straight line function of temp,

     set newrecruits ( ( recruits11 * multiplier ) * 6.5 ) / 365

     create-crabs1 random-normal newrecruits 500 ;; create the smallest crabs, then initialize their variables
  [
     set color 27
     set size 1  ;; smallest size class
     setxy  120 random-pycor
  ]

      ; the following code is for the alternative recruitment function where recruitment is just a function of the temperature five years earlier.

;     ;set newrecruits ( ( ( -16.93 + 24.82 * incubationtemp ) * 1000 ) * 3 ) / 365
;      set newrecruits ( ( ( -16.93 + 24.82 * incubationtemp ) * 7000 ) ) / 365
;      set newrecruits1 random-normal newrecruits 500
;      if newrecruits1 < 0 [ set newrecruits1 0 ]
;      set-default-shape crabs1 "crab1"
;  create-crabs1 newrecruits1  ;; create the smallest crabs, then initialize their variables
;  [
;    set color 27
;    set size 1  ;; smallest size class
;    setxy  120 random-pycor
;  ]

  set-default-shape crabs2 "crab2"
  set recruits12 item (year - 2) listparentstockS
      set newrecruits2 random-normal ( ( recruits12 / 365 ) * 4.5 ) 500
      if newrecruits2 < 0  [ set newrecruits2  0 ]
  create-crabs2  newrecruits2 ;; create the medium crabs, then initialize their variables
  [
    set color 26
    set size 1.5  ;; medium size class
    setxy  120 random-pycor
  ]

  set-default-shape crabs3 "crab3"
  set recruits13 item (year - 2) listparentstockM
      set newrecruits3 random-normal ( ( recruits13 / 365 ) * 2.5 ) 500
      if newrecruits3 < 0 [ set newrecruits3  0 ]
  create-crabs3  newrecruits3 ;; create the largest crabs, then initialize their variables
  [
    set color 25
    set size 2  ;; largest size class
    setxy  120 random-pycor
  ]
;;;;;;;;;;;;;;;;;;;;;;;

      ; this and the next two sets of code provide the immigration from the south

      set-default-shape crabs1 "crab1"
      set newrecruits ( ( recruits11 * multiplier ) * 6.5 ) / 365
      ;set newrecruits ( ( ( -16.93 + 24.82 * incubationtemp ) * 4000 ) ) / 365
      set newrecruits1S ( random-normal newrecruits 500 )
      set-default-shape crabs1 "crab1"
      if newrecruits1S < 0 [ set newrecruits1S  0 ]
  create-crabs1 newrecruits1S ;; create the smallest crabs, then initialize their variables
  [
    set color 27
    set size 1  ;; smallest size class
    setxy random-pxcor 0

  ]
  set-default-shape crabs2 "crab2"

  set recruits12 item (year - 2) listparentstockS
      set newrecruits2S ( random-normal ( ( recruits12 / 365 ) * 4.5 ) 500 )
      if newrecruits2S < 0 [ set newrecruits2S  0 ]
  create-crabs2  newrecruits2S ;; create the medium crabs, then initialize their variables
  [
    set color 26
    set size 1.5  ;; medium size class
   setxy random-pxcor 0

  ]
  set-default-shape crabs3 "crab3"
  set recruits13 item (year - 2) listparentstockM
      set newrecruits3S ( random-normal ( ( recruits13 / 365 ) * 2.5 ) 500 )
      if newrecruits3S < 0 [ set newrecruits3S  0 ]
  create-crabs3  newrecruits3S ;; create the largest crabs, then initialize their variables
  [
    set color 25
    set size 2  ;; largest size class
    setxy random-pxcor 0
  ]
  ]
;;;;;;;;;;;;;;;;;;;;;;;;;;

   ; the following immigration is read from the sliders and comes into play during the first 5 years of the simulation. Crabs are assumed to recruit to the fishery at age 5.
   ; crabs entering from the east

    [ set-default-shape crabs1 "crab1"
  create-crabs1 random-normal 3000 50 ;; create the smallest crabs, then initialize their variables
  [
    set color 27
    set size 1  ;; smallest size class
    setxy  120 random-pycor
  ]
  set-default-shape crabs2 "crab2"
  create-crabs2 random-normal 2300 20 ;; create the medium crabs, then initialize their variables
  [
    set color 26
    set size 1.5  ;; medium size class
    setxy  120 random-pycor
  ]
  set-default-shape crabs3 "crab3"
  create-crabs3 random-normal 1000 12 ;; create the largest crabs, then initialize their variables
  [
    set color 25
    set size 2  ;; largest size class
    setxy  120 random-pycor
  ]
;;;;;;;;;;;;;;;;;;;;;

      ; crabs entering from the south

      set-default-shape crabs1 "crab1"
  create-crabs1 ( random-normal 3000 50 ) ;; create the smallest crabs, then initialize their variables
  [
    set color 27
    set size 1  ;; smallest size class
    setxy random-pxcor 0

  ]
  set-default-shape crabs2 "crab2"
  create-crabs2 ( random-normal 2300 20 );; create the medium crabs, then initialize their variables
  [
    set color 26
    set size 1.5  ;; medium size class
   setxy random-pxcor 0

  ]
  set-default-shape crabs3 "crab3"
  create-crabs3 ( random-normal 1000 12 ) ;; create the largest crabs, then initialize their variables
  [
    set color 25
    set size 2  ;; largest size class
    setxy random-pxcor 0
  ]
  ] ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to crab-catch  ;; the procedure calculates the daily catch of each boat fishing the area.

   setup-lists  ;; resets the lists at the start of a day.
   if hibernation > hibernation-temperature
   [
   ask patches with [ vessel != 0 ] ; selecting only those patches that have pots and therefore the presence of a fishing boat
   [
     set catchS 0

  ask crabs1-here ; cycle through every size 1 crab on the patch in question and determine whether or not it gets caught
  [

    set catchability1 random-float 1.0  ;; catchability is the chance that the crab will be caught.

    ifelse catchability1 < q1 and (catchS + catchM + catchL) < 320 [  set crabcatch1 crabcatch1 + 1 ;; if the chance of being caught is less than this threshold the crab
          ; is caught and removed from the population.
      ; In addition if the number of crabs already caught exceeds 320, the pot is deemed full and the crab cannot be caught. This applies to all crab sizes.
     set catchS catchS + crabcatch1    ; adds the crabs of size 1 to the catch total for this patch
      if catchability1 < q1 [ die ]  ; caught crabs are removed from the population.
      ]
    [ set catchS catchS + 0 ] ]

   if vessel = 1 [ set list1 lput catchS list1 ] ; the programme looks for the list accumulating catches for each vessel and adds the catch.
    if vessel = 2 [ set list2 lput catchS list2 ]
    if vessel = 3 [ set list3 lput catchS list3 ]
    if vessel = 4 [ set list4 lput catchS list4 ]
    if vessel = 5 [ set list5 lput catchS list5 ]
    if vessel = 6 [ set list6 lput catchS list6 ]
    if vessel = 7 [ set list7 lput catchS list7 ]
    if vessel = 8 [ set list8 lput catchS list8 ]
    if vessel = 9 [ set list9 lput catchS list9 ]
    if vessel = 10 [ set list10 lput catchS list10 ]
    if vessel = 11 [ set list11 lput catchS list11 ]
    if vessel = 12 [ set list12 lput catchS list12 ]
    if vessel = 13 [ set list13 lput catchS list13 ]
    if vessel = 14 [ set list14 lput catchS list14 ]
    if vessel = 15 [ set list15 lput catchS list15 ]
    if vessel = 16 [ set list16 lput catchS list16 ]
    if vessel = 17 [ set list17 lput catchS list17 ]
    if vessel = 18 [ set list18 lput catchS list18 ]
    if vessel = 19 [ set list19 lput catchS list19 ]
    if vessel = 20 [ set list20 lput catchS list20 ]
   ]

    ask patches with [ vessel != 0 ] [
      set catchM 0

   ask crabs2-here  ;; cycles through all the crabs of size 2 and calculates the catch by each vessel on each day.

   [
     set catchability2 random-float 1.0  ;; catchability can be different for the different crab sizes
     ifelse catchability2 < q2 and (catchS + catchM + catchL) < 320 [ set crabcatch2 crabcatch2 + 1 ;; if the chance of being caught is less than this threshold
                                                                                                       ;the crab is caught and removed from the population.
     set catchM catchM + crabcatch2  ; adds the crabs of size 2 to the catch total for this patch
     if catchability2 < q2 [ die ]
      ]

    [ set catchM catchM + 0 ] ]

   if vessel = 1 [ set list21  lput catchM list21 ]
    if vessel = 2 [ set list22 lput catchM list22 ]
    if vessel = 3 [ set list23 lput catchM list23 ]
    if vessel = 4 [ set list24 lput catchM list24 ]
    if vessel = 5 [ set list25 lput catchM list25 ]
    if vessel = 6 [ set list26 lput catchM list26 ]
    if vessel = 7 [ set list27 lput catchM list27 ]
    if vessel = 8 [ set list28 lput catchM list28 ]
    if vessel = 9 [ set list29 lput catchM list29]
    if vessel = 10 [ set list30 lput catchM list30 ]
    if vessel = 11 [ set list31 lput catchM list31 ]
    if vessel = 12 [ set list32 lput catchM list32 ]
    if vessel = 13 [ set list33 lput catchM list33]
    if vessel = 14 [ set list34 lput catchM list34 ]
    if vessel = 15 [ set list35 lput catchM list35 ]
    if vessel = 16 [ set list36 lput catchM list36 ]
    if vessel = 17 [ set list37 lput catchM list37]
    if vessel = 18 [ set list38 lput catchM list38 ]
    if vessel = 19 [ set list39 lput catchM list39]
    if vessel = 20 [ set list40 lput catchM list40 ]
    ]

    ask patches with [ vessel != 0 ] [

      set catchL 0

   ask crabs3-here  ;; cycles through all the crabs of size 3 and calculates the catch by each vessel on each day.
   [
     set catchability3 random-float 1.0
      ifelse catchability3 < q3 and (catchS + catchM + catchL) < 320 [ set crabcatch3 crabcatch3 + 1 ;; if the chance of being caught is less than this threshold the crab
                                                                                                       ;is caught and removed from the population.
     set catchL catchL + crabcatch3 ; adds the crabs of size 3 to the catch total for this patch
     if catchability3 < q3 [ die ]
      ]

    [ set catchL catchL + 0 ] ]

   if vessel = 1 [ set list41  lput catchL list41 ]
    if vessel = 2 [ set list42 lput catchL list42 ]
    if vessel = 3 [ set list43 lput catchL list43 ]
    if vessel = 4 [ set list44 lput catchL list44 ]
    if vessel = 5 [ set list45 lput catchL list45 ]
    if vessel = 6 [ set list46 lput catchL list46 ]
    if vessel = 7 [ set list47 lput catchL list47 ]
    if vessel = 8 [ set list48 lput catchL list48 ]
    if vessel = 9 [ set list49 lput catchL list49]
    if vessel = 10 [ set list50 lput catchL list50 ]
    if vessel = 11 [ set list51 lput catchL list51 ]
    if vessel = 12 [ set list52 lput catchL list52 ]
    if vessel = 13 [ set list53 lput catchL list53]
    if vessel = 14 [ set list54 lput catchL list54 ]
    if vessel = 15 [ set list55 lput catchL list55 ]
    if vessel = 16 [ set list56 lput catchL list56 ]
    if vessel = 17 [ set list57 lput catchL list57]
    if vessel = 18 [ set list58 lput catchL list58 ]
    if vessel = 19 [ set list59 lput catchL list59]
    if vessel = 20 [ set list60 lput catchL list60 ]


    ]
   ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to sum-catches



  ask turtles [

    set totalcrabs count turtles
    set totalcrabs1 count crabs1
    set totalcrabs2 count crabs2
    set totalcrabs3 count crabs3

  ]

  ask patches with [ vessel != 0 ] [


  ;before the catches for each vessel from each patch for each crab size are summed, the variable for the totals is set to zero

  set catch1 0 set catch21 0 set catch41 0
  set catch2 0 set catch22 0 set catch42 0
  set catch3 0 set catch23 0 set catch43 0
  set catch4 0 set catch24 0 set catch44 0
  set catch5 0 set catch25 0 set catch45 0
  set catch6 0 set catch26 0 set catch46 0
  set catch7 0 set catch27 0 set catch47 0
  set catch8 0 set catch28 0 set catch48 0
  set catch9 0 set catch29 0 set catch49 0
  set catch10 0 set catch30 0 set catch50 0
  set catch11 0 set catch31 0 set catch51 0
  set catch12 0 set catch32 0 set catch52 0
  set catch13 0 set catch33 0 set catch53 0
  set catch14 0 set catch34 0 set catch54 0
  set catch15 0 set catch35 0 set catch55 0
  set catch16 0 set catch36 0 set catch56 0
  set catch17 0 set catch37 0 set catch57 0
  set catch18 0 set catch38 0 set catch58 0
  set catch19 0 set catch39 0 set catch59 0
  set catch20 0 set catch40 0 set catch60 0
  ]



  ask n-of 1 patches with [ vessel = 1 ] [ ; without this line the programme prints the same totals for every patch belonging to a vessel.
      set catchtotal 0
  set catch1 sum butfirst list1
  set catch21 sum butfirst list21
  set catch41 sum butfirst list41
  set catchtotal catch1 + catch21 + catch41
  if v1 [
  file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch1 ",")
  file-type (word catch21 ",")
  file-type (word catch41 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area1)
] file-close
  ]


  ask n-of 1 patches with [ vessel = 2 ] [
  set catchtotal 0
  set catch2 sum butfirst list2
  set catch22 sum butfirst list22
  set catch42 sum butfirst list42
  set catchtotal catch2 + catch22 + catch42
  if v2 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch2 ",")
  file-type (word catch22 ",")
  file-type (word catch42 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area2)
]file-close
  ]



  ask n-of 1 patches with [ vessel = 3 ] [
  set catchtotal 0
  set catch3 sum butfirst list3
  set catch23 sum butfirst list23
  set catch43 sum butfirst list43
  set catchtotal catch3 + catch23 + catch43
  if v3 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch3 ",")
  file-type (word catch23 ",")
  file-type (word catch43 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area3)
]file-close
  ]



  ask n-of 1 patches with [ vessel = 4 ] [
        set catchtotal 0
  set catch4 sum butfirst list4
   set catch24 sum butfirst list24
  set catch44 sum butfirst list44
      set catchtotal catch4 + catch24 + catch44
  if v4 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch4 ",")
  file-type (word catch24 ",")
  file-type (word catch44 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area14)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 5 ] [
        set catchtotal 0
  set catch5 sum butfirst list5
  set catch25 sum butfirst list25
  set catch45 sum butfirst list45
  set catchtotal catch5 + catch25 + catch45
  if v5  [
       file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch5 ",")
  file-type (word catch25 ",")
  file-type (word catch45 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area5)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 6 ] [
        set catchtotal 0
  set catch6 sum butfirst list6
  set catch26 sum butfirst list26
  set catch46 sum butfirst list46
  set catchtotal catch6 + catch26 + catch46
  if v6 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch6 ",")
  file-type (word catch26 ",")
  file-type (word catch46 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area6)
]file-close
  ]


    ask n-of 1 patches with [ vessel = 7 ] [
        set catchtotal 0
    set catch7 sum butfirst list7
  set catch27 sum butfirst list27
  set catch47 sum butfirst list47
  set catchtotal catch7 + catch27 + catch47
  if v7  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch7 ",")
  file-type (word catch27 ",")
  file-type (word catch47 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area7)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 8 ] [
        set catchtotal 0
  set catch8 sum butfirst list8
  set catch28 sum butfirst list28
  set catch48 sum butfirst list48
  set catchtotal catch8 + catch28 + catch48
  if v8  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch8 ",")
  file-type (word catch28 ",")
  file-type (word catch48 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area8)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 9 ] [
        set catchtotal 0
  set catch9 sum butfirst list9
  set catch29 sum butfirst list29
  set catch49 sum butfirst list49
  set catchtotal catch9 + catch29 + catch49
  if v9  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch9 ",")
  file-type (word catch29 ",")
  file-type (word catch49 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area9)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 10 ] [
        set catchtotal 0
    set catch10 sum butfirst list10
  set catch30 sum butfirst list30
  set catch50 sum butfirst list30
  set catchtotal catch10 + catch30 + catch50
  if v10  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch10 ",")
  file-type (word catch30 ",")
  file-type (word catch50 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area10)
]file-close
  ]


    ask n-of 1 patches with [ vessel = 11 ] [
        set catchtotal 0
    set catch11 sum butfirst list11
  set catch31 sum butfirst list31
  set catch51 sum butfirst list51
  set catchtotal catch11 + catch31 + catch51
  if v11  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch11 ",")
  file-type (word catch31 ",")
  file-type (word catch51 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area11)
] file-close
  ]


  ask n-of 1 patches with [ vessel = 12 ] [
        set catchtotal 0
  set catch12 sum butfirst list12
  set catch32 sum butfirst list32
  set catch52 sum butfirst list52
  set catchtotal catch12 + catch32 + catch52
  if v12  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch12 ",")
  file-type (word catch32 ",")
  file-type (word catch52 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area12)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 13 ] [
        set catchtotal 0
    set catch13 sum butfirst list13
  set catch33 sum butfirst list33
  set catch53 sum butfirst list53
  set catchtotal catch13 + catch33 + catch53
  if v13  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch12 ",")
  file-type (word catch33 ",")
  file-type (word catch53 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area13)
] file-close
  ]


  ask n-of 1 patches with [ vessel = 14 ] [
        set catchtotal 0
 set catch14 sum butfirst list14
  set catch34 sum butfirst list34
  set catch54 sum butfirst list54
  set catchtotal catch14 + catch34 + catch54
  if v14 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch14 ",")
  file-type (word catch34 ",")
  file-type (word catch54 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area14)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 15 ] [
        set catchtotal 0
  set catch15 sum butfirst list15
  set catch35 sum butfirst list35
  set catch55 sum butfirst list55
  set catchtotal catch15 + catch35 + catch55
  if v15  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch15 ",")
  file-type (word catch35 ",")
  file-type (word catch55 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area15)
]file-close
  ]


  ask n-of 1 patches with [ vessel = 16 ] [
        set catchtotal 0
    set catch16 sum butfirst list16
  set catch36 sum butfirst list36
  set catch56 sum butfirst list56
  set catchtotal catch16 + catch36 + catch56
  if v16  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch16 ",")
  file-type (word catch36 ",")
  file-type (word catch56 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area16)
      ] file-close
  ]


  ask n-of 1 patches with [ vessel = 17 ] [
        set catchtotal 0
    set catch17 sum butfirst list17
  set catch37 sum butfirst list37
  set catch57 sum butfirst list57
  set catchtotal catch17 + catch37 + catch57
  if v17 [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch17 ",")
  file-type (word catch37 ",")
  file-type (word catch57 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area17)
 ] file-close
  ]


  ask n-of 1 patches with [ vessel = 18 ] [
        set catchtotal 0
    set catch18 sum butfirst list18
  set catch38 sum butfirst list38
  set catch58 sum butfirst list58
  set catchtotal catch18 + catch38 + catch58
  if v18  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch18 ",")
  file-type (word catch38 ",")
  file-type (word catch58 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area18)
  ] file-close
  ]


  ask n-of 1 patches with [ vessel = 19 ] [
  set catchtotal 0
  set catch19 sum butfirst list19
  set catch39 sum butfirst list39
  set catch59 sum butfirst list59
  set catchtotal catch19 + catch39 + catch59
  if v19  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch19 ",")
  file-type (word catch39 ",")
  file-type (word catch59 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area19)
  ] file-close
  ]


  ask n-of 1 patches with [ vessel = 20 ] [
        set catchtotal 0
    set catch20 sum butfirst list20
  set catch40 sum butfirst list40
  set catch60 sum butfirst list60
  set catchtotal catch20 + catch40 + catch60
  if v20  [
      file-open "Catches_per_vessel_per_day v11.csv"
  file-type (word year ",")
  file-type (word samples ",")
  file-type (word catchability1 ",")
  file-type (word catchability2 ",")
  file-type (word catchability3 ",")
  file-type (word catch20 ",")
  file-type (word catch40 ",")
  file-type (word catch60 ",")
  file-type (word catchtotal ",")
  file-type (word totalcrabs ",")
  file-type (word totalcrabs1 ",")
  file-type (word totalcrabs2 ",")
  file-type (word totalcrabs3 ",")
  file-type (word vessel ",")
  file-print (word area20)
  ]file-close
  ]


;; In what follows the vessel totals are added together to produce the global catch for a given day
  set totalcatch1 0 set totalcatch2 0 set totalcatch3 0 set totalcatch 0
  set totalcatch1 totalcatch1 + catch1 + catch2 + catch3 + catch4 + catch5 + catch6 + catch7 + catch8 + catch9 + catch10 + catch11 + catch12 + catch13 + catch14 + catch15 + catch16 + catch17 + catch18 + catch19 + catch20
  set totalcatch2 totalcatch2 + catch21 + catch22 + catch23 + catch24 + catch25 + catch26 + catch27 + catch28 + catch29 + catch30 + catch31 + catch32 + catch33 + catch34 + catch35 + catch36 + catch37 + catch38 + catch39 + catch40
  set totalcatch3 totalcatch3 + catch41 + catch42 + catch43 + catch44 + catch45 + catch46 + catch47 + catch48 + catch49 + catch50 + catch51 + catch52 + catch53 + catch54 + catch55 + catch56 + catch57 + catch58 + catch59 + catch60
  set totalcatch totalcatch + totalcatch1 + totalcatch2 + totalcatch3

set samples samples + 1

 file-close
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

There are 2 versions of this model.

Uploaded by When Description Download
Paul Hart over 1 year ago Updated version with best recruitment function Download this version
Paul Hart about 2 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Catches_per_vessel_per_day v11.csv data File for the output of catch data by vessel and day over 1 year ago, by Paul Hart Download
Co-ords IPA pots vessels sed2 depth.txt data File with input data about 2 years ago, by Paul Hart Download
Slapton temps daily mean st dev.txt data Temperature profile for the model over 1 year ago, by Paul Hart Download
Spawning_stock_size_v11.csv data File for recording spawning stock size each year over 1 year ago, by Paul Hart Download
SST Plymouth 95-14 M & SD.txt data Sea surface temperature off Plymouth for recruitment function over 1 year ago, by Paul Hart Download

This model does not have any ancestors.

This model does not have any descendants.