Hi guys,
I am looking for a generic python way to manipulate text into solvable equations.
For example:
there may be some constants to initialize
e1,e2=0.58,0.62
ma1,ma2=0.85,1.15
mw=0.8
Cpa,Cpw=1.023,4.193
dba,dbr=0.0,25.0
and a set of equations (written here for readability rather than the solver)
Q=e1*ma1*Cpa*(tw1-dba)
Q=ma1*Cpa*(dbs-dba)
Q=mw*Cpw*(tw1-tw2)
Q=e2*ma2*Cpa*(dbr-tw2)
Q=ma2*Cpa*(dbr-dbo)
This leaves 5 unknowns, so presumably the system can be solved.
Q, dbo, dbr, tw1, tw2
Actual systems are non-linear and much more complicated.
I have already solved this easy example with scipy, Delphi, Sage... so I'm not looking for the solve part.
The equations are typed directly into a text editor and I want a Python program to give me an array of unknowns and an array of error functions.
y = mysolver.fsolve(f, x)
So, for the above example
x=[Q,dbo,dbr,tw1,tw2]
f=[Q-e1*ma1*Cpa*(tw1-dba), Q-ma1*Cpa*(dbs-dba), Q-mw*Cpw*(tw1-tw2),
Q-e2*ma2*Cpa*(dbr-tw2), Q-ma2*Cpa*(dbr-dbo)]
I just don't know how to extract the unknowns and create the error functions.
I tried the compile.parse() function and it seems to give a structured breakdown.
Can anyone give some ideas on the best approach.