Exemplo n.º 1
0
    def step(self):
        """Does one simulation time step."""

        self.ptime = self.ttime = 0
        self.qtime = -time.time()

        try:
            if (self.intraj.mode == "xyz"):
                for b in self.beads:
                    myatoms = read_xyz(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units,
                                                  1.0)
                    b.q[:] = myatoms.q
            elif (self.intraj.mode == "pdb"):
                for b in self.beads:
                    myatoms, mycell = read_pdb(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units,
                                                  1.0)
                    mycell.h *= unit_to_internal("length", self.intraj.units,
                                                 1.0)
                    b.q[:] = myatoms.q
                self.cell.h[:] = mycell.h
            elif (self.intraj.mode == "chk"
                  or self.intraj.mode == "checkpoint"):
                # reads configuration from a checkpoint file
                xmlchk = xml_parse_file(self.rfile)  # Parses the file.

                from ipi.inputs.simulation import InputSimulation
                simchk = InputSimulation()
                simchk.parse(xmlchk.fields[0][1])
                mycell = simchk.cell.fetch()
                mybeads = simchk.beads.fetch()
                self.cell.h[:] = mycell.h
                self.beads.q[:] = mybeads.q
                softexit.trigger(" # Read single checkpoint")
        except EOFError:
            softexit.trigger(" # Finished reading re-run trajectory")

        self.qtime += time.time()
Exemplo n.º 2
0
def init_chk(filename):
    """Reads an checkpoint file and returns the data contained in it.

   Args:
      filename: A string giving the name of the checkpoint file to be read from.

   Returns:
      A Beads object, Cell object and Thermostat object as read from the
      checkpoint file.
   """

    # reads configuration from a checkpoint file
    rfile = open(filename, "r")
    xmlchk = xml_parse_file(rfile)  # Parses the file.

    from ipi.inputs.simulation import InputSimulation
    simchk = InputSimulation()
    simchk.parse(xmlchk.fields[0][1])
    rcell = simchk.cell.fetch()
    rbeads = simchk.beads.fetch()
    rthermo = simchk.ensemble.thermostat.fetch()

    return (rbeads, rcell, rthermo)
Exemplo n.º 3
0
def init_chk(filename):
   """Reads an checkpoint file and returns the data contained in it.

   Args:
      filename: A string giving the name of the checkpoint file to be read from.

   Returns:
      A Beads object, Cell object and Thermostat object as read from the
      checkpoint file.
   """

   # reads configuration from a checkpoint file
   rfile = open(filename,"r")
   xmlchk = xml_parse_file(rfile) # Parses the file.

   from ipi.inputs.simulation import InputSimulation
   simchk = InputSimulation()
   simchk.parse(xmlchk.fields[0][1])
   rcell = simchk.cell.fetch()
   rbeads = simchk.beads.fetch()
   rthermo = simchk.ensemble.thermostat.fetch()

   return (rbeads, rcell, rthermo)
Exemplo n.º 4
0
    def step(self):
        """Does one simulation time step."""

        self.ptime = self.ttime = 0
        self.qtime = -time.time()

        try:
            if self.intraj.mode == "xyz":
                for b in self.beads:
                    myatoms = read_xyz(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units, 1.0)
                    b.q[:] = myatoms.q
            elif self.intraj.mode == "pdb":
                for b in self.beads:
                    myatoms, mycell = read_pdb(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units, 1.0)
                    mycell.h *= unit_to_internal("length", self.intraj.units, 1.0)
                    b.q[:] = myatoms.q
                self.cell.h[:] = mycell.h
            elif self.intraj.mode == "chk" or self.intraj.mode == "checkpoint":
                # reads configuration from a checkpoint file
                xmlchk = xml_parse_file(self.rfile)  # Parses the file.

                from ipi.inputs.simulation import InputSimulation

                simchk = InputSimulation()
                simchk.parse(xmlchk.fields[0][1])
                mycell = simchk.cell.fetch()
                mybeads = simchk.beads.fetch()
                self.cell.h[:] = mycell.h
                self.beads.q[:] = mybeads.q
                softexit.trigger(" # Read single checkpoint")
        except EOFError:
            softexit.trigger(" # Finished reading re-run trajectory")

        self.qtime += time.time()