Hello Oscar.

Thank you very much for the reply. Yes, I am indeed looking at the source. I 
think Faisal identified the problem in his response and I look forward to being 
a part of the discussion to address it. The SymPy community seems very open, 
and I appreciate that. 

Joe Heafner
Sent from my iPad

> On Jul 19, 2021, at 05:37, Oscar Benjamin <oscar.j.benja...@gmail.com> wrote:
> 
> Hi Joe,
> 
> The vector integration functionality is relatively new. It was added
> last year I think in a GSOC project. It's possible that this is a bug
> or a corner case that wasn't fully considered.
> 
> Have you looked into the code at all?
> 
> Oscar
> 
>> On Sun, 18 Jul 2021 at 00:19, Joe Heafner <heafn...@gmail.com> wrote:
>> 
>> Hello everyone.
>> 
>> I teach undergraduate physics and have used Python, specifically VPython, 
>> for going on 20 years although I am by no means an expert. I am interested 
>> in incorporating computation (with Python using Jupyter Notebook) into 
>> introductory calculus-based mechanics and electromagnetic theory courses. I 
>> have an MS in physics and have taught for 30 years. I am a Python and LaTeX 
>> evangelist.
>> 
>> I am relatively new to SymPy and am amazed at its power. I want to bring 
>> this power into the introductory undergraduate physics curriculum.
>> 
>> Now that you know a bit about me, I have some questions about orienting 
>> surfaces defined with ParametricRegion. After a lot of online searching, I 
>> found this discussion
>> 
>> https://github.com/sympy/sympy/issues/19320
>> 
>> which doesn't seem to address my questions so was directed here by the SymPy 
>> Twitter feed.
>> 
>> Here is my specific situation. Consider the integral of a vector field over 
>> a surface to calculus flux.
>> 
>> from sympy import *
>> from sympy.vector import *
>> C = CoordSys3D('C')
>> a, b, c = symbols('a b c', positive=True)
>> x, y, z, F = symbols('x y z F')
>> F = 3*(-C.k)  # F points in the -z direction
>> 
>> Consider a square with vertices (0,0),(5,0),(5,5),(0,5). Treat the square as 
>> a Type 1 region, doing the y integral first.
>> 
>> square = ParametricRegion((x,y),(,y,0,5),(x,0,5))
>> vector_integrate(F, square)
>> 
>> I get 75 as the answer, which means that square must have an orientation in 
>> the -z direction. I can justify that by noting that the order in which I 
>> defined the parameters implies such an orientation ( yhat \times xhat = 
>> -zhat)
>> 
>> Now if I treat the square as a Type 2 region, doing the x integral first, I 
>> get a different answer.
>> 
>> square = ParametricRegion((x,y),(x,0,5),(y,0,5))
>> vector_integrate(F, square)
>> 
>> I get -75 as the answer, which means that square must have an orientation in 
>> the +z direction. I can also justify this because note that I reversed the 
>> order of the parameter definitions (xhat \times yhat = +zhat). Reversing the 
>> definitions reverses the surface's orientation. No problem.
>> 
>> Now here's where my trouble begins. Consider now a triangular region with 
>> vertices (0,0),(5,0),(0,5). Treat the triangle as a Type 1 region, doing the 
>> y integral first.
>> 
>> triangle = ParametricRegion((x,y),(x,0,5),(y,0,5-x))
>> vector_integrate(F, triangle)
>> 
>> I get 75/2, which means triangle must have an orientation in the -z 
>> direction. This does NOT seem to follow the convention from the previous 
>> example since I specified the parameter definitions in the order that I 
>> thought would give triangle an orientation in the +z direction but 
>> apparently that is wrong. Unlike with square, reversing the order of the 
>> parameter definitions doesn't change the orientation.
>> 
>> Now if I treat the triangle as a Type 2 region, doing the x integral first I 
>> get a different answer.
>> 
>> triangle = ParametricRegion((x,y),(x,0,5-y),(y,0,5))
>> vector_integrate(F, triangle)
>> 
>> I get -75/2, which means triangle must have an orientation in the +z 
>> direction, which, again, doesn't match my intuition from the square example. 
>> Also once again, reversing the order of the parameter definitions doesn't 
>> change the orientation.
>> 
>> With square, I can EITHER change the order of the parameters themselves 
>> (e.g. (x,y) vs. (y,x)) OR change the order of the parameter definitions 
>> (e.g. (x,0,5),(y,0,5) vs. (y,0,5),(x,0,5)).
>> 
>> With triangle, it seems that changing the order of the parameters themselves 
>> (e.g. (x,y) vs. (y,x)) DOES change the surface's orientation but changing 
>> the order of the parameter definitions DOES NOT. If I keep the order of the 
>> parameters the same (e.g. always (x,y)) then the only way to change 
>> triangle's orientation is to treat it as either a Type 1 or Type 2 region.
>> 
>> Here is my ultimate question. What rule(s) is/are used internally to orient 
>> a surface and why does the rule(s) appear to be different for different 
>> surfaces as I have presented here? How/why does a Type 1 region's 
>> orientation differ from a Type 2 region's orientation? They seem to collapse 
>> to behavior with square when the integral is the same regardless of whether 
>> it's written for a Type 1 or Type 2 region. I have never seen that addressed 
>> in calculus UNLESS different forms are used. Am I missing something obvious? 
>> Am I missing something subtle? I can't seem to find a consistent SymPy rule 
>> for surface orientation. Does one exist?
>> 
>> I look forward to responses!
>> Joe
>> 
>> --
>> 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+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/sympy/2a688b87-2616-49ab-b62e-42b417b48cb5n%40googlegroups.com.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "sympy" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/sympy/zy9gQH9gMvQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> sympy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAHVvXxRcbYHAcncvcMtdURGQ134RD9XevcyvBDhGFumeaTP2wg%40mail.gmail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/A34BD106-73B2-430A-99AB-F6C48A392A66%40gmail.com.

Reply via email to