[WIP] Add examples of usage of vector integration - #20021
Conversation
|
✅ Hi, I am the SymPy bot (v160). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.
Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed. |
🟠Hi, I am the SymPy bot (v160). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it. This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75. The following commits add new files:
If these files were added/deleted on purpose, you can ignore this message. |
Codecov Report
@@ Coverage Diff @@
## master #20021 +/- ##
=============================================
+ Coverage 75.849% 75.854% +0.005%
=============================================
Files 670 670
Lines 173699 173699
Branches 40978 40978
=============================================
+ Hits 131750 131759 +9
+ Misses 36209 36199 -10
- Partials 5740 5741 +1 |
| >>> sphere = ParametricRegion((r*sin(phi)*cos(theta),r*sin(phi)*sin(theta), r*cos(phi)), | ||
| ... (theta, 0, pi), (phi, 0, pi), (r, 0, 3)) | ||
| >>> vector_integrate(1, sphere) | ||
| -18*pi |
There was a problem hiding this comment.
why is this result negative? I would indeed expect 18*pi, the volume of the half-sphere, as you have defined theta to reach pi (instead of 2*pi).
There was a problem hiding this comment.
In ParametricIntegral class
variables = cls._bounds_case(parametricregion.limits)
coeff = Matrix(parametricregion.definition).jacobian(variables).det()
integrand = simplify(parametricfield*coeff)
l = [(var, parametricregion.limits[var][0], parametricregion.limits[var][1]) for var in variables]
result = integrate(integrand, *l)The volume element requires calculating the jacobian. So the sign depends on the order of variables used in the calculation of jacobian. This order is determined by the bounds_case function which topologically sorts the parameters to remove the problem of interdependent bounds.
So in the current form, the order in which the bounds are defined at the initialization of ParametricRegion object does not matter in the calculation of integral. Because in the end, parameters ger sorted by bounds_case function. Is this correct? Or should the result depend on the order of parameters and the sorting should only take place when required?
There was a problem hiding this comment.
For example,
sphere1 = ParametricRegion((r*sin(phi)*cos(theta),r*sin(phi)*sin(theta), r*cos(phi)),\
(theta, 0, pi), (phi, 0, pi), (r, 0, 3))
sphere2 = ParametricRegion((r*sin(phi)*cos(theta),r*sin(phi)*sin(theta), r*cos(phi)),\
(r, 0, 3), (theta, 0, pi), (phi, 0, pi))In the present implementation, vector_integrate(1, sphere1) and vector_integrate(1, sphere2) returns result with same sign.
Is this desired or should the order matter?
|
Any news? |
|
There are still some examples missing. |
|
|
||
| Consider a triangular lamina 𝑅 with vertices (0,0), (0, 5), (5,0) and with density :math:`\rho(x, y) = xy\:kg/m^2`. Find the total mass. | ||
|
|
||
| >>> triangle = ParametricRegion((x, y), (x, 0, 5), (y, 0, 5 - x)) |
There was a problem hiding this comment.
does this work with the polygon object as well?
There was a problem hiding this comment.
No. vector_integrate will perform line integral over the sides of the polygon instead of calculating the area enclosed.
There was a problem hiding this comment.
OK, maybe that's an issue for some future work.
There was a problem hiding this comment.
Yes. We can add new classes in geometry module for representing such regions.
There was a problem hiding this comment.
I will open an issue for this then.
There was a problem hiding this comment.
It would require an algorithm to decompose the polygon into triangles (or pyramids in the 3D case). Well, maybe for GSoC 2021 :)
There was a problem hiding this comment.
Yes, for polygons it will be difficult. But I think adding a class to represent a triangular area will be easier.
|
(Copied from sympy/vector gitter room) I still have some more things to add to this.
Apart from these points, I think this PR is ready to merge. Perhaps, I will make these changes in a separate PR. |
References to other Issues or PRs
#19320
Brief description of what is fixed or changed
Add examples highlighting the usage of SymPy's vector integration functionality.
Other comments
Release Notes
NO ENTRY