Το θέμα Γ4 όπως θα μπορούσε να το λύσει ένας μαθητής μετά από 10 χρόνια κάνοντας χρήση υπολογιστικής Φυσικής αν μεταφράζω σωστά τον όρο computational physics.

Λύση της άσκησης με καθαρά υπολογιστικές μεθόδους και χρήση του λογισμικού Vidle for Vpython.

Αρχικές συνθήκες

\[m = 1kg\] \[k = 105 \frac{N}{m}\] \[u_o = 2 \cdot \sqrt{10} \frac{m}{s}\] \[ball.m = 1\] \[ball.pos = vector(0,0,0)\] \[ball.vel = vector(2 \cdot \sqrt{10},0,0)\] \[t = 0\] \[while ball.vel.x > 0:\] \[Fel=-105 \cdot ball.pos\] \[T=vector(-5,0,0)\] \[Fnet=Fel+T\] \[ball.vel = ball.vel + \frac{Fnet}{ball.m} \cdot deltat\] \[ball.pos = ball.pos + ball.vel \cdot deltat\] \[t = t + deltat\] \[print(t,ball.pos.x)\]

Η φυσική που χρησιμοποείτε για τον υπολογισμό της μέγιστης συσπείρωσης του ελατηρίου είναι:

Ο δεύτερος νόμος του νεύτωνα

\[ΣF = m\cdot α ball.vel = ball.vel + \frac{Fnet}{ball.m} \cdot deltat\]

όπου

\[ΣF = Fελ + Τ = -kx – μmg\]

και ο ορισμός του μεγέθους της ταχύτητας

\[α = \frac{Δυ}{Δt}\] \[ball.pos = ball.pos + ball.vel \cdot deltat\]

Παρακάτω μπορεί κάποιος να δει τον κώδικα και να πειραματιστεί. Μπορεί να λύσει τα πάντα στηριζόμενος μόνο σε βασικές αρχές (2ος και 3ος Νόμος του Νεύτωνα).

# STARTUP (Don't edit, typically) 
from __future__ import division
from visual import *
from physutil import *
import csv
# VISUALIZATION & GRAPH INITIALIZATION
# ===========================================
# Setup window for plotting
graph = PhysGraph(1)
# Setup Display window for visualization 
scene = display(width = 640, height = 480, background = color.black, range = 2.5, title = "VPython Test")
# Create object for visualization
ball = sphere(color = color.red, radius = 0.02)
# Create a track behind object to visualize trajectory
trail = curve(color = color.green, radius = 0.02)
# Create small sphere to mark the origin in Display window
origin = sphere(pos=vector(0,0,0), color = color.yellow, radius = 0.02)
# SYSTEM PROPERTIES and INITIAL CONDITIONS 
# ===========================================
# System Mass
#EDIT THIS (next one line): 
ball.m = 1
#Initial Conditions
#EDIT THIS (next three lines, as necessary) 
ball.pos = vector(0,0,0)
ball.vel = vector(2*sqrt(10),0,0)
t = 0 #the time when we choose to start our clock
# OTHER INITIALIZATION 
# ===========================================
#
#Timestep
#EDIT THIS (next one line, as necessary)
deltat = 0.004
#unit vector for x axis---choose "right" as direction of +x axis
vhat=ball.vel/(sqrt(ball.vel.x*ball.vel.x+ball.vel.y*ball.vel.y+ball.vel.z*ball.vel.z))
#OPTIONAL: Output model predictions to file (.csv format)
#To use, uncomment next five lines (delete leftmost # ONLY)
outputfile = open('pythonTest.csv', 'wb') # Set name of output file.
# NOTE: if the file already exists,
# it will be overwritten 
DataWriter = csv.writer(outputfile, delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL) # Create writer object
DataWriter.writerow(['Time (s)','Position (m)','Velocity (m/s)']) # Write column headers for time, position, and velocity
# CALCULATION LOOP(Motion Prediction and Visualization)
# ===========================================
while ball.vel.x > 0:
#Calculate Net Force
#EDIT THIS (next one line; add more lines if necessary)
Fel=-105*ball.pos
T=vector(-5,0,0)
Fnet=Fel+T
#Predict new velocity (Insert Newton's 2nd Law here)
#EDIT THIS (next one line)
ball.vel = ball.vel + (Fnet/ball.m)*deltat
#Predict new position
#EDIT THIS (next one line)
ball.pos = ball.pos + ball.vel*deltat
# advance the clock
t = t + deltat
#Update the object's track
trail.append(pos = ball.pos)
#Plot something as a function of time
#EDIT THIS (next one line, as necessary)
graph.plot(t,ball.pos.x)
#To speed up or slow down program execution
#Edit next line (larger number, faster execution)
rate(50)
#OPTIONAL: Output model predictions to file (.csv format)
#To use, uncomment next line
DataWriter.writerow([str(t),str(ball.pos.x),str(ball.vel.x)])
print(t,ball.pos.x)
#OPTIONAL: Output model predictions to file (.csv format)
#To use, uncomment next line
outputfile.close()

https://www.youtube.com/watch?v=00wNUmVYxt4



blog comments powered by Disqus

Published

22 October 2013

Category

Άσκηση

Tags