abcd

30 Reputation

6 Badges

4 years, 294 days

MaplePrimes Activity


These are answers submitted by abcd

Removal of the instruction xi:=0 (3rd line) will prevent the first message which warns you that diff(..., xi) = diff(..., 0) as no meanings.
For the second one (number of dependent variables ...) : the quantity  L[i] is never fixed, which introduces another unknown.

I did a simple test with n:= 1 in a loop from 1 to 1.
The message  (number of dependent variables ...) subsists despite these corrections.

To understand where it comes from, type the command  indets(PDE, 'function');
It should return f(eta, xi), theta(eta, xi), phi(eta, xi) and all their partial derivatives.
But it returns partial(eta) and partial(2) too.

I think there you have typped inadvertently some hidden character somewhere.
Open a maple worksheet (ctrl+n or cmd+n if you have a Mac) ; select "text" (not "math" just below the "Start.mw" tab)  next drag and drop your fourth line in this worksheet.

Your first second order derivative looks like that 
`∂`(`#mscripts(mo("⁢"),none(),none(),none(),none(),none(),mn("2"))`)*f(eta, xi)/(`∂`(eta)*`#mscripts(mo("⁢"),none(),none(),none(),none(),none(),mn("2"))`)

instead of diff(phi(eta, xi), eta, eta)

Your hidden character is probably here.
Correct and try again.



My advice : I stopped using the document mode : nice as it may be I prefer using the "old" worksheet mode where you are sure that what you typped is wgat you get.

For an alternative to Carl's solution you can also use 

N :=  ...  # your number of samples

Statistics:-Sample(DiscreteUniform(0, 100), N);


For your particular case I do not know if one method is better than the other.
Probably Carl's is simpler

Hey everyone, 

I present two different points of view (statistical and geometrical) and try to show that, even in relatively simple situations, the statisticsl notion of "uniformity" may be confusing.

To summarize my position : 

  • I consider that the algorithms given by vv and carl (sorry for those whom I may have forgotten) solve the "triangle case" in an unquestionable way 
  • I do not perfectly agree with the "ellipse solution" provided by vv (but it is a personal opinion based on a specific interpretation of uniformity , see the .mw file)
  • For more general figures : the acceptation/rejection algorithm always gives a correct solution but may suffer a poor acceptance ratio. 
  • Some strategies based on "uniform" (it would be better to say "regular" or "homogenous") tesselation are very efficient and practically without any restriction (see on the internet articles about CVT : Centroidal Voronoi Tesselation).

 

 

Download DifferentPointsOfView.mw

I'm new on MaplePrimes and I don't know exactly to whom I have to answer.

To your question Markiyan "how about the triangle or the quadrilateral ? " I can say that : the problem of the equipartition (otherwise stated "uniform distribution") of a set of points within a closed subset is a very common problem in statistics.

It raises two issues : how to generate this set and how to asses its equipartition.

