1ttyoff:true$ 2dimension(w) := block(/* w is an equation or a list of 3 equations with an indeterminate on the left and a product of 4 powers of mass, length, tyme, temperature, and charge on 5 the right. globally establishes corresponding row(s) for 6 exponent matrices, returning done. */ 7 [v, actual, valid], 8 valid: '[mass, length, tyme, charge, temperature], 9 w:listify(w), 10 for u in w do ( 11 v:rhs(u), u:lhs(u), 12 actual: listofvars(v), 13 for ac in actual do if not member(ac,valid) then print( 14 "warning:", ac, "not member of", valid), 15 put(u,v,'dimension))) $ 16 17listify(w) := if listp(w) then w else [w] $ 18 19%pure: '[boltzmannsconstant, electricpermittivityofavacuum] $ 20 21nondimensionalize(u) := block(/* u is a list of indeterminates 22 representing classes of physical quantities such as velocity or 23 length, for which dimensions have previously been established 24 by the dimension function. returns a list of nondimensional 25 combinations of the physical quantities in u. */ 26/* ratmx:false in doe macsyma */ 27 [b, c, v, w, m, n, i, r, basis, logexpand, ratmx:false, scalarmatrixp], 28 u: listify(u), 29 30 /* determine basis: */ 31 m:n:0, 32 basis:[length, tyme, mass, temperature, charge], 33 if member('boltzmannsconstant, %pure) then (m:m+1, 34 basis:delete('temperature,basis)), 35 if member('electricpermittivityofavacuum,%pure) then (m:m+1, 36 basis:delete('charge,basis)), 37 if member('gravityconstant,%pure) then (n:n+1, 38 basis:delete('mass,basis)), 39 if member('plancksconstant,%pure) then (n:n+1, 40 basis:delete('tyme,basis)), 41 if member('speedoflight,%pure) then (n:n+1, 42 basis:delete('length,basis)), 43 if basis=[] then return(u), 44 if n>0 and m<2 then error("invalid to include gravityconstant", 45 "plancksconstant or speedoflight without also including", 46 "boltzmannsconstant & electricpermittivityofavacuum"), 47 c:b:v:w: [], 48/* ratmx:false in doe macsyma */ 49 logexpand:/* ratmx: */true, scalarmatrixp:false, 50 n:0, m:length(basis), 51 52 /* construct matrix of exponents: */ 53 for uu in u do (b: get(uu, 'dimension), 54 if b=false then error("first do an appropriate dimension(",''uu, 55 "= term with powers of mass, length, tyme, temperature & charge" 56 ), 57 if member('boltzmannsconstant, %pure) then 58 b: subst(temperature=mass*length^2/tyme^2, b), 59 if member(electricpermittivityofavacuum,%pure) then 60 b: subst(charge=length^(3/2)*mass^(1/2)/tyme, b), 61 if member(speedoflight,%pure) then 62 if member(plancksconstant,%pure) then 63 b: subst([length=1/mass,tyme=1/mass], b) 64 else if member(gravityconstant,%pure) then 65 b: subst([mass=tyme,length=tyme], b) 66 else b: subst(length=tyme, b) 67 else if member(plancksconstant,%pure) then 68 if member(gravityconstant,%pure) then 69 b: subst([mass=length^(-1/3), tyme=length^(-5/3)], b) 70 else b: subst(tyme=mass*length^2, b) 71 else if member(gravityconstant,%pure) then 72 b: subst(mass=length^3/tyme^2, b), 73 b:log(b), r:[], 74 for uu in basis do r:cons(coeff(b,log(uu)), r), 75 c:cons(r,c), w:cons(uu,w), n:n+1), 76 c:substinpart('matrix,c,0), 77 r:rank(c), 78 if r=0 then return(u), 79 if r=n then return([]), 80 81 /* delete dependent columns: */ 82 i:1, 83 while r<m do (b:submatrix(c,i), 84 while rank(b)<r do (i:i+1, 85 b:submatrix(c,i)), 86 m:m-1, 87 c:b), 88 89 /* partition into a nonsingular part and the other rows: */ 90 c:substinpart("[",c,0), b:[], 91 for j:1 thru r do( 92 b:cons(first(c),b), 93 while rank(substinpart('matrix,b,0))<j do( 94 c:endcons(first(c),rest(c)), 95 b:cons(first(c),rest(b)), 96 w:endcons(first(w),rest(w))), 97 c:rest(c), v:cons(first(w),v), w:rest(w)), 98 c:substinpart('matrix,c,0), b:substinpart('matrix,b,0), 99 100 /* form the matrix of physical-quantity exponents and the 101 corresponding dimensionless products: */ 102 c: c.b^^-1, b:[], 103 for l:1 thru n-r do 104 b: cons(w[l]/product(v[k]^c[l,k],k,1,r), b), 105 return(b)) $ 106 107dimension([ 108acceleration = length/tyme^2, 109angle = 1, 110angularacceleration = 1/tyme^2, 111angularmomentum = mass*length^2/tyme^2, 112angularvelocity = 1/tyme, 113area = length^2, 114boltzmannsconstant = mass*length^2/tyme^2/temperature, 115capacitance = tyme^2*charge^2/mass/length^2, 116charge = charge, 117current = charge/tyme, 118currentdensity = charge/tyme/length^2, 119density = mass/length^3, 120distance = length, 121electricfield = mass*length/tyme^2/charge, 122electricpermittivity = tyme^2*charge^2/mass/length^3, 123electricpermittivityofavacuum = tyme^2*charge^2/mass/length^3, 124energy = mass*length^2/tyme^2, 125enthalpy = length^2/tyme^2, 126frequency = 1/tyme, 127filmcoefficient = mass/tyme^3/temperature, 128flow = length^3/tyme, 129gravityconstant = length^3/mass/tyme^2, 130heat = mass*length^2/tyme^2, 131heatcapacity = mass*length^2/tyme^2/temperature, 132heattransfercoefficient = 1/tyme, 133inductance = mass*length^2/charge^2, 134internalenergy = length^2/tyme^2, 135kinematicviscosity = length^2/tyme, 136length = length, 137mass = mass, 138moment = mass*length^2/tyme^2, 139momentum = mass*length/tyme, 140magneticinduction = mass/tyme/charge, 141magneticpermittivity = mass*length/charge^2, 142plancksconstant = mass*length^2/tyme, 143poissonsratio = 1, 144power = mass*length^2/tyme^3, 145pressure = mass/length/tyme^2, 146resistance = mass*length^2/tyme/charge^2, 147specificheat = length^2/tyme^2/temperature, 148speedoflight = length/tyme, 149shearmodulus = mass/length/tyme^2, 150surfacetension = mass/tyme^2, 151stefanboltzmannconstant = mass/tyme^3/temperature^4, 152stress = mass/length/tyme^2, 153strain = 1, 154temperature = temperature, 155thermalconductivity = mass*length/tyme^3/temperature, 156thermalexpansioncoefficient = 1/temperature, 157thermaldiffusivity = length^2/tyme, 158tyme = tyme, 159velocity = length/tyme, 160volume = length^3, 161voltage = mass*length^2/tyme^2/charge, 162viscosity = mass/tyme/length, 163work = mass*length^2/tyme^2, 164youngsmodulus = mass/length/tyme^2]) $ 165alias(time,tyme,cputime,time)$ 166ttyoff: false$ 167