mechanical-movement_2009


Information

Created with NetLogo version NetLogo 4.0.4
Running with NetLogoLite.jar version 404.


WHAT IS IT?


-------
A simulation of a simple crank and piston.
Inspired by a diagram from "507 Mechanical Movements" by Henry T. Brown, originally published in 1896.
I was thinking about making a mechanical movement construction set, with drag-and-drop features... but then "crayon physics" happened, and I thought, "why bother?"

Procedures

NetLogo Version: NetLogo 4.0.4

globals
[ disk
  piston
  rod
  old-diam
  
]

to startup
   setup
end

to resize
   if drive-diam != old-diam
   [ set old-diam drive-diam
     ask disk [ set size .001 + drive-diam setxy (min-pxcor + size * .5 + 1) 0 ]
     ask rod  [ set size .001 + max-pxcor - min-pxcor - ( [xcor] of disk - min-pxcor ) - .5 * [size] of disk - [size] of piston - 2 ] 
   ]
end
   
to setup
   ca
   
   ask patches [ set pcolor white ]
   
   crt 1 [ set disk self set size drive-diam set old-diam drive-diam ]
   crt 1 [ set piston self set size 10]
   crt 1 [ set rod self ]
      
   ask disk
   [ set shape "disk"
     setxy (min-pxcor + size * .5 + 1) 0
     set color brown
     set heading 90
   ]
   ask rod 
   [ ; set shape "linkage"
      set shape "rod"
      __set-line-thickness 1
     set size max-pxcor - min-pxcor - ( [xcor] of disk - min-pxcor ) - .5 * [size] of disk - [size] of piston - 2
     snap-to-tail disk
     set color blue
     set rod self
     set heading 90
   ]
   ask piston
   [ set shape "piston"
     snap-to-tail-x rod
     set color green
     set piston self 
     face disk
   ]
   
   ask rod
   [ face piston ]
   
  ;;  __tie rod disk
   
end


to go
   ;; rotate the drive wheel
   
   resize
   every (1 / 30 )
   [ 
     ask disk
     [ rt speed + .1
     ]
     ;; snap the end of the rod to the drive wheel
     ;; point the rod at the piston
     ask rod
     [  snap-to-tail disk
        set heading towards piston
     ]
     ;; push the piston to the location of the end of the rod
     ask piston 
     [ snap-to-tail-x rod
     ]
     tick
   ]   
end       

to snap-to-tail [ agent ]
   setxy ( [ xcor + dx * size * .5 ] of agent ) ( [ ycor + dy * size * .5] of agent )   
end  

to snap-to-tail-x [ agent ]
   set xcor ( [ xcor + dx * size  ] of agent )
end 
    
   

                    


Download Link

View or download the complete model file (to download: right-click, save-link-as):
-- Download mechanical-movement_2009 --