布局弹簧具有不同的弹簧常数

时间:2016-03-04 00:07:49

标签: netlogo

The top picture is the material at the time of <code>setup</code> and the bottom picture is at the time of error

我正在尝试使用与layout-spring类似的东西来模拟组织力学,但我想改变弹簧常数&#34;根据补丁变量的链接,即链接的异构弹簧常数。有没有办法使用layout-spring原语执行此操作?不幸的是我不知道java我相信是源代码。

我还尝试使用NetLogo语言开始编码layout-spring,但在测试代码时,节点拍摄不正确。以下是我尝试过的相关代码。

links-own [fx fy k]

turtles-own [dxx dyy]

to setup
ask patches with [(pxcor <= (-20)) and ((abs pycor) < (max-pycor / 2))] [sprout 1]
ask turtles [create-links-to turtles-on neighbors4]

to deform   ; propagate deformation of the material by connecting nodes with springs

ask driver [set heading 90   ;driver is an agentset
            fd .01]
ask pinned [set xcor min-pxcor] ;prevents translation of the entire material ;pinned is an agentset

ask links [set fx (k * (link-length - 1) * sin link-heading) * -1
           set fy (k * (link-length - 1) * cos link-heading) * -1]

 ask not-pinned [set dxx sum [fx] of my-in-links
                 set dyy sum [fy] of my-in-links]

 ask not-pinned [set xcor xcor + dxx
                 set ycor ycor + dyy]

 end

这段简单的代码无效。如果我可以使这个工作,也许我可以使用补丁变量来改变链接的弹簧常数(k)。但是如果有办法使用layout-spring原语来实现这一点,那么我更喜欢这样的方法。

0 个答案:

没有答案