MY MAPLE WORKSHEET IS VERY VERY VERY SLOW: can you help me to speed it up?

Hi to everybody.  I have to manipulate a system of partial differential equation,one by one.I have in particolar to derive a lot of time my differential equations(shallow water equations),and then to group, to substitute and at the and I need time derivative in function of spatial derivative.

I'm almost done. The problem is that now every time that  I execute a command it takes  a lot of time. The entire file takes some minuts to compile. It's so slow.

I have got some your  suggestion like to convert everyting in MATH1D but it's slow anyway. I attach you the file So my question is:

maybe it will be better working in classical maple instead of standart. But if I save my file as .mws  the file that I get has a lot of line where is written: 

Typesetting:-mi("output redirected...",italic = "true",mathvariant = "italic")

 print([label reference non supported]); input placeholder 

How can I do to convert correctly in classic maple?

will it help me?

thanks a lot

alberto

Download 8216_M1DdaZERO2.doc
View file details   Note: the file is .doc but in fact it is a maple compressed file. My file was bigger of 800 k so I compressed it with winrar and I colled him .doc because is not possible to upload rar files. So you have to rename it rar and than extract him.

 

roman_pearce's picture

Can't open file

I can't even open your file. It is has been a few minutes now and the Maple interface is using 700MB of RAM!

convert correctly to Classic

It may depend on your input. I will not try to open your worksheet.

One thing that you may try is:

1. Suppress all the output: From the menu, in View >  Show/Hide Contents , unselect Output.

2. Select all the input, Edit > Select All, or Ctrl-A

3. Copy to the clipboard, Edit > Copy or Ctrl-C

4. Open Classic GUI and paste the input: Edit > Paste, Shift-Insert or Ctrl-V

If you have not used "special" symbols, you can use your code right away. Otherwise, you will have to edit.

Thanks. I know if you don't

Thanks. I know if you don't have 2 GB i think is difficult to open it,with me the Maple interface is using 900MB of RAM!!

 I  tryed your suggestion jakubi. It says:  unable to cut/copy to rft selection too large. But it copies it anyway,and  if I past it in the classic worksheet I get that weird lines:  print([output redirected]); input placeholder.

It takes a while to cancel all the lines,expecially if I have to convert more documents. WHy do they appear? In any case I canceled the lines. But I'm not able to run the document. Also if I press the !!! bottom,nothing happens. I attached you the two file mws. One without weird lines

Download 8216_EAvoltaBONA.mws
View file details

and one with weird lines

Download 8216_EAvoltaBONA_wierdLINES.mws
View file details

thanks a lot

alberto

Axel Vogt's picture

may be this is what you want

may be this is what you want ... www.mapleprimes.com/files/102_alberto_10Jul2008.mws
I cleaned up your lines and replaced all semicolon by a double point to avoid printing
Your last Y3 can be simplified considerably:

  length(Y3);
                                161079  
  X3:=simplify(Y3,size): length(%); 
                                 7821
Now determine indeterminates, make it a procedure and optimize it, finally try to
generate 'shorter' statements:

  theIndets:=convert(indets(X3),list); 
         theIndets := [Hx, Zx, Zxx, qx, qxx, GRAVIT, Hxxxx, Qxxx, Qxxxx, Zxxx]
  p1:=codegen[makeproc](X3, theIndets):
  p2:=codegen[optimize](p1, tryhard):
  codegen[prep2trans](p2):
  p3:=codegen[split](%);

By this the computational costs are also decreased:

  codegen[cost](Y3); 
  codegen[cost](X3); 
  codegen[cost](p2);
  codegen[cost](p3); 

  5355 additions + 18384 multiplications + 1350 divisions + 9909 functions
   313 additions + 998 multiplications + 135 functions + divisions
  63 storage + 63 assignments + 254 multiplications + 117 additions + 3 functions + divisions
  66 storage + 66 assignments + 254 multiplications + 117 additions + 3 functions + divisions

Then you are ready to generate Fortran code. Unfortunately Maple thinks
that the lines are too long - however it produces them as comment lines
and thus you should be able to finish manually (the message is a bit mis-
leading since we already tried it):

  Fortran(p3);

  Warning, the function names {CS} are not recognized in the target language
  Warning, character limit for Fortran77 statements exceeded; please filter
    input through codegen[split] first.
  






