Usage#

The simulation inputs that the wrapper needs to be provided with are the molecular structure, solvent, temperature and pressure. Such simulation inputs must be instantiated as CUDS objects in the wrapper session using the namespace from the wrapper ontology. The cobramm namespace and the wrapper session can be imported as follows:

from osp.core.namespaces import cobramm
from osp.wrappers.cobrammwrapper import CobrammSession

The pattern of CUDS objects that the COBRAMM wrapper expects as input is depicted in the figure at the end of this section.

The input information is employed to run the following workflow:

  1. Solvent-solute MM optimization, thermalization and equilibration dynamics (Amber force field for the solvent and GAFF for the solute) with the charges estimated by the AM1-BCC method from antechamber.

  2. Set-up of the high-medium-low layers for QM/MM COBRAMM driven computations from the last MD snapshot produced in 1) (which is supposed to return the better solvent organization): the solvent MM shell is selected as a spherical droplet around the chromophore,

  3. QM(DFT: b3lyp, STO-3G)/MM optimization for locating the representative ground state equilibrium structure of the solvated chromophore,

  4. QM(DFT: b3lyp, STO-3G)/MM frequency calculation on the QM/MM minimum optimized in 3),

  5. Wigner ensemble generation,

  6. Single point QM(TDDFT: cam-b3lyp, STO-3G, nroot=5)/MM calculations on top of each equilibrated Wigner snapshots found in 7),

  7. Sum over gaussian-functions centered at the excitation energy values found in 6) (with the gaussian maximum set at the oscillator strength value and a fixed 0.2 ev standard deviation) divided by the number of Wigner samples.

The Low/Medium/High accuracy level do set parameters for MD simulations (boxsize, cutoff, initial optimization steps, time step of the MD run, heating time, time of the final equilibration steps) and QM/MM simulations (solvent droplet radius, mobile layer radius, number of samples produced in the Wigner sampling) of increasing complexity, accuracy and computational cost.

After the simulation is run, the simulated spectrum is available as a collection CUDS objects attached to the SYSTEM object. Their structure is depicted in the figure below.

COBRAMM Wrapper input

Diagram showing the pattern of input CUDS objects that the COBRAMM wrapper expects to find in the session’s knowledge graph and the CUDS objects that are produced as simulation outputs.

Example#

An example of how to use the wrapper is available in examples/simulation_example.py. In the example, the COBRAMM wrapper is used to compute the linear absorption spectrum of Formaldehyde in water at 1 atm and 300 K.

 1 from osp.core import cobramm
 2 from osp.wrappers.cobrammwrapper import CobrammSession
 3 from osp.core.utils import pretty_print
 4 
 5 
 6 # the following is the geometry of a formaldehyde molecule
 7 atoms_to_add = [["C", [0.60720,  0.00000, -0.00040]],
 8                 ["O", [-0.60040, 0.00000,  0.00010]],
 9                 ["H", [1.14720,  0.93530,  0.00160]],
10                 ["H", [1.14720, -0.93530,  0.00160]]]
11 
12 
13 # now open a new CobrammSession to execute the simulation
14 with CobrammSession() as session:
15     wrapper = cobramm.wrapper(session=session)
16 
17     # Create input ontological object
18     system = cobramm.system()
19     material = cobramm.material()
20 
21     # define the material by specifying atom symbols and cartesian coordinates, atom-by-atom
22     for atom_symbol, atom_coords in atoms_to_add:
23         atom = material.add(cobramm.atom())
24         atom.add(cobramm.position(vector_value=atom_coords, unit="Ang"))
25         atom.add(cobramm.element_id(atom_symbol=atom_symbol))
26 
27     material.add(cobramm.charge(integer_value=0))
28     system.add(material)
29 
30     molecule = cobramm.molecule(commercial_name="water")
31     solvent = cobramm.solvent()
32     solvent.add(molecule)
33     system.add(solvent)
34 
35     temperature = cobramm.temperature(scalar_value=300, unit="K")
36     system.add(temperature)
37 
38     pressure = cobramm.pressure(scalar_value=1, unit="bar")
39     system.add(pressure)
40 
41     # Set accuracy
42     accuracy = cobramm.accuracy(accuracy_value=1)
43 
44     # Set case
45     case = cobramm.case(case_name="absorption")
46 
47     system_wrapper = wrapper.add(system, rel=cobramm.has_part)
48     accuracy_wrapper = wrapper.add(accuracy, rel=cobramm.has_part)
49     case_wrapper = wrapper.add(case, rel=cobramm.has_part)
50 
51     # pretty-print the material so far
52     print("\n")
53     pretty_print(system)
54     print("\n")
55 
56     # run the simulation
57     wrapper.session.run()
58 
59     # extract the spectrum
60     spectrum = (wrapper.get(oclass=cobramm.system)[0]).get(oclass=cobramm.spectrum)[0]
61 
62     # pretty-print the final spectrum
63     print("\n")
64     pretty_print(spectrum)
65     print("\n")

Lines 22-25: we include in the material the four atoms of the formaldehyde specifying their cartesian coordinates in Angstroms.

Lines 30-39: we specify the physical conditions, i.e., temperature, pressure, and solvent.

Lines 47-49: we add the material specified above to the COBRAMM wrapper.

Line 57: we run the simulation.

Line 60: we extract the simulated spectrum.