Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: BandFragmentJob #130

Draft
wants to merge 33 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0c696bc
first draft of bandfragment and nocv multijob recipes
patrickmelix Jun 19, 2024
291acdd
Merge branch 'master' into pEDA
patrickmelix Jun 28, 2024
1d2240e
fix depreceated sphinx add_stylesheet
patrickmelix Jul 31, 2024
0a5ee75
more work on bandfragment
patrickmelix Jul 31, 2024
af4d761
documentation
patrickmelix Jul 31, 2024
9024089
code example
patrickmelix Aug 8, 2024
4c9f248
fix error in results, add loading of optimized sp, add loading of NOCV
patrickmelix Aug 8, 2024
e05a365
fix relative restart paths not working by using symlinks
patrickmelix Aug 14, 2024
b99ff4a
fix non-working adffragment
patrickmelix Aug 19, 2024
6091022
Update results collector of ADFFragmentResults, now get the full eda …
patrickmelix Aug 26, 2024
6f7198d
some work on NOCV
patrickmelix Aug 27, 2024
a8ce54b
fix add_to_instance import as suggested
patrickmelix Aug 27, 2024
f5893be
formatting with black
patrickmelix Aug 27, 2024
1092503
move example to file
patrickmelix Aug 27, 2024
81f2d7f
Merge branch 'master' into pEDA
patrickmelix Aug 27, 2024
e6aafb6
fix relative path of doc example
patrickmelix Aug 27, 2024
6c9af4e
add NOCVBandFragmentJob to doc
patrickmelix Aug 27, 2024
aa3e066
run black on bandfrag.py
patrickmelix Aug 27, 2024
beefc24
Revert "fix non-working adffragment"
patrickmelix Sep 12, 2024
3674eba
fix revert
patrickmelix Sep 12, 2024
dd3be2d
move optimized fragments from BAND into ADF, enable frag specific set…
patrickmelix Sep 25, 2024
3e52686
adffragment check routine that does something useful
patrickmelix Oct 22, 2024
b9db468
run black on adffragment
patrickmelix Oct 22, 2024
3886d3f
Merge branch 'master' into pEDA
patrickmelix Oct 22, 2024
f4a60d1
now with correct black options
patrickmelix Oct 22, 2024
483b792
remove unused import
patrickmelix Oct 22, 2024
cb5f32c
adffragment add eigenvalue and oi extraction
patrickmelix Nov 22, 2024
5e8947a
add check_nocv_eigenvalues
patrickmelix Dec 4, 2024
8e00e64
fix bad .full. insertion
patrickmelix Dec 4, 2024
a4a8fb1
Merge branch 'master' into pEDA
patrickmelix Dec 4, 2024
ae45260
run black
patrickmelix Dec 4, 2024
d3af820
fixing doc issues
patrickmelix Dec 4, 2024
067fe8e
fix doc relative link
patrickmelix Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@ def setup(app):
.. |VibrationsJob| replace:: :class:`~scm.plams.recipes.vibration.VibrationsJob`
.. |IRJob| replace:: :class:`~scm.plams.recipes.vibration.IRJob`
.. |VibrationsResults| replace:: :class:`~scm.plams.recipes.vibration.VibrationsResults`
.. |ADFFragmentJob| replace:: :class:`~scm.plams.recipes.adffragment.ADFFragmentJob`
.. |ADFFragmentResults| replace:: :class:`~scm.plams.recipes.adffragment.ADFFragmentResults`
.. |BANDFragmentJob| replace:: :class:`~scm.plams.recipes.bandfragment.BANDFragmentJob`
.. |BANDFragmentResults| replace:: :class:`~scm.plams.recipes.bandfragment.BANDFragmentResults`
.. |NOCVBandFragmentJob| replace:: :class:`~scm.plams.recipes.bandfragment.NOCVBandFragmentJob`

.. |RPM| replace:: :ref:`rerun-prevention`
.. |cleaning| replace:: :ref:`cleaning`
Expand Down
8 changes: 6 additions & 2 deletions doc/source/examples/adffragment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ADF fragment job
--------------------
.. currentmodule:: scm.plams.recipes.adffragment

In this module a dedicated job type for ADF fragment analysis is defined.
Such an analysis is performed on a molecular system divided into 2 fragments and consists of 3 separate ADF runs: one for each fragment and one for full system.
Expand All @@ -15,9 +16,12 @@ They are then added to the ``children`` list.
The dedicated |Results| subclass for ``ADFFragmentJob`` does not provide too much additional functionality.
It simply redirects the usual |AMSResults| methods to the results of the full system calculation.

The source code of the whole module with both abovementioned classes:

.. literalinclude:: ../../../recipes/adffragment.py
API
~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: ADFFragmentJob()
.. autoclass:: ADFFragmentResults()

