コード例 #1
0
ファイル: engine.py プロジェクト: song-chenchen/geomeTRIC
 def calc_new(self, coords, dirname):
     try:
         from forcebalance.gmxio import GMX
     except ImportError:
         raise ImportError(
             "ForceBalance is needed to compute energies and gradients using Gromacs."
         )
     if not os.path.exists(dirname): os.makedirs(dirname)
     try:
         Gro = Molecule("conf.gro")
         Gro.xyzs[0] = coords.reshape(-1, 3) * bohr2ang
         cwd = os.getcwd()
         shutil.copy2("topol.top", dirname)
         shutil.copy2("shot.mdp", dirname)
         os.chdir(dirname)
         Gro.write("coords.gro")
         G = GMX(coords="coords.gro",
                 gmx_top="topol.top",
                 gmx_mdp="shot.mdp")
         EF = G.energy_force()
         Energy = EF[0, 0] / eqcgmx
         Gradient = EF[0, 1:] / fqcgmx
         os.chdir(cwd)
     except (OSError, IOError, RuntimeError, subprocess.CalledProcessError):
         raise GromacsEngineError
     return {'energy': Energy, 'gradient': Gradient}
コード例 #2
0
 def calc_new(self, coords, dirname):
     if not os.path.exists(dirname): os.makedirs(dirname)
     Gro = Molecule("conf.gro")
     Gro.xyzs[0] = coords.reshape(-1, 3) * 0.529
     cwd = os.getcwd()
     shutil.copy2("topol.top", dirname)
     shutil.copy2("shot.mdp", dirname)
     os.chdir(dirname)
     Gro.write("coords.gro")
     G = GMX(coords="coords.gro", gmx_top="topol.top", gmx_mdp="shot.mdp")
     EF = G.energy_force()
     Energy = EF[0, 0] / eqcgmx
     Gradient = EF[0, 1:] / fqcgmx
     os.chdir(cwd)
     return Energy, Gradient
コード例 #3
0
ファイル: engine.py プロジェクト: leeping/geomeTRIC
 def calc_new(self, coords, dirname):
     try:
         from forcebalance.gmxio import GMX
     except ImportError:
         raise ImportError("ForceBalance is needed to compute energies and gradients using Gromacs.")
     if not os.path.exists(dirname): os.makedirs(dirname)
     try:
         Gro = Molecule("conf.gro")
         Gro.xyzs[0] = coords.reshape(-1,3) * bohr2ang
         cwd = os.getcwd()
         shutil.copy2("topol.top", dirname)
         shutil.copy2("shot.mdp", dirname)
         os.chdir(dirname)
         Gro.write("coords.gro")
         G = GMX(coords="coords.gro", gmx_top="topol.top", gmx_mdp="shot.mdp")
         EF = G.energy_force()
         Energy = EF[0, 0] / eqcgmx
         Gradient = EF[0, 1:] / fqcgmx
         os.chdir(cwd)
     except (OSError, IOError, RuntimeError, subprocess.CalledProcessError):
         raise GromacsEngineError
     return {'energy':Energy, 'gradient':Gradient}