Está en la página 1de 7

Sistema Masa resorte Amortiguado

August 22, 2019

0.1 Ajuste por polinomios


In [3]: import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
from scipy.interpolate import interp1d
import sympy
from sympy import *
from sympy import Derivative, diff, simplify
import sympy
from sympy import *
from sympy import Derivative, diff, simplify, integrate,Symbol,exp,sin,cos
from scipy.integrate import quad
from sympy import Integral, integrate
In [10]: data=pd.read_csv('resultados.txt',header=1,delim_whitespace=True)
In [15]: x=data.ix[:,1]
/home/paola/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:


http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
"""Entry point for launching an IPython kernel.

In [12]: y=data.ix[:,2]
/home/paola/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:


http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
"""Entry point for launching an IPython kernel.

1
In [5]: plt.plot(x,y,'ro')
plt.ylabel('ffff')
plt.xlabel('ffff')
plt.show

Out[5]: <function matplotlib.pyplot.show(*args, **kw)>

In [6]: coeficientes=np.polyfit(x,y,30)
polinomio=np.poly1d(coeficientes)
print(polinomio)

30 29 28 27
-2.627e-17 x + 1.249e-15 x - 2.017e-14 x + 7.248e-14 x
26 25 24 23
+ 1.102e-12 x - 4.21e-12 x - 8.642e-11 x + 1.398e-11 x
22 21 20 19
+ 6.42e-09 x + 2.684e-08 x - 3.697e-07 x - 3.684e-06 x
18 17 16 15
+ 1.398e-05 x + 0.0003414 x - 0.0001421 x - 0.02788 x
14 13 12 11 10 9
- 0.007793 x + 2.31 x - 5.972 x - 163 x + 1937 x - 1.121e+04 x
8 7 6 5 4
+ 4.123e+04 x - 1.033e+05 x + 1.797e+05 x - 2.146e+05 x + 1.701e+05 x
3 2
- 8.39e+04 x + 2.282e+04 x - 2650 x + 139.3

2
/home/paola/anaconda3/lib/python3.7/site-packages/ipykernel_launcher.py:1: RankWarning: Polyfit
"""Entry point for launching an IPython kernel.

In [7]: inter=polinomio(x)
plt.plot(x,inter,'-')
corte=0*x +88
plt.plot(x,corte,'-')
A=polinomio

0.2 Constante de elasticidad y amortiguamiento


F = kx

F
k=
x
para encontrar f se tiene encuenta la fuerza de empuje del agua así:

mg − Fe = kx

In [15]: k=((0.2*9.8)-(997*9.8)*(4/3)*(np.pi)*(0.015)**3)/0.045
print (k)

40.48603103743912

3
el cálculo del cuasi-periodo se hace teniendo en cuenta el tiempo entre dos máximos o dos
mínimos consecutivos

γ
w = ω02 − ( )2
2
despejando √
16π 2
γ = 2ω02 −
T2
In [21]: w2=(40.48603103743912/0.2)
print(w2)

202.4301551871956

In [30]: g = np.sqrt((4*202.4301551871956)-((16* (np.pi)**2)/(0.57)**2))


print(g)

17.991188231956514

Ajuste por modelo

0.3 √
− γ2 x γ
y = Ae cos ω 2 − ( )2 x + ϕ
2
In [36]: import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
import sympy
from sympy import *
from sympy import Derivative, diff, simplify,exp,cos,sin

In [2]: def funcion(x,A,g,f):


return A*np.exp((-g/2)*x)*np.cos(np.sqrt((40.48/0.2) -((g**2) /4))*x+f)

In [21]: #importar los datos


data=pd.read_csv('resultados.txt',header=1,delim_whitespace=True)
xdat=data.ix[:,1]
ydat=data.ix[:,2]

/home/cesar/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:3: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing

See the documentation here:


http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
This is separate from the ipykernel package so we can avoid doing imports until

4
In [22]: from scipy.optimize import curve_fit

In [23]: (A,g,f),_=curve_fit(funcion,xdat,ydat)

In [24]: print (A,g,f)

-28.846508940641947 3.19903998121555 -9.925610010062089

In [25]: curve_fit(funcion,xdat,ydat)

Out[25]: (array([-28.84650894, 3.19903998, -9.92561001]),


array([[ 3.36795659e+03, -3.71117814e+02, -1.78179263e+01],
[-3.71117814e+02, 8.21804298e+01, 2.69293970e+00],
[-1.78179263e+01, 2.69293970e+00, 2.40640207e+00]]))

In [26]:

In [27]: plt.plot(x,funcion(x,A,g,f),label='ajuste')

Out[27]: [<matplotlib.lines.Line2D at 0xa844812c>]

In [41]: x= sympy.symbols('x')
sympy.diff(-28.846508940641947*exp((-3.19903998121555/2)*x)*cos(sqrt((40.48/0.2) -((3.

Out[41]: 407.78959551621*exp(-1.59951999060778*x)*sin(14.1365319580032*x - 9.92561001006209) +

5
In [42]: def dx(x):
return 407.78959551621*np.exp(-1.59951999060778*x)*np.sin(14.1365319580032*x - 9.9
In [46]: x=np.linspace(0,8,1000)
plt.plot(x,dx(x),label='ajuste')
Out[46]: [<matplotlib.lines.Line2D at 0xa75d36cc>]

0.4 Desplazamiento efectivo


∫ inf
0
∥v(t)∥dt
In [4]: x=Symbol('x')
In [5]: intv=Integral(np.abs(407.78959551621*exp(-1.59951999060778*x)*sin(14.1365319580032*x -
In [6]: print(intv)
Integral(Piecewise((407.78959551621*exp(-1.59951999060778*x)*sin(14.1365319580032*x - 9.9256100

1 Energía disipada
∆E = E f − Ei
1
∆E = 0 − (mgh + kx2 )
2
1
∆E = 0 − (0.2 + 9.8 ∗ 0.045 + (40.48)(0.045)2 )
2

6
In [9]: DE = (0.2*9.8*0.045+ (1/2)*(40.48)*(0.045)**2)
print (DE)

0.129186

In [ ]:

También podría gustarte