ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 13 May 2018 19:16:11 +0200Curl in 2D Manifoldshttps://ask.sagemath.org/question/42322/curl-in-2d-manifolds/I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.
I noticed curl is not defined in a 2D manifold, why is that?
E = Manifold(2, 'E', structure='Riemannian')
cartesian.<x,y> = E.chart()
E.metric()[:] = identity_matrix(2)
v = E.vector_field(name='v')
v[:] = [-x, y^2]
cv = v.curl()
cv.display()
ValueError: the curl is not defined in dimension lower than 3
Reference: [The Divergence and Curl of a Vector Field In Two Dimensions ](http://mathonline.wikidot.com/the-divergence-and-curl-of-a-vector-field-in-two-dimensions)
Sun, 13 May 2018 10:42:57 +0200https://ask.sagemath.org/question/42322/curl-in-2d-manifolds/Answer by eric_g for <p>I'm using SageMath 8.2 on a Windows 10 Native with Jupyter Notebook.</p>
<p>I noticed curl is not defined in a 2D manifold, why is that?</p>
<pre><code>E = Manifold(2, 'E', structure='Riemannian')
cartesian.<x,y> = E.chart()
E.metric()[:] = identity_matrix(2)
v = E.vector_field(name='v')
v[:] = [-x, y^2]
cv = v.curl()
cv.display()
</code></pre>
<p>ValueError: the curl is not defined in dimension lower than 3</p>
<p>Reference: <a href="http://mathonline.wikidot.com/the-divergence-and-curl-of-a-vector-field-in-two-dimensions">The Divergence and Curl of a Vector Field In Two Dimensions </a></p>
https://ask.sagemath.org/question/42322/curl-in-2d-manifolds/?answer=42323#post-id-42323I am not sure the curl of a vector field is well defined on a 2-dimensional manifold. The reference you mention actually deals with vector fields in $\mathbb{R}^3$. In dimension 2, one could define the curl by taking the Hodge dual of the exterior derivative of the 1-form that is associated to the vector field by metric, i.e. define
$\mathrm{curl}\ v = *(\mathrm{d}v^\flat)$; this would lead a scalar field (not a vector field!) and I don't know if this is very useful.
If you really need it, you can define a Python function like this:
def curl(v):
if dim(v.domain()) == 2:
g = v.domain().metric()
return v.down(g).exterior_derivative().hodge_dual(g)
else:
return v.curl()
Then
v = E.vector_field(name='v')
v[:] = [-x, y^2]
cv = curl(v)
print(cv)
cv.expr()
yields
Scalar field on the 2-dimensional Riemannian manifold E
0
A nonzero curl is obtained as follows:
v[:] = -y , x
curl(v).expr()
It results in
2Sun, 13 May 2018 11:58:31 +0200https://ask.sagemath.org/question/42322/curl-in-2d-manifolds/?answer=42323#post-id-42323Comment by danielvolinski for <p>I am not sure the curl of a vector field is well defined on a 2-dimensional manifold. The reference you mention actually deals with vector fields in $\mathbb{R}^3$. In dimension 2, one could define the curl by taking the Hodge dual of the exterior derivative of the 1-form that is associated to the vector field by metric, i.e. define
$\mathrm{curl}\ v = *(\mathrm{d}v^\flat)$; this would lead a scalar field (not a vector field!) and I don't know if this is very useful. </p>
<p>If you really need it, you can define a Python function like this:</p>
<pre><code>def curl(v):
if dim(v.domain()) == 2:
g = v.domain().metric()
return v.down(g).exterior_derivative().hodge_dual(g)
else:
return v.curl()
</code></pre>
<p>Then</p>
<pre><code>v = E.vector_field(name='v')
v[:] = [-x, y^2]
cv = curl(v)
print(cv)
cv.expr()
</code></pre>
<p>yields</p>
<pre><code>Scalar field on the 2-dimensional Riemannian manifold E
0
</code></pre>
<p>A nonzero curl is obtained as follows:</p>
<pre><code>v[:] = -y , x
curl(v).expr()
</code></pre>
<p>It results in </p>
<pre><code>2
</code></pre>
https://ask.sagemath.org/question/42322/curl-in-2d-manifolds/?comment=42326#post-id-42326Thanks Eric.Sun, 13 May 2018 19:16:11 +0200https://ask.sagemath.org/question/42322/curl-in-2d-manifolds/?comment=42326#post-id-42326