This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from sympy.physics.quantum import TensorProduct | |
| import sympy as sp | |
| ħ,θ,φ = sp.symbols("ħ,θ,φ", real=True) | |
| def Splus_matrix(s = sp.Rational(1,2)): | |
| Splus = sp.zeros(2*s+1, 2*s+1) | |
| for j in range(1, 2*s+1): | |
| m = s-j | |
| Splus[j-1,j] = ħ*sp.sqrt(s*(s+1) - m*m -m) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The example requires qmsolve package: https://github.com/quantum-visualizations/qmsolve | |
| import numpy as np | |
| from qmsolve import Hamiltonian, SingleParticle, init_visualization | |
| #interaction potential | |
| def sperical_well(particle): | |
| a = 5 | |
| r = np.sqrt((particle.x)**2 + (particle.y)**2 + (particle.z)**2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| def get_all_roots_from_interval(func, extent,N): | |
| roots = [] | |
| x = np.linspace(extent[0],extent[1], N) | |
| for i in range(len(x)-1): | |
| if func(x[i])*func(x[i+1]) <= 0: | |
| bisection(x[i],x[i+1], roots,func) | |
| return roots | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #======================================================================================================================================= | |
| # This script computes the equation of motion of a damped double pendulum using a full Newtonian analysis with sympy, | |
| # then solve them numerically, and finally visualize the solution using matplotlib. | |
| #======================================================================================================================================= | |
| import sympy as sp | |
| import numpy as np | |
| import matplotlib.pyplot as plt |