## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
ramanishsingh
@ramanishsingh
I am trying to generate an initial configuration (.xyz) file for cp2k using mbuild.
Is there a way to minimize the energy of the whole box of atoms?

import mbuild as mb
class I2(mb.Compound):
def init(self):
super(I2, self).init()

    iodine1= mb.Particle(pos=[0.0, 0.0, 0.0], name='I')
iodine2= mb.Particle(pos=[0.8, 0.0, 0.0], name='I')
self.add_bond((iodine2,iodine1))

i2 = I2()
i2.energy_minimize(steps=100, algorithm='steep', forcefield='GAFF')
i2.visualize()
box = mb.Box(lengths=[1.4184, 1.4184, 1.4184])

box_of_i2= mb.fill_box(compound=i2, n_compounds=24, box=box)
box_of_i2.energy_minimize(steps=100000, algorithm='steep', forcefield='GAFF')
box_of_i2.visualize()

Mike Henry
@mikemhenry
box_of_i2.energy_minimize(steps=100000, algorithm='steep', forcefield='GAFF') should do it
do you get an error?
ramanishsingh
@ramanishsingh
%%%%%%%%%
I am trying this but it gives me an initial config that has very high energy
Mike Henry
@mikemhenry
If you double the steps is the energy lower?
ramanishsingh
@ramanishsingh
I did not check the dependence of energy on the no. steps. Just gave randomly a high number of steps. Will check and post here
Mike Henry
@mikemhenry
It might just take longer to relax, Is this just a box of I2? So like 48 atoms in total? Also cg I think is better at not getting stuck in a local minima than steep
This might be too big of a hammer, but you could run md using hoomd or something if you want really get things relaxed, If you just have I2 then you only need to look up the LJ term and the bond term
ramanishsingh
@ramanishsingh
Yes, 48 atoms ( cp2k calculations are expensive ) :)
Mike Henry
@mikemhenry
so it shound't be to bad if you need something lower energy for cp2k
ramanishsingh
@ramanishsingh
Currently I am generating input structure using MCCCS-MN, but thought it would be cool if could directly be done in mbuild
I will try cg
Mike Henry
@mikemhenry
More steps should give you a better result, I've found md to be pretty slow, but 48 isn't to bad, you can try md as well and see how that goes
ramanishsingh
@ramanishsingh
Thanks @mikemhenry . md works much better. The initial structure has much lower ene
*energy as compared to steep and cg
Mike Henry
@mikemhenry
Glad that worked for you @ramanishsingh
ramanishsingh
@ramanishsingh

How to install mbuild on cluster?
I tried : python -m pip install --user mbuild
but when I import mbuild it gives me an error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/panfs/roc/groups/12/siepmann/singh891/projects/signac/mnd/mbuild/mbuild/init.py", line 2, in <module>
from mbuild.coarse_graining import coarse_grain
File "/panfs/roc/groups/12/siepmann/singh891/projects/signac/mnd/mbuild/mbuild/coarse_graining.py", line 3, in <module>
from mbuild.compound import Compound
File "/panfs/roc/groups/12/siepmann/singh891/projects/signac/mnd/mbuild/mbuild/compound.py", line 14, in <module>
import mdtraj as md
File "/home/siepmann/singh891/.local/lib/python3.7/site-packages/mdtraj/init.py", line 30, in <module>
from .formats.registry import FormatRegistry
File "/home/siepmann/singh891/.local/lib/python3.7/site-packages/mdtraj/formats/init.py", line 4, in <module>
from .dcd import DCDTrajectoryFile
File "init.pxd", line 918, in init mdtraj.formats.dcd
ValueError: numpy.ufunc size changed, may indicate binary incompatibility. Expected 216 from C header, got 192 from PyObject

Alex Yang
@ahy3nz
It looks like the issue is with the mdtraj library. How did you install mdtraj?
ramanishsingh
@ramanishsingh
python -m pip install --user mdtraj
Justin Gilmer
@justinGilmer

Sorry just getting to this @ramanishsingh . To install mbuild on a cluster, we recommend using Anaconda to install and create an environment. We host mBuild and Foyer to be pip installable, however, some of our dependencies like mdtraj do not list all of their dependencies like numpy with their pip recipe.

It is usually a much easier process to install through anaconda.

conda create -n mosdef36 python=3.6
conda activate mosdef36
conda install -c mosdef -c conda-forge -c omnia mbuild foyer

