Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
105 changes: 60 additions & 45 deletions doc/source/examples/COSMORSCompound/cosmors_compound.ipynb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,31 @@ Enable the parallel calculation through ``JobRunner``. Here, we’ll assign one
config.job.runscript.nproc = 1 # Number of cores for each job
config.log.stdout = 1 # Suppress plams output

Optional compound metadata keyed by molecule name. This metadata is passed to ADFCOSMORSCompoundJob via ``mol_info``, written to the “Compound Data” section of the generated COSKF file, and used by AMSCrs GUI and ``pyCRS.Database`` to search compounds.

.. code:: ipython3

mol_info_by_name = {
"CO": {"CAS": "630-08-0", "IUPAC": "Carbon monoxide", "Other Name": ""},
"H2O": {"CAS": "7732-18-5", "IUPAC": "Water", "Other Name": ""},
}

.. code:: ipython3

molecules = read_molecules("./compounds_xyz")

results = []
for name, mol in molecules.items():
job = ADFCOSMORSCompoundJob(molecule=mol, coskf_name=name, coskf_dir="test_coskfs_xyz")
mol_info = mol_info_by_name.get(name)
job = ADFCOSMORSCompoundJob(molecule=mol, coskf_name=name, coskf_dir="test_coskfs_xyz", mol_info=mol_info)
results.append(job.run())

::

[19.03|15:14:40] JOB plamsjob STARTED
[19.03|15:14:40] JOB plamsjob STARTED
[19.03|15:14:40] JOB plamsjob/gas STARTED
[19.03|15:14:40] JOB plamsjob/solv STARTED
[19.03|15:14:40] JOB plamsjob/sigma STARTED
[13.03|09:03:55] JOB plamsjob STARTED
[13.03|09:03:55] JOB plamsjob STARTED
[13.03|09:03:55] JOB plamsjob/gas STARTED
[13.03|09:03:55] JOB plamsjob/solv STARTED

.. code:: ipython3

Expand All @@ -52,21 +61,23 @@ Enable the parallel calculation through ``JobRunner``. Here, we’ll assign one

::

[19.03|15:14:40] Waiting for job plamsjob to finish
[19.03|15:14:40] JOB plamsjob.002/gas STARTED
[19.03|15:14:40] JOB plamsjob.002/solv STARTED
[19.03|15:14:40] Waiting for job gas to finish
[19.03|15:14:40] JOB plamsjob.002/sigma STARTED
[19.03|15:14:40] Waiting for job solv to finish
[19.03|15:14:40] Waiting for job gas to finish
[19.03|15:14:40] Waiting for job solv to finish
[19.03|15:14:45] JOB plamsjob.002/gas SUCCESSFUL
[19.03|15:14:49] JOB plamsjob.002/solv SUCCESSFUL
[19.03|15:14:49] JOB plamsjob.002/sigma SUCCESSFUL
[19.03|15:14:50] JOB plamsjob.002 SUCCESSFUL
[19.03|15:14:57] JOB plamsjob/gas SUCCESSFUL
[19.03|15:15:10] JOB plamsjob/solv SUCCESSFUL
[19.03|15:15:10] JOB plamsjob/sigma SUCCESSFUL
[13.03|09:03:55] JOB plamsjob/sigma STARTED
[13.03|09:03:55] JOB plamsjob.002/gas STARTED
[13.03|09:03:55] Waiting for job plamsjob to finish
[13.03|09:03:55] JOB plamsjob.002/solv STARTED
[13.03|09:03:55] JOB plamsjob.002/sigma STARTED
[13.03|09:03:55] Waiting for job gas to finish
[13.03|09:03:55] Waiting for job solv to finish
[13.03|09:03:55] Waiting for job solv to finish
[13.03|09:03:55] Waiting for job gas to finish
[13.03|09:03:59] JOB plamsjob.002/gas SUCCESSFUL
[13.03|09:04:03] JOB plamsjob.002/solv SUCCESSFUL
[13.03|09:04:03] WARNING: Main KF file sigma.crskf not present in /path/plams/examples/COSMORSCompound/plams_workdir/plamsjob.002/sigma
[13.03|09:04:03] JOB plamsjob.002/sigma CRASHED
[13.03|09:04:05] JOB plamsjob.002 FAILED
[13.03|09:04:10] JOB plamsjob/gas SUCCESSFUL
[13.03|09:04:22] JOB plamsjob/solv SUCCESSFUL
[13.03|09:04:22] WARNING: Main KF file sigma.crskf not present in /path/plams/examples/COSMORSCompound/plams_workdir/plamsjob/sigma
... (PLAMS log lines truncated) ...

.. code:: ipython3
Expand Down Expand Up @@ -96,22 +107,24 @@ Lastly, we give this information to the ``ADFCOSMORSCompoundJob`` class, includi

results = []
for name, mol in molecules.items():
mol_info = mol_info_by_name.get(name)
job = ADFCOSMORSCompoundJob(
molecule=mol, # The initial structure
coskf_name=name, # a name to be used for coskf file
coskf_dir="test_coskfs_smiles", # a directory to put the .coskf files generated
preoptimization="GFN1-xTB", # perform preoptimize or not
singlepoint=False, # run a singlepoint in gasphase and solvation calculation without geometry optimization. Cannot be combined with `preoptimization`
name=name,
) # an optional name for the calculation directory
name=name, # an optional name for the calculation directory
mol_info=mol_info, # compound information to be stored in the Compound Data section of the COSKF file
)
results.append(job.run())

::

