コード例 #1
0
ファイル: Sjoe_m_func2.py プロジェクト: Harcion/Sjoe
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
コード例 #2
0
ファイル: test_incremental.py プロジェクト: Harcion/Sjoe
## 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))
コード例 #3
0
            return oderhs(t,y)
    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()
コード例 #4
0
ファイル: test_Sjoe_CVODE.py プロジェクト: Harcion/Sjoe
def Sjoe(t,y):
	return oderhs(y,t)
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.theta(i)] 	= -pi/2
	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


u0 = array([ -1.76242809e-06,   2.76352696e-05,   2.49863406e-02,
		3.60926024e+01,   2.49894620e-02,   3.68814017e+01,
		2.49990368e-02,   3.76634995e+01,   2.50188206e-02,
		3.84516617e+01,   2.50287876e-02,   3.92372570e+01,
		2.50226201e-02,   4.00211008e+01,   2.50039592e-02,
		4.08050833e+01,   2.49913725e-02,   4.15901103e+01,
		-4.14597895e-03,  -1.02965855e-04,  -3.90691649e-04,
		3.77207067e+02,   1.88758319e+03,   1.95269428e-03,
		3.77162759e+02,   1.88700742e+03,   3.60118751e-03,
		3.77028471e+02,   1.88525136e+03,   4.92153159e-03,
		3.76198409e+02,   1.88837187e+03,   7.63066963e-04,
		3.75738352e+02,   1.89020148e+03,  -3.82863656e-03,