In [1]:
import numpy as np
import scipy
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import seaborn as sns
sns.set_style('whitegrid')
%matplotlib inline

In [ ]:
# run cell for interactive plots
import mpld3
mpld3.enable_notebook()

In [2]:
from limtoc import (load_log, plot_log, display_log_plot, plot_fft,
                    calculate_stiffness, calculate_fit, plot_fit)

In [3]:
data = load_log('torque_oscillation.log.gz')
plot_log(data)


running limtoc 626a9c2, k =    3.140
Out[3]:
(<matplotlib.figure.Figure at 0x10da8acc0>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x117937a58>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x117962a90>], dtype=object))

In [4]:
print('x = (a + bt)*exp(c*t)*sin(2*pi*e*t + d)')

# use subset of data when oscillating
d1 = data[4300:6000]
d2 = data[9800:12400]
for di in [d1, d2]:
    #fig, ax = plot_fft(di)
    fit = calculate_fit(di)
    fig, ax = plot_fit(di, fit)
    a, b, c, d, e = fit[1][2]
    
    k_c, k_m = calculate_stiffness(di)
    print('desired stiffness is {} N-m/rad'.format(k_c))
    print('measured stiffness is {} N-m/rad'.format(k_m))
    
    # I = k / (2*pi*f_n)^2
    I = k_m/(2*np.pi*e)**2
    print('')
    print('moment of inertia is {} kg-m^2'.format(I))
    
    print('')
    print('assuming coulomb friction dominates')
    # b = ±2*F_d*2*pi*f_n/(pi*k)
    print('friction torque is {} N-m'.format(np.abs(b * k_m/(4*e))))


x = (a + bt)*exp(c*t)*sin(2*pi*e*t + d)
desired stiffness is 3.1400629194771628 N-m/rad
measured stiffness is 3.0747205736119034 N-m/rad

moment of inertia is 0.03043904895357336 kg-m^2

assuming coulomb friction dominates
friction torque is 0.08350598823024578 N-m
desired stiffness is 3.140041054924147 N-m/rad
measured stiffness is 3.1182677963264136 N-m/rad

moment of inertia is 0.03055860294178925 kg-m^2

assuming coulomb friction dominates
friction torque is 0.08604230636341675 N-m

In [5]:
data = load_log('k0m0.06.log.gz')
plot_log(data)


running limtoc 1085d10, k =    0.000, m =    0.059
Out[5]:
(<matplotlib.figure.Figure at 0x11b64f4e0>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11b1db1d0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11bb7fba8>], dtype=object))

In [6]:
data = load_log('k0m1.log.gz')
plot_log(data)


running limtoc 4aad09c, k =    0.000, m =    1.000
Out[6]:
(<matplotlib.figure.Figure at 0x11b37ad30>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11b1e4b70>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11b54eb00>], dtype=object))

In [7]:
data = load_log('k3.14m1.log.gz')
plot_log(data)


running limtoc 4aad09c, k =    3.140, m =    1.000
Out[7]:
(<matplotlib.figure.Figure at 0x11bbe3c88>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11b4f6d68>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11c748630>], dtype=object))

In [8]:
data = load_log('k3m0.07.log.gz')
plot_log(data)


running limtoc 4aad09c, k =    3.000, m =    0.070
Out[8]:
(<matplotlib.figure.Figure at 0x117bd6828>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11b3227f0>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11c7507b8>], dtype=object))

In [9]:
data = load_log('k3m0.15.log.gz')
plot_log(data)


running limtoc 4aad09c, k =    3.000, m =    0.150
Out[9]:
(<matplotlib.figure.Figure at 0x11b5774a8>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11bb76198>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11c8efd68>], dtype=object))

In [10]:
data = load_log('k3m0.5.log.gz')
plot_log(data)


running limtoc 4aad09c, k =    3.000, m =    0.500
Out[10]:
(<matplotlib.figure.Figure at 0x11c78fa58>,
 array([<matplotlib.axes._subplots.AxesSubplot object at 0x11c18eac8>,
        <matplotlib.axes._subplots.AxesSubplot object at 0x11d471208>], dtype=object))