787 Reputation

12 Badges

3 years, 134 days

MaplePrimes Activity

These are answers submitted by mmcdara

Not the solution, just a way to derive the equations by applying differential operators.
I think you have an ambiguity about the pressure (you declare p bar as a constant but it has a priori different values at z=-1 and z=+1 (unless pa is null)

For the solution: I'm not familiar with pdsolve and PDETools, but I'm afraid that you will have to do the things by hand. 
If I'm not mistaken this is a classical poiseuille flow with uniform velocity at the inlet (parabolic profile expected at the outlet) and I remember solving it by hand long ago at school. Maybe you will have to reproduce explicitely the same modus operandi in Maple?

Wait for a more enlightened reply about pdsolve/PDEtools




SetCoordinates(cylindrical[r,theta, z]):

alias(u=u(r, 'theta', z));
alias(v=v(r, 'theta', z));
alias(p=p(r, 'theta', z));



u, v


u, v, p


V := VectorField(< v, 0, u >);

V := Vector(3, {(1) = v(r, theta, z), (2) = 0, (3) = u(r, theta, z)}, attributes = [vectorfield, coords = cylindrical[r, theta, z]])


(v+r*(diff(v, r))+r*(diff(u, z)))/r


Continuity_equation := eval(expand(%));

v/r+diff(v, r)+diff(u, z)


Diffusion_term := beta^2 *~ map(expand, eval(%));

Diffusion_term := Vector(3, {(1) = beta^2*(-v(r, theta, z)/r^2+(diff(v(r, theta, z), r))/r+diff(diff(v(r, theta, z), r), r)+(diff(diff(v(r, theta, z), theta), theta))/r^2+diff(diff(v(r, theta, z), z), z)), (2) = 2*beta^2*(diff(v(r, theta, z), theta))/r^2, (3) = beta^2*(diff(diff(u(r, theta, z), z), z)+(diff(u(r, theta, z), r))/r+diff(diff(u(r, theta, z), r), r)+(diff(diff(u(r, theta, z), theta), theta))/r^2)})


Pressure_term := 1 *~ Gradient(p)

Pressure_term := Vector(3, {(1) = diff(p(r, theta, z), r), (2) = (diff(p(r, theta, z), theta))/r, (3) = diff(p(r, theta, z), z)})


Advection_term := 1 *~ Vector[column](3, i -> DotProduct(V, Gradient~(V[i])))

Advection_term := Vector(3, {(1) = v(r, theta, z)*(diff(v(r, theta, z), r))+u(r, theta, z)*(diff(v(r, theta, z), z)), (2) = 0, (3) = v(r, theta, z)*(diff(u(r, theta, z), r))+u(r, theta, z)*(diff(u(r, theta, z), z))})


C := :-Vector[column](3, i -> Advection_term[i] = - Pressure_term[i] + Diffusion_term[i])[[1, 3]]

C := Vector(2, {(1) = v(r, theta, z)*(diff(v(r, theta, z), r))+u(r, theta, z)*(diff(v(r, theta, z), z)) = -(diff(p(r, theta, z), r))+beta^2*(-v(r, theta, z)/r^2+(diff(v(r, theta, z), r))/r+diff(diff(v(r, theta, z), r), r)+(diff(diff(v(r, theta, z), theta), theta))/r^2+diff(diff(v(r, theta, z), z), z)), (2) = v(r, theta, z)*(diff(u(r, theta, z), r))+u(r, theta, z)*(diff(u(r, theta, z), z)) = -(diff(p(r, theta, z), z))+beta^2*(diff(diff(u(r, theta, z), z), z)+(diff(u(r, theta, z), r))/r+diff(diff(u(r, theta, z), r), r)+(diff(diff(u(r, theta, z), theta), theta))/r^2)})


NS := [Continuity_equation, entries(C, nolist)]

[v/r+diff(v, r)+diff(u, z), v*(diff(v, r))+u*(diff(v, z)) = -(diff(p, r))+beta^2*(-v/r^2+(diff(v, r))/r+diff(diff(v, r), r)+(diff(diff(v, theta), theta))/r^2+diff(diff(v, z), z)), v*(diff(u, r))+u*(diff(u, z)) = -(diff(p, z))+beta^2*(diff(diff(u, z), z)+(diff(u, r))/r+diff(diff(u, r), r)+(diff(diff(u, theta), theta))/r^2)]


# You can say "p bar is a constant and { p(z=-1)=0 & p(z=-1)=0 & p(z=-+1)=p__a } unless p__a=0 too  

BC := [
:-D[1](u)(0, 'theta', z) = 0,
v(0, 'theta', z) = 0,
u(1, 'theta', z) = 0,
v(1, 'theta', z) = p+alpha

seq(print(BC[i]), i=1..numelems(BC))

(D[1](u))(0, theta, z) = 0


v(0, theta, z) = 0


u(1, theta, z) = 0


v(1, theta, z) = p+alpha





Replace your line   Diam;
by                           Diam := simplify(Diam);

Nevertheless I would be tempted to say that Maple should simplify automatically.

Your line evalf(Diam) is corrupted.
Just rewrite it

PS:Personnaly I never use this document mode input that I find very capricious and subjected to hide characters mistakenly typed

I'm not sure I understand you perfectly.
What I think is: you have a discrete RV "X" with mass function fX(x)=1/(x+1) for x = 0, ..., k, where k is some given number (>0).

If It is that, a way to proceed is to use a ProbabilityTable Distribution




# Discrete distribution from a probability table
# The sum of all masses must be equal to 1.

P := k -> [seq(1/(x+1), x=0..k)] /~ add(1/(x+1), x=0..k) ;

# example:

K := 5:
N := 10^3:


X := RandomVariable(ProbabilityTable(P(K))):

S := Sample(X, N):


P := proc (k) options operator, arrow; `~`[:-`/`]([seq(1/(x+1), x = 0 .. k)], ` $`, add(1/(x+1), x = 0 .. k)) end proc


"[[Typesetting:-mfrac(Typesetting:-mn("20",mathvariant = "normal"),Typesetting:-mn("49",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false"), Typesetting:-mfrac(Typesetting:-mn("10",mathvariant = "normal"),Typesetting:-mn("49",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false"), Typesetting:-mfrac(Typesetting:-mn("20",mathvariant = "normal"),Typesetting:-mn("147",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false"), Typesetting:-mfrac(Typesetting:-mn("5",mathvariant = "normal"),Typesetting:-mn("49",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false"), Typesetting:-mfrac(Typesetting:-mn("4",mathvariant = "normal"),Typesetting:-mn("49",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false"), Typesetting:-mfrac(Typesetting:-mn("10",mathvariant = "normal"),Typesetting:-mn("147",mathvariant = "normal"),linethickness = "1",denomalign = "center",numalign = "center",bevelled = "false")]]"


Vector[row]([3., 2., 6., 2., 1., 1., 2., 1., 2., 1.])







If your only concern is to compare the model and the experiment, and if this experiment is a "not too large" collection of triples (t, x, y) , then the option output=Array[ ...], where ... is the list of the experimental t values, is probably the simpler solution.

Regarding now your "comparison metric".
The answer is very simple: there is unfortunately no good way to proceed!
Computing "the Root Mean Square of all (xexperiment(t)-xmodel(t), yexperiment(t)-ymodel(t))" seems very reasonable.
But it can be a very poor solution for some problems, specifically if x or y are of different natures, vary on very different scales and so on.
Luckily it doesn't seem to be the case here.

Another point you must be aware of: if the (t, x, y) experimental values come from measurements, there are probably entailed by "errors". Suppose that x and y are perfectly measured, but that t is not.
For instance the "true" t is T=1, and the measured value is t=1.1: then comparing the experiment at time t=1.1 to the model at time t=1.1 doesn't make sense.
A (the?) correct approach in this case is to use a bayesian framework where one infer the true value of T given its measure t.

Maybe you could be interested in "fitting" your model on the experiments? For instance to assess the value of A ...?
You also mention that "The problem is however that even if the (x,y) curves are rather close, if may not be a good model".
Are you concerned with aapossible "model error"?
Here again, for these two questions, the correct answer relies to the "bayesian calibration of computer model" issue.

Let me know if you are interested by taht.

To conclude: try your  "Root Mean Square of all (xexperiment(t)-xmodel(t), yexperiment(t)-ymodel(t)", examine carefully the residues (the model-to-experiment distance at each time t) and if all looks good, then it's done 

MAT := < header1, header2, <Column(t1[2,1],1..2) | Column(t2[2,1],2) > >:



Assuming the DEFINITION below suits you, you will find some elements in the attached file.


  • Let E the ellipse defined by the equation (x/a)^2+(y/b)^2=1
  • For each point P on E one define s(P) as the measure of the angle (counter clockwise counted) between Ox and OM
  • Let A and B two points on E such that
    • s(A) > =  0
    • s(B) > s(A)
    • s(B) <= 2*Pi
  • Let M any point such that s(A) <= s(M) <= s(B)
  • Let x(A) the abscissa of A and x(B) the one of B

Then the mean value of the distance d(O, M) from O=(0, 0) to M as M moves from A to B is defined by the integral of d(O, M) between x(A) and x(B), divided by x(B)-x(A).

In file you will find a procedure 'md' which computes the mean value of d(O, M). It takes 4 arguments:

  1. b
  2. alpha = s(A)
  3. beta = s(B)

'md' handles (if I'm not mistaken) the 3 cases:

  1. alpha < Pi and beta < Pi
  2. alpha < Pi and beta > Pi
  3. alpha > Pi and beta > Pi 

Before that you will find a few lines that treat more formally the first situation alpha < Pi and beta < Pi

As claimed in this file, I was not capable to obtain a general formal solution for any values of a and b (that's why I arbitrarily wrote a:=2 and b:=1 at the top at the file).
The search of a general formal solution requires using assumptions about a, b, p, q (see the commands in the file) and the 'int' procedure of Maple is not very comfortable with 'assume' or 'assuming' statements (someone here will probably correct me on this point)

Here is a possible (NOT THE) definition of the mean radius.

I replace "arithmetic mean" by mean in the sense (one sense) mentioned by Rouben:

  • I consider the canonical ellipse with principal axis Ox and Oy (natural cartesian coordinates)
  • let M1, M2<> M1 two points  on the ellipse
  • Let M a third point on the ellipse.
     Assuming M moves from M1 to M2 counterclockwise in such a way that the angular sector swept by M is less than 2*Pi,
    one can define the mean radius by the mean value of OM when M moves from M1 to M2.



Maybe the shortest solution?
(just for fun, no practical interest when compared to the previous answers)


splitChange := proc(w)
  local bw:
  bw := map(u -> if w[u+1]<>w[u] then cat(w[u], " ") else w[u] end if, [$1..length(w)-1]);
  StringTools:-Words(cat(op(bw), w[-1]));
end proc:


I guess you took as a reference the article by Faith Chelimo Kosgei?
(  practically the one I was able to find on the subject)

If it so I understand you asked for some help (I 've rarely read such a muddled, obscure and confusing paper!)

Nevertheless, after a lot of work spent to read between the lines of the article, you will find in the attached file the algorithm applied to the 3 toy examples this paper contains.

I leave you the pleasure to apply the method to your own test cases

I don't know what Maple version you use (in a previous thread you said tou used Maple 13?) but in Maple 2015 (and beyond.. but I can verify this right now) your code is not correct.
The line

should be replaced by 
V:= r -> piecewise(0<=r and r<=R, -VV, r>R, 0):

Here is your original code

A few points beyond the above correction

  1. Some lines are unnecessary:

  2. As Carl Love wrote, you need another IC/BC condition, dot instance D(u)(0) = something
    With, for instance, SYS2:={diff(u(r), r, r)+k^2*u(r) = V(r)*u(r), u(0) = 0, D(u)(0)=1} you should obtain this curve
    odeplot(sol, [r, u(r)], r = 0 .. 2);

The GB is reduced w.r.t the plex order (proof here)


It seems indeed that the help pages do not mention if th GB is reduced or not.



Use "randomize" to generate a random sed on each node


Samplor := proc(N) 
  local Seed:
  Sample(Uniform(0, 1), N); 
end proc:

Map(Samplor, [2, 2, 2, 2]);



# example
Y := Array(1..N, i -> i^2);
             [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
DY := map(u -> Y[u+1]-Y[u-1], [$2..N-1])
                [8, 12, 16, 20, 24, 28, 32, 36]



You will find some hints in the attached file.

There are basically 2 problems wiith your code:

  1. value is a reserved word in Maple
  2. You don't read teploty.txt, so the test fails because the "value" is not valuated.

A temporary solution until someone here will provide a clever one

M := `<|>`(`<,>`(1, 3, 2), `<,>`(4, 1, 3)):

# Structure of M

S := op(2, M);

 {(1, 1) = 1, (1, 2) = 4, (2, 1) = 3, (2, 2) = 1, (3, 1) = 2,  (3, 2) = 3}

# Reverse S

T := map(u -> rhs(u)=[lhs(u)], S);

 {1 = [1, 1], 1 = [2, 2], 2 = [3, 1], 3 = [2, 1], 3 = [3, 2],  4 = [1, 2]}

# A simple procedure to find a value "n"
# (should be improved to handle the case "n is not an element of M")

Find := proc(n) map(u -> if lhs(u)=n then rhs(u) end if, T); end proc:

                        {[1, 1], [2, 2]}
                            {[3, 1]}
                        {[2, 1], [3, 2]}


4 5 6 7 8 9 10 Page 6 of 10