Equation of Continuity and the Derivative of a Scalar following the Motion:
Section 3.1 in BS&L
> restart;
> with(linalg):
> Ds:=(s,v)->diff(s,t)+v[1]*diff(s,x)+v[2]*diff(s,y)+v[3]*diff(s,z); The derivative of a scalar: s following the motion of a fluid moving
with velocity v.
> v:=vector([vx(x,y,z,t),vy(x,y,z,t),vz(x,y,z,t)]);
> Ds(s(x,y,z,t),v); This gives the derivative following the fluid motion for a scalar s
> DDv:=v->diverge(v,vector([x,y,z]));
> DDv(v); The divergence of the vector v wrt position vector [x,y,z]
> eqcont1:=diff(rho(x,y,z,t),t)+DDv(evalm(rho(x,y,z,t)*v)); eq 3.1-4
> eqcont2:=Ds(rho(x,y,z,t),v)+rho(x,y,z,t)*DDv(v); eq 3.1-6
> simplify(eqcont1-eqcont2); Showing the 3.1-4 and 3.1-6 are identical.
> eqcon2a:=(rho,v)->Ds(rho,v)+rho*DDv(v); A more general form of the continuity equation that can be used for simplified cases.
> eqcon2a(rho(x,y,z,t),vector([vx(x,y,z,t),vy(x,y,z,t),vz(x,y,z,t)]));
> simplify(%-eqcont2);
> eqcon2a(rho(x,y),vector([vx(x,y),vy(x,y),0])); For steady flow in the x and y directions
> eqcon2a(rho,vector([vx(x,y),vy(x,y),0])); For the same case, but with rho constant.
>