In [25]:
%matplotlib inline
In [63]:
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from SpecificHeat import spec_heat_apiezon_n
sns.set_context('talk', font_scale=1.25, rc={'lines.linewidth':3})
sns.set_style('whitegrid')
In [27]:
#%%writefile -a SpecificHeat.py
#import numpy as np
#
def spec_heat_copper(T, echo=False):
"""Return the specific heat for Copper at temperature 'T' in Kelvin
Parameters
----------
T : float, int, list, numpy.ndarray
Temperature in Kelvin at which the specific heat should be calculated.
echo : boolean, optional
When true, the function prints a sentence with the values to the command line.
Returns
-------
C : numpy.ndarray
The specific heat of Apiezon N at tempterature T in uTg^(-1)K^(-1)
Reference
---------
[1] D. L. Martin, Review of Scientific Instruments 58, 639 (1987)
[2] cygenics.nist.gov/Papers/Cryo_Materials
"""
# Convert whatever the input is into a numpy array.
if isinstance(T, (float, int)):
T = np.asarray([T])
elif isinstance(T, list):
T = np.asarray(T)
elif isinstance(T, np.ndarray):
pass
else:
raise TypeError('Invalid temperature type. Type a float, int, list or numpy array.')
C = np.ndarray(T.shape)
# MArtin 87
A1 = np.array([-0.8209550462989,
+0.1877774093791,
-0.1572548380193E-1,
+0.5828318431167E-3,
-0.1420296394933E-5,
-0.3466012703872E-6,
+0.1030643882976E-7,
-0.1621415050746E-9,
+0.1678243825986E-11,
-0.1225826347399E-13,
+0.6497335630403E-16,
-0.2516918128676E-18,
+0.7065147741950E-21,
-0.1400307720276E-23,
+0.1858984964834E-26,
-0.1483657580275E-29,
+0.5382629833814E-33])
# Matin 68
gamma = 165.2
Omega = 345.8
# NIST
A2 = np.array([-1.91844,
-0.15973,
+8.61013,
-18.99640,
+21.96610,
-12.73280,
+3.54322,
-0.37970,
+0])
for i, t in enumerate(T):
#print(i, t)
# Martin87
#if t >= 20 and t <= 320:
# for n, a in enumerate(A1):
# #print(n, a)
# C[i] += a/63.546*T**(n)
# Martin68
#if t <= 3.0:
# C[i] = gamma * (1/63.546) * t +(464.34/(Omega**(3)))*t**(3)
#else:
# C[i] = np.NaN
# NIST
for n, a in enumerate(A2):
c = a*np.log10(t)**n
#print('10^({:.3}*log({})^{}) = {:.3}'.format(a, t, n, 10**c))
C[i] += c
C = (10**C)
# Print the results to the commant line
if echo:
try:
for i, t in enumerate(T):
# print(i, t)
print('The specific heat of Apiezon N at {} K is {:.3f} J g^(-1) K^(-1)'.format(t, C[i]))
except IndexError:
print('The specific heat of Apiezon N at {} K is {:.3f} J g^(-1) K^(-1)'.format(T, C))
# Return the resutling array
return C
In [18]:
def therm_cond_copper(T):
log_kappa = ((2.2154 - 0.88068*T**(0.5) + 0.29505*T - 0.048310*T**(1.5) + 0.003207*T**2)/
(1 - 0.47461*T**(0.5) + 0.13871*T - 0.020430*T**(1.5) + 0.001281*T**2))
kappa = 10**log_kappa
return kappa
In [59]:
x = np.linspace(0.0, 270.0)
print(x)
In [60]:
copper = pd.DataFrame({r'C_p' : spec_heat_copper(x),
r'\kappa' : therm_cond_copper(x)},
index=x)
In [61]:
copper
Out[61]:
In [64]:
fig, axes = plt.subplots();
copper.plot(ax=axes,
secondary_y=r'\kappa'
);
axes.set_title('Uh...');
axes.set_xlabel('Temperature [K]');
axes.set_ylabel('Specific Heat [J/kg*K]');
Out[64]:
In [32]:
plt.loglog(x, spec_heat_copper(x), x, therm_cond_copper(x), basex=10, basey=10);
plt.xlabel('Temperature [K]');
plt.ylabel('Specific Heat [J/kg*K]');
In [42]:
therm_cond_copper(x)
Out[42]:
In [58]:
spec_heat_copper(x)
Out[58]: