Exemplo n.º 1
0
	def DIFEQ(self,Qd,Q,t,P):
		#/ --------------------------------------------------------------------------
		if (0==self.done):
			G    = P[jG]

			self.x[0] = Q[iX1]
			self.y[0] = Q[iY1]
			self.x[1] = Q[iX2]
			self.y[1] = Q[iY2]
			self.x[2] = Q[iX3]
			self.y[2] = Q[iY3]
			self.x[3] = Q[iX4]
			self.y[3] = Q[iY4]

			self.m[0] = P[jM1]
			self.m[1] = P[jM2]
			self.m[2] = P[jM3]
			self.m[3] = P[jM4]

			for k in range(1,NN):
				for i in range(0,k):
					self.dx[k][i] = self.x[k] - self.x[i]
					self.dy[k][i] = self.y[k] - self.y[i]
					self.dx[i][k] = -self.dx[k][i]
					self.dy[i][k] = -self.dy[k][i]

			for k in range(1,NN):
				for i in range(0,k):
					tt = (self.dx[k][i]*self.dx[k][i]) + (self.dy[k][i]*self.dy[k][i])
					self.DEN[k][i] = Math.POWER(tt,-1.5)
					self.DEN[i][k] = self.DEN[k][i]

			for i in range(0,NN):
				sumx = 0.0
				sumy = 0.0
				for k in range(0,NN):
					if k != i:
						tk = self.m[k]*self.DEN[k][i]
						sumx += (tk*self.dx[k][i])
						sumy += (tk*self.dy[k][i])
				self.xdd[i] = G*sumx
				self.ydd[i] = G*sumy


			Qd[iVX1] = self.xdd[0]
			Qd[iVY1] = self.ydd[0]
			Qd[iX1]  = Q[iVX1]
			Qd[iY1]  = Q[iVY1]
			Qd[iVX2] = self.xdd[1]
			Qd[iVY2] = self.ydd[1]
			Qd[iX2]  = Q[iVX2]
			Qd[iY2]  = Q[iVY2]
			Qd[iVX3] = self.xdd[2]
			Qd[iVY3] = self.ydd[2]
			Qd[iX3]  = Q[iVX3]
			Qd[iY3]  = Q[iVY3]
			Qd[iVX4] = self.xdd[3]
			Qd[iVY4] = self.ydd[3]
			Qd[iX4]  = Q[iVX4]
			Qd[iY4]  = Q[iVY4]
Exemplo n.º 2
0
    def DIFEQ(self, Qd, Q, t, P):
        #/ --------------------------------------------------------------------------
        if 0 == self.done:
            xd1 = Q[0]
            x1 = Q[4]
            yd1 = Q[1]
            y1 = Q[5]
            xd2 = Q[2]
            x2 = Q[6]
            yd2 = Q[3]
            y2 = Q[7]

            m1 = P[0]
            m2 = P[2]

            dx21 = x2 - x1
            dy21 = y2 - y1
            dx12 = x1 - x2
            dy12 = y1 - y2

            r12sq = (dx12 * dx12) + (dy12 * dy12)
            den = Math.POWER(r12sq, 1.5)

            if den > 0.0:
                pass
            else:
                print "INFINITY\n"

            a1 = Math.N_G * m2 * dx21
            a2 = Math.N_G * m2 * dy21
            a3 = Math.N_G * m1 * dx12
            a4 = Math.N_G * m1 * dy12

            Qd[0] = Math.SAFEDIV(a1, den)
            Qd[1] = Math.SAFEDIV(a2, den)
            Qd[2] = Math.SAFEDIV(a3, den)
            Qd[3] = Math.SAFEDIV(a4, den)
            Qd[4] = xd1
            Qd[5] = yd1
            Qd[6] = xd2
            Qd[7] = yd2