Please find below my complete code.
I am facing problems withe last segment of the code with is in red. I am
not able to get the results printed from the same. Please help me out.
html('<center><h2>Tyre Design</h2></b>by : Madan Saini')
#Input Parameters
PI = pi.n()
r = var('r')
@interact(layout=[['t_size'],['od','sw'],['nsd','ut'],['bn','bg'],['pn','pg'],['rg','beta_c'],['rim_d','rim_w'],['rim_f'],['auto_update']])
def myplot(t_size=input_box('3.00-18',label='Tyre
Size',width=20),od=input_box(round(627,2),label='Tyre Outer
Dia.',width=20), sw=input_box(round(80,2),label='Tyre Section
Width',width=20), nsd=input_box(round(6.5,2),label='Non Skid
Depth',width=20), ut=input_box(round(2.5,2),label='Under Tread',width=20),
bn=input_box(round(0,0),label='No of Breakers',width=20),
bg=input_box(round(1.2,2),label='Breaker Gauge',width=20),
pn=input_box(round(2,0),label='No of Plies',width=20),
pg=input_box(round(0.85,2),label='Ply Gauge',width=20),
rg=input_box(round(2.5,2),label='Side Rubber Gauge',width=20),
rim_d=input_box(round(458.7,2),label='Rim Dia (D)',width=20),
rim_w=input_box(round(65,0),label='Rim Width(A)',
width=20),rim_f=input_box(round(14,2),label='Rim Flange
Height(G)',width=20), beta_c=input_box(40,label='Crown Angle',width=20),
auto_update=False):
#Initial guess: Assume the closest ellipse
rc = ((od/2)-nsd-ut-(bn*bg)-(pn*pg/2))
W = ((sw/2)-rg-(pn*pg/2))
rb = ((rim_d/2)+rim_f-(pn*pg*1.5))
zb = rim_w/2.0
rw_init = rc*(rb/rc+sqrt(1-(zb/W)^2))/(1+sqrt(1-(zb/W)^2))
rw = var('rw')
Bc = var('Bc')
def find_tire_width(data):
rw = data[0]
Bc = data[1]
r = var('r')
F =
(r^2-rw^2)*sqrt(rc^2-r^2*sin(Bc)^2)/sqrt((rc^2-rw^2)^2*rc^2*cos(Bc)^2-(r^2-rw^2)^2*(rc^2-r^2*sin(Bc)^2))
z = function('z',r)
d2 =
desolve_rk4(diff(z,r)+F,z,ics=[rc*0.9999,0],end_points=(rw-(rc-rw)/2),step=-(rc-rw)/2000)
S = spline(d2)
return [S(rw), S(rb)]
Bc = (90-beta_c)/180*PI
zwb = find_tire_width([rw_init, Bc])
zbn = zwb[1]
zwn = zwb[0]
print "Calculated Shape"
print "rc = ",round(rc,3),", W = ",round(W,3),", rb = ",round(rb,3),",
zb = ",round(zb,3),", Bc = ",round(Bc,3)
print " "
print "Intial rw based on elliptical approximation = ",round(rw_init,3)
print " "
print "Natural Shape"
print "zw = ",round(zwn,3),", zb = ",round(zbn,3)
def f(input):
zwb = find_tire_width(input)
return ((W-zwn)^2+(zb-zbn)^2);
c1 = lambda input: input[0]-rb
c2 = lambda input: rc - input[0]
c3 = lambda input: input[1]
c4 = lambda input: pi/2 - input[1]
a = minimize_constrained(f,[c1, c2, c3, c4],[rw_init, Bc])
a0 = a[0]
a1 = a[1]
print " "
print "Optimal Shape"
print "rw = ",round(a0,3),", Bc = ",round(a1,5),"rad",", Bc =
",round((a1*180/PI),2),"deg"
zwb = find_tire_width(a)
zwo = zwb[0]
zbo = zwb[1]
print "zw = ",round(zwo,3),"zb = ",round(zbo,3)
Rest of the code is working fine. If I dont use the interact function. Then
the code works fine.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.