Netlogo Programming question - Chemical Equilibrium temperature and pressure implementation
I am trying to code something in Netlogo..I am using an existing model Chemical Equilibrium and am trying to implement the following:
turtles-own [speed ]
ask turtles [
;; set velocity ( ambient-temperature = 30 )
;; fd velocity
if temp > 40 [ "speed" increases of turtles ]
ifelse temperature 开发者_Python百科< 30 [ speed of turtles decreases]
]
;; to temp
but it does not seem to work
(it temperature is more than 40 the speed of the turtles increases if the temperature is less than 30 the speed of the turtles decreases) temperature is a slider on the model
the same for pressure ask turtles [
;; if pressure > 50 then speed increases of turtles
;; if pressure < 50 then speed decreases of turtles
]
;; to pressure
thanks
I think what you are trying to do is something like this:
turtles-own [speed]
to setup
ca
create-turtles 50 [
set speed 1
]
end
to go
ask turtles [
if (temperature > 40) [
set speed min (list (speed + 1) 100) ;cap the speed at 100 otherwise it will shoot to infinity
]
if (temperature < 30) [
set speed max (list (speed - 1) 0); min speed is 0
]
;move
forward speed
]
end
I had to add minimum and maximum speeds (0 and 100 respectively) otherwise the speed would quickly shoot to innfinity. Also, "temperature" is a slider in my model.
精彩评论