# Density of charge and current loop

Given that $D = (r^2cos(phi/2)$, $rsin(phi/2), 0)$ in cylindrical coordinates represents an electric flux density, calculate the total charge inside the closed surface defined by $r = 1$, $z = 0$, and $z = 1$.

Local Gauss law is

$∇D=ρ$

In cylindrical coordinates

$∇=(d/d r)*D_r+(1/r)*(d/dφ)*D_φ+(d/dz)*D_z$ so that

$2r*cos φ/2+(1/r)*r*(1/2)*cos φ/2+0=ρ$

$ρ=cos φ/2*(2r+1/2)$

The charge inside the given volume is (volume element in cylindrical coordinates is $d V=r*d r*dφ*dz$)

$Q_inside=∫_0^1 ∫_0^2π∫_0^1 ρ*rdrdφdz=∫_0^1∫_0^2π (2r^2+r/2)*cos φ/2*drdφ=∫_0^10*d r=0$

The magnetic field in a given region is $B=k(y+z)zhat x$. What is the force on the square loop of side $a$ centered on origin in the plane (yz), if it has a clockwise current $I$

$overrightarrow{B}(y,z)=k(y+a)z*hat x$

$d F=I(d L ×B)$ so that

$F=I∮B d L=$

$=I{int_a^{-a} k(y+a)*a*d y+ int_a^{-a} k(-a+a)z*dz+int_{-a}^a k(y+a)(-a)d y+int_{-a}^a k(a+a)z*dz}$

$F=I k a{-2∫_{-a}^a (y+a)d y+ 2∫_(-a)^a z d z}=2Ika(-2a^2+0)=-4Ika^3$