thanks wonderful

thanks wonderful suggestions, you are great!!!!!!

But three things are not clear to me:

1)Why I wasn't able to execute with the !!! bottom the file I have attached you above?(EAvoltaBONA.mws)

2)there are not other possibility other then cancel the weird lines one by one?why they appears when I copy the commands in the classic version?

3) when I open your file with the classical worksheet and I execute it (now it work) it shows me all the outputs of the commands Fortran(%): WHY?there are the double point!!!

thanks

alberto

 

Axel Vogt's picture

good to hear it helped

1. Do not know ... may be your cursor was placed on some output
in that case I would go to the 1st input line of the sheet

2. The editor is somewhat weak ... usually I do such things through
a text editor (replace newLine + > + blank by newLine)

3. Maple has at least 2 possibilities for output and what you observe
is working like a print command - this is intended and ok

thanks wonderful

sORRY I posted here two times and I don't now how to cancel this post...you can only edit not cancel...

I have 4GB of Ram and I

I have 4GB of Ram and I still couldn't open the file at all.

Java limit?

This FAQ page might give a hint, and the version for Maple 9.5 was more explicit:

When Maple starts, it sets the maximum amount of memory Java may potentially use based on the amount of physical memory in the machine. If that maximum is too high, Java refuses to start, so on machines with lots of physical memory (more than 1GB), Maple will not start either. This problem has been reported to Sun. In the meantime, we have created a new program launcher that respects this limitation on the maximum amount of memory that could ever be used by Java, and thus avoids the problem. This change does not affect the amount of memory available to non-Java components of Maple, including the math engine, which will still take advantage of all the machine's internal memory when solving large problems.

So, if there is an upper limit to the memory that Java may use, may be that this imposes a upper limit to the size of the Standard worksheet that can be loaded, independently of the amount of the physical memory.

Thanks to your help, I write

Thanks to your help, I wrote the maple code and it works. But I have still a problem when I get my fortran 77 exit:  in the fortran code I would like to have  the variables CS(1),CS(2),CS(3),CS(4)  (the 4 components of the variable CS) but I get CS(1.D0),CS(2.D0),CS(3.D0),CS(4.D0) , i.e. it recognizes the number between brackets like a real  number and not like the component of a variable. And I also would like to have the vector CS between the argoment of the fortran function. Do you know please how I can do that?I read the help but I didn't find the solution. I attach to you my maple classic file.

Download 8216_ricominciatoFINO5ordine.mws
View file details

thanks a lot

Alberto

 

Axel Vogt's picture

CS(1) vs. CS[1]

If you write CS(n) then Maple considers CS as function and by default it assumes floats. There are 2 ways: either declare variables for CS as integers (i.e. define as as an input) or use CS[1] (have not tested that).

May be quick and dirty is to use an editor to clean up the resulting code you have (do not forget to make a comment on such in your script, you may not remember it in 2 years).

"And I also would like to have the vector CS between the argoment of the fortran function" - I do not understand that. May be to use it as an argument? Then you declare CS as array of length 4 I think and have to use it before in your definitions, like proc(cs::Array(1..4,datatype=float)) end proc;

Exactly I would like to use

Exactly I would like to use CS as argument of the fortran function.  i tried just to use square bracket cs[1] but it  doesn't work. I tried to declare directly CS inside makeproc. Maybe I have to use  codegen[makeparam] , but I tried to declare CS with that but it gives me error.  I ve looked for a solution in the help menu and in the examples but i didn't find some problem similar to this. can you take a look to the file? I attach it to you. You can see in the first part of the MAPLEsheet that  I  tried to declare directly CS inside makeproc and it gives me error.
Download 8216_ricominciatoFINO5ordine.mws
View file details

tahnks
 

alberto

Axel Vogt's picture

3 cents or some more

first: if you have a question you should break it up into the essential part - I will not read 85 pages

second: essentially you ask how to handle an array as inpu, yes? You should try it with some simple code, say 2 or 3 lines

third: you have only 3 or 4 dimensions for your CS - in that case I simply would not invest much time and use 3 or 4 parameters cs1, ... , cs4 and if I really would need that as an array, then I would write a simple wrapper (with array notation) to call the function (with parameter notation)

for that Y3:= subs(CS(1)=cs1, CS(2)=cs2, CS(3)=cs3, CS(4)=cs4, Y3) should work and one can proceed as suggested

