Beispiel #1
0
def oderhs(t,z, args = (9.81, 628.32, 1000.)):
	g,w0,F_a = args
	n = int((len(z)-4)/5)
	dz = array(zeros(len(z)))
	ind = Index(n)
	ring_state = r_[z[ind.x():ind.y()+1], z[ind.xdot():ind.ydot()+1]]
	F_x = 0
	F_y = F_a

	for j in xrange(0,n):
		rhs, F_xj, F_yj = rhs_ball(r_[z[ind.r(j):ind.theta(j)+1], z[ind.rdot(j):ind.phidot(j)+1]], ring_state, args = (g,w0))
		F_x += F_xj
		F_y += F_yj
		dz[ind.r(j)] = z[ind.rdot(j)]
		dz[ind.theta(j)] = z[ind.thetadot(j)]
		dz[ind.rdot(j):ind.phidot(j)+1] = rhs

	dz[ind.x():ind.y()+1] = z[ind.xdot():ind.ydot()+1]
	dz[ind.xdot()] = F_x/m0
	dz[ind.ydot()] = F_y/m0
	return dz
Beispiel #2
0
## Initial position/motion of the rolling elements
n = 8
N = 5*n+4
u0 = array(zeros(N))
ind = Index(n)
# This is rand(8)*1e-6:
perturbation = array([  9.78702856e-07,   2.93684668e-07,   4.79000309e-07,
						3.21827339e-07,   8.01445882e-07,   7.26611584e-08,
						8.74822963e-08,   7.41679693e-07])

for i in xrange(0,n):
	u0[ind.r(i)]        = (b0+c0)/2 + perturbation[i] #rand()*1e-6       # r
	u0[ind.theta(i)]    = -pi/2 + 2*pi*i/n# theta
	u0[ind.rdot(i)]     = 0               # rdot
	u0[ind.thetadot(i)] = 0*b0/(b0+c0)#*w0   # thetadot
	u0[ind.phidot(i)]   = 0*b0/2/a0*628.32      # phidot - note that phi is not a state variable since it does not matter here

end_state = array([9.81, 628.32, 1000.])
h = 1. / numpy.max(end_state)

#rhs_ = Sjoe((0,0,0))
#rhs = Sjoe(10*h*end_state)
rhs_ = Sjoe((0.0981,0,0))
def f(u):
	return rhs_(0,u)
A0 = jac(f,u0)

uk = copy(u0)
#
#rhs_ = Sjoe((0.0981,0,0))
#def f(u):
    rhs.name = 'rhs'
    return rhs
#Sjoe.name = 'Sjoe'

## Initial position/motion of the rolling elements
n = 8
N = 5*n+4
u0 = array(zeros(N))
ind = Index(n)

for i in xrange(0,n):
    u0[ind.r(i)]        = (b0+c0)/2       # r
    u0[ind.theta(i)]    = -pi/2 + 2*pi*i/n# theta
    u0[ind.rdot(i)]     = 0               # rdot
    u0[ind.thetadot(i)] = b0/(b0+c0)*w0   # thetadot
    u0[ind.phidot(i)]   = b0/2/a0*w0      # phidot - note that phi is not a state variable since it does not matter here

rhs = Sjoe()

cv=IVP.CVode(rhs,u0)
cv.set_method('BDF','Newton')
atol = array(zeros(N))
for i in range(0,N):
    atol[i] = 1e-8
cv.set_tolerance(atol,rtol=1.e-8)

numsteps = 100
t0 = 0.005

ex_time0 = time.clock()
cv(t0,numsteps)