Greg McColm

10 Reputation

One Badge

12 years, 359 days

MaplePrimes Activity


These are replies submitted by

Many thanx to everyone.  I think that there was a buffer flow, and for some reason I get the wrong error message when there is a buffer overflow.

I think that it got uploaded this time: Diamond_MAS.mw

Here is the worksheet.  I am trying to draw ball-and-stick pictures of materials at the atomic level.  The particular image I am drawing is diamond.

Incidentally, Maple Primes keeps forgetting my user name, which is Greg McColm.

I didn't want to post code because there is A LOT of code, and debugging my code is my problem.  I just wanted to know what that error meant.  But anyway, here are the programs (for Maple 2020):

BALL := proc(RAD, colour, center, bounds)

         # plot a sphere of a given size and color at a particular

         # place

         local EQN;

         EQN := (x - center[1])^2 +

                (y - center[2])^2 +

                (z - center[3])^2 = RAD^2;

         return plots[implicitplot3d](EQN,

                x = bounds[1][1]..bounds[1][2],

                y = bounds[2][1]..bounds[2][2],

                z = bounds[3][1]..bounds[3][2],

                scaling = constrained, color=colour,

                style=patchnogrid, axes=none,

                numpoints=100000);

        end proc;

        # SPECIFICATIONS:

        # Input:

        #  bounds is a 3-list of 2-lists of numbers

        #  center is a 3-vector or 3-list

        #  colour is a name of a color

        #  RAD is a positive number

        # Local:

        #  equation is an algebraic expression

        # Output is a plot object

STICK := proc(x, y, RAD, colour)

          # Plot a tube of color colour and radius RAD

          # from x to y

          local fmla, lfmla, t;

          fmla := x*t + y*(1-t);

          lfmla := convert(fmla, list);

          return plots[tubeplot](lfmla, t = 0..1, radius=RAD,

            numpoints=20, tubepoints=10, scaling=constrained,

            style=patchnogrid, color=colour);

         end proc;

         # SPECIFICATIONS:

         # Input:

         #  colour is a name of a color

         #  RAD is a (positive) number

         #  x and y are vectors

         # Local:

         #  cfmla is a list of algebraic expressions

         #  fmla is a vector of algebraic expressions

         # Output is a plot object

Picture := proc(vertices, edges, bounds)

            # Draw picture of inputted molecular structure

            local e, points, P, source, sticks, target, v;

            points := NULL;

            for v in vertices do

             P := BALL(v[1], v[2], v[3], bounds);

             points := points, P;

            end do;

            sticks := NULL;

            for e in edges do

             source := e[1][1];

             target := e[1][2];

             P := STICK(source, target, e[2], e[3]);

             sticks := sticks, P;

            end do;

            plots[display]([points, sticks]);

           end proc;

           # SPECIFICATIONS:

           # Input:

           #  bounds is a 3-list of 2-lists of numbers

           #  edges is a list of lists of two integers, a real,

           #    and a color

           #  vertices is a list of lists of a real 3-vector,

           #    a real, and a color

           # Local:

           #  e is a list of a real 3-vector, a real, and a color

           #  P is a plot object

           #  points is a list of plot objects

           #  source is a 3-vector

           #  sticks is a list of plot objects

           #  target is a 3-vector

           #  v is a list of two integers, a real, and a color

           # No output, but prints a picture of the structure

 

I asked it to draw a fragment of an infinite graph, about sixty

vertices.  It took a few minutes, and then produced the graph.  But

I wanted more of the graph, so I asked it to draw a larger fragment,

about 300 vertices worth.  It quickly produced a box with some

vertices in it, and the error message "Plot Internal Error:unrecognised

option Dag in Plot."  I asked it to draw something smaller - about

200 vertices, and after an hour, it was still running.

 

The amount of code is nontrivial, and there is additional code to

produce the input.  I post the worksheet for anyone sufficiently

masochistic.  I was just hoping that someone could tell

me what that error meant so I could try fixing whatever was wrong.

Many thanx to Joe Riel: changing the semi-colon to a colon did the trick.  But I think that it's a bug because when I don't output the result from rand directly or indirectly, and just print Mary had a little lamb, I don't get this stuff.

I have been playing with Maple for years, but never encountered this because I am a Neanderthal who writesto external files only when I have everything all set to write.  I encountered this in my class when as student of mine was fiddling with features (there are always a few students who fiddle with features) stumbled across this and couldn't get rid of the extraneous output.  Needless to say, in a class that includes technophobic neophytes, I am going to avoid the metaphysics of fprintf.

Anyway, the Neanderthal workaround appears to be using a semi-colon, or better, not doing computations when outputting to external files.

Page 1 of 1