You wrote that a set of N points is uniformly distributed in a closed (2D) domain D of size |D| if, for any subpart A of D, of measure |A|, the number #(A) of points within A verifies : 
lim(#(A)/N, N=+infinity) = |A|/|D|

This is a very good definition. It is used to asses, not the equipartition itself, but the difference between a partition and the theoritical equipartition.

This difference is known as the "Discrepancy" of the set of points. 

To be short, a discrepancy measure (there exist more than a single one) is defined by a formula like  #(A)/N - |A|/|D|.


Assessing the discrepancy is a very difficult task (as you pointed out there exist an infinity of shapes for A ... and of size and location). So people usually restrict the problem to simpler situations.
The canonical situation is D=[0, 1] x [0, 1] and each A is a rectangle [0, a] x [0, b]. This choice gives rise to a special definition for the discrepancy  (I will denote D0) : even if it is the simplest one it carries a lot of numerical difficulties to be assessed.


There exist a lot of theoritical results concerning D0.
For example one knows the analytical formula for D0 when the N points come from a Monte-Carlo sampling.
One knows aloso the analytical expressions of D0 when they are generated by a so-called "low discrepancy sequence".

For all the questions related to the discrepancy the following link could be a gateway
https://en.wikipedia.org/wiki/Low-discrepancy_sequence

If you like old books : Seminumerical Algorithms by D. Knuth

In any case you put your finger on a very important point : we must not judge of the equipartition of a set of points by just taking a look to a plot.





 

Hi, 

I'm interested in your problem.
First of all I guess you know analytical solutions exist for linear heat equations in 1D.   
So I suppose your real problem is more complicated than the one you submitted.

For your "toy problem" I began to verify some basic points : for example, "does Maple returns the good solution for still simpler test cases ?".

The simplest one is (1) a single material, with constant thermal conductivity and Dirichlet BCs on the two sides.
Even if the analytical solution is well known, let's just try to verify Maple returns the stationary solution.
You will find in the enclosed file that it is the case : so, without presuming if the transient solution is correctly computed, this is already a good point.

A more complex case is (2) Always a single material, with constant thermal conductivity, but now a Dirichlet BC on the left side and a Robin BC on the right one. I didn't look deeply in the solution Maple gibes, but it seems qualitatively correct.

Now a problem closer to yours (3) Still a single material, with constant thermal conductivity, and Robin Bcs on the two sides (reply to mars sancandi : this problem is well posed ... but the problem with 2 Neuman BCs is not). As you will the solution Maple provides is wrong (look to the argumenty concerning the value of the temperature at the mid point).
This is quite suspect and ominous.

 

Finally let's try to solve the problem you submitted us.

You write a system with 2 temperatures plus 2 continuity relations at the interface x=L1 (temperature and heat flux continuity).

This is a very common way to proceed when you use Finite Volume of FE methods, because you need these relations to build consistent numerical approximations in the cells (or elements) on the two sides of the alpha discontinuity.
Nevertheless, even with these relations, a good way to proceed is to adapt your mesh accordingly to the thermal diffusion. I do not if you are familiar with this but the idea is to have the same cell Peclet's number in all the cells : simply speaking that means that if alpha = 1 in the left material and 10 in the right one, the length of the cells in the latter has to be 10 times smaller than this same length in the former.
This is somethong pdsolve does not permit.

In the file above you will find the analytical stationary solution for 2 materials with different thermal conduction coefficients and 2 Dirichlet BCs.
This solution is followed by a Maple solution where alpha is defined by a piecewise continuous function. The (quasi) stationary solution is obviously false.

So is the Maple solution obtained with a smooth variant of this previous piecewise continuous alpha, which prooves the discontinuity is not an explanation of the bad result Maple returns.

Finally I end my file by a still simpler problem where alpha is a linear function of x.
Here again the result is obviously false.

 

Looking to the pdsolve help page one sees that pdsolve can be called in different ways.
It seems to me (but the opinion of someone from the Maplesoft team would be welcome) that it is not possible to use the `numeric`option with a PDE system that contains non partial differential equations (such as your two legitimate continuity constraints).

Unfortunately I have not enough time to spend on you (interesting) problem and I'm not sure Maple can provide the good solution to it. Nevertheless I keep an eye on it and on its developments to come

Hope I helped ?

 

 

 

 

 


Download HeatEquation.mw

The problem is you have no boundary condition of Dirihlet type.

T1(x, t=0) = ... and T1(x, t=0) = ... are initial conditions 

A parabolic problem (such as heat conduction) over a domain Dx[0, T[ (D is the spatial "s" domain) is well posed if and only if there exist a non null part of the boundary of D where the unknown (T) is given.
Here the conditions you write at x=0 and x=0.3 are not of Dirichlet's type (values of T)  but of Robin's type (one also says "mixed type condition or "Fourier's condition") to account for natural convection to the ambient surroundings.

(see any course on the correct boundary conditions for parabolic PDE.)

 

Your problem is just ill posed and Maple says you that (Dirichlet) conditions must be defined at one or two points for each independent variable ...


Rewrite your problem with a single temperature (not 2) and define the conduction coefficient continuous piecewise function of X alpha := piecewise(x<0.1, alpha1, alpha2), it will be much simpler

 

PS : For Carl Love :  at x=L1 the OP has not written boundary conditions (as you said) but just Temperature and heat flux continuity conditions 

 

Maybe you will find, in  the attached  file,  some ideas that will help you to solve your exact problem 

Download Plot-P-diff.mw

 

I'm not sure I adress exactly your problem but I propose you this piece of code (which needs probably a lot of improvements).
It enables to make a contourplot map over the "ternary" triangle.
I give four illustrative examples : 3 of them are maps of functions that depend only a single component (a, b or c) ; the fourth one is a more complex function.

I hope that will help you,
let me know

 

 

Download TernaryContourPlot.mw

When you use Maple within a worksheet you use Maple as an interpreted language, nor a compiled one

If you want a fast construction to matrix a look help(Compiler).

Maple offers you the possibility to compile procedures (with a lot of limitations of course). For your case  the inclosed file here will show you hox to proceed


PS : for all people interested : I do not understand  why the instruction 

a[i, j] := abs(i-j+1)^0.3 -abs(i-j)^0.3:

is not correctly compiled (check  the results) as 

a[i, j] := abs(i-j+1)^0.3:
a[i, j] := a[i, j] -abs(i-j)^0.3:

is ???

Download Powers.mw

Not to my knowledge

For the moment Maple proposes only "classical statistical tools". 
For more advanced statistics I advice you to look to other products (Matlab, as you seem to know well, or R, which has my favor).

 

But ... If you want to code a fuzzy c-means algorithm in Maple and distribute it , I'll take it.

 

 

Hi, I mot sure that this his the more elegant code but this is a solution :

restart:

f := (3*a[1]+5*a[2])*U[1] + (-6*a[1]+2*a[2])*U[2];

# find all the indeterminates (a set by default)

unknowns := convert(indets(f), list);

# Isolate the U's and the a's

FindU := map(x -> if substring(convert(x, string), 1) = "U" then x end if, unknowns);
FindA := map(x -> if substring(convert(x, string), 1) = "a" then x end if, unknowns);

# Count their numbers

CountU := numelems(FindU);
CountA := numelems(FindA);

# Extract the list of all the coefficients (see a remark below)

g := coeffs(collect(f, unknowns, 'distributed'), unknowns);

# put the coeffs in the matrix.

M := Matrix(CountA, CountU, [g]);


Remark : it works here because the order [U1, U2, a1, a2] returned by indets list firstly names with a capital.
If your coeffs are A1 and A2 and your variables u1 and u2, the code will not give you the correct matrix.


-----------------------------------------

Here is a more general code based on the assumption that variables are always CAPITAL letters and coefficients alwyas SMALL letters. It wors whatever the first letters are :

restart:

f := (3*a[1]+5*a[2])*U[1] + (-6*a[1]+2*a[2])*U[2];


unknowns := indets(f):

FirstLetters := map(x -> substring(convert(x, string), 1), unknowns);

# Assuming capital stands always for variables (alone)

VariableLetter := map(x -> if StringTools[IsUpper](x) then x end if, FirstLetters);
CoeffsLetter := `minus`(FirstLetters, VariableLetter);

unknowns := convert(unknowns, list);

FindVariables := map(x -> if substring(convert(x, string), 1) = op(VariableLetter) then x end if, unknowns);
FindCoeffs := map(x -> if substring(convert(x, string), 1) = op(CoeffsLetter) then x end if, unknowns);

CountVariables := numelems(FindVariables);
CountCoeffs := numelems(FindCoeffs);

g := coeffs(collect(f, unknowns, 'distributed'), unknowns);
M := Matrix(CountVariables, CountCoeffs, [g]);


Now you can easily transform this code into a "quite safe" procedure.






Page 1 of 1