"Memory Error " when solve a set of 6 equations simultaneously.

187 views
Skip to first unread message

Renxian

unread,
Dec 17, 2012, 11:39:36 AM12/17/12
to sy...@googlegroups.com
i am trying to solve the following equations symboliclly,
 
 
 
 
 
 
 
 
 
 
 
and the code is :
 
from sympy import *
from sympy.plotting import *
init_printing(use_unicode=False, wrap_line=False, no_global=True)
CL_syb,CLw_syb,CD_syb,Ctau_syb,alpha_e_syb,CLT_syb=var('CL_syb,CLw_syb,CD_syb,Ctau_syb,alpha_e_syb,CLT_syb')
V=var('V')
#total axial force (ox body axis)
TotalAxialForce=2*1*1/(2*V**2*4)*sin(alpha_e_syb+0.2)-(Ctau_syb*cos(0.2)-CD_syb*cos(alpha_e_syb)+CL_syb*sin(alpha_e_syb))
#total normal force (oz body axis)
TotalNormalForce=2*1*1/(2*V**2*4)*cos(alpha_e_syb+0.2)-(Ctau_syb*sin(0.2)+CD_syb*sin(alpha_e_syb)+CL_syb*cos(alpha_e_syb))
#pitch moment (about cg)
PitchMoment=(2+(2-1)*CLw_syb)-2*CLT_syb+Ctau_syb*1/1
#total lift coefficient
TotalLiftCoefficient=CL_syb-(CLw_syb+CLT_syb*2/3)
#total drag coefficient
TotalDragCoefficient=CD_syb-(2+1*CL_syb**2)
#wing/body lift coefficient
WingBodyLiftCoefficient=CLw_syb-1*(alpha_e_syb+0.3-0.1)syb,alpha_e_syb,CLT_syb against V .
result=solve([TotalAxialForce,TotalNormalForce,PitchMoment,TotalLiftCoefficient,TotalDragCoefficient,WingBodyLiftCoefficient],[CL_syb,CLw_syb,CD_syb,Ctau_syb,alpha_e_syb,CLT_syb])
 
means to get CL_syb,CLw_syb,CD_syb,Ctau_
but i alway get  "Memory Error "  after run it .    any body know what the problem might be and how to solve it???
 
it is not lack of memory . i used a 8 G memory computer and when the programe was runing, there is more than 5 G left.

Renxian

unread,
Dec 17, 2012, 11:49:36 AM12/17/12
to sy...@googlegroups.com
and the error python thrown is :
 
Traceback (most recent call last):
  File "F:\test2.py", line 22, in <module>

    result=solve([TotalAxialForce,TotalNormalForce,PitchMoment,TotalLiftCoefficient,TotalDragCoefficient,WingBodyLiftCoefficient],[CL_syb,CLw_syb,CD_syb,Ctau_syb,alpha_e_syb,CLT_syb])
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 782, in solve
    solution = _solve_system(f, symbols, **flags)
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 1384, in _solve_system
    soln = _solve(eq2, s, **flags)
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 1099, in _solve
    return _solve(f_num.rewrite(tan), symbol, **flags)
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 1206, in _solve
    result = _tsolve(f_num, symbol, **flags)
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 1898, in _tsolve
    u = unrad(eq, sym)
  File "C:\Python27\lib\site-packages\sympy\solvers\solvers.py", line 2399, in unrad
    return (_mexpand(eq), cov, list(dens))
  File "C:\Python27\lib\site-packages\sympy\simplify\sqrtdenest.py", line 10, in _mexpand
    return expand_mul(expand_multinomial(expr))
  File "C:\Python27\lib\site-packages\sympy\core\function.py", line 1782, in expand_multinomial
    power_base=False, basic=False, multinomial=True, log=False)
  File "C:\Python27\lib\site-packages\sympy\core\cache.py", line 88, in wrapper
    func_cache_it_cache[k] = r = func(*args, **kw_args)
  File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2699, in expand
    expr, hit = Expr._expand_hint(expr, hint, deep=deep, **hints)
  File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2635, in _expand_hint
    arg, arghit = Expr._expand_hint(arg, hint, **hints)
  File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2635, in _expand_hint
    arg, arghit = Expr._expand_hint(arg, hint, **hints)
  File "C:\Python27\lib\site-packages\sympy\core\expr.py", line 2643, in _expand_hint
    newexpr = getattr(expr, '_eval_expand_' + hint)(**hints)
  File "C:\Python27\lib\site-packages\sympy\core\power.py", line 487, in _eval_expand_multinomial
    expansion_dict = multinomial_coefficients(len(p), n)
  File "C:\Python27\lib\site-packages\sympy\ntheory\multinomial.py", line 140, in multinomial_coefficients
    return dict(multinomial_coefficients_iterator(m, n))
  File "C:\Python27\lib\site-packages\sympy\ntheory\multinomial.py", line 231, in multinomial_coefficients_iterator
    t1 = _tuple(t)
MemoryError
 
 

Stefan Krastanov

unread,
Dec 17, 2012, 1:43:48 PM12/17/12
to sy...@googlegroups.com
I vaguely recollect that most versions of windows have some memory
limit for running processes. It may or it may not be that.

However, in any case if solve requires a few gigabytes of RAM to solve
your equation then probably the solution will not be pretty. If you
want a symbolic solution to gather insight on your problem, your best
bet is to do some preprocessing on your equations and see whether
there is some structure that you can use to help `solve`. If you just
need numerical solutions and don't care about performance just use
numerical solvers.

Finally, this may well be a bug in SymPy, however I am not convinced
for the moment.
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/zotKon4wh54J.
>
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.

Aaron Meurer

unread,
Dec 17, 2012, 5:10:02 PM12/17/12
to sy...@googlegroups.com
SymPy has a hard time inverting the sines and cosines, and that is
essentially the part of the code it gets stuck in (the rest of the
system is just polynomials). I don't hold out much hope, as our
algorithms for solving trig expressions are very limited at the
moment. Perhaps someone who knows his way around the solve code could
step through it and get some more insight.

Aaron Meurer

Renxian

unread,
Dec 18, 2012, 11:42:28 AM12/18/12
to sy...@googlegroups.com

thanks!!!
Reply all
Reply to author
Forward
0 new messages