If you do not have anaconda on the cluster, you can download a minimial conda install called miniconda

https://docs.conda.io/en/latest/miniconda.html

ramanishsingh
@ramanishsingh
Do I need to install open babel separately?
I tried installing it from pip and source but couldn't get it installed.
Justin Gilmer
@justinGilmer

that can also be installed using conda

conda install -c openbabel openbabel

ramanishsingh
@ramanishsingh
The conda install is also not working,
"'An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda."
Justin Gilmer
@justinGilmer
when trying to install conda? or when trying to install mbuild
ramanishsingh
@ramanishsingh
Sorry for the vague message.
Conda is already installed on the cluster, and I successfully installed mbuild using the commands you posted.
But open babel installation is not working, with : conda install -c openbabel openbabel
or pip install
Justin Gilmer
@justinGilmer

Hmm,

There are a few other channels you can try to install it from:
conda install -c bioconda openbabel
conda install -c conda-forge openbabel

if those do not work, you might need to contact the IT department of the cluster and see if they can help.

Alyssa Travitz
@atravitz
hi all, i'm trying out mbuild today and wanted to know if there's a way to add constraints to packing. I typically use the select atom function in packmol, and don't see an analogous method in mbuild. I want to essentially have a layer of molecules with their 'ports' all arranged on an invisible surface. i know that monolayer exists, but it looks like i'd need to explicitly define a lattice layer for a surface?
Matt Thompson
@mattwthompson
Hi Alyssa, there are probably a few different ways of handling this, not sure which is best. One that comes to mind is initializing a 2-D lattice and populating compounds out in those two dimensions. This would produce an ordered structure (I don't know if that's good or bad for your use case) but it would assure that the ports are pointing in the same way.
If you wanted to go with a packing approach to get a less-ordered initial structure, we don't have the atom selection syntax built in at the moment but I think @mikemhenry has accomplished similar things by using the fix_orientation flag that prohibits rotation while packing
Alyssa Travitz
@atravitz
i'm avoiding an ordered structure if possible, @mikemhenry 's solution sounds like it would work. my ideal case would be putting bounds on the 'ports', similar to atom selection, but I'll try fix_orientation and let you know how it goes :)
Mike Henry
@mikemhenry
Good luck @atravitz maybe it would work if you do the rotations to get things aligned the way you want them to, then to use fix_orientation also if there is some functionality you want extend to mbuild's packmol wrapper, let me know!
Alyssa Travitz
@atravitz
thanks @mikemhenry. I'd like to extend mbuild's packmol wrapper. who would be the right person to talk to about the "right" way to go about it? I have a few ideas of how to implement it, but I want it to be as friendly/similar to your api as possible
Justin Gilmer
@justinGilmer

@atravitz our resident expert is @mattwthompson but myself and a few others have played around with its api as well.

So if you want to start a discussion on GitHub, that would probably get a lot of good input!

ramanishsingh
@ramanishsingh
Hi, this may be a very stupid question, but is there a simple way to do a very basic MD simulation (maybe using GAFF) after generating the input structure using mbuild?
ramanishsingh
@ramanishsingh
I mean what would be the easiest and fastest option.
I will be using the structure generated by mbuild for CP2K MD, so want to run a few MD steps using a FF before I throw that structure in CP2K.
Matt Thompson
@mattwthompson
The general strategy would be to write it out to an MD engine and use update_coordinates against the output file
you could run something in LAMMPS or GROMACS with a simple input script
ramanishsingh
@ramanishsingh
Thanks Matt.
I have more questions.
currently I am generating the .top file using self written xml file.
Is there any way I can generate the .top file using 'GAFF' or 'oplsaa' without having to write the xml file? ( I am also doing the energy minimization using GAFF and I think that uses Openbabel)
forcefield_name='oplsaa' is giving me this error:
AttributeError: 'Atom' object has no attribute 'whitelist'
Matt Thompson
@mattwthompson
That error usually means the force field object is empty
try Forcefield(name='oplsaa')
ramanishsingh
@ramanishsingh
That works!! thanks
@bdice
Hi all, does MoSDeF have a logo? I didn't see anything besides plain text "MoSDeF" on the website, and just wanted to be sure I wasn't missing anything when I give MoSDeF credit.
Matt Thompson
@mattwthompson
One is in the works, hopefully won't be long now