Gary Palmer

84 Reputation

11 Badges

16 years, 294 days

 

 

 

Mac w OS X, 10.4.6, 3.06 GHz Intel Duo with 4GB RAM, Maple14 Student

MaplePrimes Activity


These are replies submitted by Gary Palmer

@Gary Palmer 
I will follow this with the script. I am hoping it will be accessible to members. One second equals approximately 250 million years, so perhaps I will learn to slow it down a little bit.

 

The suggestions were appreciated.

The suggestions were appreciated.

 @Joe Riel 

By command-line I mean an operating system shell.  Don't know what you call it on the Mac, but Terminal has the right flavor.

Yes, the terminal gives access to bash. Thank you for the suggestions regarding turning off the memory print outs. I did in fact try the plotsetup(maple) in a tiny demo program and it worked well, but it didn't work when inserted into my program. 

It is very possible that a bug crept in. I will try your suggestions for using the syntax checker and debugger at my first opportunity.

 @Joe Riel 

By command-line I mean an operating system shell.  Don't know what you call it on the Mac, but Terminal has the right flavor.

Yes, the terminal gives access to bash. Thank you for the suggestions regarding turning off the memory print outs. I did in fact try the plotsetup(maple) in a tiny demo program and it worked well, but it didn't work when inserted into my program. 

It is very possible that a bug crept in. I will try your suggestions for using the syntax checker and debugger at my first opportunity.

@Alejandro Jakubi 


Perhaps you could post a sample script showing this problem with the maplet driver.

No, this forum lacks such useful tools as a quote reply. Anyway, you could also use e.g. the tag in the html editor.

 

Thanks for the blockquote suggestion.

I simply added a plotsetup(maplet) line right before I called the animation procedure (see the message above that contains the main procedures). I suspect the problem was just that creating the plot objects used too much memory, especially if objects from the previous program execution were not adequately cleared from the editor working space. I don't have the time to try to recreate the event, but I would be happy send or post the whole program as it existed then. I have since been carving it up into library documents, and that took me some time to learn, but it has taken much of the load off the editor. The reorganization has left me with one fatal and resistant bug so I can't yet report on the final result.

I don't want to cut and paste the whole program into this window, because it loses too much formatting. Can you email through this forum? If not, perhaps you could suggest another way to post it.

@Alejandro Jakubi 


Perhaps you could post a sample script showing this problem with the maplet driver.

No, this forum lacks such useful tools as a quote reply. Anyway, you could also use e.g. the tag in the html editor.

 

Thanks for the blockquote suggestion.

I simply added a plotsetup(maplet) line right before I called the animation procedure (see the message above that contains the main procedures). I suspect the problem was just that creating the plot objects used too much memory, especially if objects from the previous program execution were not adequately cleared from the editor working space. I don't have the time to try to recreate the event, but I would be happy send or post the whole program as it existed then. I have since been carving it up into library documents, and that took me some time to learn, but it has taken much of the load off the editor. The reorganization has left me with one fatal and resistant bug so I can't yet report on the final result.

I don't want to cut and paste the whole program into this window, because it loses too much formatting. Can you email through this forum? If not, perhaps you could suggest another way to post it.

@Gary Palmer 

I had commented some lines that consumed memory in order to work on other parts of the program. When I cut and pasted from the program in the Maple editor to this forum, the commented lines were inadvertently deleted. An attempt to edit my own reply produced an error message, so I provide the correction here with the lines that rotate the stars.

