Skip to content
Snippets Groups Projects
Commit 1bb22dea authored by Sam Calisch's avatar Sam Calisch
Browse files

add coil coil plots

parent 9ec47d36
Branches
No related tags found
No related merge requests found
%% Cell type:code id: tags:
``` python
from __future__ import division
from numpy import *
%pylab inline
rcParams.update({'font.size': 18})
```
%% Output
Populating the interactive namespace from numpy and matplotlib
WARNING: pylab import has clobbered these variables: ['cm']
`%matplotlib` prevents importing * from pylab and numpy
%% Cell type:code id: tags:
``` python
data = {}
with open('coil-coil-force.csv','r') as datafile:
for i in range(5):
datafile.readline() #strip headers
#magnet_os = [item.split(',')[0] for item in datafile.readline().split('magnet_os=') if item is not ''][1:]
#magnet_os = 1e6*asarray(map(float,magnet_os))
#Ns = [10+5*i for i in range(8)]
#gaps = [300 + 100*i for i in range(6)]
raw_data = []
for line in datafile.readlines():
raw_data.append([float(item) for item in line.strip('\n').split(',') if item is not ''])
raw_data = asarray(raw_data).reshape(9,6,-1)
#raw_data = asarray(raw_data)[:,2:].reshape(9,6,-1)
```
%% Cell type:code id: tags:
``` python
cm = plt.get_cmap('cool')
figure(figsize=(10,8))
for i,series in enumerate(raw_data):
plot(series[:,1],-series[:,2],label='N=%d'%(series[0,0]),c=cm(i/len(raw_data)))
legend(loc=(1.05,0))
xlabel('gap (um)')
ylabel('Force (N)')
grid(True)
ylim([0,-1.1*amin(raw_data[:,:,2])])
```
%% Output
(0, 0.15818192466432918)
%% Cell type:code id: tags:
``` python
cm = plt.get_cmap('cool')
stroke = linspace( amin(magnet_os), amax(magnet_os), 100)
figure(figsize=(12,10),dpi=600)
current_ind = 2
gap_ind = 3
matplotlib.rcParams.update({'font.size': 18})
for i,series in enumerate(raw_data[gap_ind,::-1]):
f = interp1d(magnet_os, series, kind=3)
plot(magnet_os,series,ls='',marker='+',c=cm((11-i)/11))
plot(stroke,f(stroke),label='%.1f A'%(currents[::-1][i]),c=cm((11-i)/11))
#legend(loc=(1.01,.01))
xlabel('stroke (um)')
ylabel('Force (N)')
#title('Linear Motor, %d um gap'%(1e6*gaps[gap_ind]))
ylim([-.15,.3])
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-0f8b8e9ee4a1> in <module>()
1 cm = plt.get_cmap('cool')
----> 2 stroke = linspace( amin(magnet_os), amax(magnet_os), 100)
3 figure(figsize=(12,10),dpi=600)
4 current_ind = 2
5 gap_ind = 3
NameError: name 'magnet_os' is not defined
%% Cell type:code id: tags:
``` python
cm = plt.get_cmap('cool')
stroke = linspace( amin(magnet_os), amax(magnet_os), 100)
figure(figsize=(12,10))
for i,series in enumerate(raw_data[:,0]):
z = poly1d(polyfit(magnet_os, series,11))
plot(magnet_os,series,label='gap=%d um'%(1e6*gaps[i]),ls='',marker='+',c=cm(i/5))
plot(stroke, z(stroke),c=cm(i/5))
legend(loc='lower right')
xlabel('stroke (um)')
ylabel('X Force (N)')
```
%% Output
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-5-d31a02cbe3fa> in <module>()
1 cm = plt.get_cmap('cool')
----> 2 stroke = linspace( amin(magnet_os), amax(magnet_os), 100)
3 figure(figsize=(12,10))
4 for i,series in enumerate(raw_data[:,0]):
5 z = poly1d(polyfit(magnet_os, series,11))
NameError: name 'magnet_os' is not defined
%% Cell type:code id: tags:
``` python
```
......
% Model,coil-coil-speaker.mph
% Version,COMSOL 5.3.1.275
% Date,"Dec 6 2018, 18:31"
% Table,"Table 1 - Global Evaluation 1 (mf.Forcex_0, mf.Forcey_0)"
% n_base,gap (um),"Electromagnetic force, y component (N)","Electromagnetic force, y component (N)"
10,300,-0.08207832378554145,-0.08207832378554127
10,399.99999999999994,-0.07207995122423291,-0.07207995122423318
10,500,-0.06373598062465724,-0.06373598062465777
10,600,-0.0566827914620302,-0.0566827914620302
10,700,-0.0506489792651917,-0.050648979265191414
10,799.9999999999999,-0.04545350371480208,-0.045453503714802175
15,300,-0.10360535584513815,-0.10360535584513784
15,399.99999999999994,-0.0933795780919582,-0.09337957809195868
15,500,-0.08452823010679891,-0.08452823010679804
15,600,-0.07677324661102114,-0.07677324661102099
15,700,-0.06992593745049328,-0.06992593745049319
15,799.9999999999999,-0.06385954116102241,-0.06385954116102234
20,300,-0.11733593022414841,-0.1173359302241507
20,399.99999999999994,-0.10815248353435279,-0.10815248353435303
20,500,-0.09987214162066027,-0.0998721416206589
20,600,-0.0923865951283783,-0.09238659512837842
20,700,-0.08555875581043242,-0.08555875581043178
20,799.9999999999999,-0.07932920066366841,-0.07932920066366683
25,300,-0.12632287888983637,-0.12632287888983676
25,399.99999999999994,-0.11833786175619836,-0.11833786175619584
25,500,-0.11100748269901356,-0.11100748269901378
25,600,-0.1041951104803409,-0.10419511048034096
25,700,-0.09782299733157954,-0.0978229973315815
25,799.9999999999999,-0.09185694713120071,-0.0918569471312006
30,300,-0.13243670824432408,-0.1324367082443262
30,399.99999999999994,-0.1255622679167983,-0.12556226791679798
30,500,-0.11915997994561496,-0.11915997994561418
30,600,-0.11308691704329457,-0.11308691704329465
30,700,-0.1073357944779216,-0.10733579447792117
30,799.9999999999999,-0.10184917943757642,-0.10184917943757658
35,300,-0.13677056452536177,-0.13677056452536293
35,399.99999999999994,-0.13080203713586655,-0.13080203713586697
35,500,-0.12520532188410496,-0.125205321884104
35,600,-0.11987380567515953,-0.11987380567516014
35,700,-0.11473430806567451,-0.1147343080656759
35,799.9999999999999,-0.10976340358680196,-0.10976340358680212
40,300,-0.13990717323235577,-0.13990717323235657
40,399.99999999999994,-0.13464194505199106,-0.1346419450519912
40,500,-0.12971940000903395,-0.1297194000090345
40,600,-0.1250385352876598,-0.12503853528766032
40,700,-0.12048766714948608,-0.12048766714948725
40,799.9999999999999,-0.11605950233797482,-0.11605950233797617
45,300,-0.14211371951863244,-0.14211371951863422
45,399.99999999999994,-0.13748934375145,-0.1374893437514511
45,500,-0.1331845458640706,-0.13318454586407008
45,600,-0.12904000501347995,-0.1290400050134822
45,700,-0.12500747238217932,-0.12500747238217835
45,799.9999999999999,-0.12106189037455688,-0.12106189037455767
50,300,-0.1438017496948447,-0.1438017496948458
50,399.99999999999994,-0.13962160946955932,-0.1396216094695604
50,500,-0.1357819565413621,-0.13578195654136546
50,600,-0.13211486751869694,-0.13211486751869667
50,700,-0.12856833135755893,-0.12856833135755996
50,799.9999999999999,-0.1250506633749004,-0.12505066337490012
img/coil-coil-flux.png

341 KiB

img/coil-coil-force.png

47.7 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment