【问题标题】:Netlogo Programming question - Chemical Equilibrium temperature and pressure implementationNetlogo 编程题 - 化学平衡温度和压力实现
【发布时间】:2011-01-23 15:28:27
【问题描述】:

我正在尝试在 Netlogo 中编写代码。我正在使用现有的化学平衡模型并尝试实现以下内容:

乌龟自己的[速度]

问海龟 [

;; set velocity ( ambient-temperature = 30 )
;; fd velocity
if temp  > 40 [ "speed" increases of turtles  ]  
ifelse temperature < 30 [ speed of turtles decreases]

]

;;温度

但它似乎不起作用

(温度超过 40 龟的速度增加 如果温度低于 30,海龟的速度会降低) 温度是模型上的一个滑块

压力也一样 问海龟 [

;; if pressure > 50 then speed increases of turtles
;; if pressure < 50 then speed decreases of turtles

]

;;给压力

谢谢

【问题讨论】:

    标签: computer-science simulation netlogo chemistry


    【解决方案1】:

    我认为您正在尝试做的事情是这样的:

    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
    

    我必须添加最小和最大速度(分别为 0 和 100),否则速度会很快达到无穷大。此外,“温度”是我模型中的一个滑块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-10
      • 1970-01-01
      • 1970-01-01
      • 2015-05-01
      • 2012-06-16
      • 2016-05-28
      • 2022-11-08
      • 1970-01-01
      相关资源
      最近更新 更多