Created
June 5, 2018 15:04
-
-
Save Ephraim-Bryski/3a385c53fd5de2fef3248b0bb684a15e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tkinter import * | |
import math | |
tk=Tk() | |
WIDTH=5000 | |
HEIGHT=400 | |
canvas=Canvas(tk,width=WIDTH,height=HEIGHT) | |
tk.title('Viscosity') | |
canvas.pack() | |
dt=.0001 | |
u=500 | |
VEL1=10000 | |
VEL2=0 | |
p=0 | |
w=.05 | |
AMP=30000 | |
class Layer(): | |
def __init__(self,posy): | |
self.shape=canvas.create_rectangle(0,posy,10,posy+10,fill='blue') | |
self.vel=0 | |
def move(self,above,below,vel,i,t): | |
acc=p+u*((above-vel)+(below-vel)) | |
self.vel+=acc*dt | |
if i==0: | |
self.vel=VEL1 | |
if i==len(layers)-1: | |
self.vel=VEL2 | |
canvas.move(self.shape,self.vel*dt,0) | |
layers=[] | |
for x in range(40): | |
layers.append(Layer(x*10)) | |
for x in range(10000): | |
for i in range(len(layers)): | |
if i==0: | |
above=layers[i].vel | |
else: | |
above=layers[i-1].vel | |
if i==len(layers)-1: | |
below=layers[i].vel | |
else: | |
below=layers[i+1].vel | |
vel=layers[i].vel | |
layers[i].move(above,below,vel,i,x) | |
tk.update() | |
tk.mainloop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment