tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are replies submitted by tomleslie

All I get when I try to download this latest worksheet is

Bad Request

I assume for some reason that the link is broken.

I can only suggest that you try to download your own upload - and make sure it works!

Upload modified worksheet with new/corrected PDEs/BCS/ICS.

There is nothing I can do with a pdf file (other than read it!)

Applying my carefully calibrated eyebal to the set of differential equations PDE[1..3] I can tell that you require exactly 12 boundary/initial conditions

A quick check on your code indicates that you have 17 boundary/initial conditions: some of these may be simple repeats. I suggest you work out which 12 boundary conditions you need - becuase I can't do it for you

Then code them correctly: since I suspect that this system will only be solved numerically, the initial/boundary conditions need to be coded using 'D'operator syntax - see the pdsolve/numeric help page

Your worksheet as posted contains 6 partial differential equations, PDE[1..3] and PDE[a1..a3]. As a general rule, if you have three dependent variables (as in u(x,t), w(x,t), phi(x,t) ) then you should only have three PDEs

A comment in your worksheet suggests that x=La, then (by some means) the set of equations PDE[a1..a3] becomes "operative", and for all other values of x, the PDEs, given by PDE[1..3] are "operative".

So my first question would be do you actually have some kind of piecewise definition of equations, PDE[1..3] are valid for certain values of x, and PDE[a1..a3] are valid for other values of x - and if so what is this piecewise definition?

I'm (nearly) certain that it makes no sense at all to define a set of PDEs at a point (say x=La). Apart from anything else, if they were only defined at a point (x=La) then any derivative wrt x would automatically become meaningless. You cannot (generally) differentiate any function which is only defined at a point

I think you really need to clarify the sytem of PDEs which you wish to solve

Clarify the question and post an example of the behaviour which you find surprising

Your first post clearly states

need to plot the positve roots and  against so(4-->5)

The above post states

Plot the roots S[1, 2, 3] against continous value of so,

Since one of your roots is negative, then one of the above statements is downright wrong - which statement is wrong? (Or am I supposed to guess??)

The worksheet I posted above (posRoots.mw) shows how to plot all three roots or just the positive roots - you just have to select which you want - because you keep changing your mind, and expecting me to guess your intentions is going to get you precisely nowhere.

So before going any further, I need to know whether the posted worksheet does what you want - In other words does it enable you to

plot the positve roots and  against so(4-->5) and
Plot the roots S[1, 2, 3] against continous value of so,

In other words does it do what you asked for - or doesn't it?

After you answer all of the above, then we can move on to you latest request. A couple of new variable/functions have appeared -namely 'xs' and 'zs'. Was I supposed to be able guess at the existence of these functions? Or were your two earlier posts just incomplete/incorrect?

I don't propose to do anything about computin values for these quantities, since the code you provide is so obviously riddled with errors, and once again I'd have to make so many guesses about what you want. Consider the exerpt from the code you posted. I have reformatted it, to make it more or less readable

 

for so from 4 to 5 do # s0 from 4 to 5(continous value)
     sol:=evalf(solve(Q(s),s)):
     S:=array([],1..3):
     S[1]:=sol[1];
     S[2]:=sol[2];
     S[3]:=sol[3];
    
xs:=(so-u)*d*(a1+u)/(m1*u);
     zs:=((m2-d2)*xs-a2*d2)*(a3+ys)/(m3*(a2+xs));
     g1:=eval(subs(u=S[1],xs));
     g2:=eval(subs(u=S[2],xs));
     g3:=eval(subs(u=S[3],xs));
     k1:=eval(subs(u=S[1],zs));
     k2:=eval(subs(u=S[2],zs));
     k3:=eval(subs(u=S[3],zs));
end do;
with(plots):pointplot([[so,k1],[so,k2],[so,k3]],axes=boxed);# all value of [so,S[1,2,3] and [so,xs],[so,zs]

For the moment I will confine myself to a few

observations

  1. The default step size in a 'for' loop in Maple is 1, so when you make the statement 'for so from 4 to 5 do', then this loop will execute exactly twice, once for so=4, and once for so=5. Is this what you intended?
  2. Since you are making no attempt to store values from each loop iteration, then each time you run the loop, all previous values will be overwritten, so each of g1, g2, g3, k1, k2, k3 will contain one value - that evaluated on the final loop iteration, when so=5. Presumably this intentional?
  3. After the loop exits the value of so will be 6 (one greater than the final loop value) and k1,k2,k3, will contain a single value (evaluated at so=5). In other words, in your pointplot() command the entry [so,k1], will plot exactly one point - corresponding to so=6 and k1 evaluated when so=5. I assume this is intentional?
  4. Why are the values g1, g2, g3 being evaluated in this loop, they are used nowhere and evaluated nowhere, so are completely irrelevant. Or are you saving these up for the next time you change the question, and all of a sudden they become really important?

