11
$\begingroup$

Why I get the error below with this code:

Needs["VectorAnalysis`"]

ρ = 1000;
g = 9.80665;
μ = 0.001;
p[x_, y_, z_, t_] = {x^2, Sqrt[y], -z, t^3};
f[x_, y_, z_, t_] = {-x^2, Sqrt[y]/2, z, t^2};

ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f

Error:

Set::write: "Tag Times in 1000\ Dt[v,t] is Protected."
$\endgroup$
2
  • 2
    $\begingroup$ Are you trying to solve the Navier Stokes's equation? IF so, you should look at NDSolve... If you are just trying to get rid of the error, switching = with == in the final line helps... check ref/character/Equal in Mathematica Help. $\endgroup$
    – dearN
    Commented Oct 10, 2012 at 19:36
  • 1
    $\begingroup$ See also: How do I identify the source of a “Tag times protected” error? $\endgroup$
    – Mr.Wizard
    Commented Feb 3, 2016 at 6:56

1 Answer 1

15
$\begingroup$

Any time you try to execute a command of the form a*b=c, you'll generate this error:

enter image description here

Of course, that's exactly what you've done in your last line:

ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f

We can see the issue more clearly if we examine the left side of the equation in FullForm

FullForm[a*b]
(* Out: Times[a,b] *)

Furthermore, Times is protected.

Attributes[Times]
(* Out: {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected} *)

Thus, you're trying to set the value of a protected symbol. As rm-rf points out, it's not just about removing the ρ, as otherwise you're trying to set the value of Dt.

Perhaps more to the point - if you want to represent an equation that you want to solve, you should type:

ρ Dt[v, t] == -Gradient[p] + μ Laplacian[v] + f

Note the double equals sign. This tests for equality, rather than setting a value - which is what you generally want when solving an equation.

$\endgroup$
1
  • $\begingroup$ Could you explain a bit more about the why? OP clearly has no clue why it happened, and if he merely takes this suggestion and removes the ρ to not make it of the form a*b=c, then he'll get a Tag Dt is Protected error... back to square 1 :) $\endgroup$
    – rm -rf
    Commented Oct 10, 2012 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.