Clouds self-organization

Clouds self-organization preview image

1 collaborator

Alonsela Alon Sela (Author)

Tags

Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 163 times • Downloaded 11 times • Run 0 times
Download the 'Clouds self-organization' 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

globals
[old-pen-mode
  minx
  maxx
  miny
  maxy
  ]


patches-own [
  chemical]

turtles-own
[d_growth]

to setup
  create-turtles population [
    setxy random-xcor random-ycor
    set size random 5
    ;set shape "circlephase"
    set shape "cloud"
    set d_growth 0
    ifelse label-all [set label who]
                     [set label "" if (who = 0) [set label "yohooo"]]
    if (heading > 0 and heading < 90)
    [set color red]
    if (heading > 90 and heading <= 180)
    [set color green]
     if (heading > 180 and heading < 360)
     [set color gray]

  ]
  set minx min [xcor] of turtles
  set maxx max [xcor] of turtles
  set miny min [ycor] of turtles
  set maxy max [ycor] of turtles
end 

to update
  set minx min [xcor] of turtles
  set maxx max [xcor] of turtles
  set miny min [ycor] of turtles
  set maxy max [ycor] of turtles
  let maxhumidity max[pcolor] of patches  ; scale max = 40
  ;print maxhumidity

  ask turtles [
    if phase-turn?
    [ifelse humidity-preserve-cloud
      [let humidity 40 - [pcolor] of patch-here ; scale 30-40
;        set heading heading + phase-speed * (1 + 10 / (humidity + 0.001)) ]
         ifelse (heading > 0 and heading < 180)
         [if (maxhumidity > 0 ) [set heading heading + (phase-speed) * (1 - (humidity / (maxhumidity))) ]]  ;this area needs refining with Ilan acording to real theory of humidity and clouds
         [set heading heading + (phase-speed + 0.001)]
      ]

       [set heading heading + phase-speed]

    let new-size sin(heading) * size-scaler
    set d_growth  new-size - size
    set size new-size
    if (size < 0 )
    [set size 0
      set d_growth 0]

    if debug? [if who = 0 [print d_growth]]
    ifelse (d_growth > 0 )
    [set color red]
    [set color green]
    ]
    if size > 0 [update-position ]

    set xcor xcor + random-float 0.1 - 0.05 + wind-speed
    set ycor ycor + random-float 0.1 - 0.05

    if (size > 0) [set chemical chemical + 50]     ; change here type of relationship between cloud and humidity of space

    ;   if ( xcor < 2) [set xcor max10]
    ;   if ( ycor < miny + 1 or ycor > maxy - 1) [set ycor 10]
  ]
  diffuse chemical (diffusion-rate / 100)
  if humidity-path-color?
  [ask patches
    [ set chemical chemical * (100 - evaporation-rate) / 100  ;; slowly evaporate chemical
      recolor-patch ]
  ]
  penmode
  tick
end 

to update-position  ;turtle procedure

  let old-heading heading
  let friends-set turtles in-radius radius
  set friends-set friends-set with [self != myself]
  set friends-set friends-set with [size > 0]
  if debug? [
    print "______________________________________________"
    type "from " type who type " num of friends = " print count(friends-set)
    ask friends-set [if debug? [type "...frined number = "print who]]
  ]
  let myXvector 0
  let myYvector 0
  ask friends-set [
    if debug? [type "self = " print myself type " friend # = " type who type " with d_growth =" print precision [d_growth] of turtle who 3]
    let inf influence who myself
    set myXvector myXvector + first inf
    set myYvector myYvector + last inf

    if debug?
  [
      type "turtle " type myself type ": myXvector= " type precision myXvector 3 type " myXvector = " print precision myYvector 3]
  ]
  if move?
  [ set xcor xcor + myXvector * slowingfactor
    set ycor ycor + myYvector * slowingfactor
  ]
end 

;to-report cloudsize [cloudnum] ;turtle reporter - receives agent number
;  let reporter 0
;  ask turtle cloudnum [set reporter size]
;  report reporter
;end

to-report influence [source destin] ;reports the influence of "source" on "destin"
  let destination destin
  let angle 0
  let deltax [xcor] of turtle source - [xcor] of destination
  let deltay [ycor] of turtle source - [ycor] of destination
  ifelse (deltay != 0 or deltay != 0)
    [set angle atan deltay deltax]
    [set angle 0]
  set deltax cos angle
  set deltay sin angle

  let influence_source [d_growth] of turtle source
;  let vectorsize ((deltax ^ 2) + (deltay ^ 2)) ^ 0.5
;
;if debug? [type "" type "source = " type source type " dest = " type destination type "influence = " print precision influence_source 4
;  type " deltax = " type precision deltax 3 type " deltay = " type precision deltay 3 type " power = "print precision influence_source  3
;           type "d_growth of " type "of turtle " type source type "= " print precision influence_source 3]
;
  if (influence_source >  0 )
   [set deltax precision (- deltax) 5
    set deltay precision (- deltay) 5]
;
  let result list deltax deltay
  if debug? [type "turtle " type source
    ifelse (influence_source > 0) [type " REPEL "] [type " ATTRACT " ]
    type "turtle " type destin type " by" print result]
  report result
end 

to penmode
  if  (old-pen-mode != pen-down?)
    [if debug? [print "pen- changemode"]
      ifelse pen-down?
        [ask turtles [pen-down]]
        [ask patches [set pcolor black]
         ask turtles [pen-up
                      pen-erase
]
        ]
    ]
  set old-pen-mode pen-down?
end 

to recolor-patch  ;; patch procedure
     ;; scale color to show chemical concentration
    set pcolor scale-color yellow chemical 0.1 5
end 

to clear
  clear-all
  reset-ticks
end 

There is only one version of this model, created about 3 years ago by Alon Sela.

Attached files

File Type Description Last updated
Clouds self-organization.png preview Preview for 'Clouds self-organization' about 3 years ago, by Alon Sela Download

This model does not have any ancestors.

This model does not have any descendants.