1 Web VPython 3.
2
2
3 canvas( align = "right" , width = 700 , height = 400 )
4 parede = caixa( pos = vec( - 20 , 0 , 0 ), tamanho = vec( 2 , 20 , 30 ), cor = [Link])
5 chão = caixa( pos = vec( 0 , - 10 , 0 ), tamanho = vec( 40 , 2 , 30 ), cor = [Link])
6
7
8 mola = hélice( pos = vec( - 20 , 0 , 0 ), eixo = vec( 25 , 0 , 0 ), raio = 2.5 , cor = [Link])
9 massa = caixa( pos = vec( 5 , 0 , 0 ), tamanho = vec( 10 , 10 , 10 ), m = 1 , cor = [Link])
10
11 gráfico = gráfico( título = "X x t" , alinhamento = "direita" )
12 g1 = gcurve( gráfico = gráfico, cor = [Link])
13 g2 = gcurve( gráfico = gráfico, cor = [Link])
14 g3 = gcurve( gráfico = gráfico, cor = [Link])
15 g4 = gcurve( gráfico = gráfico, cor = [Link])
16
17 v = arrow(pos = [Link], color = [Link], sacele = 100, shaftwidth=[Link]/3, axis = vec(-2,0,0))
18 run = False
19
20 def start(r):
21 global run
22 run = not run
23 if run:
24 [Link] = "Pause"
25 [Link] = True
26 else:
27 [Link] = "Voltar"
28 [Link] = False
29
30 def Def_coif(evt):
31 global b,k,t, aux_t,A
32 [Link] = vec(5,0,0)
33 [Link] = [Link] - [Link]
34 t = 0
35 [Link]()
36 [Link]()
37 [Link]()
38 [Link]()
39 [Link] = "Começar"
40 k = int(input("K: "))
41 b = int(input("b: "))
42
43
44 b1 = button(text="Começar", bind=start)
45 b2 = button(text = "Condições iniciais", bind = Def_coif)
46
47 X_0 = 0.1#m
48 v_0 = -2#m/s
49
50 k = int(input("K: "))
51 b = int(input("b: "))
52 dt = 0.001
53 t = 0
54
55 while True:
56 rate(1/dt)
57 if run:
58 gama = b/(2*massa.m)
59 w = sqrt(k/massa.m)
60 w_1 = sqrt((w ** 2 ) - (gama ** 2 ))
61 [Link].x = 100 * exp( - gama * t) * ( 0,209 * cos(w_1 * t + 1,07 ))
62 [Link].x = 5 * ( - gama * ([Link].x / 100 ) - exp( - gama * t) * w_1 * ( 0.209 * sin(w_1 * t +
1.07 )))
63 [Link] = [Link] - [Link]
64 [Link] = [Link]
65 E_c = (massa.m / 2 ) * (([Link].x / 5 ) ** 2 )
66 E_p = (k / 2 ) * (([Link].x / 100 ) ** 2 )
67 [Link](t, [Link].x / 100 )
68 [Link](t, (E_c + E_p))
69 [Link](t, E_c)
70 [Link](t, E_p)
71 t += dt
72
73