Acellera / htmd

HTMD: Programming Environment for Molecular Discovery
https://software.acellera.com/docs/latest/htmd/index.html
Other
261 stars 59 forks source link

Get water box size #991

Closed phisanti closed 3 years ago

phisanti commented 3 years ago

I have built a water box following the example. When I plot the image, I see all the molecules, so it seems to work fine. However, I would like to print the output of the full solvated box, but the output I got is an array [0, 0, 0]. Therefore, I was wondering how to properly calculate the box size containing the system. Here is a snippet of my code:

# ... load molecule and stuff....

# Generate water box:
coo = mol.get('coords','noh and (lipids or protein)')
m = np.min(coo, axis=0) + [0, 0, -10]
M = np.max(coo, axis=0) + [0, 0, 10]
smol = solvate(peri_ph, minmax=np.vstack((m,M)))
box_size = "box dimensions, x: {x}, y: {y}, z: {z}".format(x = str(smol.box[0][0]),y= str(smol.box[1][0]),z = str(smol.box[2][0]))

Output: box dimensions, x: 0.0, y: 0.0, z: 0.0

stefdoerr commented 3 years ago

Hi, the box size is only read from xtc or dcd files, meaning from simulations. Solvating does not set the box size. What would you like to do with it?

stefdoerr commented 3 years ago

Ah sorry, to calculate the box size you could just do: mol.coords.max(axis=0) - mol.coords.min(axis=0) that should give you the total size of the box

phisanti commented 3 years ago

That was what I need. Thanks!