Free advice

  1. Stop writing code until you can determine
  2. exactly what you want, and explain it clearly

 

Which probably isn't worth much because |I have never got my head around the tradeoffs beteween processor threads and Maple threads.

Just to make things really clear, the processor on my current machine is

Intel Core i7 3770K @ 3.50GHz, Ivy Bridge 22nm Technology

and if I use ctrl-alt-delete->performance, then I get 8 "cpu" panes. I have always interpreted this as my processor is capable of running 8 threads. Important to note that that an application may not ask for multiple threads, but Intel/Windows will decide that multiple threads are possible, and run them anyway.

As an example, if I execute

restart:
L:= RandomTools:-Generate(list(integer, 2^18)):
CodeTools:-Usage(mul(x, x= L), iterations= 4):

then the output is

memory used=149.69GiB, alloc change=8.91GiB, cpu time=47.85s, real time=47.94s, gc time=6.69s

and according to the ctrl-alt-delete/performance monitor, four of my "cpus" start working really hard, and my memory usage spikes to 13.8GB. (the machine has 16GB of physical RAM).

My assumption has always been that this is what happens when win7/intel attempts to multithread for efficiency purposes.

On the other hand, if I execute your code group

restart:
gc();
L:= RandomTools:-Generate(list(integer, 2^18)):
CodeTools:-Usage(Threads:-Mul(x, x= L),iterations= 4):

then according to the ctrl-alt-delete/performance monitor, all 8 of my "cpus" fire up and the output is

memory used=1.21GiB, alloc change=1.29GiB, cpu time=4.08s, real time=1.31s, gc time=39.57m

This is way faster than the previous version - as in 36.59x in real time. I have always put this down to the fact that Maple is *way* better at determining an optimum mulithreading strategy than win7/intel is.

Now for the confusing stuff.

If I execute kernelopts(numcpus), it returns 8. Trust me, I only have 1cpu on this machine and the relevant help page states

 "this will be the actual number of CPUs that the machines has (treating hyperthreaded CPUs as 1 CPU). " 

so I would expect the answer to be 1, because I only have  one cpu (which admittedly can support 8 threads).

I don't really understand the purpose of your final code group: nothing in it changes the number of cpus/threads, so I woud expect to get the same answer, every time the loop executes - which is what happens. I will admit that I don't understand why each iteration executes about twice as fast the single calculation above. I can only assume that the loop construct changes the way that the calculation is "threaded" and produces something more efficient - no idea why.

FWIW the output of

gc();
for n to kernelopts(numcpus) do
     print(kernelopts(numcpus= n));
     CodeTools:-Usage(Threads:-Mul(x, x= L), iterations= 4)
end do:

 is

memory used=1.21GiB, alloc change=0 bytes, cpu time=2.71s, real time=631.75ms, gc time=7.99m
                               1
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.50s, real time=582.25ms, gc time=8.04m
                               2
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.46s, real time=578.00ms, gc time=8.07m
                               3
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.51s, real time=558.50ms, gc time=588.90ms
                               4
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.70s, real time=598.00ms, gc time=16.28m
                               5
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.73s, real time=601.00ms, gc time=8.17m
                               6
memory used=1.21GiB, alloc change=0 bytes, cpu time=2.59s, real time=563.75ms, gc time=557.70ms
                               7
memory used=1.21GiB, alloc change=512.00MiB, cpu time=2.93s, real time=640.25ms, gc time=604.50ms

 

You get an upvote from me because I posted a similar question some time ago, see

http://www.mapleprimes.com/questions/204975-Debugger-Irritation

and I got no answers

I too had problems with the concept of plotting  a "contour" for a vector field, so in my original response, I ignored this term, and demonstrated how to plot a simple vector field (mea culpa etc).

When it became obvious that the OP really, really wanted a "contour", I did a little playing around, but didn't come up with anything I thought satisfactory, so I didn't re-post, although I did try a few things!

My first thought was to use the 'grid' option in fieldplot3d() to specify that vectors should be determined for only one z-value, as in

plots:-fieldplot3d( [ sin(x),
                             sin(y),
                             sqrt(sin(x)^2+sin(y)^2)
                          ],
                          x = -1 .. 1,
                          y = -1 .. 1,
                          z = -1 .. 1,
                         grid=[10,10,1]
                       );

However this produced the error "Error, (in plots/fieldplot3d) grid dimensions must be > 1". Now I'm not sure why one has to have a grid dimension >1, becuase producing only one collection of vectors in a given dimension, would seem to be logically "reasonable". I then decided to get "clever" by using the option 'grid[10, 10, 3]', along with the 'view' option, so that only the vectors around z=0 woul be visible, as in

