69 lines
1.7 KiB
Python
69 lines
1.7 KiB
Python
# coding: utf-8
|
|
|
|
from lab import *
|
|
import pickle
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
def plot((name, points), n):
|
|
plt.figure(n+1)
|
|
|
|
if name == 'azoto':
|
|
plt.ylim(-5,-5.5)
|
|
elif name == 'acqua':
|
|
plt.ylim(4, 4.5)
|
|
elif name =='stearico':
|
|
name = 'acido stearico'
|
|
elif name == 'glicole':
|
|
plt.ylim(-0.7,-0.4)
|
|
|
|
plt.title(name.capitalize())
|
|
plt.xlabel('tempo')
|
|
plt.ylabel('differenza di potenziale (mV)')
|
|
plt.plot(filter(lambda x: x!=0, points), '#44b34e')
|
|
plt.show()
|
|
|
|
|
|
set = pickle.load(open('termocoppia.pickle'))
|
|
for i, curve in enumerate(set.iteritems()):
|
|
#plot(curve, i)
|
|
pass
|
|
|
|
V = map(np.mean,
|
|
[ set['stagno'][150:250] # Tf
|
|
, set['indio'][125:250] # Tf
|
|
, set['acqua'][150:225] # Te
|
|
, set['stearico'][80:120] # Tf
|
|
, [0] # miscela acqua-ghiaccio
|
|
, set['glicole'][130:170] # Tf
|
|
, set['etere'][50:150] # Tf
|
|
, set['azoto'] # Te
|
|
])
|
|
|
|
T = [ 505.08 # Tf Sn
|
|
, 429.75 # Tf In
|
|
, 373.15 # Te H2O
|
|
, 342.40 # Tf CH3-(CH2)16-COOH
|
|
, 273.15 # Tf H2O
|
|
, 260.20 # Tf HO-(CH2)2-OH
|
|
, 156.80 # Tf CH3CH2-O-CH2CH3
|
|
, 77.36 # Te N2
|
|
]
|
|
|
|
x = np.linspace(-6, 6, 100)
|
|
a,b,c,d,e = polynomial(V, T, 4)
|
|
f = lambda x: a.mean*x**4 + b.mean*x**3 + c.mean*x**2 + d.mean*x + e.mean
|
|
g = lambda n,x: sum(a*x**i for i, a in enumerate(polyfit(V,T,n)))
|
|
# q(np.sum((np.polyval(np.polyfit(V,T,7), V) - T) ** 2), 1)*100
|
|
|
|
plt.figure(8)
|
|
plt.xlabel('Differenza di potenziale (mV)')
|
|
plt.ylabel('Temperatura (K)')
|
|
plt.scatter(V, T, color='#6972cc')
|
|
plt.plot(x, g(5,x), '#6972cc')
|
|
plt.show()
|
|
print '''
|
|
T(V)={a.n:.3f}V^4+{b.n:.3f}V^3{c.n:.3f}V^2+{d.n:.3f}V+{e.n:.3f}
|
|
'''.format(**dict(a=a,b=b,c=c,d=d,e=e))
|