Single orbiting body
Model was written in NetLogo 6.1.1
•
Viewed 118 times
•
Downloaded 11 times
•
Run 0 times
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
breed [planets planet] breed [sats sat] breed [vectors vector] globals [ grav-const distance-m planet-mass-kg satellite-mass-kg vx-m-s vy-m-s acc-m-s2 vx vy acc-x acc-y m-per-patch kinetic-energy potential-energy check-orbit? vector-vectors-scale-factor ] turtles-own [ id ] to configure-iss set planet-radius 6.371 set planet-mass 5.972 set satellite-mass 41.97 set initial-velocity 7.66 set initial-altitude 6.709 setup end to setup clear-all set check-orbit? true reset-ticks set grav-const 6.67408 * 10 ^ (-11) set m-per-patch 1000000 set planet-mass-kg planet-mass * 10 ^ 24 set satellite-mass-kg satellite-mass * 10 ^ 4 create-planets 1 [ ;set label (word "planet, diameter " (size * 100) " km") set color blue set size planet-radius * 2 set shape "circle" ] create-sats 1 [ set color red set heading 270 setxy 0 initial-altitude set acc-m-s2 grav-const * planet-mass-kg / (distance one-of planets * m-per-patch) ^ 2 set pen-size 1 ] set vx-m-s -1 * initial-velocity * 1000 set vy-m-s 0 ; ask one-of sats [ hatch-vectors 1 [ set id "acc" set color green hide-turtle ] hatch-vectors 1 [ set id "vel" set color blue hide-turtle ] ] end to go if check-orbit? [ clear-links ask one-of sats [ set distance-m distance one-of planets * m-per-patch set acc-m-s2 grav-const * planet-mass-kg / (distance-m) ^ 2 set acc-x -1 * acc-m-s2 * xcor / (distancexy 0 0) ; use similar triangles to get standard basis vecs from scalar set acc-y -1 * acc-m-s2 * ycor / (distancexy 0 0) set vx-m-s vx-m-s + acc-x set vy-m-s vy-m-s + acc-y set kinetic-energy 0.5 * satellite-mass-kg * (vx-m-s ^ 2 + vy-m-s ^ 2) set potential-energy -1 * grav-const * satellite-mass-kg * planet-mass-kg / (distance-m) let new-x xcor + vx-m-s / m-per-patch let new-y ycor + vy-m-s / m-per-patch facexy new-x new-y if vectors-shown [make-vectors] set xcor new-x set ycor new-y test-kill-orbit ] ] ifelse show-planet [ ask planets [show-turtle] ] [ ask planets [hide-turtle] ] tick end to make-vectors pen-up ask vectors with [id = "acc"] [ set xcor max list (min (list (0.5 * vectors-scale-factor * (acc-x) + [xcor] of one-of sats) max-pxcor)) min-pxcor set ycor max list (min (list (0.5 * vectors-scale-factor * (acc-y) + [ycor] of one-of sats) max-pycor)) min-pycor create-links-from sats [ set color green set label (word "acc: " precision acc-m-s2 2 " m/s/s") ] ] ask vectors with [id = "vel"] [ set xcor max list (min (list (vectors-scale-factor * (vx-m-s / 2000) + [xcor] of one-of sats) max-pxcor)) min-pxcor set ycor max list (min (list (vectors-scale-factor * (vy-m-s / 2000) + [ycor] of one-of sats) max-pycor)) min-pycor create-links-from sats [ set color blue set label (word "vel: " precision (sqrt(vx-m-s ^ 2 + vy-m-s ^ 2) / 1000) 2 " km/s") ] ] pen-down end to test-kill-orbit if distancexy 0 0 < planet-radius or abs xcor > max-pxcor or abs ycor > max-pycor [ set shape "x" set check-orbit? false ask vectors with [id = "acc" or id = "vel"] [die] stop ] end ; Copyright 2020 Will Bradley
There is only one version of this model, created over 4 years ago by Will Bradley.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Single orbiting body.png | preview | Preview for 'Single orbiting body' | over 4 years ago, by Will Bradley | Download |
This model does not have any ancestors.
This model does not have any descendants.