[19.03|15:15:16] JOB H2O STARTED
[19.03|15:15:16] JOB CO STARTED
[19.03|15:15:16] JOB H2O/preoptimization STARTED
[19.03|15:15:16] JOB CO/preoptimization STARTED
[13.03|09:04:25] JOB H2O STARTED
[13.03|09:04:25] JOB CO STARTED
[13.03|09:04:25] JOB H2O/preoptimization STARTED
[13.03|09:04:25] JOB H2O/gas STARTED

.. code:: ipython3

Expand All @@ -120,25 +133,27 @@ Lastly, we give this information to the ``ADFCOSMORSCompoundJob`` class, includi

::

[19.03|15:15:16] Waiting for job H2O to finish
[19.03|15:15:16] JOB CO/gas STARTED
[19.03|15:15:16] JOB H2O/gas STARTED
[19.03|15:15:16] JOB H2O/solv STARTED
[19.03|15:15:16] JOB CO/solv STARTED
[19.03|15:15:16] JOB H2O/sigma STARTED
[19.03|15:15:16] JOB CO/sigma STARTED
[19.03|15:15:16] Waiting for job gas to finish
[19.03|15:15:16] Waiting for job preoptimization to finish
[19.03|15:15:16] Waiting for job preoptimization to finish
[19.03|15:15:16] Waiting for job gas to finish
[19.03|15:15:16] Waiting for job solv to finish
[19.03|15:15:16] Waiting for job solv to finish
[19.03|15:15:16] JOB H2O/preoptimization SUCCESSFUL
[19.03|15:15:16] JOB CO/preoptimization SUCCESSFUL
[19.03|15:15:23] JOB H2O/gas SUCCESSFUL
[19.03|15:15:27] JOB H2O/solv SUCCESSFUL
[13.03|09:04:25] JOB H2O/solv STARTED
[13.03|09:04:25] Waiting for job H2O to finish
[13.03|09:04:25] JOB H2O/sigma STARTED
[13.03|09:04:25] JOB CO/preoptimization STARTED
[13.03|09:04:25] JOB CO/gas STARTED
[13.03|09:04:25] JOB CO/solv STARTED
[13.03|09:04:25] JOB CO/sigma STARTED
[13.03|09:04:25] Waiting for job gas to finish
[13.03|09:04:25] Waiting for job preoptimization to finish
[13.03|09:04:25] Waiting for job solv to finish
[13.03|09:04:25] Waiting for job preoptimization to finish
[13.03|09:04:25] Waiting for job gas to finish
[13.03|09:04:25] Waiting for job solv to finish
[13.03|09:04:26] JOB H2O/preoptimization SUCCESSFUL
[13.03|09:04:26] JOB CO/preoptimization SUCCESSFUL
[13.03|09:04:32] JOB H2O/gas SUCCESSFUL
[13.03|09:04:37] JOB H2O/solv SUCCESSFUL
[13.03|09:04:37] WARNING: Main KF file sigma.crskf not present in /path/plams/examples/COSMORSCompound/plams_workdir/H2O/sigma
... (PLAMS log lines truncated) ...
[19.03|15:15:31] Waiting for job CO to finish
[13.03|09:04:40] Waiting for job CO to finish
[13.03|09:05:06] WARNING: Main KF file sigma.crskf not present in /path/plams/examples/COSMORSCompound/plams_workdir/CO/sigma

.. code:: ipython3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,12 @@ Here we plot the three lowest-energy conformers.

.. figure:: conformers_files/conformers_23_0.png

You can also open the conformers in AMSmovie to browse all conformers 1000+ conformers:
You can also open the conformers in AMSmovie to browse all 1000+ conformers:

.. code:: ipython3

# Open AMSmovie in a Jupyter Notebook, equivalent to the shell command:
# amsmovie /path/plams/examples/ConformersMultipleMolecules/plams_workdir/conformers/conformers.rkf
!amsmovie {rkf}

Finally in AMS2025+, you can also inspect the conformer data using the JobAnalysis tool.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,30 @@ Initial imports

import pyCRS
import matplotlib.pyplot as plt
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
import math

IPythonConsole.ipython_useSVG = True
IPythonConsole.molSize = 150, 150
import scm.plams as plams

try:
from scm.plams import view # view molecule using AMSview in a Jupyter Notebook in AMS2026+
except ImportError:
from scm.plams import plot_molecule # plot molecule in a Jupyter Notebook in AMS2023+

def view(molecule, **kwargs):
plot_molecule(molecule)

Property prediction from SMILES (ethyl acetate)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code:: ipython3

from scm.plams import from_smiles

# smiles = 'CCO' # ethanol
smiles = "O=C(OCC)C" # ethyl acetate
rdkit_mol = Chem.MolFromSmiles(smiles)
rdkit_mol # show the molecule in a Jupyter notebook
view(plams.from_smiles(smiles), width=300, height=300)

.. figure:: property_prediction_files/property_prediction_3_0.svg
.. figure:: property_prediction_files/property_prediction_3_0.png

Temperature-independent properties
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -49,7 +56,7 @@ Temperature-independent properties
criticalpressure : 38.243 bar
criticaltemp : 544.189 K
criticalvol : 0.271 L/mol
density : 0.894 kg/L (298.15 K)
density : 0.894 kg/L
dielectricconstant : 6.834
entropygas : 382.780 J/(mol K)
flashpoint : 265.005 K
Expand Down Expand Up @@ -165,7 +172,10 @@ Continuing from the previous example, you can also create e.g. a bar chart with

prop = "boilingpoint"
values = [mol.properties.get(prop, None) for mol in mols]
plt.barh(smiles_list, values)
filtered = [(s, v) for s, v in zip(smiles_list, values) if not math.isnan(v)]
smiles_plot, values_plot = zip(*filtered)

plt.barh(smiles_plot, values_plot)
plt.title("Boiling point [K]");

.. figure:: property_prediction_files/property_prediction_13_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading