Mac Dude

1556 Reputation

17 Badges

12 years, 212 days

MaplePrimes Activity

These are questions asked by Mac Dude

I am trying to add a specific property (radiation length) to the Elements in ScientificConstants.

To do this  I first 

ScientificConstants:-AddProperty(radiationlength); # this seems to work

I then load a table of element name - radiationLength pairs (it is really a bigger table but only these are of interest):

                       datatype=anything,delimiter="\t"); # works too

(I made the file using downloaded data).

I then want to fill the radiationlength properties for all elements for which I've got the value:

for i from 1 to LinearAlgebra:-RowDimension(data) do
  elemt:=data[i,1]; # the element name as a string
end do;

which fails with the error

Error, (in ScientificConstants:-ModifyElement) element ``H `` is not known

H is the first element in the table of radiation lengths so it is getting the right one.

At  issue is that somehow the element name (called descriptor in the Help files) does not seem to get properly evaluated. In fact I tried various ways "by hand", none except just the unevaluated element name (i.e H,He etc. worked).

There must be a way to set these in a loop. Does someone know how?


Mac Dude



I have a code that is built on a module which in turn contains records, procs etc. to model certain electronic devices.

The main program first instantiates the various circuits I am using. These are mostly Maple records. It then enters a loop that iterates over a number of cycles this system executes in order to build up statistics.

My problem is that somewhere the code has a memory leak, and Maple eats up rather vast amounts of memory, that increase with the number of cycles in the loop. I suspect that some of the methods I am calling allocate a new instance on each cycle, which is not the intended behaviour. What I am looking for is a way to diagnose e.g. which record, or which proc, gets allocated anew every time. I know about usage but that prints out only the amount of memory allocated; that does not help; I know the number is large. I am looking for a tool that e.g. tells me that record xx is allocated 1000 times etc.



Occasionally I use the Variables palette to inspect some variables after a run. In Maple2018 it seems every Vector or Array returns something like "Empty variable structure" or similar. I never saw this in prior versions of Maple.

A bug? Or am I missing something??


I am having difficulties with a recursive function call with named parameters.

The proc is defind as follows:

Subs:=proc(eqn::seq(equation),elemt::Element,{num::boolean:=false},$) option remember;
qs[i]=Subs(eqn,elemt[qs[i]]); # This is where I need to add something like 'num'=num
end proc;

My difficulty is with the "num" flag. In the code this flag governs whether to try to evalf() certain results or not. That and the recursion per se all works. What does not work is when I add the num option to the internal call. I have been trying 'num'=num, ''num''=num, "num"=num and `num`=num.  I either get an error that something like true=true is not a valid argument here, or that "num" is not valid.

Any hint?


Mac Dude

I have the following function involving 2 piecewise constructs:

ftotal := -1.70678763408500*10^6*dpp[f]*piecewise(t < 0, 0, 0 <= t and t <= t1, 1-cos(t*Pi/t1), t1 < t, 2)-3.41357526817000*10^6*corrFac*piecewise(t < 0, 0, 0 <= t and t <= t1, 1/2-(1/2)*cos(2*t*Pi/t1), t1 < t, 0)+3.51914976100000*10^8;

(This is a result from a prior calculation in Maple; I did not create this construct orginally). The condition blocks are the same for both piecewise functions so this can be simplified to one piecewise function. Per the Help this can be achieved using convert:


but I get this error:

Error, (in PiecewiseTools:-Convert) unable to compare 0 and t1

Since I pasted everything into a new sheet I know that t has no assigned value. Same is true for t1 (and specifically I need this for general t and t1). The conversion to Heaviside works; but converting from that back to piecewise fails with the same error.

Is there any way I can achieve the desired result other than doing it by hand?

Sample sheet is attached. I originally ran into this in Maple 2016 but verified the same issue is present in Maple 2017.



3 4 5 6 7 8 9 Last Page 5 of 23