<jupyter_start><jupyter_text>Validating a dihedral potential<jupyter_code>%matplotlib notebook
import matplotlib.pyplot as plt
from lammps import IPyLammps
L = IPyLammps()
import math

L.units("real")
L.atom_style("molecular")

L.boundary("f f f")
L.neighbor(0.3, "bin")

L.dihedral_style("harmonic")
L.read_data("data.dihedral")
L.pair_style("zero", 5)
L.pair_coeff("*", "*")
L.mass(1, 1.0)
L.velocity("all", "set", 0.0, 0.0, 0.0)
L.run(0);
L.image(zoom=1.0)
L.atoms[3].position
L.atoms[3].position = (1.0, 0.0, 1.0)
L.image(zoom=1.0)
L.eval("pe")
L.atoms[3].position = (1.0, 0.0, -1.0)
L.run(0);
phi = [d * math.pi / 180 for d in range(360)]
pos = [(1.0, math.cos(p), math.sin(p)) for p in phi]
K = 80.0
d = 1
n = 2
E_analytical = [K * (1 + d * math.cos(n*p)) for p in phi]
pe = []
for p in pos:
    L.atoms[3].position = p
    L.run(0);
    pe.append(L.eval("pe"))
plt.plot(range(360), pe, range(360), E_analytical)
plt.xlabel('angle')
plt.ylabel('E')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.21747967479674796, 'fraction_numerical': 0.05589430894308943, 'mean_word_length': 4.441988950276243, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '358718', 'license': 'MIT', 'n_tokens_mistral': 493, 'n_tokens_neox': 462, 'n_words': 96, 'path': 'lammps-master/python/examples/pylammps/dihedrals/dihedral.ipynb', 'repo_name': 'rajkubp020/helloword', 'size': '984'}