Example #1
0
    def run_nanohive(self):
        """
        Slot for "Run Simulation" button.
        """
        sim_name = self.get_sim_name()
        sim_parms = self.get_sim_data()
        sims_to_run = self.get_sims_to_run()
        results_to_save = self.get_results_to_save()

        run_nh_simulation(self.assy, sim_name, sim_parms, sims_to_run, results_to_save)
Example #2
0
    def calculate_esp(self):

        cmd = greenmsg("Calculate ESP: ")

        errmsgs = [ # warning: their indices in this list matter.
            "Error: Nano-Hive plug-in not enabled.",
            "Error: Nano-Hive Plug-in path is empty.",
            "Error: Nano-Hive plug-in path points to a file that does not exist.",
            "Error: Nano-Hive plug-in is not Version 1.2b.",
            "Error: Couldn't connect to Nano-Hive instance.",
            "Error: Load command failed.",
            "Error: Run command failed.",
            "Simulation Aborted"
         ]

        sim_parms = self.get_sim_parms()
        sims_to_run = ["MPQC_ESP"]
        results_to_save = [] # Results info included in write_nh_mpqc_esp_rec()

        # Temporary file name of ESP image file.
        nhdir = find_or_make_Nanorex_subdir("Nano-Hive")
        tmp_espimage_file = os.path.join(nhdir, "%s.png" % (self.name))

        # Destination (permanent) file name of ESP image file.
        espimage_file = get_nh_espimage_filename(self.assy, self.name)

        msg = "Running ESP calculation on [%s]. " \
              "Results will be written to: [%s]" % (self.name, espimage_file)
        env.history.message( cmd + msg ) 

        r = run_nh_simulation(self.assy, 'CalcESP', 
                              sim_parms, sims_to_run, results_to_save)

        if r:
            msg = redmsg(errmsgs[r - 1])
            env.history.message( cmd + msg )
            return

        msg = "ESP calculation on [%s] finished." % (self.name)
        env.history.message( cmd + msg ) 

        # Move tmp file to permanent location. Make sure the tmp file is there.
        if os.path.exists(tmp_espimage_file):
            shutil.move(tmp_espimage_file, espimage_file)
        else:
            print "Temporary ESP Image file ", tmp_espimage_file, \
                  " does not exist. Image not loaded."
            return

        self.espimage_file = espimage_file
        self.load_espimage_file()
        self.assy.changed()
        self.assy.w.win_update()

        return