finally you should aware, that the resulting Fortran code may cause numerical problems - at least it will be not quite clear that it is 'stable'

so perhaps it is reasonable to break it up before (for better control) and not to pump all into 1 function - but that is on you, you have to know why you want it your way

at least you need intensive tests

i apologize for the length

i apologize for the length of the file,I meant if you could read just the first lines. I now how to declare an array in a procedure, my problem is to create a procedure from a formulation that contain an array using "makeproc". I tried in all the way, i have looked for an example in the help but there are no examples of that and i wasn't able to do that. I have problem when I write:
 

qxt:=codegen[makeproc](FORTR,parameters = [CS::Array(1..4,datatype=float),op(theIndets)]  );
 

I attach the file to you,just a  few lines.
 

download 8216_fewLINES.mws
View file details

Thanks
 

Alberto
 

ps:I don't understand your proposal of writing a procedure like Y3:= subs(CS(1)=cs1, CS(2)=cs2, CS(3)=cs3, CS(4)=cs4. It has to be general not just for 4 component but also for 100. I'm just trying with 4 but I will generalize.  And I would like to have a only fortran function that has as argument also the array CS. I have to do that  for a lot of time and lot of equation and it s long to substitute everytime all the CS(1.D0),CS(2.D0)...expecially if are 100 component. 

Axel Vogt's picture

and that?

I see, much better to read - thx. 

The following may almost do what you are looking for (where FORTR
is your last expression used:

  qxt:=codegen[makeproc](FORTR,parameters = [CS,op(theIndets)]  ):
  qxt:=codegen[optimize](%, tryhard):
  codegen[prep2trans](%):
  qxt:=codegen[split](%):

  eval(qxt): convert(%,string):
  #StringTools[Substitute](%, "(CS", "(CS::Array(numeric, 1..100)"):
  StringTools[Substitute](%, "(CS", "(CS::Array(numeric)"):
  parse(%):
  theProc:=(%):
  CodeGeneration[Fortran](theProc);

It is a bit dirty and I do not speak Fortran ... in C it seems ok.

And I had to use Maple 11, since the idiotic help in Maple 12 lost
too much help links on older commands - what a shame ...


The proposal ... that is not a procedure, it is just the command to
replace subexpressions (one could write that in a way without typing
in all the possibly 100 different terms, but the above should do it).

Thanks now it works how I

Thanks now it works how I would like.

I have another question:   since I have to do the same thing for every equations and for every order of derivative it would be more general(it would work for any kind and number of equations) and also more efficient to calcolate all the derivatives and just at the end to use  codegen[optimize](%,tryhard] ) and create just one function optimized to get all the derivatives. So I thought to have two external "for" cycles and to create a vector eq[1..Neq,1..Nder]  where in the first column I have the first order time derivative for every equations and in the second one the second order time derivative for every equations and so on.  My problem is just  a problem with  the cycles. Without cycles it works, with the cycle it says me

"Error, invalid input: lhs received 0, which is not valid for its 1st argument, expr". 

It is quite strange.  I think it has the problem at the first instruction,becouse it doesn't seem to print anything. Maybe is something that I ignore about cycles in Maple but I read all the section about the cycles in the guide it seems  correct.

I have just put two "for" external cycles and adapted to the cycle the code that you have already seen(now I have correct it with your suggestion to get the CS vector in fortran). Can you please take a look to the file?there are just a  few lines

 Download 8216_COMPACTform.mws
View file details

Thanks

Alberto

hi, I 'm in real

hi,

I 'm in real diffculty...I tried in all the way to do that cycle but it doesn't work. It's quite strange. can you take a look to my worksheet please? are just a few Iines. I read the guide but i cannot understand why it doesn't accept the cycle.

thanks Alberto

Axel Vogt's picture

coding style

Hm ... it is not so much fun to check codes - and yours is extremely ugly (sorry to say so, it is not meant personal offending).

You permanently overwrite variables, no line breaks, no idents ...

My guessing is: you should reset the variables for the loops (or put the inner body into a procedure, which would force you to be more clean).

The error message gives you, where the first error occurs: when you use 'lhs'

Hope you can accept, that I do not want to step in details through your code - may be, the suggestions above give you some idea, how to build it more clean - otherwise it is hard to check.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}