Ejemplo n.º 1
0
    def config(self,**kw):
        """     Change the options for this runner object"""
        # first the normal parameters, then IRS=... style parameters
        for key in self.options:
            if key in kw:
                value = kw[key]
                del kw[key]
                if key == 'log':
                    if self.options[key] is None:
                        self.stdout = sys.stdout
                    sys.stdout = value or self.stdout
                elif key == 'err':
                    if self.options[key] is None:
                        self.stderr = sys.stderr
                    sys.stderr = value or self.stderr
                elif key == 'constants':
                    # do not completely replace existing constants data but
                    # leave the special keys such as unames, parnames, etc,
                    # intact
                    self.options[key].update(value)
                    value = self.options[key]
                elif key == 'solution' and not hasattr(value, "load"):
                    t=kw.get('t')
                    if "t" in kw and value is not None:
                        del kw["t"]
                    value = parseS.AUTOSolution(value,t=t)
                self.options[key] = value

        self.options["constants"].update(**kw)
Ejemplo n.º 2
0
    def __init__(self,**kw):
        # Set the signal handler
        if hasattr(signal,'SIGALRM') and demo_max_time > 0:
            signal.signal(signal.SIGALRM, self.__handler)

        self.options={}
        self.options["log"] = None
        self.options["err"] = None
        self.options["auto_dir"] = None
        self.options["demos_dir"] = None
        self.options["equation"] = "all"
        self.options["verbose"] = "yes" # note: this is ignored!
        self.options["clean"] = "no"
        self.options["dir"] = "."
        self.options["executable"] = None
        self.options["command"] = None
        self.options["makefile"] = None
        self.options["constants"] = parseC.parseC()
        self.options["solution"] = parseS.AUTOSolution()
        self.options["homcont"] = None
        self.options["selected_solution"] = None

        kw = self.config(**kw)
 def __realinit(self, fort7_filename, fort8_filename, fort9_filename,
                constants):
     ioerrors = []
     try:
         parseB.parseBR.__init__(self, fort7_filename)
         for i, d in enumerate(self):
             self[i] = bifDiagBranch(d)
     except IOError:
         ioerrors.append(str(sys.exc_info()[1]))
         parseB.parseBR.__init__(self)
         fort7_filename = None
     if isinstance(fort8_filename, parseS.AUTOSolution):
         fort8_filename = [fort8_filename]
     try:
         solution = parseS.parseS(fort8_filename)
     except IOError:
         ioerrors.append(str(sys.exc_info()[1]))
         solution = None
         if fort7_filename is None:
             raise AUTOExceptions.AUTORuntimeError('\n'.join(ioerrors))
     if fort7_filename is None and fort8_filename is not None:
         # simulate a bifurcation diagram
         labels = {}
         for s in solution:
             br = s["Branch number"]
             if labels == {} or br != branch.BR:
                 if labels != {}:
                     branch.labels = Points.PointInfo(labels)
                 branch = bifDiagBranch()
                 self.append(branch)
                 branch.BR = br
                 branch.coordarray = []
                 branch.coordnames = []
                 branch.headernames = []
                 branch.headerlist = []
                 branch.c = constants
                 labels = {}
                 base = 0
                 i = 0
             pt = s["PT"]
             lab = s["LAB"]
             ty = s["TY number"]
             if i >= base + pt - 1:
                 # point numbers wrapped around
                 base += 9999
             i = base + pt - 1
             labels[i] = {s["TY"]: {"LAB": lab, "TY number": ty, "PT": pt}}
         if labels != {}:
             branch.labels = Points.PointInfo(labels)
     if fort9_filename is not None and self.data != []:
         try:
             # for now just attach diagnostics information to first branch
             self[0].diagnostics = parseD.parseD(fort9_filename)
         except IOError:
             pass
     i = 0
     if solution is not None:
         for d in self:
             if constants is None and d.c is not None:
                 constants = d.c
             constants = parseC.parseC(constants)
             for k in constants:
                 if k in self.nonekeys:
                     constants[k] = None
             for ind in d.labels.getIndices():
                 if i >= len(solution):
                     break
                 x = d._gettypelabel(ind)[1]
                 s = solution[i]
                 if x.get("LAB", 0) != 0 or s["LAB"] == 0:
                     i = i + 1
                     s = x["solution"] = parseS.AUTOSolution(
                         s, constants=constants)
                     if d.coordnames != []:
                         s.b = d[ind]