import numpy as np import matplotlib.pyplot as plt
deflennard_jones_potential(r, epsilon, sigma): """ Calculate the Lennard-Jones potential energy for a given distance r. Parameters: r (float or numpy.ndarray): Distance between particles. epsilon (float): Depth of the potential energy well. sigma (float): Distance at which the potential energy is zero. Returns: float or numpy.ndarray: Potential energy at distance r. """ # Calculate the terms in the LJ potential term1 = (sigma / r)**12 term2 = (sigma / r)**6 # LJ potential energy potential_energy = 4 * epsilon * (term1 - term2) return potential_energy
# Define parameters epsilon = 1.0# Depth of the potential energy well sigma = 1.0# Distance at which potential energy is zero
# Generate distance values r_values = np.linspace(0.9, 3.0, 100) # Range of distances to evaluate
deflennard_jones_potential(r, epsilon, sigma): """ Calculate the Lennard-Jones potential energy for a given distance r. Parameters: r (float or numpy.ndarray): Distance between particles. epsilon (float): Depth of the potential energy well. sigma (float): Distance at which the potential energy is zero. Returns: float or numpy.ndarray: Potential energy at distance r. """ # Calculate the terms in the LJ potential term1 = (sigma / r)**12 term2 = (sigma / r)**6 # LJ potential energy potential_energy = 4 * epsilon * (term1 - term2) return potential_energy
lennard_jones_potential関数は、与えられた距離 r に対するレナード-ジョーンズポテンシャルエネルギーを計算します。
r は粒子間の距離で、epsilonはポテンシャルエネルギーの深さを表し、sigmaはポテンシャルエネルギーがゼロになる距離を表します。
term1とterm2はレナード-ジョーンズポテンシャルの計算に使用される項です。
potential_energyはレナード-ジョーンズポテンシャルの値を計算し、その値を返します。
3. パラメータの定義
1 2
epsilon = 1.0# Depth of the potential energy well sigma = 1.0# Distance at which potential energy is zero