My task at university is to model the collision of two particles. One subtask is to calculate the minimal distance of the two particles in dependance of a constant b.
I have to vary the constants b and I wanted to do so by just applying the function below on the whole linspace. However, instead of an array of solutions, the function returns just one value.
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import fsolve
#given constants
sigma = 1
eps = 0.5
n_b = 100
b_var = np.linspace(0,3,n_b)
E = 0.2
def U(r):
return 4*eps*((sigma/r)**12 - (sigma/r)**6)
def r_min(b):
F = lambda r: E*(1 - (b**2/r**2)) - U(r)
return fsolve(F,1)[0]
print(r_min(b_var))
>>> 0.98549755197