Chaste  Build::
UnitCollection.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef UNITCOLLECTIONS_HPP
37 #define UNITCOLLECTIONS_HPP
38 
39 #include <map>
40 #include <string>
41 #include <sstream>
42 #include <boost/units/quantity.hpp>
43 #include <boost/units/derived_dimension.hpp>
44 #include <boost/units/make_scaled_unit.hpp>
45 #include <boost/units/scaled_base_unit.hpp>
46 #include <boost/units/scale.hpp>
47 #include <boost/units/static_rational.hpp>
48 #include <boost/units/units_fwd.hpp>
49 #include <boost/units/io.hpp>
50 #include <boost/units/reduce_unit.hpp>
51 #include <boost/units/pow.hpp>
52 #include <boost/units/cmath.hpp>
53 
54 #include <boost/units/systems/si.hpp>
55 #include <boost/units/systems/si/base.hpp>
56 #include <boost/units/systems/si/io.hpp>
57 #include <boost/units/systems/si/dimensionless.hpp>
58 #include <boost/units/systems/si/time.hpp>
59 #include <boost/units/systems/si/length.hpp>
60 #include <boost/units/systems/si/force.hpp>
61 #include <boost/units/systems/si/pressure.hpp>
62 #include <boost/units/systems/si/mass.hpp>
63 #include <boost/units/systems/si/amount.hpp>
64 #include <boost/units/systems/si/plane_angle.hpp>
65 #include <boost/units/systems/si/absorbed_dose.hpp>
66 
67 #include <boost/units/base_units/metric/minute.hpp>
68 #include <boost/units/base_units/metric/hour.hpp>
69 #include <boost/units/base_units/metric/day.hpp>
70 #include <boost/units/base_units/metric/mmHg.hpp>
71 #include <boost/units/base_units/metric/micron.hpp>
72 
82 namespace units = boost::units;
83 namespace unit{
84 
85  typedef units::unit<units::dimensionless_type, units::si::system> dimensionless;
86  BOOST_UNITS_STATIC_CONSTANT(no_unit, dimensionless);
87 
88  // angle
89  typedef units::derived_dimension<units::plane_angle_base_dimension, -1>::type plane_angle_dimension;
90  //typedef units::unit<plane_angle_dimension, units::si::system> plane_angle;
91  typedef units::si::plane_angle plane_angle;
92  BOOST_UNITS_STATIC_CONSTANT(radians, plane_angle);
93 
94  // Time
95  typedef units::derived_dimension<units::time_base_dimension, 1>::type time_dimension;
96  typedef units::unit<time_dimension, units::si::system> time;
97  BOOST_UNITS_STATIC_CONSTANT(seconds, time);
98  BOOST_UNITS_STATIC_CONSTANT(minutes, units::metric::minute_base_unit::unit_type);
99  BOOST_UNITS_STATIC_CONSTANT(hours, units::metric::hour_base_unit::unit_type);
100  BOOST_UNITS_STATIC_CONSTANT(days, units::metric::day_base_unit::unit_type);
101  typedef units::derived_dimension<units::time_base_dimension, -1>::type rate_dimension;
102  typedef units::unit<rate_dimension, units::si::system> rate;
103  BOOST_UNITS_STATIC_CONSTANT(per_second, rate);
104  typedef units::make_scaled_unit<rate, units::scale<60, units::static_rational<-1> > >::type per_minute_type;
105  BOOST_UNITS_STATIC_CONSTANT(per_minute, per_minute_type);
106  typedef units::make_scaled_unit<rate, units::scale<3600, units::static_rational<-1> > >::type per_hour_type;
107  BOOST_UNITS_STATIC_CONSTANT(per_hour, per_hour_type);
108 
109  // Length
110  typedef units::derived_dimension<units::length_base_dimension, 1>::type length_dimension;
111  typedef units::unit<length_dimension, units::si::system> length;
112  BOOST_UNITS_STATIC_CONSTANT(metres, length);
113  typedef units::derived_dimension<units::length_base_dimension, 2>::type area_dimension;
114  typedef units::unit<area_dimension, units::si::system> area;
115  BOOST_UNITS_STATIC_CONSTANT(metres_squared, area);
116  typedef units::derived_dimension<units::length_base_dimension, 3>::type volume_dimension;
117  typedef units::unit<volume_dimension, units::si::system> volume;
118  BOOST_UNITS_STATIC_CONSTANT(metres_cubed, volume);
119 
120  BOOST_UNITS_STATIC_CONSTANT(microns, units::metric::micron_base_unit::unit_type);
121  typedef units::derived_dimension<units::length_base_dimension, -1>::type per_length_dimension;
122  typedef units::unit<per_length_dimension, units::si::system> per_length;
123  BOOST_UNITS_STATIC_CONSTANT(per_metre, per_length);
124  typedef units::derived_dimension<units::length_base_dimension, -2>::type per_area_dimension;
125  typedef units::unit<per_area_dimension, units::si::system> per_area;
126  BOOST_UNITS_STATIC_CONSTANT(per_metre_squared, per_area);
127 
128  // Mass
129  typedef units::derived_dimension<units::mass_base_dimension, 1>::type mass_dimension;
130  typedef units::unit<mass_dimension, units::si::system> mass;
131  BOOST_UNITS_STATIC_CONSTANT(kg, mass);
132  typedef units::derived_dimension<units::mass_base_dimension, 1, units::time_base_dimension, -1>::type mass_flow_rate_dimension;
133  typedef units::unit<mass_flow_rate_dimension, units::si::system> mass_flow_rate;
134  BOOST_UNITS_STATIC_CONSTANT(kg_per_second, mass_flow_rate);
135  typedef units::derived_dimension<units::mass_base_dimension, 1, units::length_base_dimension, -2, units::time_base_dimension, -1>::type mass_flux_dimension;
136  typedef units::unit<mass_flux_dimension, units::si::system> mass_flux;
137  BOOST_UNITS_STATIC_CONSTANT(kg_per_metre_squared_per_second, mass_flux);
138 
139  // Amount
140  typedef units::si::amount amount;
141  BOOST_UNITS_STATIC_CONSTANT(moles, units::si::amount);
142  typedef units::derived_dimension<units::amount_base_dimension, 1, units::time_base_dimension, -1>::type molar_flow_rate_dimension;
143  typedef units::unit<molar_flow_rate_dimension, units::si::system> molar_flow_rate;
144  BOOST_UNITS_STATIC_CONSTANT(mole_per_second, molar_flow_rate);
145  typedef units::derived_dimension<units::amount_base_dimension, 1, units::length_base_dimension, -3, units::time_base_dimension, -1>::type concentration_flow_rate_dimension;
146  typedef units::unit<concentration_flow_rate_dimension, units::si::system> concentration_flow_rate;
147  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_cubed_per_second, concentration_flow_rate);
148  typedef units::derived_dimension<units::amount_base_dimension, 1, units::length_base_dimension, -2, units::time_base_dimension, -1>::type molar_flux_dimension;
149  typedef units::unit<molar_flux_dimension, units::si::system> molar_flux;
150  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_squared_per_second, molar_flux);
151  typedef units::derived_dimension<units::amount_base_dimension, 1, units::length_base_dimension, -5, units::time_base_dimension, -1>::type concentration_flux_dimension;
152  typedef units::unit<concentration_flux_dimension, units::si::system> concentration_flux;
153  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_pow5_per_second, concentration_flux);
154  typedef units::derived_dimension<units::amount_base_dimension, 1, units::length_base_dimension, -3>::type concentration_dimension;
155  typedef units::unit<concentration_dimension, units::si::system> concentration;
156  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_cubed, concentration);
157  typedef units::derived_dimension<units::amount_base_dimension, 1, units::length_base_dimension, -4>::type concentration_gradient_dimension;
158  typedef units::unit<concentration_gradient_dimension, units::si::system> concentration_gradient;
159  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_pow_4, concentration_gradient);
160  typedef units::derived_dimension<units::amount_base_dimension, -1, units::time_base_dimension, -1, units::length_base_dimension, 3>::type rate_per_concentration_dimension;
161  typedef units::unit<rate_per_concentration_dimension, units::si::system> rate_per_concentration;
162  BOOST_UNITS_STATIC_CONSTANT(metre_cubed_per_mole_per_second, rate_per_concentration);
163  typedef units::derived_dimension<units::amount_base_dimension, 1, units::mass_base_dimension, -1>::type molar_mass_dimension;
164  typedef units::unit<molar_mass_dimension, units::si::system> molar_mass;
165  BOOST_UNITS_STATIC_CONSTANT(mole_per_kg, molar_mass);
166  typedef units::derived_dimension<units::length_base_dimension, -3>::type number_density_dimension;
167  typedef units::unit<number_density_dimension, units::si::system> number_density;
168  BOOST_UNITS_STATIC_CONSTANT(per_metre_cubed, number_density);
169 
170  // Velocity
171  typedef units::derived_dimension<units::length_base_dimension, 1, units::time_base_dimension, -1>::type velocity_dimension;
172  typedef units::unit<velocity_dimension, units::si::system> velocity;
173  BOOST_UNITS_STATIC_CONSTANT(metres_per_second, velocity);
174 
175  // Force/Pressure/Stress
176  typedef units::derived_dimension<units::mass_base_dimension, 1, units::length_base_dimension, 1, units::time_base_dimension, -2>::type force_dimension;
177  typedef units::unit<force_dimension, units::si::system> force;
178  BOOST_UNITS_STATIC_CONSTANT(newtons, force);
179 
180  typedef units::derived_dimension<units::mass_base_dimension, 1, units::length_base_dimension, -1, units::time_base_dimension, -2>::type pressure_dimension;
181  typedef units::unit<pressure_dimension, units::si::system> pressure;
182  BOOST_UNITS_STATIC_CONSTANT(pascals, pressure);
183  BOOST_UNITS_STATIC_CONSTANT(mmHg, units::metric::mmHg_base_unit::unit_type);
184 
185  // Flow
186  typedef units::derived_dimension<units::mass_base_dimension, 1, units::length_base_dimension, -1, units::time_base_dimension, -1>::type dynamic_viscosity_dimension;
187  typedef units::unit<dynamic_viscosity_dimension, units::si::system> dynamic_viscosity;
188  BOOST_UNITS_STATIC_CONSTANT(poiseuille, dynamic_viscosity);
189  typedef units::derived_dimension<units::length_base_dimension, 3, units::time_base_dimension, -1>::type flow_rate_dimension;
190  typedef units::unit<flow_rate_dimension, units::si::system> flow_rate;
191  BOOST_UNITS_STATIC_CONSTANT(metre_cubed_per_second, flow_rate);
192  typedef units::derived_dimension<units::mass_base_dimension, 1, units::length_base_dimension, -4, units::time_base_dimension, -1>::type flow_impedance_dimension;
193  typedef units::unit<flow_impedance_dimension, units::si::system> flow_impedance;
194  BOOST_UNITS_STATIC_CONSTANT(pascal_second_per_metre_cubed, flow_impedance);
195 
196  // Diffusivity, Solubility, Permeability
197  typedef units::derived_dimension<units::length_base_dimension, 2, units::time_base_dimension, -1>::type diffusivity_dimension;
198  typedef units::unit<diffusivity_dimension, units::si::system> diffusivity;
199  BOOST_UNITS_STATIC_CONSTANT(metre_squared_per_second, diffusivity);
200  typedef units::derived_dimension<units::length_base_dimension, 5, units::time_base_dimension, -1, units::amount_base_dimension, -1>::type diffusivity_per_concentration_dimension;
201  typedef units::unit<diffusivity_per_concentration_dimension, units::si::system> diffusivity_per_concentration;
202  BOOST_UNITS_STATIC_CONSTANT(metre_pow5_per_second_per_mole, diffusivity_per_concentration);
203  typedef units::derived_dimension<units::amount_base_dimension, 1, units::mass_base_dimension, -1, units::length_base_dimension, -2, units::time_base_dimension, 2>::type solubility_dimension;
204  typedef units::unit<solubility_dimension, units::si::system> solubility;
205  BOOST_UNITS_STATIC_CONSTANT(mole_per_metre_cubed_per_pascal, solubility);
206  typedef units::derived_dimension<units::mass_base_dimension, -1, units::length_base_dimension, 1, units::time_base_dimension, 2>::type volumetric_solubility_dimension;
207  typedef units::unit<volumetric_solubility_dimension, units::si::system> volumetric_solubility;
208  BOOST_UNITS_STATIC_CONSTANT(per_pascal, volumetric_solubility);
209 
210  typedef units::derived_dimension<units::length_base_dimension, 1, units::time_base_dimension, -1>::type membrane_permeability_dimension;
211  typedef units::unit<membrane_permeability_dimension, units::si::system> membrane_permeability;
212  BOOST_UNITS_STATIC_CONSTANT(metre_per_second, membrane_permeability);
213 
214  // Radiation
215  typedef units::derived_dimension<units::length_base_dimension, 2, units::time_base_dimension, -2>::type absorbed_dose_dimension;
216  typedef units::unit<absorbed_dose_dimension, units::si::system> absorbed_dose;
217  BOOST_UNITS_STATIC_CONSTANT(gray, absorbed_dose);
218 
219  typedef units::derived_dimension<units::length_base_dimension, -2, units::time_base_dimension, 2>::type per_absorbed_dose_dimension;
220  typedef units::unit<per_absorbed_dose_dimension, units::si::system> per_absorbed_dose;
221  BOOST_UNITS_STATIC_CONSTANT(per_gray, per_absorbed_dose);
222 
223  typedef units::derived_dimension<units::length_base_dimension, -4, units::time_base_dimension, 4>::type per_absorbed_dose_squared_dimension;
224  typedef units::unit<per_absorbed_dose_squared_dimension, units::si::system> per_absorbed_dose_squared;
225  BOOST_UNITS_STATIC_CONSTANT(per_gray_squared, per_absorbed_dose_squared);
226 
227 };
228 
229 
230 #endif /* UNITCOLLECTIONS_HPP */