newPlot := proc (theta) 
          plots[display](
               rotate(earth, 0, 0, theta), 
               seq(rotate(theBar[i], 0, 0, theta), i = 1 .. nops(theBar)), 
               seq(rotate(stars[i], 0,0,theta), i=1..nops(stars)),
               seq(rotate(coreStars[i], 0,0,theta), i=1..nops(coreStars)),
               seq(rotate(shadowStars[i], 0,0,theta), i=1..nops(shadowStars),
               seq(rotate(HEobj[i], 0, 0, theta), i = 1 .. nops(HEobj)), 
               center, rotate(capsHE15230901, 0, 0, theta),
               rotate(capEarth, 0, 0, theta), 
               rotate(capCentMW, 0, 0, theta), 
               rotate(capBarMW, 0, 0, theta), 
               capScale) 
          end proc:

     animate(newPlot, [theta], theta = 0 .. 2*Pi, frames = 50, 
          title = "Figure. Earth and HE1523-0901,\n oldest star in Milky Way (13.2 billion yrs)\n
                    plotted in disk of Milky Way.",
          titlefont = [Times, bold, 16], 
          scaling = constrained, 
          axes = normal, orientation = [-75, 70, 0]
     );

@Gary Palmer 

I had commented some lines that consumed memory in order to work on other parts of the program. When I cut and pasted from the program in the Maple editor to this forum, the commented lines were inadvertently deleted. An attempt to edit my own reply produced an error message, so I provide the correction here with the lines that rotate the stars.

newPlot := proc (theta) 
          plots[display](
               rotate(earth, 0, 0, theta), 
               seq(rotate(theBar[i], 0, 0, theta), i = 1 .. nops(theBar)), 
               seq(rotate(stars[i], 0,0,theta), i=1..nops(stars)),
               seq(rotate(coreStars[i], 0,0,theta), i=1..nops(coreStars)),
               seq(rotate(shadowStars[i], 0,0,theta), i=1..nops(shadowStars),
               seq(rotate(HEobj[i], 0, 0, theta), i = 1 .. nops(HEobj)), 
               center, rotate(capsHE15230901, 0, 0, theta),
               rotate(capEarth, 0, 0, theta), 
               rotate(capCentMW, 0, 0, theta), 
               rotate(capBarMW, 0, 0, theta), 
               capScale) 
          end proc:

     animate(newPlot, [theta], theta = 0 .. 2*Pi, frames = 50, 
          title = "Figure. Earth and HE1523-0901,\n oldest star in Milky Way (13.2 billion yrs)\n
                    plotted in disk of Milky Way.",
          titlefont = [Times, bold, 16], 
          scaling = constrained, 
          axes = normal, orientation = [-75, 70, 0]
     );

It sounds as if you are running the animation in the same Document in which you are coding. Is that right?

Correct.

You could edit the code in a separate Document from that in which you run the animation. There are several ways to do this (and maybe you're already doing one of them). 

I think it depends on what is meant by "that in which you run the animation." I have never separated the animation procedure from the bulk of the code. I will try that.

You could have multiple Documents open, but using distinct kernel engines. In one of them you could edit the code for the procedures that do the work.

This sounds promising.

- Or, as mentioned by others, you could simply use a text editor to program plaintext .mpl source files, and then `read` them into the Document that runs the animation. Or you could use a text editor, and use its facilities to savelib the .mpl source file in a library, instead using `read`.

I did try creating the code in a text editor, but I submitted it directly to the maple ?interpreter ?compiler. I need to try moving part of it to a library.

Maybe it would be good to look for the cause of the slowness, though. Does the entire Document get slow, when you run the animation?

Yes, and saving becomes very slow and unreliable.

Are you using a Plot Component in the Document? Are you animating it using the GUI or Plot Component's own animation facility, or are you mimicing that using a sequence of plots controlled by a Button Component?

I had not heard of a Plot Component. I am not using a Button Component. I will look into these.

Without providing the whole program and all the unhelpful detail, this is what I am doing:

     newPlot := proc (theta)
          plots[display](
               rotate(earth, 0, 0, theta),
               seq(rotate(theBar[i], 0, 0, theta), i = 1 .. nops(theBar)),
               seq(rotate(HEobj[i], 0, 0, theta), i = 1 .. nops(HEobj)),
               center, rotate(capsHE15230901, 0, 0, theta),
               rotate(capEarth, 0, 0, theta),
               rotate(capCentMW, 0, 0, theta),
               rotate(capBarMW, 0, 0, theta),
               capScale)
     end proc:

     animate(newPlot, [theta], theta = 0 .. 2*Pi, frames = 50,
          title = "Figure. Earth and HE1523-0901,\n oldest star in Milky Way (13.2 billion yrs)\n
                    plotted in disk of Milky Way.",
          titlefont = [Times, bold, 16], 
          scaling = constrained,
          axes = normal, orientation = [-75, 70, 0]
     );


All the items being rotated are 3 dimensional plot structures, either points, lines, spheres or textplots. I have run it with up to a thousand stars and produced working plots, but it's tedious working with the editor and a thousand is barely enough. Once the plot is saved to a gif, it runs briskly in a browser window.

Have you tried using the Standard GUI with 1D Maple notation input, inside a Worksheet instead of a Document?

Yes. I didn't see any improvement in performance and I had the added difficulty of having to break up the single large execution group created when I converted to the 1D.

How many frames do you want to be shown? This can relate to whether you use something like the plots[animate] command (which has to build and store all frames at once) or whether you mimic animation using Components (which can form only one frame at a time, and keep total allocation down).

More frames (hundreds) is better, as it creates a smoother and slower animation, but I soon noticed that more frames meant more rotations and more memory usage, so if I can mimick it with Components I will be happy to try it.

I don't know how it is on the Mac, but on Linux and Windows the GUI and the kernel engine consume memory separately. Getting an accurate view on total memory allocation by Maple can involve finding out the separate memory use of each.

Understood, but I wouldn't know how to do it. It appears that too many plot objects accumulate and are not cleared when the program is rerun. If the editor and the program run in the same kernal, that must aggravate the shortage of RAM.

These are all great ideas and I will follow them up and report back within a few days.

Mac w OS X, 10.4.6, 3.06 GHz Intel Duo with 4GB RAM, Maple14 Student

It sounds as if you are running the animation in the same Document in which you are coding. Is that right?

Correct.

You could edit the code in a separate Document from that in which you run the animation. There are several ways to do this (and maybe you're already doing one of them). 

I think it depends on what is meant by "that in which you run the animation." I have never separated the animation procedure from the bulk of the code. I will try that.

You could have multiple Documents open, but using distinct kernel engines. In one of them you could edit the code for the procedures that do the work.

This sounds promising.

- Or, as mentioned by others, you could simply use a text editor to program plaintext .mpl source files, and then `read` them into the Document that runs the animation. Or you could use a text editor, and use its facilities to savelib the .mpl source file in a library, instead using `read`.

I did try creating the code in a text editor, but I submitted it directly to the maple ?interpreter ?compiler. I need to try moving part of it to a library.

Maybe it would be good to look for the cause of the slowness, though. Does the entire Document get slow, when you run the animation?

Yes, and saving becomes very slow and unreliable.

Are you using a Plot Component in the Document? Are you animating it using the GUI or Plot Component's own animation facility, or are you mimicing that using a sequence of plots controlled by a Button Component?

I had not heard of a Plot Component. I am not using a Button Component. I will look into these.

Without providing the whole program and all the unhelpful detail, this is what I am doing:

     newPlot := proc (theta)
          plots[display](
               rotate(earth, 0, 0, theta),
               seq(rotate(theBar[i], 0, 0, theta), i = 1 .. nops(theBar)),
               seq(rotate(HEobj[i], 0, 0, theta), i = 1 .. nops(HEobj)),
               center, rotate(capsHE15230901, 0, 0, theta),
               rotate(capEarth, 0, 0, theta),
               rotate(capCentMW, 0, 0, theta),
               rotate(capBarMW, 0, 0, theta),
               capScale)
     end proc:

     animate(newPlot, [theta], theta = 0 .. 2*Pi, frames = 50,
          title = "Figure. Earth and HE1523-0901,\n oldest star in Milky Way (13.2 billion yrs)\n
                    plotted in disk of Milky Way.",
          titlefont = [Times, bold, 16], 
          scaling = constrained,
          axes = normal, orientation = [-75, 70, 0]
     );


All the items being rotated are 3 dimensional plot structures, either points, lines, spheres or textplots. I have run it with up to a thousand stars and produced working plots, but it's tedious working with the editor and a thousand is barely enough. Once the plot is saved to a gif, it runs briskly in a browser window.

Have you tried using the Standard GUI with 1D Maple notation input, inside a Worksheet instead of a Document?

Yes. I didn't see any improvement in performance and I had the added difficulty of having to break up the single large execution group created when I converted to the 1D.

How many frames do you want to be shown? This can relate to whether you use something like the plots[animate] command (which has to build and store all frames at once) or whether you mimic animation using Components (which can form only one frame at a time, and keep total allocation down).

More frames (hundreds) is better, as it creates a smoother and slower animation, but I soon noticed that more frames meant more rotations and more memory usage, so if I can mimick it with Components I will be happy to try it.

I don't know how it is on the Mac, but on Linux and Windows the GUI and the kernel engine consume memory separately. Getting an accurate view on total memory allocation by Maple can involve finding out the separate memory use of each.

Understood, but I wouldn't know how to do it. It appears that too many plot objects accumulate and are not cleared when the program is rerun. If the editor and the program run in the same kernal, that must aggravate the shortage of RAM.

These are all great ideas and I will follow them up and report back within a few days.

Mac w OS X, 10.4.6, 3.06 GHz Intel Duo with 4GB RAM, Maple14 Student

@Joe Riel 

Ideally you could just export to a .mpl file, then, from the command line do

maple -F your_export.mpl

Which command line is this? The one in the Terminal program? 

The -F is to prevent Maple from exiting after it process the script.

You will probably have to make some changes to the script.  For example, some of the 2D math, if that is what you used, might need to be tweaked a bit, but possibly not.

It's all 3D, using with(plots), with(plottools). I did export it as Maple Input and gave it an .mpl suffix. It required a fair amount of clean up, changing semicolons back to colons, removing extra "%;" lines, fixing inappropriate pound signs, rejoining split text quotes. I ran it in the terminal program. While running it reported increments of RAM usage and a total of nearly 4 GB of RAM, but that was not showing up in the activity monitor. But of course, nothing showed up because there was no plot driver. I did not notice that my open Maple process had quit.

You will have to assign a plot driver.

By default the command line uses a text based plot driver.  Not sure what is appropriate for the Mac, but probably plotsetup(maplet) is what you want.  Add that before doing any plotting. Best thing to do is try it and see what happens.

In the past, I have used the following, wrapped in with the plot object to export larger jpegs. Is this what you mean? As I recall, it didn't work with animated gifs, but I'll give it another try.

plotsetup(jpeg, plotoutput = path, plotoptions = "height=900,width=1000") 

Also, responding to a previous suggestion, I used plotsetup(maplet). This worked fine for a single plot of a function, but when I included it in my script I got nothing, not even the maplet window. 

******************

I'm not sure how one quotes a previous message in this forum.

 

@Joe Riel 

Ideally you could just export to a .mpl file, then, from the command line do

maple -F your_export.mpl

Which command line is this? The one in the Terminal program? 

The -F is to prevent Maple from exiting after it process the script.

You will probably have to make some changes to the script.  For example, some of the 2D math, if that is what you used, might need to be tweaked a bit, but possibly not.

It's all 3D, using with(plots), with(plottools). I did export it as Maple Input and gave it an .mpl suffix. It required a fair amount of clean up, changing semicolons back to colons, removing extra "%;" lines, fixing inappropriate pound signs, rejoining split text quotes. I ran it in the terminal program. While running it reported increments of RAM usage and a total of nearly 4 GB of RAM, but that was not showing up in the activity monitor. But of course, nothing showed up because there was no plot driver. I did not notice that my open Maple process had quit.

You will have to assign a plot driver.

By default the command line uses a text based plot driver.  Not sure what is appropriate for the Mac, but probably plotsetup(maplet) is what you want.  Add that before doing any plotting. Best thing to do is try it and see what happens.

In the past, I have used the following, wrapped in with the plot object to export larger jpegs. Is this what you mean? As I recall, it didn't work with animated gifs, but I'll give it another try.

plotsetup(jpeg, plotoutput = path, plotoptions = "height=900,width=1000") 

Also, responding to a previous suggestion, I used plotsetup(maplet). This worked fine for a single plot of a function, but when I included it in my script I got nothing, not even the maplet window. 

******************

I'm not sure how one quotes a previous message in this forum.

 

@Alejandro Jakubi 

 

I think I understand in general now, but it will take me a little time to experiment. I also found this page helpful:

http://www.maplesoft.com/support/faqs/detail.aspx?sid=32660. Thanks for the help.

@Alejandro Jakubi 

 

I think I understand in general now, but it will take me a little time to experiment. I also found this page helpful:

http://www.maplesoft.com/support/faqs/detail.aspx?sid=32660. Thanks for the help.

1 2 3 4 Page 2 of 4