Exemplo n.º 1
0
    def fetch(self):
        """Creates a simulation object.

        Returns:
           A simulation object of the appropriate type and with the appropriate
           properties and other objects given the attributes of the
           InputSimulation object.

        Raises:
           TypeError: Raised if one of the file types in the stride keyword
              is incorrect.
        """

        super(InputSimulation, self).fetch()

        # We fetch format and store it in the global variable
        ipi_global_settings["floatformat"] = self.floatformat.fetch()
        try:
            _ = ipi_global_settings["floatformat"] % 1.0
        except:
            print("Error: <simulation> has invalid floatformat attribute.")
            exit(-1)

        # small hack: initialize here the verbosity level -- we really assume to have
        # just one simulation object
        verbosity.level = self.verbosity.fetch()

        syslist = []
        fflist = []
        for (k, v) in self.extra:
            if k == "system":
                syslist.append(v.fetch())
            elif k == "system_template":
                # This will actually generate automatically a bunch
                # of system objects with the desired properties set
                # automatically to many values.
                syslist += v.fetch()
            elif (k == "ffsocket" or k == "fflj" or k == "ffdebye"
                  or k == "ffdmd" or k == "ffplumed" or k == "ffsgdml"
                  or k == "ffyaff" or k == "ffcommittee"):
                info(" # @simulation: Fetching" + k, verbosity.low)
                fflist.append(v.fetch())

        # this creates a simulation object which gathers all the little bits
        import ipi.engine.simulation as esimulation  # import here as otherwise this is the mother of all circular imports...

        rsim = esimulation.Simulation(
            mode=self.mode.fetch(),
            syslist=syslist,
            fflist=fflist,
            outputs=self.output.fetch(),
            prng=self.prng.fetch(),
            smotion=self.smotion.fetch(),
            step=self.step.fetch(),
            tsteps=self.total_steps.fetch(),
            ttime=self.total_time.fetch(),
            threads=self.threading.fetch(),
        )

        return rsim
Exemplo n.º 2
0
    def fetch(self):
        """Creates a simulation object.

      Returns:
         A simulation object of the appropriate type and with the appropriate
         properties and other objects given the attributes of the
         InputSimulation object.

      Raises:
         TypeError: Raised if one of the file types in the stride keyword
            is incorrect.
      """

        super(InputSimulation, self).fetch()

        # small hack: initialize here the verbosity level -- we really assume to have
        # just one simulation object
        verbosity.level = self.verbosity.fetch()

        syslist = []
        fflist = []
        for (k, v) in self.extra:
            if k == "system":
                for isys in range(v.copies.fetch(
                )):  # creates multiple copies of system if desired
                    syslist.append(v.fetch())
                    if (v.copies.fetch() > 1):
                        syslist[-1].prefix = syslist[-1].prefix + (("%0" + str(
                            int(1 + np.floor(
                                np.log(v.copies.fetch()) / np.log(10)))) + "d")
                                                                   % (isys))
            elif k == "ffsocket":
                fflist.append(v.fetch())
            elif k == "fflj":
                fflist.append(v.fetch())
            elif k == "ffdebye":
                fflist.append(v.fetch())
            elif k == "ffyaff":
                fflist.append(v.fetch())

        # this creates a simulation object which gathers all the little bits
        import ipi.engine.simulation as esimulation  # import here as otherwise this is the mother of all circular imports...
        rsim = esimulation.Simulation(mode=self.mode.fetch(),
                                      syslist=syslist,
                                      fflist=fflist,
                                      outputs=self.output.fetch(),
                                      prng=self.prng.fetch(),
                                      paratemp=self.paratemp.fetch(),
                                      step=self.step.fetch(),
                                      tsteps=self.total_steps.fetch(),
                                      ttime=self.total_time.fetch())

        return rsim
Exemplo n.º 3
0
    def fetch(self):
        """Creates a simulation object.

        Returns:
           A simulation object of the appropriate type and with the appropriate
           properties and other objects given the attributes of the
           InputSimulation object.

        Raises:
           TypeError: Raised if one of the file types in the stride keyword
              is incorrect.
        """

        super(InputSimulation, self).fetch()

        # small hack: initialize here the verbosity level -- we really assume to have
        # just one simulation object
        verbosity.level = self.verbosity.fetch()

        syslist = []
        fflist = []
        for (k, v) in self.extra:
            if k == "system":
                syslist.append(v.fetch())
            elif k == "system_template":
                syslist += v.fetch(
                )  # this will actually generate automatically a bunch of system objects with the desired properties set automatically to many values
            elif k == "ffsocket" or k == "fflj" or k == "ffdebye" or k == "ffplumed":
                print "fetching", k
                fflist.append(v.fetch())
            elif k == "ffyaff":
                fflist.append(v.fetch())

        # this creates a simulation object which gathers all the little bits
        import ipi.engine.simulation as esimulation  # import here as otherwise this is the mother of all circular imports...
        rsim = esimulation.Simulation(mode=self.mode.fetch(),
                                      syslist=syslist,
                                      fflist=fflist,
                                      outputs=self.output.fetch(),
                                      prng=self.prng.fetch(),
                                      smotion=self.smotion.fetch(),
                                      step=self.step.fetch(),
                                      tsteps=self.total_steps.fetch(),
                                      ttime=self.total_time.fetch(),
                                      threads=self.threading.fetch())

        return rsim