0% found this document useful (0 votes)
22 views

LAB SET 06

The document outlines a lab set focused on finding the gradient, divergence, and curl of vector functions, along with their geometrical interpretations. It includes Python code using the SymPy library to compute these mathematical operations and demonstrates the application of Green's Theorem for evaluating a specific integral. The results of the computations for each operation are presented, showcasing the outputs of the gradient, divergence, and curl calculations.

Uploaded by

jeevanambkj555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

LAB SET 06

The document outlines a lab set focused on finding the gradient, divergence, and curl of vector functions, along with their geometrical interpretations. It includes Python code using the SymPy library to compute these mathematical operations and demonstrates the application of Green's Theorem for evaluating a specific integral. The results of the computations for each operation are presented, showcasing the outputs of the gradient, divergence, and curl calculations.

Uploaded by

jeevanambkj555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

LAB SET 06: Finding Gradient, Divergent, Curl and their

Geometrical interpretation and Verification of Green's Theorem


1. To find Gradient of 𝝋 = 𝒙𝟐 𝒚 + 𝟐𝒙𝒛 − 𝟒
Program Code:
from sympy.vector import*
from sympy import symbols
N=CoordSys3D('N')
x,y,z=symbols('x y z')
A=N.x**2*N.y+2*N.x*N.z-4
delop=Del()
display(delop(A))
gradA=gradient(A)
print("\n Gradient of {A} is\n")
display(gradA)

Output:
∂ ∂ ∂
( xN2 yN + 2xN zN − 4) iN + ( (xN2 yN + 2xN zN − 4)jN + ( (xN2 yN + 2xN zN
∂xN ∂yN ∂zN
− 4))k N
Gradient of {A}is

2xN yN + 2zN iN + xN2 jN + (2xN ) k N

2. To find Gradient of 𝑭 = 𝒙𝟐 𝒚𝒛𝒊+𝒚𝟐 𝒛𝒙𝒋+𝒛𝟐 𝒙𝒚𝒌


Program Code:
from sympy.vector import*
from sympy import symbols
N=CoordSys3D('N')
x,y,z=symbols('x y z')
A=N.x**2*N.y*N.z*N.i+N.y**2*N.z*N.x*N.j+N.z**2*N.x*N.y*N.k
delop=Del()
divA=delop.dot(A)
display(divA)
print("\n Divergence of {A} is \n")
display(divergence(A))

Output:
∂ ∂ ∂
xN yN zN2 +∂y xN yN2 zN + ∂x xN2 yN zN
∂z N N N

Divergence of {A} is
6xN yN zN

3. To find Curl of 𝑭 = 𝒙𝟐 𝒚𝒛𝒊+𝒚𝟐 𝒛𝒙𝒋+𝒛𝟐 𝒙𝒚𝒌


Program Code:
from sympy.vector import*
from sympy import symbols
N=CoordSys3D('N')
x,y,z=symbols('x y z')
A=N.x**2*N.y*N.z*N.i+N.y**2*N.z*N.x*N.j+N.z**2*N.x*N.y*N.k
delop=Del()
curlA=delop.cross(A)
display(curlA)
print("\n Curl of {A} is \n")
display(curlA)

Output:
∂ ∂ ∂ ∂ ∂
(∂y xN yN zN2 -∂z xN yN2 zN )iN + − ∂x xN yN zN2 + ∂z xN2 yN zN jN + (∂x xN yN2 zN −
N N N N N

xN2 yN zN ) kN
∂y N

Curl of {A} is (−xN yN2 + xN zN2 )iN + xN2 yN − yN2 zN jN + (−xN2 zN + yN2 zN ) ) k N
METHOD II:
1.To find gradient of ∅ = 𝑥 2 𝑦𝑧
Program Code:
from sympy . physics . vector import *
from sympy import var , pprint
var ('x,y,z')
v= ReferenceFrame ('v')
F=v[0] ** 2*v[1]*v[2]
G= gradient (F,v)
F=F. subs ([(v[0],x) ,(v[1],y) ,(v[2],z)])
print (" Given scalar function F=")
display (F)
G=G. subs ([(v[0],x) ,(v[1],y) ,(v[2],z)])
print ("\n Gradient of F=")
display (G)

Output:

Given scalar function F=𝑥 2 𝑦𝑧

Gradient of F=
2𝑥𝑦𝑧𝐯̂ 𝐱+𝑥2𝑧𝐯̂ 𝐲+𝑥2𝑦𝐯̂ 𝐳

Green's Theorem (only for Mech and EEE )


Using Green's theorem,evaluate [ 𝑥 + 2𝑦 𝑑𝑥 + (𝑥 − 2𝑦)𝑑𝑦], where c is the
region boundede by coordinate axes and the line x=1 and y=1.
Program Code:

from sympy import*


var('x,y')
p=x+2*y
q=x-2*y
f=diff(q,x)-diff(p,y)
soln=integrate(f,[x,0,1],[y,0,1])
print("I=",soln)
Output:
('I=', -1)

You might also like