Question: How to expand Unit expressions of combined units (compound units) to a product of Unit expressions?

Example: Exanding the left hand side below to the right hand side

Unit('kg'*'m'/'s'^2) = Unit('kg')*Unit('m')/Unit('s')^2;

Such functionality would be useful for manipulating rational functions whose coefficients have units that can otherwise only be simplified by substituting new dimensionless independent variables as dicussed here.

Is there statement that can be mapped over an expression that identifies all subsexpressions with units and expands them to a products of units?

Probably not possible but also desireable: A variant that expands derived physical quantities to a product of base units as for example Newton to base units: Unit('N') = Unit('kg')*Unit('m')/Unit('s')^2;

Unit('N') = Unit('kg')*Unit('m')/Unit('s')^2;

Edit: Example from the link above on Unit expressions with compound units

``

Example that cannot be simplified

H(s) = 60.*Unit('m'*'kg'/('s'^2*'A'))/(.70805*s^2*Unit('kg'^2*'m'^2/('s'^3*'A'^2))+144.*s*Unit('kg'^2*'m'^2/('s'^4*'A'^2))+0.3675e-4*s^3*Unit('kg'^2*'m'^2/('s'^2*'A'^2)))

H(s) = 60.*Units:-Unit(m*kg/(s^2*A))/(.70805*s^2*Units:-Unit(kg^2*m^2/(s^3*A^2))+144.*s*Units:-Unit(kg^2*m^2/(s^4*A^2))+0.3675e-4*s^3*Units:-Unit(kg^2*m^2/(s^2*A^2)))

(1)

simplify(%)

H(s) = 60.*Units:-Unit(m*kg/(s^2*A))/(.70805*s^2*Units:-Unit(kg^2*m^2/(s^3*A^2))+144.*s*Units:-Unit(kg^2*m^2/(s^4*A^2))+0.3675e-4*s^3*Units:-Unit(kg^2*m^2/(s^2*A^2)))

(2)

After expansion of Unit expression (here done by hand) simplifcationis possible with other Maple commands

H(s) = 60.*Unit('m')*Unit('kg')/((.70805*s^2*Unit('kg')^2*Unit('m')^2/(Unit('s')^3*Unit('A')^2)+144.*s*Unit('kg')^2*Unit('m')^2/(Unit('s')^4*Unit('A')^2)+0.3675e-4*s^3*Unit('kg')^2*Unit('m')^2/(Unit('s')^2*Unit('A')^2))*Unit('s')^2*Unit('A'))

H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A))

(3)

factor(H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A)))

H(s) = 1632653.061*Units:-Unit(s)^2*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)*s*(19266.66666*s*Units:-Unit(s)+3918367.346+.9999999999*s^2*Units:-Unit(s)^2))

(4)

normal(H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A)))

H(s) = 60.*Units:-Unit(s)^2*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(5)

Normalization to a dimensionless equation expression (that still has units) by a scaling factor with units

Sc := Unit('s')^3*Unit('A')/(Unit('m')*Unit('kg'))

Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg))

(6)

(H(s) = 60.*Units[Unit](s)^2*Units[Unit](A)/(Units[Unit](m)*Units[Unit](kg)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))*(1/Sc)

Units:-Unit(m)*Units:-Unit(kg)*H(s)/(Units:-Unit(s)^3*Units:-Unit(A)) = 60./(Units:-Unit(s)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(7)

Rewriting the left hand side

(proc (x) options operator, arrow; x = convert(x, units, m/V) end proc)(Sc)

Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)) = Units:-Unit(m/V)

(8)

isolate(Units[Unit](s)^3*Units[Unit](A)/(Units[Unit](m)*Units[Unit](kg)) = Units[Unit](m/V), Unit('m'))

Units:-Unit(m) = Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m/V)*Units:-Unit(kg))

(9)

subs(Units[Unit](m) = Units[Unit](s)^3*Units[Unit](A)/(Units[Unit](m/V)*Units[Unit](kg)), Units[Unit](m)*Units[Unit](kg)*H(s)/(Units[Unit](s)^3*Units[Unit](A)) = 60./(Units[Unit](s)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))

H(s)/Units:-Unit(m/V) = 60./(Units:-Unit(s)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(10)

Magnitude plot

abs(H(s)/Units[Unit](m/V) = 60./(Units[Unit](s)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))

abs(H(s))/Units:-Unit(m/V) = 60./(Units:-Unit(s)*abs(s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2)))

(11)

H(s) = H(f), s = I*omega, omega = 2*Pi*f

H(s) = H(f), s = I*omega, omega = 2*Pi*f

(12)

subs(H(s) = H(f), s = I*omega, omega = 2*Pi*f, abs(H(s))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs(s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2))))

abs(H(f))/Units:-Unit(m/V) = 60./(Units:-Unit(s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units:-Unit(s)+144.-0.14700e-3*Pi^2*f^2*Units:-Unit(s)^2)))

(13)

plot(rhs(abs(H(f))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units[Unit](s)+144.-0.14700e-3*Pi^2*f^2*Units[Unit](s)^2)))), f = 0*Unit('Hz') .. 10*Unit('Hz'), labels = [f/Unit('Hz'), lhs(abs(H(f))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units[Unit](s)+144.-0.14700e-3*Pi^2*f^2*Units[Unit](s)^2))))])

 

 


Download Expansion_of_Unit_command_and_simplification_to_m_per_V.mw

Please Wait...