Hi Omar,

On Wed, Nov 10, 2010 at 10:56 AM, Omar Awile <omar.aw...@gmail.com> wrote:
> Hi all,
>
> I've recently started playing around with sympy. I am mainly
> interested in the fcode printer module as I would like to be able to
> write symbolic expressions and generate on the fly fortran code that
> is inserted into a fortran subroutine that is part of a larger
> parallel code.
>
> After trying out a couple simple examples that compiled nicely into
> fortran code I tried an example that is slightly more complicated, but
> I can't seem to figure out how to write this properly in sympy. So
> here is what I would like to express
>
> $dw_p = \frac{V_p}{e^2} \sum_{q=1}^{N}{(w_p - w_q) \mu (x_p - x_q)}
> \forall p=1,...,N$
>
> In fortran this would be something like
>
> do p=1,n
>   do q=1,n
>      dw(p) = dw(p) + (w(p) - w(q))*mu*(x(p)-x(q))
>   enddo
>   dw(p) = dw(p)*(V(p)/(e**2))
> enddo
>
> I tried to accomplish this with following python/sympy code:
> http://codepad.org/O7L70QJV
>
> But when I try to run this I get an exception:
> IndexConformanceException: Indices are not consistent: -w[p] + w[q]
>
> I must be doing something wrong, but I don't quite get what..
> (actually the code I tried doesn't even contain the $\frac{V_p}{e^2}$,
> but I don't know how to express this properly, apart from using
> sympy.sum, but the fcode printer doesn't like sum.)
>
> I was looking a bit through the documentation but wasn't sure were to
> look actually and I even bugged the devs in the IRC channel who
> adviced me to post this to the mailinglist. So I hope I'm not asking a
> too obvious question...

Øyvind wrote this code, so maybe he can comment. Otherwise it just has
to be debugged why it is behaving as it is.

I am very interested in how you insert the code into your fortran
code. Do you generate a simple module, compile it and link it? Or how
do you insert it on the fly?

Ondrej

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sy...@googlegroups.com.
To unsubscribe from this group, send email to 
sympy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to