Hi all,

As this is my first message in this group, I will first introduce myself, 
my actual question starts in the next paragraph. I am a PhD student in 
physics. I am working on the modelling of organic solar cells by the 
so-called drift-diffusion approach, hence I plan on using sympy to deal 
with PDE and some systematic manipulations of them that I do by hand for 
now. I am quite familiar with python and its mainstream scientific 
libraries (I teach it as a TA) but I am new to sympy.

One of the first thing I tried to write in sympy was an equation of the 
following form, where  the divergence of some vector appears:

$$\frac{\partial c }{\partial t} - \vec\nabla . \vec{j_c} = 0 $$

However I found no way of writing this properly in sympy. 
Indeed, using the vector module does not take into account derivatives the 
way I expect it to, consider the following code:
import sympy as sp
import sympy.vector as spv

# Initialise coordinate system 
S = spv.CoordSysCartesian('S')
delop = spv.Del(S)

# Create a new field without explicit expression
u0, u1, u2 = sp.symbols('u0:3')
J1 = u0*S.i + u1*S.j + u2* S.k
J2 = S.x*S.i + S.y*S.j + S.z* S.k

# Derivatives surprised me
print('div(J1) = ', delop.dot(J1))
print('div(J2) = ', delop.dot(J2))
It's output goes as follow:

> div(J1) =  0
> div(J2) =  Derivative(S.x, S.x) + Derivative(S.y, S.y) + Derivative(S.z, S.z)
>
>
I assumed, however that the output would look like this:

> div(J1) =  Derivative(u0, S.x) + Derivate(u1, S.y) + Derivative(u2, S.z)
> div(J2) =  Derivative(S.x, S.x) + Derivative(S.y, S.y) + Derivative(S.z, S.z)
>
>
Is there a misunderstanding somewhere on my part or was sympy.vector not 
designed for this kind of purposes?

Right now I am planning on writing my own set of classes and method to 
handle these vectorial expressions, but before I do so I would like to be 
sure that I haven't misunderstood the issue.

Thank you very much for reading through,
Best regards,
Alexis Prel

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/0ef6b9d3-bb95-4d9e-a5df-cef7b76a2542%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to