Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. # coding=utf-8
  2. import math
  3.  
  4. import matplotlib.pyplot as plt
  5. import numpy
  6. from pylab import rcParams
  7. from scipy.integrate import odeint
  8. from scipy.integrate import quad
  9. from scipy.special import *
  10. from sympy import *
  11.  
  12. rcParams["figure.figsize"] = (12, 9)
  13.  
  14.  
  15. def rhs(U, t, deltaM, eps):
  16. return [U[1], -(deltaM + eps * cos(2 * t)) * U[0]]
  17.  
  18.  
  19. tempDelta = 1
  20. epsilon = 0.5
  21.  
  22. A = quad(lambda xk: 0.8476479 * math.exp(-5 * math.pow(xk, 3) + xk + 0.5), 0, 1)[0]
  23. x = Symbol('x')
  24. solveEquation = solve(x - 1.4 ** x, x)
  25. B = solveEquation[0]
  26. for solve in solveEquation:
  27. if B < solve:
  28. B = solve
  29.  
  30. print(A)
  31. print(B)
  32.  
  33. U0 = A
  34. U01 = B
  35.  
  36. startTime = 0.
  37. endTime = 10.
  38. NTimeSteps = 20
  39. time = numpy.linspace(startTime, endTime, NTimeSteps + 1)
  40. initX = [U0, U01]
  41.  
  42. delta = 1.
  43. epsilon = 0.5
  44. out0 = odeint(rhs, initX, time, args=(delta, epsilon))
  45. print(out0)
  46. plt.ioff()
  47. plt.plot(time, out0[:, 0], label=r'$\delta = 1$, $\varepsilon = 0.5$')
  48. plt.legend()
  49. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement