Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. import numpy as np
  2. from scipy import optimize
  3.  
  4. J = 100.
  5. N = 5000.
  6. U = 0.05
  7.  
  8. Lambda = N*U/(2*J)
  9. print Lambda, np.sqrt(1-1/(Lambda**2))
  10.  
  11.  
  12. def func(x):
  13.     return [-2 * J * np.sqrt(1 - x[0] ** 2) * np.sin(x[1]),
  14.             N * U * x[0] + 2 * J * x[0] * np.cos(x[1]) / np.sqrt(1 - x[0] ** 2)]
  15.  
  16.  
  17. def jac(x):
  18.     return np.array([[2 * J * x[0] * np.sin(x[1]) / np.sqrt(1 - x[0] ** 2),
  19.                       -2 * J * np.sqrt(1 - x[0] ** 2) * np.cos(x[1])],
  20.                      [N * U + 2 * J * np.cos(x[1]) / (np.sqrt(1 - x[0] ** 2) * (1 - x[0] ** 2)),
  21.                       2 * J * x[0] * np.sin(x[1]) / np.sqrt(1 - x[0] ** 2)]])
  22.  
  23.  
  24. sol = optimize.root(func, [0.5, np.pi + 0.1], jac=jac, method='hybr')
  25. print sol.x
  26. print func(sol.x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement