leeping / geomeTRIC

Geometry optimization code that includes the TRIC coordinate system
https://geometric.readthedocs.io/
Other
147 stars 65 forks source link

Virtual site #115

Closed Anthoni-Alcaraz closed 10 months ago

Anthoni-Alcaraz commented 4 years ago

Hi,

I'm new with geomeTric. I'm trying to use geometric with a system that contains virtual site in OpenMM, but I get this error: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1878, in main run_optimizer(**vars(args)) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1808, in run_optimizer progress = Optimize(coords, M, IC, engine, dirname, params) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1330, in Optimize optimizer = Optimizer(coords, molecule, IC, engine, dirname, params) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 908, in __init__ self.H0 = self.IC.guess_hessian(self.coords) File "/usr/local/lib/python3.7/site-packages/geometric/internal.py", line 3244, in guess_hessian Hprim = self.Prims.guess_hessian(coords) File "/usr/local/lib/python3.7/site-packages/geometric/internal.py", line 2521, in guess_hessian elem1 = min(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b])) ValueError: 'M' is not in list Traceback (most recent call last): File "/usr/local/bin/geometric-optimize", line 10, in <module> sys.exit(main()) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1878, in main run_optimizer(**vars(args)) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1808, in run_optimizer progress = Optimize(coords, M, IC, engine, dirname, params) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 1330, in Optimize optimizer = Optimizer(coords, molecule, IC, engine, dirname, params) File "/usr/local/lib/python3.7/site-packages/geometric/optimize.py", line 908, in __init__ self.H0 = self.IC.guess_hessian(self.coords) File "/usr/local/lib/python3.7/site-packages/geometric/internal.py", line 3244, in guess_hessian Hprim = self.Prims.guess_hessian(coords) File "/usr/local/lib/python3.7/site-packages/geometric/internal.py", line 2521, in guess_hessian elem1 = min(Elements.index(self.elem[ic.a]), Elements.index(self.elem[ic.b])) ValueError: 'M' is not in list.

I save the system like this from openmm: with open('system.xml', 'w') as outfile: outfile.write(XmlSerializer.serialize(system)) and I use the same pdb file. Also I add a constraints file, because my molecules are rigid.

Do you have any advice?

Thank you in advance

Anthoni

leeping commented 4 years ago

Hello Anthoni,

I think the issue is that you have a particle with an atomic symbol M that is not in the periodic table. Can you look into why this is part of your PDB file?

Anthoni-Alcaraz commented 4 years ago

Thank you for answering so fast. I have a virtual site (M) in my molecules, because I need it for energy calculation. Is there any way to handle it?

Anthoni

leeping commented 4 years ago

Hello Anthoni,

I haven't implemented support for virtual sites yet, but even if there were support for virtual sites, I don't think it should be in the PDB file. I believe virtual sites should be added by Modeller.addExtraParticles().

Thanks,

Anthoni-Alcaraz commented 4 years ago

Hi,

I have virtual sites in my PDB file, because I get a frame from a trajectory computed by OpenMM. I agree with Modeller.addExtraParticles() is the way to add a virtual site in OpenMM. As I mentioned I'm new with geometric and I tested some examples. However, my system didn't work. I have my XML file for OpenMM and I didn't find a way to pass my force field to geometric. Also I didn't find in geometric (OpenMM examples) if there is a way to modify the recipe for OpenMM.

Thank you,

Anthoni

leeping commented 4 years ago

Hello Anthoni,

To run an optimization with OpenMM, you need to pass a PDB file using --pdb and either a system XML or force field XML file as the input file (it autodetects which one). I currently haven't implemented virtual sites as it would involve a call to Modeller to add extra particles and keeping only the forces on the "real" atoms. The virtual site positions should not be optimized as they are functions of the "real" atom positions.

I recommend that you try a system without virtual sites first. I may be able to try adding virtual sites but can't guarantee I could do it in the short term. You could try modifying the OpenMM class in engine.py to do it yourself, and I would welcome your contribution to the codebase (if you do this, please add an example).

Thanks,

Anthoni-Alcaraz commented 4 years ago

Hi,

Thank you for that suggestions. I'll try it and I'll see If I could modify to contribute. :)

Best,

Anthoni

leeping commented 10 months ago

Closing this issue due to age.