[latexpage]
Irei descrever notas do curso de física 4 que ministrei na ufjf.
Apresentarei um App que desenvolvi em Python utilizando a biblioteca Bokeh[https://bokeh.pydata.org].
Este App que pode ser utilizada para o ensino do diagrama espaço-tempo.
$\beta=v/c$
Onde v é a velocidade do referencial e c a velocidade da luz.
Diagrama espaço-tempo(Clique na imagem)
O código Python utilizado foi o seguinte:
import numpy as np
import matplotlib.pyplot as plt
from bokeh.layouts import row, widgetbox
from bokeh.models import CustomJS, Slider, Div
from bokeh.plotting import figure, output_file, show, ColumnDataSource
from bokeh.models import Arrow, OpenHead, NormalHead, VeeHead
xmin=-10
xmax=10
ymin=-10
ymax=10
deltax=xmax-xmin+1
beta=0.8
x = np.linspace(xmin,xmax,deltax)
x0=[xmin]
x1=[xmax]
y0=[xmin*beta]
y1=[xmax*beta]
x2=[ymin*beta]
x3=[ymax*beta]
y2=[ymin]
y3=[ymax]
source = ColumnDataSource( data=dict(x0=x0, x1=x1, y0=y0, y1=y1,x2=x2, x3=x3, y2=y2, y3=y3) )
plot = figure(y_range=(-10, 10),x_range=(-10, 10), plot_width=720, plot_height=720)
# plot eixo ct
plot.add_layout(Arrow(end=OpenHead(line_color=”black”, line_width=3),x_start=0, y_start=-10, x_end=0, y_end=10))
plot.text( [-2], [ymax-1], text=[“ct(ano-luz)”], text_color=”black”, text_align=”center”, text_font_size=”15pt”)
# plot eixo x
plot.add_layout(Arrow(end=OpenHead(line_color=”black”, line_width=3),x_start=-10, y_start=0, x_end=10, y_end=0))
plot.text( [xmax-1.5], [-1], text=[“x(ano-luz)”], text_color=”black”, text_align=”center”, text_font_size=”15pt”)
# plot eixo luz
plot.line(x,x, line_width=1, color=”red”, line_alpha=0.8)
plot.text( [xmax-1], [ymax-1], text=[“eixo luz”], text_color=”red”, text_align=”center”, text_font_size=”10pt”)
plot.line(x,-x, line_width=1, color=”red”, line_alpha=0.8)
plot.text( [xmin+1], [ymax-1], text=[“eixo luz”], text_color=”red”, text_align=”center”, text_font_size=”10pt”)
callback = CustomJS(args=dict(source=source), code=”””
var data = source.data;
var beta = beta.value;
x0 = data[‘x0’]
y0 = data[‘y0’]
x1 = data[‘x1’]
y1 = data[‘y1’]
x2 = data[‘x2’]
y2 = data[‘y2’]
x3 = data[‘x3’]
y3 = data[‘y3’]
y0[0]=beta*x0[0]
y1[0]=beta*x1[0]
x2[0]=beta*y2[0]
x3[0]=beta*y3[0]
source.trigger(‘change’);
“””)
beta_slider = Slider(title=”beta (Continuous)”, start=-1, end=1, value=beta, step=0.1, callback=callback, callback_policy=”continuous”)
callback.args[“beta”] = beta_slider
# plot eixo x’
plot.add_layout(Arrow(end=OpenHead(line_color=”blue”, line_width=2),line_color=’blue’,x_start=’x0′,y_start=’y0′,x_end=’x1′,y_end=’y1′,source=source))
plot.text( x1[0]-2, y1[0]-3, text=[“x'(ano-luz)”], text_color=”blue”, text_align=”center”, text_font_size=”15pt”)
# plot eixo ct’
plot.add_layout(Arrow(end=OpenHead(line_color=”blue”, line_width=2),line_color=’blue’,x_start=’x2′,y_start=’y2′,x_end=’x3′,y_end=’y3′,source=source))
plot.text( x3[0]-3, y3[0]-1, text=[“ct'(ano-luz)”], text_color=”blue”, text_align=”center”, text_font_size=”15pt”)
layout = row( plot, widgetbox(beta_slider))
output_file(“space-time-diagram.html”, title=”space_time_diagram.py example”)
show(layout)