def fe(y): res = free_energy.subs({"y1": y[0], "y2": y[1], "y3": y[2]}) if isinstance(res, sympy.Basic): #print y #raise "evaluation returns formula not a number" #print "evaluation returns formula not a number" #print y #print res try: res = float(res) except: res = np.nan if res == np.nan: print "NaN" return res
"Wplus3": 52000, "Wminus12": 12000, "Wminus13": 12000, "Wminus23": 12000, "B1": 8000, # 8000 "B2": 8000, "B3": 8000, "THETA1": 52500, "THETA2": 52500, "THETA3": 52500, "N1": 1000, "N2": 1000, "N3": 1000, "beta": 1/24} free_energy = free_energy.subs(param) sympy.pprint(free_energy) def fe(y): res = free_energy.subs({"y1": y[0], "y2": y[1], "y3": y[2]}) if isinstance(res, sympy.Basic): #print y #raise "evaluation returns formula not a number" #print "evaluation returns formula not a number" #print y #print res try: res = float(res) except: