course_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revisionBoth sides next revision
course_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution [2021/09/02 03:51] – created pwirvingcourse_planning:183_projects:f21_week_1_problem_river_crossing_computational_problem_solution [2021/09/02 03:57] pwirving
Line 55: Line 55:
  
 <code Python boat_sol.py> <code Python boat_sol.py>
-from __future__ import division +GlowScript 2.9 VPython 
-from visual import * + 
-from physutil import *+get_library('https://cdn.rawgit.com/PERLMSU/physutil/master/js/physutil.js')
  
 scene.width = 900 scene.width = 900
Line 66: Line 66:
 W = 20 W = 20
 origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red) origin = cylinder(pos=vector(0,0,0), axis=vector(0,0,5), radius=0.2, color=color.red)
-water = box(pos=vector(-30,0,0), height=W, width=0, length=200, material=materials.wood, color=color.blue, opacity=0.4)+water = box(pos=vector(-30,0,0), height=W, width=0, length=200, color=color.blue, opacity=0.4)
 boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white) boat = sphere(pos=vector(0,-W/2,0), radius=0.4, color=color.white)
  
Line 82: Line 82:
  
 vboatshore = vboatwater + vwatershore vboatshore = vboatwater + vwatershore
 +
  
 #Time and time step #Time and time step
Line 95: Line 96:
 #Calculation Loop #Calculation Loop
 while boat.pos.y <= W/2: while boat.pos.y <= W/2:
- rate(100) +    rate(100) 
- +     
- water.pos = water.pos + vwatershore*dt +    water.pos = water.pos + vwatershore*dt 
- boat.pos = boat.pos + vboatshore*dt +    boat.pos = boat.pos + vboatshore*dt
- +
- vboatwaterMotionMap.update(t, vboatwater) +
- vboatshoreMotionMap.update(t, vboatshore) +
- vwatershoreMotionMap.update(t, vwatershore)+
  
- t = t + dt+     
 +    vboatwaterMotionMap.update(t, vboatwater) 
 +    vboatshoreMotionMap.update(t, vboatshore) 
 +    vwatershoreMotionMap.update(t, vwatershore) 
 +  
 +     
 +    t = t + dt
 </code> </code>
  • course_planning/183_projects/f21_week_1_problem_river_crossing_computational_problem_solution.txt
  • Last modified: 2022/09/06 13:03
  • by valen176