plots:-fieldplot3d
         ( [ sin(x),
              sin(y),
              sqrt(sin(x)^2+sin(y)^2)
           ],
           x=-1..1,
           y=-1..1,
           z=-1..1,
           grid=[10,10,3],
           arrows=THICK,
           view=[-1..1,-1..1,-0.5..0.5]
        );

This (sort of) did what I wanted/thought except for two things

  1. It still doesn't look anything like a "contour"
  2. The anchor points for the displayed vectors bothered me. I expected(?!) that the the displayed vectors would have their midpoints at z=0. I could probably have understood if the vector roots ( or tips) were at z=0. But the vectors don't seem to "rooted" (or "centred" whatever) in any way I could determine

The latter execution group above poduces answers very close to those which you have provided, except for the fact that you have a typo in your code - according to the OP's original, the y-coefficient should be sin(y) not cos(y), so your code should read

with(Student:-VectorCalculus):
F:=VectorField(<sin(x),sin(y),sqrt(sin(x)^2+sin(y)^2)>);
R:=PositionVector([x,y,0]);
PlotPositionVector(R,x=-1..1,y=-1..1,vectorfield=F);

Any further discrepancy is probaly down to how the displayed vectors are "rooted" - and I freely admit I cannot figure out how my fieldplot() approach is doing it.

But neither of us is really produicing contours  :-(

Re-read my original answer - particularly the part which says

None of these three expressions evaluates to zero (ie a root) for any value of 'so' which I have tried

So when you refer to " (+ve roots of Q(s),so)"  or "choose the +ve roots " which "roots" are you talking about. There aren't any!

I get the same error message in Maple 18 and Maple 2016

If I change the form of equation, to

solve((x+1/exp(1))^x =1, x);

then I get the correct answers.

Similarly, if I solve for a "general case" and substitute after solution, as in

subs(a=exp(-1), [solve((x+a)^x = 1, x)]);

then again I get the correct answers.

Setting infolevel[solve]:=3, produces

Main: Entering solver with 1 equation in 1 variable
Dispatch: dispatching to Powers handler
Error, (in Engine:-Dispatch) invalid subscript selector

so I assume the problem is with the "Powers handler"

Same help exists in 2015, but not Maple 18.

Using "%m" gives output in Maple ".m" format, and it seems(?) to be identical to the results when using

save(expr, filename)

when 'filename' has a '.m' extension.

Tried a few experiments but I can't make "%Zm" do anything different from "%m"

Relevant help refers to "dotm representation" as distinct from ".m representation" - meaningful, or a typo?

The only other place I can find a reference to 'dotm' is as an option in the MapleTA[ToString] command.

Not idea what is meant by "a scaled plot of a big graph"

Can't find any indication that OP is interested in "graph clustering".

If the latter point is relevant(?), then the commands

GraphTheory[GlobalClusteringCoefficient]
GraphTheory[LocalClusteringCoefficient]

would probably come in useful. It would probably then be possible to extract more-or-less relevant subgraphs using the GraphTheory[InducedSubgraph] command

But all of this is mere speculation

When I execute this worksheet it works correctly. See the attached: don't execute just read the output of the last few execution groups to check output, Maple version etc

F2Try.mw

Since I can't reproduce in any of the Maple versions I have, I can only conclude that this is specific to your installation and/or precise Maple version

Which means the only viable options I can come up with are

  1. Reinstall your specific Version
  2. Update Maple to the latest version. Updates to the latest 18.02 Maple, same build as I use is free for anyone with a valid Maple 18 license

:-(

With 5000 links (I assume you mean edges), I'm not sure that "displaying" the graph will provide much (useful) insight.

If the data file is in a "supported" graph format, then you could try

G:=GraphTheory[ImportGraph](filename, format, out) - see the GraphTheory[ImportGraph] help page for supported graph formats.

If you can import the graph this way, then you could try the GraphTheory[DrawGraph](G, options) - and offer up a small prayer! You can get *some* kind of idea of potential outcomes using

with(GraphTheory):
K4 := CompleteGraph(100);
DrawGraph(K4);

This graph has 4950 edges - and as you can see - "displaying" it is pretty pointless

At least trying the above would be (reasonably) quick.

If the data file is not in a supported graph format, then reading the data file and constructing the graph, will be very dependent on the precise format of the data file, but some combination of readline/AddVertex/AddEdge combined with a little manipulation ought to work (in principle). I, personally, would try to do this with a "toy" example - ie create a test file with only a few edges/Vertexes, but in the same format as your original data file and use this test file to to create/verify the relevant Maple code

First 145 146 147 148 149 150 151 Last Page 147 of 207