Why am I getting an empty list as my output using solve command?
<p>I am trying to solve an equation using sympy's solve command but my output is an empty list [ ]. The only reason I think this could be happening is because there is no solution but I doubt that is the reason. Anyone know why I am not getting an answer? Thanks!</p>

<pre><code>from sympy import *

class WaterModel:

    def fp_requirement(self, Ws0, Wp0, Wg0):
        greyW = 60.0
        potW = 126.0
        rainW = 17.05

        self.Ws0 = Ws0
        self.Wp0 = Wp0
        self.Wg0 = Wg0

        self.fp = var('fp')

        filt_greyW = self.fp*greyW
        dWg = self.Wg0 - greyW + (1 - self.fp)*greyW + rainW
        dWp = self.Wp0 - potW + filt_greyW 
        F = self.Ws0 + dWp + dWg
        self.fp = solve(F,self.fp)

        return self.fp 

a = WaterModel()
fp = a.fp_requirement(1500, 100, 100)
print(fp)
</code></pre>

<p>I tried adding a few tracing statements to your function, just above the call to <strong>solve</strong>.</p>

<pre><code>    print "dWg\t", dWg, type(dWg)
    print "dWp\t", dWp, type(dWp)
    print "F\t", F, type(F)
    print "self.fp\t", self.fp
    self.fp = solve(F,self.fp)
</code></pre>

<p>Output:</p>

<pre><code>dWg 117.050000000000 - 60.0000000000000*fp &lt;class 'sympy.core.add.Add'&gt;
dWp -26.0000000000000 + 60.0000000000000*fp &lt;class 'sympy.core.add.Add'&gt;
F   1591.05000000000 &lt;class 'sympy.core.numbers.Real'&gt;
self.fp fp
[]
</code></pre>

<p>If I'm reading this correctly, your function evaluates the expressions rather than maintaining the symbolic nature of <strong>F</strong>.  Thus, when you issue the <strong>solve</strong> directive, you're trying to solve a constant for the variable <strong>fp</strong>.  That's why you get no solutions.</p>

<hr>

<p>Ah, ha!  There it is!  </p>

<pre><code>1500 + 117 - 26 - 60*fp + 60*fp =&gt; 1591
</code></pre>

<p>With <strong>fp</strong> out of the equation, there are no solutions.</p>

python sympy solver is-empty