def graph(d, I, n): plt.clf() #Representación x = d**2 y = I plt.scatter(x, y) #Regresión Lineal a, b = rl(x, y)[0:2] xr = np.linspace(min(x), max(x), 20) yr = a + b * xr plt.plot(xr, yr) mpl.guardar("MI3_Steiner_{}".format(n), "$d^2 (m^2)$", "$I (kg \\cdot m^2)$", False)
x = T[exp,r][~np.isnan(T[exp,r])] y = LnI[exp,r][~np.isnan(LnI[exp,r])] sy = sLnI[exp,r][~np.isnan(sLnI[exp,r])] a, b = rl(x,y,sy)[0:2] xr = np.linspace(min(x), max(x), 20) yr = a + b*xr yi = 1 if r%2 == 1 else 0 xi = 0 if r < 2 else 1 axs[xi, yi].scatter(x, y, color=c[r], edgecolors="black", linewidth=0.5) axs[xi, yi].plot(xr, yr, color=c[r]) axs[xi, yi].set_title('$C_{}$'.format(r+1)) for ax in axs.flat: ax.set(xlabel='T(s)', ylabel='$\ln{I}(A)$') ax.label_outer()""" mpl.guardar("CC-3LR", "T(s)", "$\ln{I}(A)$")#, False, False) import uncertainties as unc from uncertainties.umath import * v = unc.ufloat(10.2, 0.1) c = unc.ufloat(10**(-5), 0.05*10**(-5)) r = unc.ufloat(4.4*10**6, 0.05*4.4*10**6) a = log(v/r) b = (-1)/(r*c) print("a = {:.2u}, b = {:.2u}".format(a, b))
z2 = d2["z"] Be2 = d2["Bexp"] d3 = pd.read_csv("BH-3.csv", sep=';', decimal=',') z3 = d3["z"] Be3 = d3["Bexp"] #Curvas teóricas z = np.linspace(-0.450, 0.450, 450) Bt1 = B(pm, i, n, r, r, z) Bt2 = B(pm, i, n, r, r/2, z) Bt3 = B(pm, i, n, r, 2*r, z) #Gráficas plt.plot(z,Bt1,label="a=R") plt.plot(z,Bt2,label="a=R/2") plt.plot(z,Bt3,label="a=2R") plt.scatter(z1,Be1,linewidth=0.5) plt.scatter(z2,Be2,linewidth=0.5) plt.scatter(z3,Be3,linewidth=0.5) #Desviación típica s = lambda Be, Bt: (1/len(Be)) * (np.sum(((Be - Bt)**2).to_numpy()))**0.5 s1 = s(Be1, B(pm, i, n, r, r, z1)) s2 = s(Be2, B(pm, i, n, r, r, z2)) s3 = s(Be3, B(pm, i, n, r, r, z3)) print("Desviaciones - s1: {}, s2: {}, s3: {}".format(s1, s2, s3)) mpl.guardar("BH", "z(m)", "B(T)")
xr3 = np.linspace(0, max(I3), 10) yr3 = b3 * xr3 #Gráficas plt.plot(xr1, yr1, label="a=R") plt.plot(xr2, yr2, label="a=R/2") plt.plot(xr3, yr3, label="a=2R") plt.scatter(I1, Be1, linewidth=0.5) plt.scatter(I2, Be2, linewidth=0.5) plt.scatter(I3, Be3, linewidth=0.5) R = 0.2 N = 154 a, r, n, m = sy.symbols("a r n m") frac = 2 / (1 + ((a**2) / (4 * r**2)))**(3/2) mu = ((2 * m * r) / n) * (1 / frac) fmu = sy.lambdify([a, r, n, m], mu, "numpy") frac1 = frac.subs(a, r) frac2 = frac.subs(a, r/2) frac3 = frac.subs(a, 2r) mu1 = fmu(R, R, N, b1) mu2 = fmu(R/2, R, N, b2) mu3 = fmu(2*R, R, N, b3) mpl.guardar("BH2R", "I(A)", "B(T)") print("Permeabilidad orginal: {}, P1: {}, P2: {} P3:{}".format(4 * np.pi * 10**(-7), mu1, mu2, mu3))
import numpy as np import pandas as pd import matplotlib.pyplot as plt import sys sys.path.insert(1, '../Base') from reg_lin import reg_lin_b as rl import mpl_config as mpl mpl.inicio(1) #Datos d = pd.read_csv("MI1_PhiF.csv", sep=';', decimal=',') phi = d["PhiRad"] M = d["M"] #Regresión lineal ponderada sin término independiente b = rl(phi, M)[0] xr = np.linspace(min(phi), max(phi), 10) yr = b * xr #Gráficas plt.scatter(phi, M, linewidth=0.5) plt.plot(xr, yr) mpl.guardar("MI1_PhiFL", "$\\varphi (rad)$", "M(Nm)", False)
for i in range(len(V2u)): for j in range(len(V2u[i])): print("V-{}-{} = {:.2u}".format(i, j, V2u[i,j])) for i in range(3): plt.clf() #Gráficas plt.scatter(T[i], V2[i], color=c[i], edgecolors="black", linewidth=0.5) #Ajuste b = rl(T[i], V2[i])[0] xr = np.linspace(min(T[i]), max(T[i]), 10) yr = b*xr plt.plot(xr, yr, color=c[i]) mpl.guardar("LN_MRUA_A{}".format(i+1), "$T(s)$", "V(m/s)", False) #TEORICO g = unc.ufloat(9.8, 0.1) a1 = g * (m/m1); a2 = g * (m/m2); a3 = g * (m/m3) sa = lambda M: sm * ((g/M)**2 + ((g*m) / M**2)**2)**0.5 sa1 = sa(m1); sa2 = sa(m2); sa3 = sa(m3) Mu = unp.uarray([m1, m2, m3], sm); mu = unc.ufloat(m, sm) au = g*(mu / Mu) for i in range(3): print("A = {:.2u}".format(au[i])) np.savetxt("LN_MRUA_VA.csv", au, "%r", delimiter=";")