Sayuri
Sayuri

Reputation: 94

NETLOGO: pass on water amount along the nodes of a river network

I would like to simulate the water flow along a river with NETLOGO. Therefore I do have many water nodes which are linked to each other; and each water node having the variable "amount_water". Every tick, the variable "amount_water" should be passed on to the next water node. At each node waterusers (various agents) can interact with the stream flow and extract some water, which would change the variable "amount_water"; but now I would like show you the modelled river flow only, without the water users.

if you have a model world with min-pycor -6 and max-pycor 6:

breed [waternodes waternode]

waternodes-own
[
  amount_water
]

to setup  

  clear-all
  reset-ticks

  ; create the waternodes

  create-waternodes 13 [setxy 0 (who - 6) set shape "dot" set color blue]
  ask waternodes 
     [
     let neighborbelow waternodes-on neighbors4 with [pycor < [ycor] of myself]
     create-links-to waternodes-on neighborbelow
     ]

end

to go
  move-water
  update-inflow
  tick
end

to move-water
  ask waternodes 
  [
  ask out-link-neighbors [set amount_water [amount_water] of myself]
  ]

end

to update-inflow
  ask waternode 12 [set amount_water ticks]
end

(in my model, the inflow is of course not the number of ticks, but it is read in from a csv-file)

My problem: With this code, the amount of water is NOT continuously passed on from node to node (and I do not know why!!) ????

And generally, I am not so sure if this network is the best idea to represent a stream flow. Can you think of other solutions?

Many thanks

Upvotes: 0

Views: 94

Answers (1)

Sayuri
Sayuri

Reputation: 94

I have solved the problem so far. It seems that when I just call the waternodes in move-water like this

to move-water
   ask waternodes 
   [
   ask out-link-neighbors [set amount_water [amount_water] of myself]
   ]
end

, the waternodes are not always called in order from 0 to 11.

Therfore I changed the code to

to move-water
  (foreach sort-on [who] waternodes
    [the-turtle -> ask the-turtle [ask out-link-neighbors [set amount_water [amount_water] of myself]]])
end

and now it is working!

Upvotes: 1

Related Questions