matthewabide

10 Reputation

3 Badges

7 years, 172 days
I'm currently an Electrical Engineer Student at Texas Tech University work on Pulse Power. I'm hoping that Maple will help me work with the math that I need to construct the systems I work on as well as play with more Math.

MaplePrimes Activity


These are questions asked by matthewabide

Hi.

From what I can tell this is a common problem that comes up on the forums once and a while where most response provide answers that don't hit the core of the problem.  That being, when using the plot function in maple how do we properly have it plot a function that contains units within it.  This is an important feature for anyone who works with problems where unit tracking and conversion must be checked, yet the problem complexity becomes large enough such that this isn't feasible to do by hand.

To give a brief example:

T := (.2*11600)*Unit('K');
n__0 := 10^12*Unit(1/'m'^3);
Q := 0.865e-11*Unit('C');

lambda__D := sqrt(epsilon__0*k__B*T/(n__0*q__e^2));
 = 
              lambda__D := 0.003326865078 Unit(m)

Phi__F := proc (r) options operator, arrow; (1/4)*Q/(Pi*epsilon__0*r) end proc;
Phi__P := proc (r) options operator, arrow; Phi__F(r)*exp(-r/lambda__D) end proc;

 

Now lets say I want to plot the Phi functions this would require a plot function with a range that is in the units of meters.  But if I enter the statement:

plot(Phi__F(r), r = 0.1e-1*lambda__D .. 4*lambda__D)

I will produce a plot with the incorrect units on the y-axis, even though lambda__D is in units of meter, likewise the same thing will occur if I try to append the meter unit to the range manually.

plot(Phi__F(r), r = 0.1e-1*lambda__D*Unit('m') .. 4*lambda__D*Unit('m'))

Now, we can make progress if we define the unit of r within the function definition itself.

plot(Phi__F(r*Unit('m')), r = 0.1e-1*lambda__D .. 4*lambda__D)

So "Yay!", right?  Where as I have mixed feelings on that since a range shouldn't require unit additions in the function itself this is at least functional.  The second part of this problem occurs when you try to plot two functions at once, say both Phi__F and Phi__P as follows

plot({Phi__F(r*Unit('m')), Phi__P(r*Unit('m'))}, r = 0.1e-1*lambda__D .. 4*lambda__D);
Warning, expecting only range variable r in expression .7777911056e-1/r*Units:-Unit(V) to be plotted but found name V

Now we recieve a warning message and an empty plot.  For some reason maple things that V is a variable, not a unit.  What the hell?  I would like a little help here as the online docs are useless.

 

-- Matt

P.S.  If you'd like to know more about the example problem it happens to deal with the debye length of a plasma.

Any any good programming language or design program the format and style of a document is important for sharing with others.  But for the life of me, I don't know if I'm just missing the painfully obvious, but seriously is there not a blogpost or document about the best writing practices for using maple?

 

It would be a great help to understand general practices for formatting with the document blocks and execution groups.

Page 1 of 1