• API
• FAQ
• Tools
• Archive
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 18th, 2018 84 Never
ENDING IN00days00hours00mins00secs

1.     def getVectorGammaQGamma(self, Gamma, Q):
2.
3.         res = [Gamma*Q*Gamma]
4.         for i in range(len(self.array_tetha)):
5.             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)
6.
7.         return  res
8.
9.
10.     def getMatrixDiffur(self, item):
11.         matrix = [[self.subItem(self.subItem(item, self.t1, self.get_array_tetha()[0]), self.t2, self.get_array_tetha()[1]),0,0]]
12.         for i in range(len(self.array_tetha)):
13.             matrix.append(self.getVectorInMatrix(item, i+1))
14.         return matrix
15.
16.
17.
18.     def sumMatrixForDiffur(self, t, P):
19.
20.         F = self.get_F()
21.         F_matrix = self.getMatrixDiffur(F)
22.         F_vector = [F_matrix[0][0], F_matrix[1][0], F_matrix[2][0]]
23.         GQG_vector = self.getVectorGammaQGamma( self.get_Gamma(), self.get_Q())
24.         P = np.dot(np.reshape(F_matrix,(3,3)), np.reshape(P,(3,1))) + \
25.             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))) + \
26.             np.reshape(GQG_vector,(3,1))
27.
28.         return P
29.
30.
31.
32.     def SolveDiffurMatrix(self, t_array, x0):
33.         print(t_array, x0)
34.         x = (x0)
35.
36.         x_array = []
37.         x_array.append(x)
38.         t = np.linspace(t_array[0], t_array[1])
39.         t = np.array(t)
40.         x0 = np.ravel(x).T
41.         x = np.zeros((len(t), len(x0)))  # array for solution
42.         x[0, :] = x0
43.
44.         r = integ.ode(self.sumMatrixForDiffur).set_integrator("zvode")  # choice of method
45.         r.set_initial_value(x0, t)  # initial values
46.
47.         for i in range(1, t.size):
48.             x[i, :] = r.integrate(t[i])  # get one more value, add it to the array
49.             if not r.successful():
50.                 raise RuntimeError("Could not integrate")
51.
52.
53.         P = np.reshape(x[len(x) - 1], (1, 3))
54.
55.         return P[0]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top