RemDelaporteMathurin / pyEnergyDiagrams

Plot potential energy diagram in python
MIT License
1 stars 0 forks source link

creation of involontary local minimum #1

Open ehodille opened 2 years ago

ehodille commented 2 years ago

Very good tool to create easily and quickly potential energy diagram. Thank you for your work.

I try to create a simple energy diagram based on examples/example_1.py

from pyenergydiagrams import State, Diagram
import matplotlib.pyplot as plt

energies = [-0.0, -0.0, 0.2, -1, 1.3, *[1.0,1.2] * 5 ] 
states = [State(E=E) for E in energies]
my_diagram = Diagram(states)
diag_smooth = my_diagram.make_curve(5000)

plt.figure(figsize=(10,6),edgecolor='None',facecolor='None')
plt.plot(diag_smooth[0],diag_smooth[1])
plt.show()

it seems it creates some involontary local minimum at each stable and unstable equilibrium position (about 10-4, which is not a lot). Is it a creation of the interpolation method ?

RemDelaporteMathurin commented 2 years ago

Are you talking about this? image

by calling:

plt.scatter(my_diagram.x_raw, my_diagram.energies)

you can see the interpolation points:

image

Now you may notice that for each state, there are 3 copies of the same points with a bit of jitter image

That's to avoid (or at least reduce) these over/under-shoots. You can change the number of copies (3 by default) at the instanciation of State objects: https://github.com/RemDelaporteMathurin/pyEnergyDiagrams/blob/d47b75abe21b06c3cfa0092a597cf142d3030803/pyenergydiagrams/main.py#L6-L9

Example with copies = 1: image

RemDelaporteMathurin commented 2 years ago

You can set the number of copies to say 10 but then the local extrema are flatter, and you don't even get rid of these tiny overshoots. image

I guess the solution could be to better control the y position of these interpolation points

ehodille commented 2 years ago

Ok, thank you very much for your help !