Prasoon Shukla--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
First of all, I think it would be nice to start writing a wiki page
with the proposal as the general idea seems clear enough.
Second (and most important in this message), I would vote for
completely forgetting about anything outside 3D. Implementations of
vector calculus in Rn should be done (and are done to some extend) in
the geometrical algebra and differential geometry modules (and the
tensor canonicalization pull request by Pernici). The whole idea of a
vector calculus module, in my opinion, is that when working in R3 you
do not need all these generalized notions of, e.g, curl or vector
product in terms of completely antisymmetric tensors.
Obviously, we would love to have `rewrite_as` methods to couple it to
the diffgeom/ga/tensor modules but that does not mean it is a good
idea to use, for instance, the diffgeom module as a basis for your
project. It can be done and for puritans it will indeed be a deep
example of code deduplication/reuse and object oriented blah blah.
However, the code will be harder to understand and the obvious notions
of R3 calculus will be hidden behind their generalizations.
And simply from a practical standpoint, the mechanics module is
already based around R2/R3. It is more important to abstract that away
than to generalize it to cases that will not be used.
The rest of my comments are below, annotating your message.
> @Gilbert: I have been thinking along the lines of the mechanics module and
> as Stefan mentioned, I plan (at least right now) to take this idea forward
> with component wise operations on vectors. For component independent vector
> algebra, any numerical operation on any vector will inevitably get reduced
> to operations on scalars (individual components). Therefore, I believe, that
> a large part of component dependent vector operations will form a subset to
> a more complete component independent vector algebra. So definitely, in the
> long term, we will be able to extend this vector module to play nice with
> component free vector algebra, just as Raoul mentioned.
It is a bit unclear what you mean by "component dependent". Here are
the two ways this can be understood:
1. Simply using matrices without "metadata". I consider this a very
bad idea as a matrix is just a representation of the geometrical
entity vector and all that can be done this way is already in the
matrix module.
2. Using some symbolic object containing
- reference to the "world" in which we work
- reference to the reference/basis in which we represent the vector
- the coordinates in this basis, which is a matrix
EDIT: I see that you actually use the second approach. Great!
> Also, and just as you mentioned, Vector in mechanics can be extended because
> the user does not directly interact with vector objects. This means that, at
> least for mechanics, we won't have too many problems as far as integration
> with the new module is concerned. Of course, this problem remains for other
> modules (quantum, electricity-magnetism modules proposed by Sachin). For
> those, I will interact with people in the community for their requirements
> and hopefully, decide on an idea that keeps everyone happy, or at least,
> which keeps most of the people happy.
I would say, leave quantum away. Hilbert spaces in quantum mechanics
are sufficiently different from R3 to necessitate their own
implementation. On the other hand, I strongly suggest that this
project you are preparing be the basis for the electrodynamics project
by Sachin. You should definitely work together on this.
> Taking a clue from diffgeom, we are defining a coordinate system first (with
> 'rect' providing the basic cartesian coordinates, the definitions of which
> are inbuilt. We can have similar functionality for other commonly used
> coordinate systems). Then, we instantiate a vector and give it symbols to
> use for coordinates. The dimension of the vector can be calculated
> internally using the second n-tuple. The basis for any Rn space will be just
> the standard basis. Then, we can have component-wise operations that produce
> the result; in this case divergence and curl of the given vector field.
> Also, for the n-dimension case, we can have something like:
>>>> v = Vector(dim=7, symbol=y, coord=coord)
Mostly agree, but drop dim!=3. And I have a lot of technical comments
concerning the the `symbol` argument, but they can wait for later.
>
> Here, the coord object will carry the relations with one of the standard
> coordinate systems and that will be used to define all the operations of
> vector calculus.( The coord object can be generated by performing operations
> on CoordSystem object of some standard coordinate system perhaps?)
>
> This will generate a vector (unbound?) where the coordinates wrt to the
> standard basis (e1, ... , e7) are just (y1, y2, y3 ... y7).
Concerning the very important "unbound?" question. In your first
example `Vector` is actually a vector field, i.e. bound vector for
physicists (there is a difference between vector field and a bound
vector but drop it for the moment). In your second example `Vector` is
actually a vector, not a vector field. Vector analysis cares about
vector fields, so just completely drop the unbounded vectors from your
proposal. They have place in linear algebra module, in matrix
expressions module and in hilbert spaces module (the quantum module),
not here.
PS
By the way, this question show an issue that must be discussed a lot
before we are clear about how to proceed. The mechanics module deals
with bounded vectors, not vector fields. The electrodynamics module
and your vector analysis module would deal with vector fields. How can
these two notions can be combined (is it possible/practical)? I would
like to see this discussed in your proposal.
Here is an example of the issue:
1. a field
some_vortex_field = Vector((-y, x, 0), (x, y, z))
2. a bounded vector
some_force_on_some_point = Vector((1,2,0), (p_x, p_y, p_z))
The first example is what one will do in electrodynamics do define
some field. You can calculate its curl for instance.
The second example is something from the mechanics module. The point
is for instance some joint that we are studying and the vector is the
force at that point.
Does it make sense to represent both these objects with the same class?
I think Stefan probably did a better job with the terminology than I could do, and covered a lot of points. Unfortunately, as a mechanical engineer, my terminology is a bit sloppy on these topics.What ReferenceFrame really does, is provide a set of orthonormal basis vectors to define other vectors with; ReferenceFrame also provides functionality for keeping track of rotations between these orthonormal bases. The concept of an inertial frame is specified later, when equations of motion are constructed and it matters (I'm not sure if that is true for EM fields?). We didn't really allow for translation of ReferenceFrame's, but instead wrote it as if there was no knowledge of translation position/velocity/acceleration of one ReferenceFrame w.r.t. another. This places the burden on the end user to correctly define velocities of points in multiple frames.
In mechanics, we treated all vectors as vector functions. We didn't really make a distinction between bound and free vectors - there didn't seem to be a "clean" way to do it.Perhaps you could change the ReferenceFrame of mechanics into something such as OrthonormalBasis? Other basis types could then be created. A ReferenceFrame would then need to be instantiated with a basis type. This could allow multiple bases to be embedded within one ReferenceFrame (all fixed relative to each other). While I've never attempted (nor needed to nor previously thought about) this, I would imagine that you could extend this to include other types of bases (e.g. spherical) and still allow for algebraic operations between vectors defined in this way.Example:If we had a vector written with an orthonormal basis: v = 1 * e_x + 2 * e_y + 3 * e_zand another written with a spherical basis: u = 4 * e_r + 5 * e_theta + 6 * e_phithat they could be added/subtracted/dotted, e.g. u + v = 1 * e_x + 2 * e_y + 3 * e_z + 4 * e_r + 5 * e_theta + 6 * e_phiDoes that sound right?
Maybe the code could look something like this:A = ReferenceFrame('A', 'orthonormal')A.attach_basis('spherical', _some_initial_orientation_info_)v = A.x + A.yu = A.r + A.thetaMaybe it's possible to extend this to include translational information also?
@Raoul: I still haven't chosen to restrict anything yet. It's just that Stefan had mentioned that I should stay away from things other than R3. But, Rn would obviously be more desirable (just as your post mentioned). Hence the poll.
--
@Prasoon, I recently did a bit of study and planning about our coordination on vector calculus as far as our GSoC proposals are concerned. I will post my total concept of the module by first week of April (@asmeurer, is this a good enough deadline? considering this project will need lots of inputs from the sympy.physics community) but I want to clear up a few things, to make your work (and mine) easier.
1. How do you plan to implement Gauss' theorem (divergence) and Stoke's fundamental theorem of curl? I am not talking about the actual implementation here, I would like to have an idea about the API of the functions/methods that you plan to implement. I know this is a bit early for such questions maybe, but I would appreciate it if you clarify this before I upload my proposal. Just a pointer this one.
2. I would also need a look at your API for vector field functions to integrate them with some functions I plan to implement for scalar potential fields. I am not clear about this concept myself (and whether implementing scalar fields is necessary), but having methods to return vector fields from potential field gradients would a good idea. I would like the community's views on this.3. Do you plan to implement methods for polar and cylindrical coordinates?4. As your work would primarily deal with functions of the coordinates themselves, we would have to collaborate to integrate time-based fields into your work (maybe an auxiliary PR to your branch from my side, or extension of your classes as a part of my work). This is more of a query to our potential mentors here. What do you people think would be the best course of action in this case?
Okay, so I have been away a while due to a lot of reasons. Fortunately, I will have time from now on for about 3 weeks. As of now, I have a working API of the Coordinate System class, the Vector class, and, the Reference Frame class. The Reference Frame class is where I will try to implement all of the time dependent functionality. I will explain all of these in detail soon in my proposal on the wiki.The next thing that I am trying to think of is the Vector.integrate() method. As is obvious, we will use it for integration over vector and scalar fields.Now, the first thing is to have a VectorIntegral class that would represent an integral complete with the field, the type (line, area or volume) and the path/area/volume to integrate over. The problem I am having now is this: Right now, SymPy can solve integrals symbolically for the one-dimensional case. I need to implementa) Line integrals - For this I need some notion of a path. Right now, the integrate function in SymPy takes only straight paths (that is we can only provide end points and the path is just one of the coordinate axes). But, I need support for three dimensional paths. One solution I thought of is to have a class called Path that would contain the parametric definitions for the path. The methods in this class can further be used as helpers to evaluate the integral. This can be done by reducing the line integral into simple integral in one variable which SymPy can already evaluate.
b) Surface Integrals - Again, I need some way to represent an area. So, perhaps a Surface class will do the job? Implementation will be similar as mentioned above.c) Volume Integrals - Needs a Volume class. Similar implementation.The implementation of a Path, Surface and a Volume class seems to be the solution to this problem at this point. If anyone else has a better idea, please do tell. Otherwise, I think I'll go ahead with this.Another problem that I have right now is this: How do I calculate the multiple integrals that will arise in evaluating the above three cases? I think that this can be implemented with some work in the integration module, which I'll have to do at a later stage.But then again, SymPy is a symbolic maths library, and, the computations of the above mentioned integrals will be numerical in nature. So, I think that we may not need too many major changes to be able to implement this. For example, line integrals can just be reduced to integrals in one variable. Surface and volume integrals will need to be reduced to simple integrals in 2 and 3 dimensions and then be evaluated.
Anyway, these are just the ideas in my mind. And admittedly, they are in a crude form. Hopefully, in a day or two, I'll have more refined ideas to go on with. In the meantime, please make do tell any suggestions/changes that you gentlemen think should be there.Thanks
--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
> a) Line integrals - For this I need some notion of a path. Right now,I considered doing this for contour integrals in the complex plane
> the integrate function in SymPy takes only straight paths (that is we
> can only provide end points and the path is just one of the
> coordinate axes). But, I need support for three dimensional paths.
> One solution I thought of is to have a class called Path that would
> contain the parametric definitions for the path. The methods in this
> class can further be used as helpers to evaluate the integral. This
> can be done by reducing the line integral into simple integral in one
> variable which SymPy can already evaluate.
some long time ago. If you do it the "right" way, then the code could
maybe be reused for that case too. Although the typical paths in contour
integrals are somewhat specific combinations of circles and lines.
(I hoped that I could parametrize this all with the usual epsilons.)
I have the hope that one could get away with just a single parametric
> b) Surface Integrals - Again, I need some way to represent an area.
> So, perhaps a Surface class will do the job? Implementation will be
> similar as mentioned above.
>
> c) Volume Integrals - Needs a Volume class. Similar implementation.
>
> The implementation of a Path, Surface and a Volume class seems to be
> the solution to this problem at this point. If anyone else has a
> better idea, please do tell. Otherwise, I think I'll go ahead with
> this.
object depending on as many parameters as necessary:
L(u) := L(u_1, u_2, ..., u_n)
would then represent an integral over an N-dimensional hypervolume
(path: n=1, surface: n=2, volume: n=3 and so on) and the integral
Int(f , L) --> Int( f(L(u)) |J L| du
--> Int(...Int( f(L(u_1, ..., u_n)) |J L| du_1, ..., du_n
It is for sure not easy to do this all the correct way such
that all fits well together. But I think it's worth thinking
about it!
There is the most general version of the Stoke's theorem:
http://upload.wikimedia.org/math/8/e/4/8e4e3b1cd7d06acf2438e40509c4f4e7.png
in this notation independent on dimension of the "volume" Omega
and its border dOmega. From this we can get all others, and that
is the point why I think it should be possible to do this in a
mostly dimension agnostic way.
--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
I think I have a fair idea of what the class may behave like. Let's have a vector field like so (an example):v(x, y, z) = f (x, y, z) i + g (x, y, z) j + h (x, y, z) kJust and example in rectangular coordinates using variables x, y and z.Now, we can have a class, say ParamSpace(). Let us define a spherical surface like so:p = ParamRegion(x=5*sin(u)*cos(v), y=5*sin(u)*sin(v), z=5*cos(u), params=[u, v], bounds=[(u, 0, PI), (v, 0, 2*PI) ])This object can then be passed to Vector.integrate() and can serve as the container for defining the region of integration.Obviously, one problem is how to implement multiple patches. I am still thinking on it.After this, the next step is the integration itself. This means I need to add functionality to the integration module so that it can handle multiple integrals too. (I couldn't find any such functions already existing in SymPy. Is there any implementation of it?).
Another problem is with vector calc theorems. For example, if you have a contour for a line integral, what area do you choose for applying the Stokes theorem (as the area can be any that has the contour as its boundary)? Similarly for Gauss theorem too. I am still thinking in this direction. Will post here when something occurs to me.
--
Some of your examples in the interface section don't make any sense.
For example:
>>> w = 5*v
w
>>> f = w - 4*v
>>> f is v
True
If you wish you can think of the dual of a vector (a one-form) as a
one row matrix (and the vector as a one column matrix).
If you have a scalar product operation defined there is a canonical
way to get a dual of a vector.
For the vector v and scalar product <,>, the oneform for the vector is
v' such that v'(v) = <v, v>
Also, I have added the proposal to the melange portal. Here:
--
--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
--
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 sympy+un...@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.