nm

2886 Reputation

17 Badges

7 years, 255 days

MaplePrimes Activity


These are questions asked by nm

Can one hope that next version of Maple will be able to solve the standard convection-diffusion pde in 1D?

pde:=diff(u(x,t),t)=d*diff(u(x,t),x$2)+c*diff(u(x,t),x);

in 1D. Even the most simple form with zero boundary conditions can't be solved.

pde:=diff(u(x,t),t)=d*diff(u(x,t),x$2)+c*diff(u(x,t),x);
bc:=u(0,t)=0,u(L,t)=0;
ic:=u(x,0)=f(x);
sol:=pdsolve([pde,ic,bc],u(x,t)) assuming d>0,c>0,L>0

              sol := NULL

I tried some HINT's also but not all of them.

FYI, Mathematica 12.1 is now able to solve the above PDE

ClearAll["Global`*"];
pde=D[u[x,t],t]==d*D[u[x,t],{x,2}]+c*D[u[x,t],x];
bc={u[0,t]==0,u[L,t]==0};
ic=u[x,0]==f[x];
DSolve[{pde,bc,ic},u[x,t],{x,t},Assumptions->{d>0,c>0,L>0}]

Gives

Is it possible I am overlooking some other option or a trick to obtain solution for the above using pdsolve? Only reason I am asking is that Maple can solve much more complicated PDE's and the above is one of the basic diffusion based PDE's. So I am surprised why Maple still can't solve this as it is just a seperation of variables method.

Maple 2020 on windows 10. Physics version 631

I am exploring the idea of porting some of my functions to Maple from Mathematica. But I just found a big problem in importing comma delimited data that contains a string within a string. This is not a problem being imported in Mathematica, but I need help to do same thing in Maple.

I tried ImportMatrix (as suggested in https://www.mapleprimes.com/questions/221509-How-To-Read-Lines-From-File-With-Quoted-Strings and also tried Import then convert and in both cases Maple does not read the full string in the field. I will show simple example

This file, called data.txt

1,2,3,"x+y, algorithm=["123"]","OK",5

It has 6 fields (since comma seperated.

But when importing it, Maple reads the 4th field above as "x+y, algorithm=[" and drops the rest 123"]"

Here is the code

#currentdir("C:\\bug"); #change as needed
data:=ImportMatrix("data.txt", source=csv);
print(data(4));
print(data(5));

This is the output

I also tried

data := Import("data.txt",format="CSV");
data := convert(data,Matrix):
print(data(4));
print(data(5));

Same output as above.

Compare the output in Mathematica. Using the same file as input. It automatically escapes the embedded strings and reads the full field OK

SetDirectory[NotebookDirectory[]];
data = First@Import["data.txt", "Table", "FieldSeparators" -> {","}, "Numeric" -> True]

               {1, 2, 3, "x+y, algorithm=[\"123\"]", "OK", 5}

data[[4]]

              "x+y, algorithm=[\"123\"]"

What would be the right way in Maple to import such files without losing part of the field?

The file has mixed strings and non strings, just like this example shows, and each file fields are seperated by comma, but I need to be able to read fields that can contain embedded strings in them automatically.

I am using Maple 2020. I think I might have to forget about import and try to do it using lower level code using scanf, or may be there is better method using Filetools package? but thought to check first if I am overlooking some option.

I depend alot on bracket matching to help me during writing code.

Maple suddenly losses bracket matching at some lines. I think it related to using strings with "\\" in them.

I make sure I have bracket matching on

 

I use worksheet mode (corrected), Maple 2020 under windows 10.

I made small video. Notice how the brackets do not match on the second line there.

Do you see how the brackets do not match on that second line there? This movie below shows what happens when I remove "\\string" from the line. Now bracket match starts to work again.

This is a serious problem for me. Any suggestions what to try to fix it and what can cause it?. Once bracket matching is lost, it is lost all the way to the rest of the code below the location where it started to lose first time.

restart;
if length(data_last(k,8))>300 then
   fprintf(file_id,"%s\n","\\footnotesize");
fi;

I think I have to find different editor to use and write the code to .mpl file since I have lots of such code and I need to have bracket matching working.

I noticed some problems with pdsolve in 2020. Using Maple 2020 on windows 10 with latest Physics 626.

This PDE now hangs when the timeout is increased. This does not happen in Maple 2019.2.1/
 

restart; 
pde := diff(w(x,y),x)+(a*sin(lambda*x + mu)^k * (y-b*x^n -c)^2 + y - b*x^n + b*n*x^(n-1) - c)*diff(w(x,y),y) = 0; 
cpu_time := timelimit(60*5,CodeTools[Usage](assign('sol',pdsolve(pde,w(x,y))),output='realtime'));

In Maple 2019.2 it gives

    Error, (in trig/reduce/reduce) time expired

Which is good. Since I can now go on to the next PDE.

The hang goes away in Maple 2020 when small timeout is used.  For example I just tried 30 seconds timeout instead of 300 or more seconds and it did expire ok.

This tells me that it depends where it was in the kernel at the time. But as a user, I have no way to control this and so I use the same timeout for all the problems.

Do others using Maple 2020 see the same issue? I know that the timeout does not happen at exactly the same amout given, but for this one, I waited for almost 40 minutes and it still did not time out.

Is this a new bug and is there a better way to handle this other than using timelimit()?

Thank you

This behavior by Maple is completely wrong if you ask me.

But given this is how Maple works, the question I have is how to explictly close a file opened by call to readline()?

I have a proc(), where inside it, it wants to read say first 3 lines by calling readline("input.txt") on a file. Then the proc() returns back to caller.

The first call reads the first 3 lines from the file OK.

I expected all resources to be removed after the call returns, including any files opened to be automatically closed. So next time proc() is called, I expected the first 3 lines to be read again.

It turns out the next time  proc() is called, now lines 4,5,6 are read. This is becuase the file remained open between calls!  Only way to close the file is to call restart() on the whole session. But I do not want to do this. 

Looking at help, I see no method to explicity close the file other than reading all the lines.

How does one explicitly close a file opened by readline() without reading the whole file?

Here is example

restart;

foo := proc()
local n,current_line;

   for n from 1 to 3 do
       current_line:= readline("input.txt");
       print("line read is ",current_line);
   od;
end proc;

And now the above is called as follows

currentdir("C:\\test"); #change as needed
foo()
                   "line read is ", "line 1"
                   "line read is ", "line 2"
                   "line read is ", "line 3"

Next call

foo()
                   "line read is ", "line 4"
                   "line read is ", "line 5"
                   "line read is ", "line 6"

Where input.txt is 

line 1
line 2
line 3
line 4
line 5
line 6

I know how to do all this using fopen() and fscanf() and explicit fclose(). I also know I can use FileTools package.

But wanted to check first if readline() will do what I wanted more easily if I can figure how to close the file explicitly.

1 2 3 4 5 6 7 Last Page 1 of 72