Class Physical
- All Implemented Interfaces:
Serializable,Cloneable
String specifying the name of the
physical constant does not matter. The names 'PI', 'Pi', 'pI' and 'pi'
are equivalent.
The units of the physical constants are in SI units, (meter-kilogram-second).
The names allowed are as follows:
| Name | Description | Value | Reference |
| AMU | Atomic mass unit | 1.6605402E-27 kg | [1] |
| ATM | Standard atm pressure | 1.01325E+5 \(\rm {N / m^2}\) | E[2] |
| AU | Astronomical unit | 1.496E+11 m | [ ] |
| Avogadro | Avogadro's number | 6.0221367E+23 1/mole | [1] |
| Boltzman | Boltzman's constant | 1.380658E-23 J/K | [1] |
| C | Speed of light | 2.997924580E+8 m/s | E[1] |
| Catalan | Catalan's constant | 0.915965... | E[3] |
| E | Base of natural logs | 2.718... | E[3] |
| ElectronCharge | Electron change | 1.60217733E-19 C | [1] |
| ElectronMass | Electron mass | 9.1093897E-31 kg | [1] |
| ElectronVolt | Electron volt | 1.60217733E-19 J | [1] |
| Euler | Euler's constant gamma | 0.577... | E[3] |
| Faraday | Faraday constant | 9.6485309E+4 C/mole | [1] |
| FineStructure | Fine structure | 7.29735308E-3 | [1] |
| Gamma | Euler's constant | 0.577... | E[3] |
| Gas | Gas constant | 8.314510 J/mole/K | [1] |
| Gravity | Gravitational constant | 6.67259E-11 \(\rm {Nm^2/{\rm {kg}}^2}\) | [1] |
| Hbar | Planck constant / 2 pi | 1.05457266E-34 J*s | [1] |
| PerfectGasVolume | Std vol ideal gas | 2.241383E-2 \(\rm {m^3/ {\rm {mole}}}\) | [*] |
| Pi | Pi | 3.141... | E[3] |
| Planck | Planck's constant h | 6.6260755E-34 J*s | [1] |
| ProtonMass | Proton mass | 1.6726231E-27 kg | [1] |
| Rydberg | Rydberg's constant | 1.0973731534E+7 /m | [1] |
| SpeedLight | Speed of light | 2.997924580E+8 m/s | E[1] |
| StandardGravity | Standard g | 9.80665 \(\rm {m/s^2}\) | E[2] |
| StandardPressure | Standard atm pressure | 1.01325E+5 \(\rm {N/m^2}\) | E[2] |
| StefanBoltzmann | Stefan-Boltzman | 5.67051E-8 \(\rm {W/K^4/m^2}\) | [1] |
| WaterTriple | Triple point of water | 2.7316E+2 K | E[2] |
The reference for constants are indicated by the code in the [] comment above.
| [1] | Cohen and Taylor (1986) |
| [2] | Liepman (1964) |
| [3] | Precomputed mathematical constants |
The constants marked with an E before the [] are exact (to machine precision).
- Units strings have the form U1*U2*...*Um/V1/.../Vn, where Ui and Vi are the names of basic units or are the names of basic units raised to a power. Examples are, 'METER*KILOGRAM/SECOND', 'M*KG/S', 'METER', or '\(\rm {M/KG^2}\)'. These strings are case insensitive.
- The basic unit names allowed are as follows.
Units of time
day, hour = hr, min = minute, s = sec = second, yearUnits of frequency
Hertz = HzUnits of mass
AMU, g = gram, lb = pound, ounce = oz, slugUnits of distance
Angstrom, AU, ft = feet = foot, in = inch, m = meter = metre, micron, mile, mill, parsec, yardUnits of area
acreUnits of volume
l = liter = litreUnits of force
dyne, N = Newton, poundalUnits of energy
BTU(thermochemical), Erg, J = JouleUnits of work
W = wattUnits of pressure
ATM = atomosphere, bar, PascalUnits of temperature
degC = Celsius, degF = Fahrenheit, degK = KelvinUnits of viscosity
poise, stokeUnits of charge
Abcoulomb, C = Coulomb, statcoulombUnits of current
A = ampere, abampere, statampereUnits of voltage
Abvolt, V = voltUnits of magnetic induction
T = Tesla, Wb = WeberOther units
1, farad, mole, Gauss, Henry, Maxwell, OhmThe following metric prefixes may be used with the above units. Note that the one or two letter prefixes may only be used with one letter unit abbreviations.
A = atto = 1.E-18
F = femto = 1.E-15
P = pico = 1.E-12
N = nano = 1.E-9
U = micro = 1.E-6
M = milli = 1.E-3
C = centi = 1.E-2
D = deci = 1.E-1
DK = deca = 1.E+1
K = kilo = 1.E+3
myria = 1.E+4 (no single letter prefix; M means milli)
mega = 1.E+6 (no single letter prefix; M means milli)
G = giga = 1.E+9
T = tera = 1.E+12
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPhysical()Constructs a new 0-valued, dimensionless object.Physical(double value, int length, int mass, int time, int current, int temperature) Constructs a newPhysicalobject and initializes this object to adoublevalue along withintvalues for length, mass, time, current, and temperature.Constructs a newPhysicalobject and initializes this object to adoublevalue.Constructs a copy of aPhysicalobject. -
Method Summary
Modifier and TypeMethodDescriptionstatic PhysicalAdd two compatiblePhysicalobjects.static voidChecks the compatibility of twoPhysicalobjects.static PhysicalReturns the value of a constant, given its name.static doubleReturns the value of a constant, given its name, in the specified units.static PhysicalConverts a value to a different set of units.static voiddefineConstant(String name, Physical value) Defines a new constant.static voiddefinePrefix(String name, double value) Defines a new prefix.static voiddefineUnit(String name, Physical value) Defines a new unit.static PhysicalDivide adoubleby aPhysicalobject.static PhysicalDivide aPhysicalobject by adouble.static PhysicalDivide twoPhysicalobjects.doubleReturns the value of this dimensionless object.floatReturns the value of this dimensionless object.intintValue()Returns the value of this dimensionless object.longReturns the value of this dimensionless object.static PhysicalMultiply adoubleand aPhysicalobjectstatic PhysicalMultiply aPhysicalobject and adoublestatic PhysicalMultiply twoPhysicalobjects.static PhysicalNegate aPhysicalobject.static PhysicalSubtract two compatiblePhysicalobjects.toString()Returns a String containing the value and units, if any.Returns a String containing the units only.Methods inherited from class java.lang.Number
byteValue, shortValue
-
Field Details
-
value
protected double value -
dim
protected int[] dim -
LENGTH
protected static final int LENGTH- See Also:
-
MASS
protected static final int MASS- See Also:
-
TIME
protected static final int TIME- See Also:
-
CURRENT
protected static final int CURRENT- See Also:
-
TEMPERATURE
protected static final int TEMPERATURE- See Also:
-
-
Constructor Details
-
Physical
public Physical()Constructs a new 0-valued, dimensionless object. -
Physical
Constructs a copy of aPhysicalobject.- Parameters:
copy-Physicalobject from which a copy is made
-
Physical
Constructs a newPhysicalobject and initializes this object to adoublevalue.- Parameters:
value-doublevalue to which the copy of the object is initializedunits-Stringspecifying the unit
-
Physical
public Physical(double value, int length, int mass, int time, int current, int temperature) Constructs a newPhysicalobject and initializes this object to adoublevalue along withintvalues for length, mass, time, current, and temperature.- Parameters:
value-doublevalue to which this object is initializedlength-intvalue assigned to this object's lengthmass-intvalue assigned to this object's masstime-intvalue assigned to this object's timecurrent-intvalue assigned to this object's currenttemperature-intvalue assigned to this object's temperature
-
-
Method Details
-
negate
Negate aPhysicalobject.- Parameters:
x-Physicalobject which is to be negated- Returns:
Physicalobject which has been negated
-
add
Add two compatiblePhysicalobjects.- Parameters:
x-Physicalobject which is to be addedy-Physicalobject which is to be added- Returns:
Physicalobject which is the sum of x + y- Throws:
IllegalArgumentException- is thrown if x and y are not compatible
-
subtract
Subtract two compatiblePhysicalobjects.- Parameters:
x-Physicalobjecty-Physicalobject which is to be subtracted from x- Returns:
Physicalobject which is the result of x - y- Throws:
IllegalArgumentException- is thrown if x and y are not compatible
-
multiply
Multiply twoPhysicalobjects.- Parameters:
x-Physicalobject which is to be multipliedy-Physicalobject which is to be multiplied- Returns:
Physicalobject which is the product of x and y
-
multiply
Multiply aPhysicalobject and adouble- Parameters:
x-Physicalobject which is to be multipliedy-doublewhich is to be multiplied- Returns:
Physicalobject which is the product of x and y
-
multiply
Multiply adoubleand aPhysicalobject- Parameters:
x-doublewhich is to be multipliedy-Physicalobject which is to be multiplied- Returns:
Physicalobject which is the product of x and y
-
divide
Divide twoPhysicalobjects.- Parameters:
x-Physicalobject which is the numeratory-Physicalobject which is the divisor- Returns:
Physicalobject which is the result of x/y
-
divide
Divide aPhysicalobject by adouble.- Parameters:
x-Physicalobject which is the numeratory-doubleobject which is the divisor- Returns:
Physicalobject which is the result of x/y
-
divide
Divide adoubleby aPhysicalobject.- Parameters:
x-doublewhich is the numeratory-Physicalobject which is the divisor- Returns:
Physicalobject which is the result of x/y
-
intValue
public int intValue()Returns the value of this dimensionless object.- Specified by:
intValuein classNumber- Returns:
- the
intvalue of the dimensionless object - Throws:
IllegalArgumentException- is thrown if the this object is not dimensionless
-
longValue
public long longValue()Returns the value of this dimensionless object.- Specified by:
longValuein classNumber- Returns:
- the
longvalue of the dimensionless object - Throws:
IllegalArgumentException- is thrown if the this object is not dimensionless
-
floatValue
public float floatValue()Returns the value of this dimensionless object.- Specified by:
floatValuein classNumber- Returns:
- the
floatvalue of the dimensionless object - Throws:
IllegalArgumentException- is thrown if the this object is not dimensionless
-
doubleValue
public double doubleValue()Returns the value of this dimensionless object.- Specified by:
doubleValuein classNumber- Returns:
- the
doublevalue of the dimensionless object - Throws:
IllegalArgumentException- is thrown if the this object is not dimensionless
-
constant
Returns the value of a constant, given its name.- Parameters:
name- is aStringrepresenting the name of the constant to be returned- Returns:
- the
Physicalobject containing the value of the constant, in its default units - Throws:
IllegalArgumentException- is thrown when the name given is undefined
-
constant
Returns the value of a constant, given its name, in the specified units.- Parameters:
name- is aStringrepresenting the name of the constant to be returned.units- is aStringrepresenting the units in which the constant is to be returned.- Returns:
- a
doublecontaining the value of the constant in the specified units - Throws:
IllegalArgumentException- is thrown if the constant name is undefined
-
defineConstant
Defines a new constant.- Parameters:
name- aStringspecifying the name of the constant to be definedvalue- aPhysicalobject defining the value of the new constant
-
defineUnit
Defines a new unit.- Parameters:
name- aStringspecifying the name of the unit to be definedvalue- aPhysicalobject defining the value of one unit in terms of SI units
-
definePrefix
Defines a new prefix.- Parameters:
name- aStringspecifying the name of the prefix to be definedvalue- is thedoublevalue of the prefix
-
convert
Converts a value to a different set of units.- Parameters:
pOld- aPhysicalobject specifying the value to be convertedunitsNew- aStringspecifying the units to whichpOldis to be converted- Returns:
- a
Physicalobject containing the value ofpOldconverted to the new units - Throws:
IllegalArgumentException- is thrown if the new and old units are incompatible
-
checkCompatibility
Checks the compatibility of twoPhysicalobjects.- Parameters:
x- aPhysicalobjecty- aPhysicalobject to be checked against x- Throws:
IllegalArgumentException- is thrown if the twoPhysicalobjects are incompatible
-
toString
Returns a String containing the value and units, if any. -
unitsString
Returns a String containing the units only.- Returns:
- a
Stringspecifying the units of thisPhysicalobject
-