def cleanup_amber(self): if self.sander and self.amber_structs: if self.amber_structs.is_LES: import sanderles sanderles.cleanup() else: import sander sander.cleanup()
def cleanup(self): make_header('Cleaning up - Amber') if self.sander and self.amber_structs: if self.amber_structs.is_LES: import sanderles sanderles.cleanup() else: import sander sander.cleanup()
def get_total_energy(agls): # get the coor from pyrosetta inp_coor=generate_coord(agls) # initialize the object topology with coordinates parm=AmberParm("tpp-1.prmtop",inp_coor) # set up the input options inp=sander.gas_input() sander.setup (parm, parm.coordinates, None, inp) # compute the energy and force eney, frc=sander.energy_forces() # print('sander',eney.tot,eney.gb,eney.vdw, eney.elec, eney.dihedral,eney.angle, eney.bond) # clean and finish sander.cleanup() return eney.tot
#! /usr/bin/env python import sander from chemistry.amber.readparm import AmberParm, Rst7 import numpy as np pdb = '3stl' parm = AmberParm('4amber_%s.prmtop' % pdb) #topo rst = Rst7.open('4amber_%s.rst7' % pdb) #box sander.setup(parm, rst.coordinates, rst.box, sander.pme_input()) ene, frc = sander.energy_forces() print ene.tot print max(frc) import code code.interact(local=dict(globals(), **locals())) sander.cleanup()
ene, frc = sander.energy_forces() print frc[0] sander.set_positions(coords1) ene, frc = sander.energy_forces() print frc[0] sander.set_positions(coords2) ene, frc = sander.energy_forces() print frc[0] print max(frc) print ene.tot, ene.elec, ene.vdw # import code; code.interact(local=dict(globals(), **locals())) import boost.python sander.set_positions(rst.coordinates) ene, frc = sander.energy_forces() print frc[0] sander.set_positions(coords1) ene, frc = sander.energy_forces() print frc[0] sander.set_positions(coords2) ene, frc = sander.energy_forces() print frc[0] print max(frc) print ene.tot, ene.elec, ene.vdw sander.cleanup()
def energy(parm, args, output=sys.stdout): """ Compute a single-point energy using sander and print the result to the desired output """ global HAS_SANDER if not HAS_SANDER: raise SimulationError('Could not import sander') cutoff = args.get_key_float('cutoff', None) igb = args.get_key_int('igb', 5) saltcon = args.get_key_float('saltcon', 0.0) do_ewald = args.has_key('Ewald') vdw_longrange = not args.has_key('nodisper') has_1264 = 'LENNARD_JONES_CCOEF' in parm.parm_data # Get any unmarked arguments unmarked_cmds = args.unmarked() if len(unmarked_cmds) > 0: warnings.warn("Un-handled arguments: " + ' '.join(unmarked_cmds), UnhandledArgumentWarning) gbmeth, kappa = None, 0.0 if parm.ptr('ifbox') == 0: if not igb in (0, 1, 2, 5, 6, 7, 8): raise SimulationError('Bad igb value. Must be 0, 1, 2, 5, ' '6, 7, or 8') # Force vacuum electrostatics down the GB code path if igb == 0: igb = 6 inp = sander.gas_input(igb) if cutoff is None: cutoff = 1000.0 if cutoff <= 0: raise SimulationError('cutoff must be > 0') inp.cut = cutoff if saltcon < 0: raise SimulationError('salt concentration must be >= 0') inp.saltcon = saltcon elif parm.ptr('ifbox') > 0: inp = sander.pme_input() if cutoff is None: cutoff = 8.0 elif cutoff <= 0: raise SimulationError('cutoff must be > 0') inp.cut = cutoff inp.ew_type = int(do_ewald) inp.vdwmeth = int(vdw_longrange) inp.lj1264 = int(has_1264) if not hasattr(parm, 'coords'): raise SimulationError('No coordinates are loaded') # Time to set up sander sander.setup(parm, parm.coords, parm.box, inp) e, f = sander.energy_forces() if parm.chamber: output.write('Bond = %20.7f Angle = %20.7f\n' 'Dihedral = %20.7f Urey-Bradley = %20.7f\n' 'Improper = %20.7f ' % (e.bond, e.angle, e.dihedral, e.angle_ub, e.imp)) if parm.has_cmap: output.write('CMAP = %20.7f\n' % e.cmap) output.write('1-4 vdW = %20.7f 1-4 Elec. = %20.7f\n' 'Lennard-Jones = %20.7f Electrostatic = %20.7f\n' 'TOTAL = %20.7f\n' % (e.vdw_14, e.elec_14, e.vdw, e.elec, e.tot)) else: output.write('Bond = %20.7f Angle = %20.7f\n' 'Dihedral = %20.7f 1-4 vdW = %20.7f\n' '1-4 Elec = %20.7f vdWaals = %20.7f\n' 'Elec. = %20.7f' % (e.bond, e.angle, e.dihedral, e.vdw_14, e.elec_14, e.vdw, e.elec)) if igb != 0 and inp.ntb == 0: output.write(' Egb = %20.7f' % e.gb) elif e.hbond != 0: output.write(' EHbond = %20.7f' % e.hbond) output.write('\nTOTAL = %20.7f\n' % e.tot) sander.cleanup()
def energy(parm, args, output=sys.stdout): """ Compute a single-point energy using sander and print the result to the desired output """ global HAS_SANDER if not HAS_SANDER: raise SimulationError('Could not import sander') cutoff = args.get_key_float('cutoff', None) igb = args.get_key_int('igb', 5) saltcon = args.get_key_float('saltcon', 0.0) do_ewald = args.has_key('Ewald') vdw_longrange = not args.has_key('nodisper') has_1264 = 'LENNARD_JONES_CCOEF' in parm.parm_data # Get any unmarked arguments unmarked_cmds = args.unmarked() if len(unmarked_cmds) > 0: warnings.warn("Un-handled arguments: " + ' '.join(unmarked_cmds), UnhandledArgumentWarning) gbmeth, kappa = None, 0.0 if parm.ptr('ifbox') == 0: if not igb in (0, 1, 2, 5, 6, 7, 8): raise SimulationError('Bad igb value. Must be 0, 1, 2, 5, ' '6, 7, or 8') # Force vacuum electrostatics down the GB code path if igb == 0: igb = 6 inp = sander.gas_input(igb) if cutoff is None: cutoff = 1000.0 if cutoff <= 0: raise SimulationError('cutoff must be > 0') inp.cut = cutoff if saltcon < 0: raise SimulationError('salt concentration must be >= 0') inp.saltcon = saltcon elif parm.ptr('ifbox') > 0: inp = sander.pme_input() if cutoff is None: cutoff = 8.0 elif cutoff <= 0: raise SimulationError('cutoff must be > 0') inp.cut = cutoff inp.ew_type = int(do_ewald) inp.vdwmeth = int(vdw_longrange) inp.lj1264 = int(has_1264) if not hasattr(parm, 'coords'): raise SimulationError('No coordinates are loaded') # Time to set up sander sander.setup(parm, parm.coords, parm.box, inp) e, f = sander.energy_forces() if parm.chamber: output.write('Bond = %20.7f Angle = %20.7f\n' 'Dihedral = %20.7f Urey-Bradley = %20.7f\n' 'Improper = %20.7f ' % (e.bond, e.angle, e.dihedral, e.angle_ub, e.imp)) if parm.has_cmap: output.write('CMAP = %20.7f\n' % e.cmap) output.write('1-4 vdW = %20.7f 1-4 Elec. = %20.7f\n' 'Lennard-Jones = %20.7f Electrostatic = %20.7f\n' 'TOTAL = %20.7f\n' % (e.vdw_14, e.elec_14, e.vdw, e.elec, e.tot)) else: output.write( 'Bond = %20.7f Angle = %20.7f\n' 'Dihedral = %20.7f 1-4 vdW = %20.7f\n' '1-4 Elec = %20.7f vdWaals = %20.7f\n' 'Elec. = %20.7f' % (e.bond, e.angle, e.dihedral, e.vdw_14, e.elec_14, e.vdw, e.elec)) if igb != 0 and inp.ntb == 0: output.write(' Egb = %20.7f' % e.gb) elif e.hbond != 0: output.write(' EHbond = %20.7f' % e.hbond) output.write('\nTOTAL = %20.7f\n' % e.tot) sander.cleanup()