Esempio n. 1
0
    def make_default(cls):
        """Used to make the default value of the outputs class for use when no
        output is specified.

        Needed since this is a fairly complicated default, with many mutable
        objects, and the default has to be generated by a function that does not
        use any mutable objects as arguments.
        """

        return [
            eoutputs.PropertyOutput(filename="i-pi.md",
                                    stride=10,
                                    outlist=[
                                        "time", "step", "conserved",
                                        "temperature", "potential",
                                        "kinetic_cv"
                                    ]),
            eoutputs.TrajectoryOutput(filename="i-pi.pos",
                                      stride=100,
                                      what="positions",
                                      format="xyz"),
            eoutputs.CheckpointOutput(filename="i-pi.checkpoint",
                                      stride=1000,
                                      overwrite=True)
        ]
Esempio n. 2
0
    def bind(self):
        """Calls the bind routines for all the objects in the simulation."""

        if self.tsteps <= self.step:
            raise ValueError(
                "Simulation has already run for total_steps, will not even start. "
                "Modify total_steps or step counter to continue.")

        # initializes the output maker so it can be passed around to systems
        f_start = (self.step == 0
                   )  # special operations if we're starting from scratch
        if f_start:
            mode = "w"
        else:
            mode = "a"
        self.output_maker = eoutputs.OutputMaker(self.outtemplate.prefix,
                                                 f_start)

        for s in self.syslist:
            # binds important computation engines
            s.bind(self)

        # start forcefields here so we avoid having a shitload of files printed
        # out only to find the socket is busy or whatever prevented starting the threads
        for k, f in self.fflist.iteritems():
            f.start()

        # Checks for repeated filenames.
        filename_list = [x.filename for x in self.outtemplate]
        if len(filename_list) > len(set(filename_list)):
            raise ValueError(
                "Output filenames are not unique. Modify filename attributes.")

        self.outputs = []
        for o in self.outtemplate:
            o = deepcopy(o)  # avoids overwriting the actual filename
            if self.outtemplate.prefix != "":
                o.filename = self.outtemplate.prefix + "." + o.filename
            if type(
                    o
            ) is eoutputs.CheckpointOutput:  # checkpoints are output per simulation
                o.bind(self)
                self.outputs.append(o)
            else:  # properties and trajectories are output per system
                isys = 0
                for s in self.syslist:  # create multiple copies
                    no = deepcopy(o)
                    if s.prefix != "":
                        no.filename = s.prefix + "_" + no.filename
                    no.bind(s, mode)
                    self.outputs.append(no)
                    if f_start:  # starting of simulation, print headers (if any)
                        no.print_header()
                    isys += 1

        self.chk = eoutputs.CheckpointOutput("RESTART", 1, True, 0)
        self.chk.bind(self)

        if not self.smotion is None:
            self.smotion.bind(self.syslist, self.prng, self.output_maker)
Esempio n. 3
0
    def bind(self):
        """Calls the bind routines for all the objects in the simulation."""

        if self.tsteps <= self.step:
            raise ValueError(
                "Simulation has already run for total_steps, will not even start. "
                "Modify total_steps or step counter to continue.")

        for s in self.syslist:
            # binds important computation engines
            s.bind(self)

        self.outputs = []
        for o in self.outtemplate:
            if type(
                    o
            ) is eoutputs.CheckpointOutput:  # checkpoints are output per simulation
                o.bind(self)
                self.outputs.append(o)
            else:  # properties and trajectories are output per system
                isys = 0
                for s in self.syslist:  # create multiple copies
                    no = deepcopy(o)
                    if s.prefix != "":
                        no.filename = s.prefix + "_" + no.filename
                    no.bind(s)
                    self.outputs.append(no)
                    isys += 1

        self.chk = eoutputs.CheckpointOutput("RESTART", 1, True, 0)
        self.chk.bind(self)

        if self.mode == "paratemp":
            self.paratemp.bind(self.syslist, self.prng)
            softexit.register_function(self.paratemp.softexit)
Esempio n. 4
0
    def fetch(self):
        """Returns a CheckpointOutput object."""

        step = super(InputCheckpoint, self).fetch()
        return eoutputs.CheckpointOutput(self.filename.fetch(),
                                         self.stride.fetch(),
                                         self.overwrite.fetch(),
                                         step=step)
Esempio n. 5
0
    def bind(self):
        """Calls the bind routines for all the objects in the simulation."""

        if self.tsteps <= self.step:
            raise ValueError(
                "Simulation has already run for total_steps, will not even start. "
                "Modify total_steps or step counter to continue.")

        for s in self.syslist:
            # binds important computation engines
            s.bind(self)

        # Checks for repeated filenames.
        filename_list = [x.filename for x in self.outtemplate]
        if len(filename_list) > len(set(filename_list)):
            raise ValueError(
                "Output filenames are not unique. Modify filename attributes.")

        self.outputs = []
        for o in self.outtemplate:
            if type(
                    o
            ) is eoutputs.CheckpointOutput:  # checkpoints are output per simulation
                o.bind(self)
                self.outputs.append(o)
            else:  # properties and trajectories are output per system
                isys = 0
                for s in self.syslist:  # create multiple copies
                    no = deepcopy(o)
                    if s.prefix != "":
                        no.filename = s.prefix + "_" + no.filename
                    no.bind(s)
                    self.outputs.append(no)
                    isys += 1

        self.chk = eoutputs.CheckpointOutput("RESTART", 1, True, 0)
        self.chk.bind(self)

        if not self.smotion is None:
            self.smotion.bind(self.syslist, self.prng)