Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def getVectorGammaQGamma(self, Gamma, Q):
- res = [Gamma*Q*Gamma]
- for i in range(len(self.array_tetha)):
- res.append(self.getDerivate(Gamma, self.array_tetha[i]) * Q * Gamma + Gamma * Q * self.getDerivate(Gamma, self.array_tetha[i]) + Gamma * self.getDerivate(Q, self.array_tetha[i]) * Gamma)
- return res
- def getMatrixDiffur(self, item):
- matrix = [[self.subItem(self.subItem(item, self.t1, self.get_array_tetha()[0]), self.t2, self.get_array_tetha()[1]),0,0]]
- for i in range(len(self.array_tetha)):
- matrix.append(self.getVectorInMatrix(item, i+1))
- return matrix
- def sumMatrixForDiffur(self, t, P):
- F = self.get_F()
- F_matrix = self.getMatrixDiffur(F)
- F_vector = [F_matrix[0][0], F_matrix[1][0], F_matrix[2][0]]
- GQG_vector = self.getVectorGammaQGamma( self.get_Gamma(), self.get_Q())
- P = np.dot(np.reshape(F_matrix,(3,3)), np.reshape(P,(3,1))) + \
- np.dot(np.reshape(np.array([[P[0],0,0],[P[1],P[0],0],[P[2],0,P[0]]]),(3,3)), np.reshape(F_vector,(3,1))) + \
- np.reshape(GQG_vector,(3,1))
- return P
- def SolveDiffurMatrix(self, t_array, x0):
- print(t_array, x0)
- x = (x0)
- x_array = []
- x_array.append(x)
- t = np.linspace(t_array[0], t_array[1])
- t = np.array(t)
- x0 = np.ravel(x).T
- x = np.zeros((len(t), len(x0))) # array for solution
- x[0, :] = x0
- r = integ.ode(self.sumMatrixForDiffur).set_integrator("zvode") # choice of method
- r.set_initial_value(x0, t) # initial values
- for i in range(1, t.size):
- x[i, :] = r.integrate(t[i]) # get one more value, add it to the array
- if not r.successful():
- raise RuntimeError("Could not integrate")
- P = np.reshape(x[len(x) - 1], (1, 3))
- return P[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement