本文整理汇总了Python中MMTK.Trajectory.Trajectory类的典型用法代码示例。如果您正苦于以下问题:Python Trajectory类的具体用法?Python Trajectory怎么用?Python Trajectory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Trajectory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self,*args,**kwargs):
Trajectory.__init__(self,*args,**kwargs)
resolve_undefined_molecules_name(self.universe)
build_connectivity(self.universe)
示例2: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self.numberOfSteps = self.configuration['frames']['number']
self._partition = partition_universe(self.configuration['trajectory']['instance'].universe,self.configuration['atom_selection']['groups'])
self._newUniverse = copy.copy(self.configuration['trajectory']['instance'].universe)
self._newUniverse.removeObject(self._newUniverse.objectList()[:])
for i,g in enumerate(self._partition):
at = Atom("H", name="com_%d" % i)
at._mass = g.mass()
at.index = i
self._newUniverse.addObject(at)
# The output trajectory is opened for writing.
self._comt = Trajectory(self._newUniverse, self.configuration['output_files']['files'][0], "w")
# The title for the trajectory is set.
self._comt.title = self.__class__.__name__
# Create the snapshot generator.
self._snapshot = SnapshotGenerator(self._newUniverse, actions = [TrajectoryOutput(self._comt, ("configuration","time"), 0, None, 1)])
示例3: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self.configuration["dcd_file"]["instance"] = DCDFile(self.configuration["dcd_file"]['filename'])
# The number of steps of the analysis.
self.numberOfSteps = self.configuration['dcd_file']['instance']['n_frames']
# Create all objects from the PDB file.
conf = PDBConfiguration(self.configuration['pdb_file']['filename'])
# Creates a collection of all the chemical objects stored in the PDB file
molecules = conf.createAll()
# If the input trajectory has PBC create a periodic universe.
if self.configuration['dcd_file']['instance']['has_pbc_data']:
self._universe = ParallelepipedicPeriodicUniverse()
# Otherwise create an infinite universe.
else:
self._universe = InfiniteUniverse()
# The chemical objects found in the PDB file introduced into the universe.
self._universe.addObject(molecules)
resolve_undefined_molecules_name(self._universe)
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w')
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions=[TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
示例4: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self.numberOfSteps = self.configuration['frames']['number']
atoms = sorted_atoms(self.configuration['trajectory']['instance'].universe)
# The collection of atoms corresponding to the atoms selected for output.
self._selectedAtoms = Collection([atoms[ind] for ind in self.configuration['atom_selection']['indexes']])
self._chemicalObjects = set([at.topLevelChemicalObject() for at in self._selectedAtoms])
# The output trajectory is opened for writing.
self._outputTraj = Trajectory(self._selectedAtoms, self.configuration['output_files']['files'][0], "w")
# The title for the trajectory is set.
self._outputTraj.title = self.__class__.__name__
# Create the snapshot generator.
self.snapshot = SnapshotGenerator(self.configuration['trajectory']['instance'].universe, actions = [TrajectoryOutput(self._outputTraj, "all", 0, None, 1)])
# This will store the configuration used as the reference for the following step.
self._refCoords = None
# Increase the recursion limit to avoid maximum recursion depth error when calling the contiguous_object recursive function
self._oldRecursionLimit = sys.getrecursionlimit()
sys.setrecursionlimit(100000)
示例5: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self._castepFile = MDFile(self.configuration["castep_file"]["filename"])
self.numberOfSteps = self._castepFile["n_frames"]
self._universe = ParallelepipedicPeriodicUniverse()
for symbol,number in self._castepFile["atoms"]:
for i in range(number):
self._universe.addObject(Atom(symbol, name="%s_%d" % (symbol,i)))
self._universe.initializeVelocitiesToTemperature(0.)
self._velocities = ParticleVector(self._universe)
self._gradients = ParticleVector(self._universe)
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w')
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
示例6: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self.numberOfSteps = self.configuration['frames']['number']
self.configuration['trajectory']['instance'].universe.__class__.__name__ = 'InfiniteUniverse'
self.configuration['trajectory']['instance'].universe._descriptionArguments = lambda: '()'
self.configuration['trajectory']['instance'].universe.is_periodic=False
self._cellParametersFunction = self.configuration['trajectory']['instance'].universe.cellParameters
atoms = sorted_atoms(self.configuration['trajectory']['instance'].universe)
# The collection of atoms corresponding to the atoms selected for output.
self._selectedAtoms = Collection([atoms[ind] for ind in self.configuration['atom_selection']['indexes']])
self._referenceAtoms = Collection([atoms[ind] for ind in self.configuration['reference_selection']['indexes']])
# The output trajectory is opened for writing.
self._gmft = Trajectory(self._selectedAtoms, self.configuration['output_files']['files'][0], "w")
# The title for the trajectory is set.
self._gmft.title = self.__class__.__name__
# Create the snapshot generator.
self.snapshot = SnapshotGenerator(self.configuration['trajectory']['instance'].universe, actions = [TrajectoryOutput(self._gmft, "all", 0, None, 1)])
# This will store the configuration used as the reference for the following step.
self._referenceConfig = None
示例7: initialize
def initialize(self):
'''
Initialize the job.
'''
self._xtdfile = XTDFile(self.configuration["xtd_file"]["filename"])
self._xtdfile.build_universe()
self._universe = self._xtdfile.universe
self._hisfile = HisFile(self.configuration["his_file"]["filename"])
# The number of steps of the analysis.
self.numberOfSteps = self._hisfile['n_frames']
if self._universe.is_periodic:
self._universe.setShape(self._hisfile['initial_cell'])
conf = Configuration(self._universe, self._hisfile["initial_coordinates"])
self._universe.setConfiguration(conf)
self._universe.initializeVelocitiesToTemperature(0.)
self._velocities = ParticleVector(self._universe)
self._velocities.array = self._hisfile["initial_velocities"]
self._universe.setVelocities(self._velocities)
self._universe.foldCoordinatesIntoBox()
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w', comment=self._hisfile["title"])
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
示例8: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
self.numberOfSteps = self.configuration['frames']['number']
self._universe = self.configuration['trajectory']['instance'].universe
self._upperLeaflet = Collection([obj for obj in self._universe.objectList() if obj.name == self.configuration["upper_leaflet"]["value"]])
self._lowerLeaflet = Collection([obj for obj in self._universe.objectList() if obj.name == self.configuration["lower_leaflet"]["value"]])
self._membrane = Collection(self._upperLeaflet,self._lowerLeaflet)
self._upperLeafletIndexes = [at.index for at in self._upperLeaflet.atomList()]
self._lowerLeafletIndexes = [at.index for at in self._lowerLeaflet.atomList()]
self._membraneIndexes = [at.index for at in self._membrane.atomList()]
# The output trajectory is opened for writing.
self._rmt = Trajectory(self._membrane, self.configuration['output_files']['files'][0], "w")
# The title for the trajectory is set.
self._rmt.title = self.__class__.__name__
# Create the snapshot generator.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._rmt, "all", 0, None, 1)])
self._axis = self.configuration["axis"]["index"]
示例9: createTrajectoryAndIntegrator
def createTrajectoryAndIntegrator(self):
'''create trajectory and integrator'''
#initialize velocities--this has to happen after adding atoms
self.mmtkUniverse.initializeVelocitiesToTemperature(self.inventory.sample.i.temperature)
# Create trajectory and integrator.
self.mmtkTrajectory = Trajectory(self.mmtkUniverse, self.inventory.trajectoryFilename, "w")
self.mmtkIntegrator = VelocityVerletIntegrator(self.mmtkUniverse, delta_t=self.inventory.timeStep*Units.fs)
# Periodical actions for equilibration output.
self.equilibration_actions = [TranslationRemover(0, None, 100),
RotationRemover(0, None, 100),
LogOutput(self.inventory.logFilename, ('time', 'energy'), 0, None)
]
# Periodical actions for trajectory output and text log output.
self.output_actions = [TrajectoryOutput(self.mmtkTrajectory,
('configuration', 'energy', 'thermodynamic', 'time', 'auxiliary'),
0, None, 20), #TODO: Fixme so the user can specify when trajectory and sample frequency happens
#this last option makes it so none of the equilibration steps are output, consistent with Gulp
LogOutput(self.inventory.logFilename, ('time', 'energy'), 0, None, 20) #this last 0 makes it so all equilibration steps are output, consistent with Gulp
]
示例10: initialize
def initialize(self):
"""
Initialize the analysis (open trajectory, create output variables ...)
"""
self.numberOfSteps = self.configuration['frames']['number']
self._universe = self.configuration['trajectory']['instance'].universe
# Create a MMTK collection from the atoms selected for translation.
atoms = sorted_atoms(self.configuration['trajectory']['instance'].universe)
self._selectedAtoms = Collection([atoms[ind] for ind in self.configuration['atom_selection']['indexes']])
# The output trajectory is opened for writing.
self._btt = Trajectory(self._selectedAtoms, self.configuration['output_files']['files'][0], "w")
self._btt.title = self.__class__.__name__
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._btt, "all", 0, None, 1)])
# This will store the box coordinates of the previous configuration
self._boxCoords = None
示例11: initialize
def initialize(self):
'''
Initialize the job.
'''
self._atomicAliases = self.configuration["atom_aliases"]["value"]
self._fieldFile = FieldFile(self.configuration["field_file"]["filename"], aliases=self._atomicAliases)
self._historyFile = HistoryFile(self.configuration["history_file"]["filename"], self.configuration["version"]["value"])
# The number of steps of the analysis.
self.numberOfSteps = self._historyFile['n_frames']
if self._historyFile["imcon"] == 0:
self._universe = InfiniteUniverse()
else:
self._universe = ParallelepipedicPeriodicUniverse()
self._fieldFile.build_mmtk_contents(self._universe)
self._velocities = None
self._forces = None
if self._historyFile["keytrj"] == 1:
self._universe.initializeVelocitiesToTemperature(0.)
self._velocities = ParticleVector(self._universe)
elif self._historyFile["keytrj"] == 2:
self._universe.initializeVelocitiesToTemperature(0.)
self._velocities = ParticleVector(self._universe)
self._forces = ParticleVector(self._universe)
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w', comment=self._fieldFile["title"])
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
示例12: createRestartTrajectoryAndIntegrator
def createRestartTrajectoryAndIntegrator(self):
'''initialize system from previous trajectory'''
# Initialize system state from the restart trajectory
self.mmtkUniverse.setFromTrajectory(Trajectory(self.mmtkUniverse, self.inventory.restartFilename))
# Create trajectory and integrator.
self.mmtkTrajectory = Trajectory(self.mmtkUniverse, self.inventory.trajectoryFilename, "a")
self.mmtkIntegrator = VelocityVerletIntegrator(self.mmtkUniverse, delta_t=self.inventory.timestep*Units.fs)
# Periodical actions for equilibration output.
self.equilibration_actions = [TranslationRemover(0, None, 100),
RotationRemover(0, None, 100),
LogOutput(self.inventory.logFilename, ('time', 'energy'), 0, None)
]
# Periodical actions for trajectory output and text log output.
self.output_actions = [TranslationRemover(0, None, 100),
TrajectoryOutput(self.mmtkTrajectory,
('configuration', 'energy', 'thermodynamic', 'time', 'auxiliary'),
0, None, self.equilibrationSteps()), #this last option makes it so none of the equilibration steps are output, consistent with Gulp
# Write restart data every time step.
RestartTrajectoryOutput(self.inventory.restartFilename, 1),
LogOutput(self.inventory.logFilename, ('time', 'energy'), 0, None)
]
示例13: initialize
def initialize(self):
'''
Initialize the job.
'''
self._xdatcarFile = XDATCARFile(self.configuration["xdatcar_file"]["filename"])
# The number of steps of the analysis.
self.numberOfSteps = self._xdatcarFile['n_frames']
self._universe = ParallelepipedicPeriodicUniverse()
self._universe.setShape(self._xdatcarFile["cell_shape"])
for symbol,number in self._xdatcarFile["atoms"]:
for i in range(number):
self._universe.addObject(Atom(symbol, name="%s_%d" % (symbol,i)))
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w')
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
示例14: initialize
def initialize(self):
"""
Initialize the input parameters and analysis self variables
"""
# The indices of frames which should be extacted from pdb file
self.frame_list = self.configuration['nb_frame']["value"]
self.numberOfSteps = self.configuration['nb_frame']["number"]
# Create all objects from the PDB file.
pdb_config = PDBFile(self.configuration['pdb_file']['filename'], model = 0)
# Create the universe.
self._universe = pdb_config.createUnitCellUniverse()
# Construct system
self._universe.addObject(pdb_config.createAll(None, 1))
# Open the new trajectory
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], "w", "Converted from PDB")
# Make a snapshot generator for saving.
self._snapshot = SnapshotGenerator(self._universe,actions = [TrajectoryOutput(self._trajectory, None, 0, None, 1)])
示例15: initialize
def initialize(self):
'''
Initialize the job.
'''
# The number of steps of the analysis.
self.numberOfSteps = self.configuration["n_steps"]["value"]
self._lammpsConfig = LAMMPSConfigFile(self.configuration["config_file"]["value"])
self.parse_first_step()
# A MMTK trajectory is opened for writing.
self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w')
self._nameToIndex = dict([(at.name,at.index) for at in self._universe.atomList()])
# A frame generator is created.
self._snapshot = SnapshotGenerator(self._universe, actions = [TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
self._lammps.seek(0,0)
self._start = 0