An example usage: (:download:`ethene.xyz <../../../examples/ADFFrag/ethene.xyz>`,
:download:`butadiene.xyz <../../../examples/ADFFrag/butadiene.xyz>`,
Expand Down
38 changes: 38 additions & 0 deletions doc/source/examples/bandfragment.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.. _band-fragment-recipe:

BAND fragment job
--------------------

.. currentmodule:: scm.plams.recipes.bandfragment

In this module a dedicated job type for Energy Decomposition Analysis in BAND is defined.
Such an analysis is performed on a periodic system divided into 2 fragments and consists of a minimum of 3 separate BAND runs: one for each fragment and one for full system. See also |ADFFragmentJob|.

We define a new job type |BANDFragmentJob|, by subclassing |ADFFragmentJob|, which in turn is a subclass of |MultiJob|.
The constructor (``__init__``) of this new job takes 2 more arguments (``fragment1`` and ``fragment2``) and one optional argument ``full_settings`` for additional input keywords that are used **only** in the full system calculation. Furthermore, you can specify
the optimized fragment geometries using ``fragment1_opt`` and ``fragment2_opt`` for single-point calculations to also obtain the preparation energies.

In the |prerun| method two fragment jobs and the full system job are created with the proper settings and molecules.
They are then added to the ``children`` list.

The dedicated |Results| subclass for |BANDFragmentJob| does not provide too much additional functionality.
It simply redirects the usual |AMSResults| methods to the results of the full system calculation. The pEDA results can be obtained using the ``get_energy_decomposition`` method. It will return a dictionary with the available energy decomposition terms.

A derived subclass |NOCVBandFragmentJob| is also provided. It can be usefull for generating NOCV plots after the PEDA-NOCV calculation.

The source code of the whole module with both abovementioned classes:

API
~~~~~~~~~~~~~~~~~~~~~~~~~

.. autoclass:: BANDFragmentJob()
.. autoclass:: BANDFragmentResults()
.. autoclass:: NOCVBandFragmentJob()


Example
~~~~~~~~~~~~~~~~~~~~~~~~~

A basic example using `ASE to build a surface slab <https://wiki.fysik.dtu.dk/ase/ase/build/surface.html>`_ and perform a BAND fragment calculation: :download:`bandfrag_test.py <../../../examples/bandfrag.py>`

.. literalinclude:: ../../../examples/bandfrag.py
1 change: 1 addition & 0 deletions doc/source/examples/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ The source code of ``recipes`` modules is presented here to demonstrate how easy
ADFCOSMORSConformers
MDJobs
adffragment
bandfragment
ReorganizationEnergy
adfnbo
numgrad
Expand Down
56 changes: 56 additions & 0 deletions examples/bandfrag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from scm.plams import Settings
from scm.plams import fromASE
from scm.plams.recipes.bandfragment import BANDFragmentJob

# build the surface
from ase.build import fcc111, add_adsorbate

mol = fcc111("Au", size=(2, 2, 3))
add_adsorbate(mol, "H", 1.5, "ontop")
mol.center(vacuum=10.0, axis=2)

# separate the fragments
surface = mol.copy()
symbols = surface.get_chemical_symbols()
del surface[[i for i in range(len(symbols)) if symbols[i] != "Au"]]
adsorbate = mol.copy()
del adsorbate[[i for i in range(len(symbols)) if symbols[i] == "Au"]]

# optional: load the optimized molecules
from ase import io

surface_opt = io.read("surface_opt.xyz")
adsorbate_opt = io.read("adsorbate_opt.xyz")
assert len(surface_opt) == len(surface)
assert len(adsorbate_opt) == len(adsorbate)

# settings for job
base_settings = Settings()
base_settings.input.ams.task = "SinglePoint"
base_settings.input.band.basis.type = "TZP"
base_settings.input.band.basis.core = "Medium"
base_settings.input.band.dos.calcdos = "No"
base_settings.input.band.kspace.regular.numberofpoints = "5 5 1"
base_settings.input.band.beckegrid.quality = "Good"
base_settings.input.band.zlmfit.quality = "Good"
base_settings.input.band.usesymmetry = False
base_settings.input.band.xc.gga = "PBE"
base_settings.input.band.xc.dispersion = "Grimme4"

eda_settings = Settings()
eda_settings.input.band.peda = ""

eda_job = BANDFragmentJob(
fragment1=fromASE(surface),
fragment2=fromASE(adsorbate),
settings=base_settings,
full_settings=eda_settings,
fragment1_opt=fromASE(surface_opt),
fragment2_opt=fromASE(adsorbate_opt),
)

results = eda_job.run()
eda_res = eda_job.results.get_energy_decomposition()
print("{:<20} {:>10}".format("Term", "Energy [kJ/mol]"))
for key, value in eda_res.items():
print("{:<20} {:>10.4f}".format(key, value))
Loading
Loading