材料ポイント(エージェント)を結ぶスプリング(リンク)の格子として材料をモデリングしています。有向リンクを使用して物質ポイントに作用する力を合計すると、前方に(link-heading
を使用して)ストレートになります。しかし、無向リンクを使用して速度を上げたい(リンク数を半分に減らす)。問題は、力ベクトルの正しい方向を得て、計算効率の良い方法で力ベクトルを計算することです(つまり、1回の繰り返しにつき1回のみ計算します)無向リンクによる有向リンクの置換
有向リンクを使用する):
directed-links-breed [springs spring]
springs-own [Fx Fy]
ask springs [let deformation (link-length - natural-length) ;stretch is positive
let mag-force k * deformation
;;direction of force vector is easy with directed link
set Fx mag-force * (sin link-heading)
set Fy mag-force * (cos link-heading)]
;;sum x and y components of force vectors acting on material points
ask material-points [set sigmaFx sum [Fx] of my-out-springs
set sigmaFy sum [Fy] of my-out-springs]
無向リンクを使用する私の試み:無向リンクでこのメソッドを使用して
undirected-links-breed [springs spring]
springs-own [Fx Fy force]
ask springs [let deformation (link-length - natural-length) ;stretch is positive
set force k * deformation]
;;sum x and y components of force vectors acting on material points
;;use of other-end since the link-heading does not necessarily give the correct direction of the force
ask material-points [ask my-springs [set Fx force * sin towards other-end
set Fy force * cos towards other-end]
を、私はの方には、エージェントであるので、あなたは、リンクのコンテキストに向けて使用することはできません」エラーが出ます/ patch-only "、およびhaven 'しかし、これを回避する方法を見つけました。さらに、この方法では、各バネ(リンク)が反復ごとに2回(1回に向かって1回、次に2回に向かって)力成分を計算するため、有向リンクを使用することによるスピードの向上ではありません。
誰かがこれを行うために計算上効率的な方法を推奨できますか?無向リンクで行うのが望ましいですか?
力が計算された時刻を保存し、時刻が現在の時刻でない場合は、各エージェントに計算させるように依頼することもできます。あなたはマテリアルポイントを求めるようなことを言うことができます[[最後に計算された時間!=ダニ] [....]]で私のスプリングを尋ねる。あなたのシミュレーションはゆっくり走っていますか? – mattsap