Add matplotlib energy landscape plot helper with selectable layouts Unit test included. - #415
Add matplotlib energy landscape plot helper with selectable layouts Unit test included.#415nfaguirrec wants to merge 19 commits into
Conversation
…Unit test included.
Add a test for molecules and surfaces SO215, SO103
…s included SO215, SO103
SO215, SO103
| remove_text=True, | ||
| extensions=["png"], | ||
| style="mpl20", | ||
| tol=20, |
There was a problem hiding this comment.
These can be a bit flakey, but tol of 20 is quite high so should be ok...
There was a problem hiding this comment.
I just copied it from the other tests. So far, it works. But it is a great point to keep in mind, in case at some point the tests fail
|
|
||
|
|
||
| @requires_optional_package("matplotlib") | ||
| def plot_energy_landscape( |
There was a problem hiding this comment.
Re-export in top-level plams?
https://github.com/SCM-NV/PLAMS/blob/trunk/src/scm/plams/__init__.py#L151
There was a problem hiding this comment.
Well, every plot_* function in src/scm/plams/tools/plot.py has the same decorator, 10 in total. I thought it was on purpose.
$ grep -H -A1 'requires_optional_package("matplotlib")' src/scm/plams/tools/plot.py
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_band_structure(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_phonons_band_structure(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_phonons_dos(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_phonons_thermodynamic_properties(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-@requires_optional_package("ase")
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_image_grid(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_correlation(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_msd(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_work_function(
--
src/scm/plams/tools/plot.py:@requires_optional_package("matplotlib")
src/scm/plams/tools/plot.py-def plot_energy_landscape(
| connector_color: str = "black", | ||
| connector_linestyle: Any = (0, (4, 4)), | ||
| label_states: bool = True, | ||
| layout: str = "auto", |
There was a problem hiding this comment.
Can we help out the user here: Literal["auto", "dfs", "bfs", "longest_path", "force", "crossings"]?
There was a problem hiding this comment.
I added this in the function's documentation:
- Use
"auto"to compare the available strategies and pick the one with the cleanest connector pattern. - Use
"dfs"to follow one branch deeply before backtracking, which can resemble a reaction-path view. - Use
"bfs"to expand level by level from one endpoint, keeping nearby states grouped together. - Use
"longest_path"to place the main backbone of the network first and then attach side branches around it. - Use
"force"to apply a simple force-based relaxation that spreads states while reducing visual crowding. - Use
"crossings"to minimize connector crossings directly, which can help for dense networks.
| state_label = getattr(state, "display_id", state.id) | ||
| state_plot_kwargs = dict(molecule_plot_kwargs) | ||
| state_plot_kwargs.update(molecule_plot_kwargs_by_state.get(state_label, {})) | ||
| plot_molecule(state.molecule, ax=inset_ax, keep_axis=False, **state_plot_kwargs) |
There was a problem hiding this comment.
You might be able to use view method here instead, if you wanted AMSview style molecules instead of ASE style molecules
There was a problem hiding this comment.
I have added the parameter molecule_plot_backend: Literal["view", "plot_molecule"] = "view" to the plot_energy_landscape function. Now, the user can choose which backend they prefer
There was a problem hiding this comment.
By the way, I just realized that molecule_plot_backend="view"cannot be tested in CI because ams is not installed there
There was a problem hiding this comment.
I also added an example examples/EnergyLandscape/EnergyLandscape.ipynb where I show how to use these new functions, including the use of view and plot_molecule
…landscape examples and tests SO215, SO103
… landscape function SO215
Thanks! |

Now we can do these things :)
Also, including the molecules:
For surfaces, it also works!