Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support to integrate scalar/vector fields over objects of geometry module #19650

Merged
merged 6 commits into from
Jul 3, 2020

Conversation

friyaz
Copy link
Member

@friyaz friyaz commented Jun 26, 2020

References to other Issues or PRs

#19320

Brief description of what is fixed or changed

>>> from sympy.vector import CoordSys3D, vector_integrate
>>> from sympy.geometry import Point, Segment, Circle, Polygon
>>> C = CoordSys3D('C')
>>> s = Segment(Point(4, 3), Point(1, 1))
>>> vector_integrate(C.x*C.z, s)
11*sqrt(13)/2
>>> tri = Polygon((0, 0), (1, 0), (1, 1))
>>> vector_integrate(-5*C.y, tri)
-5*sqrt(2)/2 - 5/2
>>> c = Circle(Point(0, 0), 5)
>>> vector_integrate(1, c)
10*pi

Other comments

The integral takes place over the boundary of the geometric entity, not over the area or volume enclosed.

Release Notes

  • vector
    • Added support to integrate scalar/vector fields over objects of geometry module.

@sympy-bot
Copy link

sympy-bot commented Jun 26, 2020

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.

Your release notes are in good order.

Here is what the release notes will look like:

  • vector
    • Added support to integrate scalar/vector fields over objects of geometry module. (#19650 by @friyaz)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.7.

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.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
#19320 

#### Brief description of what is fixed or changed
```python
>>> from sympy.vector import CoordSys3D, vector_integrate
>>> from sympy.geometry import Point, Segment, Circle, Polygon
>>> C = CoordSys3D('C')
>>> s = Segment(Point(4, 3), Point(1, 1))
>>> vector_integrate(C.x*C.z, s)
11*sqrt(13)/2
>>> tri = Polygon((0, 0), (1, 0), (1, 1))
>>> vector_integrate(-5*C.y, tri)
-5*sqrt(2)/2 - 5/2
>>> c = Circle(Point(0, 0), 5)
>>> vector_integrate(1, c)
10*pi
```
#### Other comments
The integral takes place over the boundary of the geometric entity, not over the area or volume enclosed.
#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* vector
    * Added support to integrate scalar/vector fields over objects of geometry module.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@friyaz friyaz marked this pull request as draft June 26, 2020 16:09
vector_integrate function was modified to integrate
@friyaz friyaz marked this pull request as ready for review June 26, 2020 18:42
@friyaz friyaz requested a review from Upabjojr June 26, 2020 18:49
@codecov
Copy link

codecov bot commented Jun 26, 2020

Codecov Report

Merging #19650 into master will increase coverage by 0.008%.
The diff coverage is 95.833%.

@@              Coverage Diff              @@
##            master    #19650       +/-   ##
=============================================
+ Coverage   75.670%   75.678%   +0.008%     
=============================================
  Files          658       658               
  Lines       170977    171272      +295     
  Branches     40342     40420       +78     
=============================================
+ Hits        129379    129616      +237     
- Misses       35931     35989       +58     
  Partials      5667      5667               

sympy/geometry/curve.py Outdated Show resolved Hide resolved
@Upabjojr
Copy link
Contributor

First thought... I would try to avoid modifying the geometry module.

Since Python 3.5 there is the @singledispatch decorator, which can be used to create overloaded functions outside of classes (i.e. you can create a class method outside of a class or in another module).

@friyaz friyaz requested a review from Upabjojr June 30, 2020 13:10
@Upabjojr
Copy link
Contributor

Upabjojr commented Jul 1, 2020

This one looks ok.

sympy/vector/integrals.py Outdated Show resolved Hide resolved
@friyaz friyaz requested a review from Upabjojr July 2, 2020 10:54
sympy/vector/integrals.py Outdated Show resolved Hide resolved
@friyaz friyaz requested a review from Upabjojr July 3, 2020 05:35
@Upabjojr Upabjojr merged commit d4fadd7 into sympy:master Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants