{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import math" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "344.74\n" ] } ], "source": [ "t = 22.35 # ^Circ\n", "v_0 = 331.45*math.sqrt(1+t/273.15) # m/s\n", "print(round(v_0, 2))" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [], "source": [ "def calc(arr: list[float], frequency: float):\n", " length = len(arr)\n", " sum = 0\n", " for i in range(0, 5):\n", " sum += arr[i+5]-arr[i]\n", " sum /= 1000\n", " Delta_x = sum/25\n", " print(f\"Delta x = {round(abs(Delta_x*1000), 3)} mm\")\n", " Lambda = 2*Delta_x\n", " print(f\"Lambda = {round(abs(Lambda*1000), 3)} mm\")\n", " v = Lambda*frequency*1000\n", " print(f\"v = {round(abs(v), 3)} m/s\")\n", " # middle_val = 0\n", " # for i in range(0, length/2-1):\n", " # middle_val += pow((arr[i+5]-arr[i])/5-Delta_x, 2)\n", " # U_x = math.sqrt(middle_val/(length*(length-1)))\n", " # print(f\"U_x = {U_x}\")\n", " E = abs(abs(v)-v_0)/v_0\n", " print(f\"E = {E}\")\n" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Delta x = 4.699 mm\n", "Lambda = 9.399 mm\n", "v = 347.254 m/s\n", "E = 0.0072819778896386494\n" ] } ], "source": [ "l_1 = [136.122, 140.812, 145.515, 150.338, 154.912, 159.712, 164.438, 168.722, 173.730, 178.584] # mm\n", "f_1 = 36.946 # kHz\n", "calc(l_1, f_1)" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Delta x = 4.698 mm\n", "Lambda = 9.396 mm\n", "v = 348.062 m/s\n", "E = 0.009625687275414954\n" ] } ], "source": [ "l_2 = [174.473, 169.742, 165.060, 160.039, 155.498, 150.650, 146.098, 141.250, 136.608, 132.754] # mm\n", "f_2 = 37.043 # kHz\n", "calc(l_2, f_2)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Delta x = 9.463 mm\n", "Lambda = 18.927 mm\n", "v = 701.216 m/s\n", "E = 0.017011089199556368\n" ] } ], "source": [ "l_3 = [127.048, 136.572, 145.910, 155.173, 164.749, 174.370, 183.618, 193.390, 202.790, 211.868] # mm\n", "f_3 = 37.049\n", "calc(l_3, f_3) # 该处结果需要除2" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [], "source": [ "def calc_t(arr: list[float], delta_l:float):\n", " sum = 0\n", " for i in range(0, 5):\n", " sum += arr[i+5]-arr[i]\n", " Delta_t = sum/25\n", " print(f\"Delta_t = {round(abs(Delta_t), 3)} us\")\n", " v = delta_l/1000/(Delta_t*1e-6)\n", " print(f\"v = {round(abs(v), 3)} m/s\")\n", " E = abs(abs(v)-v_0)/v_0\n", " print(f\"E = {E}\")" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Delta_t = 28.56 us\n", "v = 350.14 m/s\n", "E = 0.015653649437656875\n" ] } ], "source": [ "t_4 = [649, 619, 591, 561, 533, 507, 475, 447, 419, 391] # us\n", "delta_l = 10.0 # mm\n", "calc_t(t_4, delta_l)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.5" } }, "nbformat": 4, "nbformat_minor": 2 }