State of Matter-Water

State of Matter-Water preview image

1 collaborator

Screen_shot_2018-02-02_at_12.53.50_pm lin xiang (Author)

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.0 • Viewed 223 times • Downloaded 17 times • Run 0 times
Download the 'State of Matter-Water' 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

turtles-own [step solid core mylink watched]
patches-own [occupied tt-here]
globals [  ]

to setup
clear-all

create-turtles number-of-molecules
[set color red
 set size 2
 set shape "molecule water"
 set step 0.2
 set solid false
 set core false
 set mylink 0
 set watched false
 setxy random-xcor random-ycor ]

 check-turtles-here

reset-ticks
end 

to check-turtles-here
  ask patches
  [ifelse any? turtles-here
    [set occupied true set pcolor 2 ]
    [set occupied false set pcolor 0]
   if count neighbors with [occupied = true] >= 5 [set occupied true set pcolor 2]
    set tt-here count turtles-here]

   diffuse pcolor 1
end 

to go

  ifelse mean [step] of turtles > 0.02
  [ melt
    attraction
    repulsion
    move]
  [ set-core
    if random 100 < 50 [crystalization]
    if not any? turtles with [solid = false] [move-1]
  ]

  check-turtles-here

  tick
end 

to move
  ask turtles with [solid = false]
    [ifelse step <= 0 [user-message "The molecules cannot be cooled any more." stop]
    [fd step
      rt random-float 360]
  ]
end 

to attraction
  ask turtles [
    let a-close-molecule one-of other turtles in-radius 9
    if a-close-molecule != nobody
     [face a-close-molecule
      fd 0.1
      rt random-float 360

    ]
  ]
end 

to repulsion
   ask turtles [
    let a-close-molecule one-of other turtles in-radius 1.2
    if a-close-molecule != nobody
     [face a-close-molecule
      fd -0.3
      rt random-float 360

    ]
  ]
end 

to set-core
  if not any? turtles with [core = true]
  [ask one-of turtles with [solid = false and abs xcor < max-pxcor - 2 and abs ycor < max-pycor - 2  ]
    [
      set core true
      set solid true

  ]]
end 

to melt
  ask turtles
    [set solid false set core false set mylink 0]
end 

to move-1
  ask turtles
    [ifelse step <= 0 [user-message "The molecules cannot be cooled any more." stop]
    [
      rt random-float 5]
  ]
end 

to crystalization
  ask turtles with [core = true]
[(ifelse
  mylink = 0
  [let partner min-one-of turtles with [solid = false] [distance myself]
   if partner != nobody [
     ask partner [
      move-to myself set heading [heading] of myself
      fd -1.1 set heading heading + 180
      set core true  set solid true set mylink mylink + 1

        ]
      set mylink mylink + 1]]

   mylink = 1
   [let partner-1 min-one-of turtles with [solid = false] [distance myself]
    if partner-1 != nobody [
     ask partner-1 [
       move-to myself set heading [heading] of myself
       set-heading-1]
       set mylink mylink + 1]]

   mylink = 2
   [let partner-2 min-one-of turtles with [solid = false] [distance myself]
    if partner-2 != nobody [
     ask partner-2 [
       move-to myself set heading [heading] of myself
       set-heading-2]
       set mylink mylink + 1
       if mylink >= 3
        [set core false

    ]]])
  ]
end 

to set-heading-1
  set heading heading + 60
  ifelse not any? other turtles-on patch-ahead 1.1
  [fd 1.1 set core true  set solid true set mylink mylink + 1 detect-boundray
  ;set color cyan
  ]
  [set heading heading - 120
    ifelse not any? other turtles-on patch-ahead 1.1
    [fd 1.1
     set core true  set solid true set mylink mylink + 1 detect-boundray

    ]
    [face patch 0 0 fd random 6 set heading random 360]]
end 

to set-heading-2
  set heading heading - 60
  ifelse not any? other turtles-on patch-ahead 1.1
  [fd 1.1
   set core true  set solid true set mylink mylink + 1 detect-boundray

  ]
  [face patch 0 0 fd random 6 set heading random 360]
end 

to detect-boundray
  if abs xcor >= max-pxcor - 1 or abs ycor >= max-pycor - 1 [set mylink 3 set core false]
end 

There are 3 versions of this model.

Uploaded by When Description Download
lin xiang over 3 years ago Fix info typos Download this version
lin xiang over 4 years ago adjust the visual Download this version
lin xiang over 4 years ago Initial upload Download this version

Attached files

File Type Description Last updated
State of Matter-Water.png preview Preview for 'State of Matter-Water' over 4 years ago, by lin xiang Download

This model does not have any ancestors.

This model does not have any descendants.