No able to get the results from the last segment
I am giving my full code below. I am unable to get the results from code marked in red. Rest is working fine
html('<center><h2>Tyre Design</h2></b>by : Madan Saini')
#Input Parameters
PI = pi.n()
@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])
show("calculated rc = " + str(rc))
show("calculated W = " + str(W))
show("calculated rb = " + str(rb))
show("calculated zb = " + str(zb))
show("calculated Bc = " + str(Bc))
show("rw_init based on elliptical approximation = "+str(rw_init))
show("zw in the natural shape = " + str(zwb[0]))
show("zb in the natural shape = " + str(zwb[1]))
from this point the code is not showing any results
def f(input):
zwb = find_tire_width(input)
return ((W-zwb[0])^2+(zb-zwb[1])^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])
view(a)
show("rw in the optimal shape = " + str(a[0]))
show("Beta in the optimal shape = " + str(a[1]) + " radians")
please help me out to solve this issue..
Still looking for the answer from someone. Please help me out..
You haven't made it very clear exactly what error message you are receiving, and your code is fairly long, so I think people are scared off a bit. It's important to provide a minimal example that isn't working, when possible.