Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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."
share|improve this question
1  
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. –  drN Oct 10 '12 at 19:36
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
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 :) –  rm -rf Oct 10 '12 at 19:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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