!!!---val.nlogo

来自「NETLOGO」· NLOGO 代码 · 共 313 行

NLOGO
313
字号
globals [
  clock            ;; number of ticks that have passed in simulation
  membrane-edge-x  ;; horizontal distance from center to edge of membrane
  membrane-edge-y  ;; vertical distance from center to edge of membrane
]

turtles-own [
  edge?            ;; are we on the edge of the membrane?
  driver?          ;; are we part of the green driving plate?
  x                ;; position on x axis in space
  y                ;; position on y axis in space
  z                ;; position on z axis in space
  velocity         ;; velocity along z axis
  neighbor-turtles ;; agentset of turtles adjacent to us
]

to setup
  ca
  set clock 0
  set membrane-edge-x floor (screen-edge-x / 2)
  set membrane-edge-y floor (screen-edge-y / 2)
  set-default-shape turtles "circle" 
  ask patches with [(abs pxcor <= membrane-edge-x) and
                    (abs pycor <= membrane-edge-y)]
    [ sprout 1
        [ set edge? (abs xcor = membrane-edge-x) or
                    (abs ycor = membrane-edge-y)
          if edge? [ set color blue ]
          set driver? (abs (xcor - gonilnik-x) <= velikost-gonilnika) and
                      (abs (ycor - gonilnik-y) <= velikost-gonilnika)
          if driver? [ set color green ]
          set x xcor
          set y ycor
          set z 0
          set velocity 0
          recolor ] ]
  ask turtles
    [ set neighbor-turtles turtles-on neighbors4 ]
  project
end

to recolor  ;; turtle procedure
  if not edge? and not driver?
    [ set color scale-color red z -20 20 ]
end

to go
  ask turtles with [not driver? and not edge?]
    [ propagate ]
  ask turtles
    [ ifelse driver?
        [ set z (amplituda * (sin (0.1 * frekvenca * clock))) ]
        [ set z (z + velocity)
          recolor ] ]
  project
  set clock clock + 1
end

to propagate   ;; turtle procedure -- propagates the wave from neighboring turtles
  set velocity (velocity +
                 (trdnost-opne * 0.01 *
                   (sum values-from neighbor-turtles [z]
                    - 4 * z)))
  set velocity (((1000 - trenje-opne) / 1000) * velocity)
end

;;; procedures for displaying in 2-D or 3-D

to project
  ifelse tri-d?
    [ project-3d ]
    [ project-2d ]
end

to project-3d
  ask turtles [
    setxy (x + (cos kot-gledanja) * y) (z + (sin kot-gledanja) * y)
    ;; don't draw turtles that "wrap" around the screen edge
    ifelse abs (z + (sin kot-gledanja) * y) > screen-edge-y
      [ hide-turtle ]
      [ show-turtle ]
    recolor
  ]
end

to project-2d
  ;; Set our on-screen x and y coordinates to be the same as our real
  ;; coordinates.  This is only needed for if the user turns THREE-D?
  ;; off while the model is running.
  ask turtles
    [ setxy x y
      recolor
      show-turtle ]
end


; *** NetLogo Model Copyright Notice ***
;
; This model was created as part of the project: CONNECTED MATHEMATICS:
; MAKING SENSE OF COMPLEX PHENOMENA THROUGH BUILDING OBJECT-BASED PARALLEL
; MODELS (OBPML).  The project gratefully acknowledges the support of the
; National Science Foundation (Applications of Advanced Technologies
; Program) -- grant numbers RED #9552950 and REC #9632612.
;
; Copyright 1996 by Uri Wilensky. All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
;    from Uri Wilensky.
; Contact Uri Wilensky for appropriate licenses for redistribution for
; profit.
;
; This model was converted to NetLogo as part of the project:
; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN
; CLASSROOMS.  The project gratefully acknowledges the support of the
; National Science Foundation (REPP program) -- grant number REC #9814682.
; Converted from StarLogoT to NetLogo, 2001.  Updated 2003.
;
; To refer to this model in academic publications, please use:
; Wilensky, U. (1996).  NetLogo Wave Machine model.
; http://ccl.northwestern.edu/netlogo/models/WaveMachine.
; Center for Connected Learning and Computer-Based Modeling,
; Northwestern University, Evanston, IL.
;
; In other publications, please use:
; Copyright 1998 by Uri Wilensky.  All rights reserved.  See
; http://ccl.northwestern.edu/netlogo/models/WaveMachine
; for terms of use.
;
; *** End of NetLogo Model Copyright Notice ***
@#$#@#$#@
GRAPHICS-WINDOW
350
20
730
400
90
90
2.0
0
10
0
0

CC-WINDOW
20
390
300
530
Command Center

BUTTON
40
40
130
80
nastavi
setup
NIL
1
T
OBSERVER

BUTTON
190
40
280
80
za鑞i
go
T
1
T
OBSERVER

SWITCH
20
320
110
360
tri-d?
tri-d?
0
1
-1000

SLIDER
20
105
150
135
trdnost-opne
trdnost-opne
0.0
50.0
10.0
0.1
1
NIL

SLIDER
170
105
300
135
trenje-opne
trenje-opne
0.0
99.0
47.0
0.1
1
NIL

SLIDER
20
165
150
195
gonilnik-x
gonilnik-x
-11
11
-11
1
1
NIL

SLIDER
170
165
300
195
gonilnik-y
gonilnik-y
5
50
0
1
1
NIL

SLIDER
90
210
230
245
velikost-gonilnika
velikost-gonilnika
0
10
3
1
1
NIL

SLIDER
20
255
150
285
amplituda
amplituda
0.0
30.0
15.0
0.1
1
NIL

SLIDER
170
255
300
285
frekvenca
frekvenca
0.0
100.0
45.0
0.1
1
NIL

SLIDER
170
325
280
355
kot-gledanja
kot-gledanja
0.0
90.0
17.0
0.1
1
NIL

@#$#@#$#@
KAJ JE TO?
---------------

Model simulira valovanje na opni. 妕irje robovi opne so fiksirani v okviru. Zelena pravokotna povr歩na predstavlja gonilno plo氳o, ki se premika gor in dol ter prikazuje sinusno valovanje.


KAKO UPORABLJAMO
----------------

Krmila za posebnosti opne:

Drsnik TRENJE krmili koli鑙no trenja oziroma tanj歛nje opne. Drsnik TRDNOST krmili mo

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?