4
$\begingroup$

I want to do engineering and scientific calculations im Maxima/wxmaxima. I do not want to manually check every time if my units make sense, how can I achieve this?

I'm looking at Maxima because it's free and solves equations etc. symbolically if asked.

$\endgroup$
2
  • 2
    $\begingroup$ I remembered this Question when a friend posted about Frink, a new programming language/calculator (available on PCs and Android) that does track units through arbitrary precision calculations. It's also free! $\endgroup$
    – hardmath
    Nov 18, 2013 at 15:03
  • $\begingroup$ Unfortunately it seems there are many different ways to do this. I'd love to see a summary and comparison of pros and cons of each $\endgroup$
    – endolith
    Apr 15, 2017 at 16:26

3 Answers 3

1
$\begingroup$

I haven't used any of the following packages but they seem to be what you are looking for:

http://maxima.sourceforge.net/docs/manual/en/maxima_51.html#SEC257

http://maxima.sourceforge.net/docs/manual/en/maxima_79.html#SEC369

$\endgroup$
2
0
$\begingroup$

There is also dimension package by Barton Willis. It is most likely already a part of your maxima installation.

http://sourceforge.net/p/maxima/code/ci/master/tree/share/physics

A direct link to a pdf file with documentation:

http://sourceforge.net/p/maxima/code/ci/master/tree/share/physics/dimension.pdf?format=raw

You may find this example useful

  load("dimension");
  depends(v, [t, x]);
  depends(p, [t, x]);
  /* put known dimensions */
  qput(rho, mass/length^3, dimension);
  qput(v, length/time, dimension);
  qput(t, time, dimension);
  qput(x, length, dimension);
  qput(L, length, dimension);

  /* Navier-Stokes equation */
  ns: rho*(diff(v, t) + v*diff(v, x)) = -diff(p, x) + mu*diff(v, x, 2);

  /* assume dimensions for `p' and `mu' are unknown and derive them */
  eq1: dimension(lhs(ns)) = dimension(part(rhs(ns), 1));
  eq2: dimension(lhs(ns)) = dimension(part(rhs(ns), 2));
  sol: solve([eq1, eq2], [dimension(p), dimension(mu)])[1];

  /* this line should give an error becouse `ns' is dimensionally inconsistent */
  /* dimension(ns); */

  /* put dimensions for `p' and `mu'  */
  put(p, assoc(dimension(p), sol),   'dimension);
  put(mu, assoc(dimension(mu), sol), 'dimension);

  /* now it is OK */
  dimension(ns);

  /* define Reynolds number as dimensionless reverse viscosity */
  one_over_mu_unit: natural_unit(1/mu, [L, rho, v]);
  Re: (1/mu)/one_over_mu_unit;

  print("dimension(mu):          ", dimension(mu));
  print("dimension(p):          ", dimension(p));
  print("Reynolds number:        ", Re);
  print("dimension(ns):        ",   dimension(ns));

The output should be:

                            mass
dimension(mu):           ----------- 
                         length time
                            mass
dimension(p):           ------------ 
                                   2
                        length time
                          rho v L
Reynolds number:         [-------] 
                            mu
                           mass
dimension(ns):         ------------- 
                             2     2
                       length  time
$\endgroup$
0
$\begingroup$

I also wanted to find a means of undertaking convenient calculations using wxMaxima, and finally came up with a very simple fix that enables me to undertake engineering calculations using any combinations of units, hybrid imperial, US customary, or SI, etc all within the body of the same calculation worksheet.
The fix is to batchload a units conversion file at the outset of the worksheet. i.e.

(%i1) batchload("/*path*/mks_UNITS_CONVERSION.wxm")

mks_UNITS_CONVERSION.wxm 
"MKSK system conversion factors.
metre kilogram seconds kelvin radians"

LENGTH
> m:1;
mm:.001;
cm:.01;
km:1000;
ins:25.4*mm;
ft:0.3048;
feet:ft;
yards:yd:36*ins;
mile:1609.344;
NM:1852;
Rad:1;
degrees:deg:%pi/180;
Radians:Rads:Rad;
MASS
> kg:1; g:0.001; tonne:1000;
lb:0.45359237; oz:lb/16;
kip:1000*lb; ton:2240*lb;cwt:112*lb;
TIME
> s:1; min:60; hour:3600; h:hour; day:24*hour; week:7*day; year:365.25*day;

For all associated derived units as required, units of force, power, pressure, heat, area, volume, flow rate and so on to cover all types of unit required. All calculations are then carried out using a coherent set of base units, (in this case MKS). The units for the input data are declared at the point of input by multiplying the amount by the associated unit name. e.g. 10.5*ins; (= 10.5 inches), or 17.35*cm; (= 17.35 centimetres). All the ensuing calculation is in the coherent MKS set of units. However, the output can be generated in any units to suit the convenience of the user. In this case (perhaps counter-intuitively) output in the desired units is obtained by dividing the calculated answer by the names of the desired units. A little bit of basic housekeeping is needed to maintain the integrity of the unit sets, but nothing different from that which would be needed if the same calculation were attempted by hand.
For me discovering this approach has totally transformed the utility of wxMaxima. All it needs is to first create and store a .wxm conversion file. The use of the batch loaded file has had no detectable effect on the runtime required for new worksheets. Hope that this helps someone! No possibility I suppose of including an appropriate .wxm file in wxMaxima's standard library?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.