.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "howtos_generated/howto_io/howto_opls.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_howtos_generated_howto_io_howto_opls.py: .. _howto_opls_setup: Setting up an OPLS force field calculation ========================================== Suppose, we define the ethanal molecule as extended xyz file (``172_ext.xyz``): .. GENERATED FROM PYTHON SOURCE LINES 12-15 .. literalinclude:: ../../../examples/howtos/howto_io/172_ext.xyz Then we can read and view the structure using: .. GENERATED FROM PYTHON SOURCE LINES 15-25 .. code-block:: Python from ase.io.opls import OPLSStructure from ase.visualize import view s = OPLSStructure('172_ext.xyz') view(s) # view with real elements elements = {'CT': 'Si', 'HC': 'H', 'H1': 'He'} view(s.colored(elements)) # view with fake elements .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 26-35 Defining the force field ------------------------ The definitions of the force field can be stored in an Amber like style (``172_defs.par``): .. literalinclude:: ../../../examples/howtos/howto_io/172_defs.par We can write LAMMPS input using the information above: .. GENERATED FROM PYTHON SOURCE LINES 35-43 .. code-block:: Python from ase.io.opls import OPLSff, OPLSStructure s = OPLSStructure('172_ext.xyz') with open('172_defs.par') as fd: opls = OPLSff(fd) opls.write_lammps(s, prefix='lmp') .. GENERATED FROM PYTHON SOURCE LINES 44-47 which writes the LAMMPS input files ``lmp_atoms`` defining atoms, bonds, etc., and ``lmp_opls`` defining the corresponding OPLS force field. A rudimentary ``lmp_in`` is also written. .. _sphx_glr_download_howtos_generated_howto_io_howto_opls.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: howto_opls.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: howto_opls.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: howto_opls.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_