Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] derived units of SI system (newbie)
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-12-10 10:52:52


AMDG

On 12/10/2010 4:52 AM, André Berthe wrote:
> I would like to calculate a shear stress based on a shear rate and a
> viscosity using Boost.Units. Here I have problems using derived
> dimensions and conversion factors based on a existing system. The
> error messages of my compiler are in German, so I tried to document my
> problems with a test code:
>
> <main.cpp>
> #include <boost/units/systems/si/dynamic_viscosity.hpp>
> #include "stress.h"
> #include "shearrate.h"
>
> namespace bu = boost::units;
> namespace SI = bu::si;
>
> main(){
> //Define a quantity of unit stress. Unfortunately there is no
> //realization of the defined physical dimension stress in si.
> //So a user defined type from stress.h (see below) is used:
> bu::quantity<SI::stress> WSS_x;
>
> //Define a shear rate. I did not understand how to use a //inverse
> time as dimension. Therefore I defined the derived
> //dimension per_time in shearrate.h. Is it possible to add it to
> //the si system (as I tried) or do I have to define
> //my own system and a conversion factor?
> bu::quantity<SI::per_time> WSR_x(1*per_second);

The inverse of time is frequency.

> //There is a existing si type for the dynamic viscosity.
> //However, there is no defined constant. How is the
> //correct way to assign a value? Should I define this
> //constant?
> bu::quantity<SI::dynamic_viscosity> eta;

You can define the constant or you can combine other
units: si::kilograms/(si::meter*si::second).

> //Calculation of the shear stress. It seems that this calculation
> //tries to use a »sizeof« on eta, that seems to have a
> // incomplete type
> //(»boost::STATIC_ASSERTION_FAILURE<false>«). And there
> //seems to be something wrong with the conversion. //Do I have to
> define a conversion factor? Or is this error
> //caused by my previous mistakes?
> WSS_x=WSR_x/eta;

The dimensions of stress are L^-1 M T^-2.
Dynamic viscosity is M L^-1 T^-1. Thus, the
ratio WSR_x/eta should be (1/T)/(M L^-1 T^-1) = M^-1 L.
You get an error because the dimensions don't
match.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net