Commit e7e5a9e4 authored by Sam Calisch's avatar Sam Calisch
Browse files

update

parent 12716ce2
This diff is collapsed.
% Model,magnet-coil-speaker.mph
% Version,COMSOL 5.3.1.275
% Date,"Dec 7 2018, 20:20"
% Table,"Table 1 - Global Evaluation 1 (mf.Forcex_0, mf.Forcey_0)"
% magnet_pitch (mm),gap (um),"Electromagnetic force, y component (N)"
3,199.99999999999997,0.8641894983096053
3,300,0.7815188844003927
3,399.99999999999994,0.706047793607393
3,500,0.6372080475337328
3,600,0.5748167735488693
3,700,0.5182462275053145
3,799.9999999999999,0.4671380641834507
3.5,199.99999999999997,0.9207138425787319
3.5,300,0.8399417851019988
3.5,399.99999999999994,0.7660594387459269
3.5,500,0.6986703234978027
3.5,600,0.6373286560425424
3.5,700,0.5815497137707148
3.5,799.9999999999999,0.5306656635101766
4,199.99999999999997,0.9197744649328616
4,300,0.8432310017902835
4,399.99999999999994,0.7740759080111601
4,500,0.7114392312992569
4,600,0.6546134132920624
4,700,0.6028383472128684
4,799.9999999999999,0.5554313260883948
4.500000000000001,199.99999999999997,0.8610976632048059
4.500000000000001,300,0.79525499546552
4.500000000000001,399.99999999999994,0.736549485844198
4.500000000000001,500,0.6835828788308063
4.500000000000001,600,0.6352322768447947
4.500000000000001,700,0.5908568125009463
4.500000000000001,799.9999999999999,0.5499090117204061
5,199.99999999999997,0.7460372217962541
5,300,0.7037125188212451
5,399.99999999999994,0.663500613606545
5,500,0.6253558455213473
5,600,0.5892259158988559
5,700,0.5549569391092586
5,799.9999999999999,0.5225056208474643
5.5,199.99999999999997,0.6172958174794003
5.5,300,0.5987078803522339
5.5,399.99999999999994,0.5772425591351684
5.5,500,0.554322153526425
5.5,600,0.5303862452809436
5.5,700,0.5065057696995219
5.5,799.9999999999999,0.4829294490316987
6,199.99999999999997,0.514408647679742
6,300,0.507083336573673
6,399.99999999999994,0.49657783878428263
6,500,0.4837368289917114
6,600,0.4692707829644498
6,700,0.4537168552377991
6,799.9999999999999,0.43745884804257873
6.500000000000001,199.99999999999997,0.4360339443223982
6.500000000000001,300,0.43353183087913605
6.500000000000001,399.99999999999994,0.428619860507283
6.500000000000001,500,0.42163113445304307
6.500000000000001,600,0.41311533407272155
6.500000000000001,700,0.40318399073912964
6.500000000000001,799.9999999999999,0.39238232951329755
7,199.99999999999997,0.3745711086350754
7,300,0.37432167691540474
7,399.99999999999994,0.3723454953976282
7,500,0.36876238067641776
7,600,0.3638235124630308
7,700,0.3577203075469937
7,799.9999999999999,0.3506544283071643
7.5,199.99999999999997,0.3250647691196492
7.5,300,0.326071019510345
7.5,399.99999999999994,0.3257525380930084
7.5,500,0.32418028203009863
7.5,600,0.3215115795046743
7.5,700,0.3178256730728548
7.5,799.9999999999999,0.31329892409812077
8,199.99999999999997,0.2844633545459577
8,300,0.28618314004967144
8,399.99999999999994,0.2868446047529096
8,500,0.28651279607732233
8,600,0.28526593167394376
8,700,0.28319954810639875
8,799.9999999999999,0.28040285597707054
% Model,magnet-coil-speaker.mph
% Version,COMSOL 5.3.1.275
% Date,"Dec 6 2018, 23:42"
% Table,"Table 1 - Global Evaluation 1 (mf.Forcex_0, mf.Forcey_0)"
% magnet_th (mm),gap (um),"Electromagnetic force, y component (N)"
0.5,300,0.48456986364292487
0.5,399.99999999999994,0.4525023673294216
0.5,500,0.42750507229682494
0.5,600,0.40844031409951276
0.5,700,0.3947183742336287
0.5,799.9999999999999,0.3854485802214254
1,300,0.5783775691819707
1,399.99999999999994,0.5320315746634457
1,500,0.4930419959359778
1,600,0.4603252736827853
1,700,0.4323024182930223
1,799.9999999999999,0.40867646837569843
1.5,300,0.6289247197550714
1.5,399.99999999999994,0.575670283446941
1.5,500,0.5299364291088474
1.5,600,0.49022851172565807
1.5,700,0.4558495003060742
1.5,799.9999999999999,0.42604635273696173
2,300,0.6720397516216423
2,399.99999999999994,0.6138912796048818
2,500,0.5638249300463641
2,600,0.5205165359345659
2,700,0.4823245880078012
2,799.9999999999999,0.4486541357760351
2.5,300,0.7060538070979323
2.5,399.99999999999994,0.6455369977712041
2.5,500,0.5932514027403134
2.5,600,0.5472913713664808
2.5,700,0.5068555560697918
2.5,799.9999999999999,0.4711221969867704
3,300,0.7332363367713702
3,399.99999999999994,0.6702271617442722
3,500,0.6165033104947446
3,600,0.568833339561078
3,700,0.5271136991769472
3,799.9999999999999,0.48984029371797105
#!/usr/bin/env python
from __future__ import division,absolute_import
import rhinoscriptsyntax as rs
from math import *
import sys
#simple class for vec2
class V2(object):
def __init__(self,*args):
if len(args)>1:
self.x = args[0]
self.y = args[1]
else:
self.x = args[0][0]
self.y = args[0][1]
self.p3l = [self.x,self.y,0]
def __add__(self,other):
return V2(self.x+other.x,self.y+other.y)
def __sub__(self,other):
return V2(self.x-other.x,self.y-other.y)
def __mul__(self,other):
try:
return V2(self.x*other.x,self.y*other.y)
except(AttributeError):
return V2(self.x*other,self.y*other)
def __rmul__(self,other):
try:
return V2(self.x*other.x, self.y*other.y)
except(AttributeError):
return V2(self.x*other,self.y*other)
def __getitem__(self,index):
return [self.x,self.y][index]
def __repr__(self):
return "V2(%.6f,%.6f)"%(self.x,self.y)
def rotate(self,th):
return V2(self.x*cos(th)-self.y*sin(th), self.x*sin(th)+self.y*cos(th))
def rotate90(self):
return V2(-self.y,self.x)
def rotate_p(self,b,th):
return b + (self-b).rotate(th)
def magnitude(self):
return sqrt(self.x*self.x + self.y*self.y)
def normalized(self):
return self*(1./self.magnitude())
def dot(self,other):
return self.x*other.x + self.y*other.y
def cross(self,other):
return self.x*other.y - self.y*other.x
def angle_between(self,other):
#unsigned angle between two vectors
c = self.cross(other)
return atan2(c,self.dot(other))
def projected_onto(self,other):
return ((self.dot(other))/(other.dot(other)))*other
def projected_orthogonal_to(self,other):
return self - self.projected_onto(other)
def close(self,other,tol=1e-6):
return (abs(self.x-other.x)<tol) and (abs(self.y-other.y)<tol)
def p3lz(self,z):
return [self.x,self.y,z]
def line(p1,p2,layer,bridge_w=0,cut_w=0):
d = p2-p1; dl = d.magnitude()
if dl==0:
return None
dn = d.normalized()
if bridge_w==0 or cut_w==0:
rs.CurrentLayer(layer)
return rs.AddLine(p1.p3l, p2.p3l)
else:
rs.CurrentLayer(layer)
output = []; dist = bridge_w
ds = []
while dist < dl-2*bridge_w:#-cut_w:
ds.append((dist, dist+cut_w))
#print bridge_w, (p1+dist*dn).p3l , (p1+(dist+bridge_w)*dn).p3l
dist += cut_w+bridge_w
#leftover = dl-bridge_w-cut_w - dist + cut_w+bridge_w
leftover = dl-bridge_w - dist + cut_w+bridge_w
for pair in ds:
output.append(rs.AddLine( (p1+(pair[0] + leftover/2)*dn).p3l , (p1+(pair[1]+ leftover/2)*dn).p3l) )
return output
def circle(c,d,layer):
rs.CurrentLayer(layer)
return rs.AddCircle(c.p3l, .5*d)
def arc(c,d,th1,th2,layer):
rs.CurrentLayer(layer)
p1 = c + d/2*V2(cos(pi/180.*th1),sin(pi/180.*th1))
p2 = c + d/2*V2(cos(pi/180.*th2),sin(pi/180.*th2))
pm = c + d/2*V2(cos(pi/180.*(th1+th2)/2),sin(pi/180.*(th1+th2)/2))
return rs.AddArc3Pt(p1.p3l,p2.p3l,pm.p3l)
def make_rectangular_spiral(x,y,h,w,R,pitch,N):
rs.CurrentLayer('coil')
r = R
hw = w/2; hh = h/2
crvs = [ ]
for i in range(N):
#r -= pitch/2
r2 = r*(1-1/sqrt(2))
crvs.append( line( V2(-hw+(i+0)*pitch,hh-r), V2(-hw+(i+.5)*pitch,-hh+r), 'coil' ) )
crvs.append( rs.AddArc3Pt( [-hw+(i+.5)*pitch,-hh+r,0], [-hw+r,-hh+(i+.5)*pitch,0], [-hw+r2+(i+.5)*pitch/sqrt(2),-hh+r2+(i+.5)*pitch/sqrt(2),0] ) )
crvs.append( line(V2(-hw+r,-hh+(i+.5)*pitch), V2(hw-r,-hh+(i+.5)*pitch), 'coil' ) )
crvs.append( rs.AddArc3Pt( [hw-r,-hh+(i+.5)*pitch,0], [hw-(i+.5)*pitch,-hh+r,0], [hw-r2-(i+.5)*pitch/sqrt(2),-hh+r2+(i+.5)*pitch/sqrt(2),0] ) )
crvs.append( line( V2(hw-(i+.5)*pitch,-hh+r), V2(hw-(i+1)*pitch,hh-r), 'coil' ) )
if i<N-1:
crvs.append( rs.AddArc3Pt( [hw-(i+1)*pitch,hh-r,0], [hw-r,hh-(i+1)*pitch,0], [hw-r2-(i+1)*pitch/sqrt(2),hh-r2-(i+1)*pitch/sqrt(2),0] ) )
crvs.append( line(V2(hw-r,hh-(i+1)*pitch), V2(-hw+r,hh-(i+1.)*pitch), 'coil' ) )
crvs.append( rs.AddArc3Pt( [-hw+r,hh-(i+1.)*pitch,0], [-hw+(i+1.)*pitch,hh-r,0], [-hw+r2+(i+1.)*pitch/sqrt(2),hh-r2-(i+1.)*pitch/sqrt(2),0] ) )
#crvs.append( line( V2(hw-(N+0)*pitch,-hh+r), V2(hw-(N+.25)*pitch,hh-r), 'coil' ) )
result = rs.JoinCurves(crvs)
rs.DeleteObjects(crvs)
rs.MoveObjects(result,[x,y,0])
return result
def main():
rs.AddLayer('magnets',(255,0,0))
rs.AddLayer('holes',(0,255,0))
rs.AddLayer('coils',(0,0,255))
mag_d = 3 #mm, diameter of magnets
hole_d = 8 #mm, diameter of air hole
s = 6 #mm, hex side length (2xmag_d?)
#lead_in = 25 #mm, lead in length
#phase_extension = 1 #mm, extension of each phase for overpass and turnaround
#wire_pitch = .22 #mm, pitch, .22 = 34 awg measured diameter (.2) + .02mm slop (determined empirically)
wire_pitch = 2*.088 #mm, pitch, .088 = measured diameter (.080) + .008 mm slop (10% applied)
N = 11 #number of turns
Nx = 3 #number of cells in x direction,
Ny = 6 #number of cells in y direction
s32 = s*sqrt(3)/2.
magnets = []; holes = []; coils = [];
for i in range(Nx):
x0 = i*3*s + s
for j in range(Ny):
y0 = j*2*s32
magnets += [
circle(V2(x0-s/2,y0+s32),mag_d,'magnets'),
circle(V2(x0,y0),mag_d,'magnets'),
circle(V2(x0+s,y0),mag_d,'magnets'),
circle(V2(x0+3*s/2,y0+s32),mag_d,'magnets')
]
holes += [circle(V2(x0+s/2,y0+s32),hole_d,'holes')]
if i<Nx-1:
holes += [circle(V2(x0+2*s,y0),hole_d,'holes')]
if j%2==0:
for k in range(N):
kk = -(N-1)/2+k
coils += [
arc(V2(x0-s/2,y0+s32),s+kk*wire_pitch,180,300,'coils') if i>0 else arc(V2(x0,y0),s-kk*wire_pitch,240,120,'coils'),
arc(V2(x0,y0),s-kk*wire_pitch,120,0,'coils'),
arc(V2(x0+s,y0),s+kk*wire_pitch,180,420,'coils'),
arc(V2(x0+3*s/2,y0+s32),s-kk*wire_pitch,240,0 if i<Nx-1 else 120,'coils'),
]
else:
for k in range(N):
kk = -(N-1)/2+k
coils += [
arc(V2(x0-s/2,y0+s32),s+kk*wire_pitch,180 if i>0 else 60,-60,'coils'),
arc(V2(x0,y0),s-kk*wire_pitch,120,360,'coils'),
arc(V2(x0+s,y0),s+kk*wire_pitch,180,60,'coils'),
arc(V2(x0+3*s/2,y0+s32),s-kk*wire_pitch,240,360,'coils') if i<Nx-1 else arc(V2(x0+s,y0),s+kk*wire_pitch,60,-60,'coils'),
]
if __name__ == '__main__':
main()
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment