forked from nourani/ScientificQuantities
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQTest.cpp
More file actions
166 lines (150 loc) · 7.73 KB
/
SQTest.cpp
File metadata and controls
166 lines (150 loc) · 7.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
* main.cpp
*
* Created on: Feb 11, 2014
* Author: navid nourani-vatani
* Locaton: https://github.com/nourani/ScientificQuantities
*/
#include <iostream>
#include "ScientificQuantities.hpp"
#include "PhysicalConstants.hpp"
using namespace SciQ;
using namespace std;
int main( int argc, char ** argv ) {
cout << "The base SI units are: " << endl
<< "\tLength: " << Length(1) << endl
<< "\tMass: " << Mass(1) << endl
<< "\tTime: " << Time(1) << endl
<< "\tCurrent: " << Current(1) << endl
<< "\tTemperature: " << Temperature(1) << endl
<< "\tAmount of Substance: " << Substance(1) << endl
<< "\tLuminous intensity: " << Luminous(1) << endl;
cout << endl << "The derived SI units are: " << endl
<< "\tAngle: " << Angle(1) << endl
<< "\tSolidAngle: " << SolidAngle(1) << endl
<< "\tFrequency: " << Frequency(1) << endl
<< "\tForce: " << Force(1) << endl
<< "\tPressure: " << Pressure(1) << endl
<< "\tEnergy: " << Energy(1) << endl
<< "\tPower: " << Power(1) << endl
<< "\tCharge: " << Charge(1) << endl
<< "\tVoltage: " << Voltage(1) << endl
<< "\tCapacitance: " << Capacitance(1) << endl
<< "\tResistance: " << Resistance(1) << endl
<< "\tConductance: " << Conductance(1) << endl
<< "\tMagnetic Flux: " << MagneticFlux(1) << endl
<< "\tMagnetic Field: " << MagneticField(1) << endl
<< "\tInductance: " << Inductance(1) << endl
<< "\tLuminous Flux: " << LuminousFlux(1) << endl
<< "\tIlluminance: " << Illuminance(1) << endl
<< "\tRadioactivity: " << Radioactivity(1) << endl
<< "\tAbsorbed dose: " << AbsorbedDose(1) << endl
<< "\tEquivalent dose: " << EquivalentDose(1) << endl
<< "\tCatalytic activity: " << CatalyticActivity(1) << endl
<< "\tDynamics Viscosity: " << DynamicViscosity(1) << endl
<< "\tMoment of Force: " << MomentOfForce(1) << endl
<< "\tSurface Tension: " << SurfaceTension(1) << endl
<< "\tAngular Velocity: " << AngularVelocity(1) << endl
<< "\tAngular Acceleration:" << AngularAcceleration(1) << endl
<< "\tIrradiance: " << Irradiance(1) << endl
<< "\tEntropy: " << Entropy(1) << endl
<< "\tSpecific Entropy: " << SpecificEntropy(1) << endl
<< "\tSpecific Energy: " << SpecificEnergy(1) << endl
<< "\tThermal Conductivity:" << ThermalConductivity(1) << endl
<< "\tEnergy Density: " << EnergyDensity(1) << endl
<< "\tElectric Field Strength:" << ElectricFieldStrength(1) << endl
<< "\tElectric Charge Density:" << ElectricChargeDensity(1) << endl
<< "\tElectric Flux Density: " << ElectricFluxDensity(1) << endl
<< "\tPermittivity: " << Permittivity(1) << endl
<< "\tPermeability: " << Permeability(1) << endl
<< "\tMolar Energy: " << MolarEnergy(1) << endl
<< "\tMolar Entropy: " << MolarEntropy(1) << endl
<< "\tExposure: " << Exposure(1) << endl
<< "\tAbsorbed Dose Rate: " << AbsorbedDoseRate(1) << endl
<< "\tRadiant Intensity: " << RadiantIntensity(1) << endl
<< "\tRadiance: " << Radiance(1) << endl
<< "\tCatalytic Concentration: " << CatalyticConcentration(1) << endl ;
cout << endl << "Some additional units defined are: " << endl
<< "\tArea: " << Area(1) << endl
<< "\tVolume: " << Volume(1) << endl
<< "\tSpeed: " << Speed(1) << endl
<< "\tAcceleration: " << Acceleration(1) << endl;
cout << endl << "The following conversions are supported: " << endl
<< "\t kilometre: " << kilometre << endl
<< "\t metre: " << metre << endl
<< "\t centimetre: " << centimetre << endl
<< "\t milimetre: " << milimetre << endl
<< "\t tonne: " << tonne << endl
<< "\t kilogram: " << kilogram << endl
<< "\t gram: " << gram << endl
<< "\t kilometre2: " << kilometre2 << endl
<< "\t metre2: " << metre2 << endl
<< "\t second: " << second << endl
<< "\t minute: " << minute << endl
<< "\t hour: " << hour << endl
<< "\t day: " << day << endl
<< "\t kelvin: " << kelvin << endl
<< "\t celcius: " << celcius << endl
<< "\t fahrenhein: " << fahrenheit << endl
<< "\t radian: " << radian << endl
<< "\t degree: " << degree << endl
<< "\t gradian: " << gradian << endl
<< "\t turn: " << turn << endl
<< "\t angleminute: " << angleminute << endl
<< "\t anglesecond: " << anglesecond << endl
<< "\t litre: " << litre << endl
<< "\t bar: " << bar << endl
<< "\t atm: " << atm << endl
<< "\t eV: " << eV << endl
<< "\t keV: " << keV << endl
<< "\t MeV: " << MeV << endl
;
cout << endl << "The following units are available: " << endl
<< "\t_km, _m, _cm, _mm, _nm" << endl
<< "\t_tonne, _kg, _g" << endl
<< "\t_s, _sec, _min, _hr, _hour, _Hz" << endl
<< "\t_A, _J, _V, _W, _C, _F, _Ohm, _S, _H" << endl
<< "\t_K, _degC" << endl
<< "\t_mol, _Bq, _Gy, _kat" << endl
<< "\t_cd, _lm, _lx" << endl
<< "\t_rad, _deg" << endl
<< "\t_N, _Pa, _bar, _atm" << endl
<< "\t_Wb, _T" << endl
<< "\t_m2, _m3" << endl
<< "\t_mps, kmph" << endl;
cout << endl << "The following physical constants are available: " << endl
<< "\tVacuum Impedance (z_0): " << VacuumImpedance << endl
<< "\tElectric Constant (ep_0): " << ElectricConstant << endl
<< "\tMagnetic Constant (mu_0): " << MagneticConstant << endl
<< "\tElementary Charge (q_elem): " << ElementaryCharge << endl
<< "\tElectron Charge (q_elec): " << ElectronCharge << endl
<< "\tElectron Mass (m_e): " << ElectronMass << endl
;
cout << endl << "Example usage:" << endl;
Length l1 = 100_m;
Time t1 = 60_s;
Speed sp1 = l1 / t1;
cout << "\n\tTravelling " << l1 << " in " << t1 << " results in a velocity of " << sp1 << "."
<< endl;
Acceleration a2 = 100_m / 10_s / 10_s;
cout << "\n\tIf the acceleration was " << a2 << " then after " << t1
<< " we would be traveling at " << a2 * t1 << endl;
Frequency f1 = 1. / t1;
cout << "\n\tIf the duration between two flashes is " << t1 << " then the light is flashing at "
<< f1 << endl;
Area a1 = l1 * l1;
Volume v1 = a1 * l1;
cout << "\n\t(" << l1 << " * " << l1 << ") = " << a1 << "; in km2 = " << a1.in( kilometre2 )
<< endl;
Angle a3 = M_PI*radian;
a3 = 3. * a3;
Angle a4 = 90_deg + 2_rad;
cout << "\n\t" << t1 << " in minutes = " << t1.in( minute ) << endl;
cout << "\n\t" << l1 << " in km = " << l1.in( kilometre ) << endl;
cout << "\n\t" << a3 << " in deg: " << a3.in( degree ) << " = " << a3.in( turn ) << " turns"
<< endl;
cout << "\n\t" << a4 << " in grad: " << a4.in( gradian ) << " (c.lees!!!)" << endl;
double l = l1;
cout << "\n\tAssigning a length (" << l1 << ") to a double: " << l << endl;
return 0;
}