Skip to content

Instantly share code, notes, and snippets.

@nelisjunior
Last active January 29, 2025 21:04
Show Gist options
  • Select an option

  • Save nelisjunior/cde18d1e19ef8d158b00b5015e092723 to your computer and use it in GitHub Desktop.

Select an option

Save nelisjunior/cde18d1e19ef8d158b00b5015e092723 to your computer and use it in GitHub Desktop.
ECT - MMF2 - Experimento 7 - Pêndulo Físico
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/nelisjunior/cde18d1e19ef8d158b00b5015e092723/ect-mmf2-exp7-pendulo-fisico.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# MMF2 - Experimento 7 - Pêndulo Físico"
],
"metadata": {
"id": "ckPCQpv3sfyN"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "lIYdn1woOS1n"
},
"outputs": [],
"source": [
"# @title Análise de Dados do Pêndulo Físico\n",
"\n",
"# Importar Bibliotecas\n",
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"from scipy import stats\n"
]
},
{
"cell_type": "markdown",
"source": [
"## 2. Dados de Entrada (Cole seus dados aqui)"
],
"metadata": {
"id": "gA-xh7xMtry9"
}
},
{
"cell_type": "code",
"source": [
"# ### 2.1. Tabela 1: Massas dos corpos\n",
"# Cole os valores medidos:\n",
"massa_barra = 0.0 # em gramas (substitua pelo valor real)\n",
"massa_Y = 0.0 # em gramas (substitua pelo valor real)\n",
"\n"
],
"metadata": {
"id": "Lz_x8tECtEY0"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# ### 2.2. Tabela 2: Corpo em Y\n",
"# Formato: [h (cm), ω (rad/s), γ (s⁻¹)]\n",
"# Cole os dados das 3 medidas:\n",
"dados_Y = np.array([\n",
" [5.10, 0.0, 0.0], # Medida 1 (substitua pelos valores reais)\n",
" [4.40, 0.0, 0.0], # Medida 2\n",
" [3.50, 0.0, 0.0] # Medida 3\n",
"])\n",
"\n"
],
"metadata": {
"id": "1tu2VqhctHaK"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# ### 2.3. Tabela 4: Barra Delgada\n",
"# Formato: [h (cm), T0 (s)]\n",
"# Cole os dados coletados:\n",
"dados_barra = np.array([\n",
" [h1, T1], # Medida 1 (substitua h1, T1 pelos valores reais)\n",
" [h2, T2], # Medida 2\n",
" # ... adicione todas as medidas\n",
"])\n"
],
"metadata": {
"id": "06C-x-qStH-8"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 3. Análise do Corpo em Y (Teorema dos Eixos Paralelos)"
],
"metadata": {
"id": "-Gk-BQ_Itn0d"
}
},
{
"cell_type": "code",
"source": [
"# ### 3.1. Calcular I0 (Equação 5)\n",
"g = 978 # cm/s²\n",
"h_Y = dados_Y[:, 0]\n",
"omega0_Y = dados_Y[:, 3] # Supondo que ω0 está na 4ª coluna após ajustes\n",
"\n",
"I0_Y = (massa_Y * g * h_Y) / (omega0_Y**2)\n",
"\n",
"# Adicionar resultados à tabela\n",
"dados_Y = np.column_stack((dados_Y, I0_Y))\n",
"\n",
"\n",
"# ### 3.2. Regressão Linear I0 vs h²\n",
"h_sq = h_Y**2\n",
"slope, intercept, r_value, p_value, std_err = stats.linregress(h_sq, I0_Y)\n",
"\n",
"# Resultados:\n",
"M_Y = slope\n",
"Ic_Y = intercept\n",
"\n",
"print(f\"Coeficientes da regressão:\")\n",
"print(f\"Massa estimada: {M_Y:.2f} ± {std_err:.2f} g\")\n",
"print(f\"Ic estimado: {Ic_Y:.2f} ± {std_err:.2f} g·cm²\")\n",
"\n",
"\n",
"# ### 3.3. Gráfico I0 vs h²\n",
"plt.figure(figsize=(8, 5))\n",
"plt.scatter(h_sq, I0_Y, label='Dados Experimentais')\n",
"plt.plot(h_sq, intercept + slope*h_sq, 'r', label='Ajuste Linear')\n",
"plt.xlabel('h² (cm²)')\n",
"plt.ylabel('I0 (g·cm²)')\n",
"plt.legend()\n",
"plt.grid()\n",
"plt.show()\n",
"\n"
],
"metadata": {
"id": "AJ7zxQjRtWfi"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 4. Análise da Barra Delgada (Período Mínimo e Raio de Giração)"
],
"metadata": {
"id": "2ox93YGLtjob"
}
},
{
"cell_type": "code",
"source": [
"# ### 4.1. Calcular Y = gT0²/(2π)²\n",
"h_barra = dados_barra[:, 0]\n",
"T0_barra = dados_barra[:, 1]\n",
"Y_barra = (g * T0_barra**2) / (4 * np.pi**2)\n",
"\n",
"\n",
"# ### 4.2. Regressão Múltipla Y = b0 + b1*h + b2*(1/h)\n",
"X = pd.DataFrame({\n",
" 'h': h_barra,\n",
" '1/h': 1/h_barra\n",
"})\n",
"model = stats.OLS(Y_barra, X).fit()\n",
"b0, b1 = model.params\n",
"print(f\"Coeficientes: b0 = {b0:.2f}, b1 = {b1:.2f}\")\n",
"\n",
"# Raio de giração experimental\n",
"kappa_exp = np.sqrt(b0)\n",
"print(f\"Raio de giração experimental: {kappa_exp:.2f} cm\")\n",
"\n",
"\n",
"# ### 4.3. Gráfico T0 vs h\n",
"plt.figure(figsize=(8, 5))\n",
"plt.scatter(h_barra, T0_barra, label='Dados Experimentais')\n",
"plt.xlabel('h (cm)')\n",
"plt.ylabel('T0 (s)')\n",
"plt.legend()\n",
"plt.grid()\n",
"plt.show()\n",
"\n",
"\n",
"# ### 4.4. Comparação com Valor Teórico\n",
"L = 28.00 # cm\n",
"alpha = 1.50 # cm\n",
"Ic_teorico = (1/12) * massa_barra * (L**2 + alpha**2)\n",
"kappa_teorico = np.sqrt(Ic_teorico / massa_barra)\n",
"\n",
"print(f\"Raio de giração teórico: {kappa_teorico:.2f} cm\")\n",
"print(f\"Diferença: {abs(kappa_exp - kappa_teorico):.2f} cm\")\n"
],
"metadata": {
"id": "lvidiZtCtZ0A"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## 5. Testes Estatísticos (Nível de Confiança 99%)"
],
"metadata": {
"id": "Xld-prnDtzxt"
}
},
{
"cell_type": "code",
"source": [
"# ### 5.1. Teste-t para Massa do Corpo Y\n",
"t_score = (M_Y - massa_Y) / std_err\n",
"p_value = stats.t.sf(np.abs(t_score), df=len(h_Y)-1)*2 # Teste bicaudal\n",
"\n",
"print(f\"Teste-t para My:\")\n",
"print(f\"Escore-t = {t_score:.2f}, p-valor = {p_value:.3f}\")\n",
"if p_value < 0.01:\n",
" print(\"Rejeita H0: Valores são diferentes (p < 0.01)\")\n",
"else:\n",
" print(\"Aceita H0: Valores são compatíveis\")\n",
"\n",
"\n",
"# ### 5.2. Teste-F para Regressão da Barra\n",
"f_value = model.fvalue\n",
"p_value_f = model.f_pvalue\n",
"\n",
"print(f\"Teste-F para regressão:\")\n",
"print(f\"F-value = {f_value:.2f}, p-valor = {p_value_f:.3f}\")\n",
"if p_value_f < 0.01:\n",
" print(\"Modelo significativo (p < 0.01)\")\n",
"else:\n",
" print(\"Modelo não significativo\")"
],
"metadata": {
"id": "B24HF7dftcLm"
},
"execution_count": null,
"outputs": []
}
],
"metadata": {
"colab": {
"name": "ect-mmf2-exp5-pendulo-fisico",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment