Kepler Light Curve

No preview image

1 collaborator

Default-person Cody Dirks (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by the author
Model was written in NetLogo 5.1.0 • Viewed 128 times • Downloaded 17 times • Run 0 times
Download the 'Kepler Light Curve' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

turtles-own
[ 
  vx     ;; x-component of velocity vector
  xc     ;; real x-coordinate (in case particle leaves world)
  yc     ;; real y-coordinate (in case particle leaves world)
]

globals
[
  period
  flux
  max-flux
  scaler
  g  ;; Gravitational Constant
]

;;;;;;;;;;;;;;;;;;;;;;;;
;;; Setup Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;

to setup
  clear-all
  set scaler scale
  setup-patches
  set max-flux count patches with [pcolor = yellow]
  set-default-shape turtles "circle"
  set period 1000000
  reset-ticks
end 

to setup-patches
  ask patches[set pcolor black]
  ask patches with [(sqrt((pxcor * pxcor) + (pycor * pycor)) < 200)][set pcolor yellow]
end 


;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Runtime Procedures ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;

to go
  if ((ticks mod period) = 0)
  [
    reset-ticks
    instance-planet
  ]
  ask turtles [ update-position ]
  calculate-flux
  check-position
  tick
end 

to instance-planet
  clear-turtles
  crt 1
  [ 
    set period round (1000 / scaler * sqrt(orbit-distance * orbit-distance * orbit-distance))
    set xc -300
    set yc 0
    set color black
    set size (200 * (planet-radius / (100 - orbit-distance)))
    setxy xc yc
    set vx (sqrt ((0.593) / orbit-distance)) * scaler
  ]
    set-plot-x-range (0) (5 * period)
end 

to update-position ;; Turtle Procedure
  ;; As our system is closed, we can safely recenter the center of mass to the origin.
  set xc (xc + vx)
  adjust-position
end 

to check-position
  ask turtles[
    if xc > max-pxcor[ die ]
  ]
end 

to adjust-position ;; Turtle Procedure
  ;; If we're in the visible world (the world inside the view)
  ;; update our x and y coordinates.
  ;; if there is no patch at xc yc that means it is outside the world
  ;; and the turtle should just be hidden until it returns to the
  ;; viewable world.
  ifelse patch-at (xc - xcor) (yc - ycor) != nobody
  [ setxy xc yc
    show-turtle
  ]
  [ hide-turtle ]
end 

to calculate-flux
  ask turtles[
    ask patches in-radius (size / 2)
      [set pcolor black]
  ]
  set flux ((count patches with [pcolor = yellow]) / max-flux)
  ask turtles[
    ask patches in-radius size[
    if (sqrt((pxcor * pxcor) + (pycor * pycor)) < 200)
      [set pcolor yellow]
    ]
  ]


;  ifelse count turtles > 0[
;    ifelse abs [xc] of turtle 0 < 200
;    [set flux (1 - ((planet-size * planet-size) / (200 * 200)))]
;    [set flux 1]
;  ]
;  [set flux 1]
end 

to update-patches
  if count turtles > 0[
    ask turtles[
      let x xc
      ask patches with [(sqrt((pxcor * pxcor) + (pycor * pycor)) < 200)][
        ifelse (sqrt((pxcor - x) * (pxcor - x) + (pycor * pycor)) < [size] of turtle 0)
        [set pcolor black]
        [set pcolor yellow]
      ]
    ]
  ]
end 



; Copyright 1998 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created over 9 years ago by Cody Dirks.

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.