public class Physical extends Number implements 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 of time
day, hour = hr, min = minute, s = sec = second, year
Units of frequency
Hertz = Hz
Units of mass
AMU, g = gram, lb = pound, ounce = oz, slug
Units of distance
Angstrom, AU, ft = feet = foot, in = inch, m = meter = metre,
micron, mile, mill, parsec, yard
Units of area
acre
Units of volume
l = liter = litre
Units of force
dyne, N = Newton, poundal
Units of energy
BTU(thermochemical), Erg, J = Joule
Units of work
W = watt
Units of pressure
ATM = atomosphere, bar, Pascal
Units of temperature
degC = Celsius, degF = Fahrenheit, degK = Kelvin
Units of viscosity
poise, stoke
Units of charge
Abcoulomb, C = Coulomb, statcoulomb
Units of current
A = ampere, abampere, statampere
Units of voltage
Abvolt, V = volt
Units of magnetic induction
T = Tesla, Wb = Weber
Other units
1, farad, mole, Gauss, Henry, Maxwell, Ohm
The 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
Modifier and Type | Field and Description |
---|---|
protected static int |
CURRENT |
protected int[] |
dim |
protected static int |
LENGTH |
protected static int |
MASS |
protected static int |
TEMPERATURE |
protected static int |
TIME |
protected double |
value |
Constructor and Description |
---|
Physical()
Constructs a new 0-valued, dimensionless object.
|
Physical(double value,
int length,
int mass,
int time,
int current,
int temperature)
Constructs a new
Physical object and initializes
this object to a double value along with int
values for length, mass, time, current, and temperature. |
Physical(double value,
String units)
Constructs a new
Physical object and initializes
this object to a double value. |
Physical(Physical copy)
Constructs a copy of a
Physical object. |
Modifier and Type | Method and Description |
---|---|
static Physical |
add(Physical x,
Physical y)
Add two compatible
Physical objects. |
static void |
checkCompatibility(Physical x,
Physical y)
Checks the compatibility of two
Physical objects. |
static Physical |
constant(String name)
Returns the value of a constant, given its name.
|
static double |
constant(String name,
String units)
Returns the value of a constant, given its name, in the specified
units.
|
static Physical |
convert(Physical pOld,
String unitsNew)
Converts a value to a different set of units.
|
static void |
defineConstant(String name,
Physical value)
Defines a new constant.
|
static void |
definePrefix(String name,
double value)
Defines a new prefix.
|
static void |
defineUnit(String name,
Physical value)
Defines a new unit.
|
static Physical |
divide(double x,
Physical y)
Divide a
double by a Physical object. |
static Physical |
divide(Physical x,
double y)
Divide a
Physical object by a double . |
static Physical |
divide(Physical x,
Physical y)
Divide two
Physical objects. |
double |
doubleValue()
Returns the value of this dimensionless object.
|
float |
floatValue()
Returns the value of this dimensionless object.
|
int |
intValue()
Returns the value of this dimensionless object.
|
long |
longValue()
Returns the value of this dimensionless object.
|
static Physical |
multiply(double x,
Physical y)
Multiply a
double and a Physical object |
static Physical |
multiply(Physical x,
double y)
Multiply a
Physical object and a double |
static Physical |
multiply(Physical x,
Physical y)
Multiply two
Physical objects. |
static Physical |
negate(Physical x)
Negate a
Physical object. |
static Physical |
subtract(Physical x,
Physical y)
Subtract two compatible
Physical objects. |
String |
toString()
Returns a String containing the value and units, if any.
|
String |
unitsString()
Returns a String containing the units only.
|
byteValue, shortValue
protected double value
protected int[] dim
protected static final int LENGTH
protected static final int MASS
protected static final int TIME
protected static final int CURRENT
protected static final int TEMPERATURE
public Physical()
public Physical(Physical copy)
Physical
object.copy
- Physical
object from which a copy is madepublic Physical(double value, String units)
Physical
object and initializes
this object to a double
value.value
- double
value to which the copy of the object
is initializedunits
- String
specifying the unitpublic Physical(double value, int length, int mass, int time, int current, int temperature)
Physical
object and initializes
this object to a double
value along with int
values for length, mass, time, current, and temperature.value
- double
value to which this object is initializedlength
- int
value assigned to this object's lengthmass
- int
value assigned to this object's masstime
- int
value assigned to this object's timecurrent
- int
value assigned to this object's currenttemperature
- int
value assigned to this object's temperaturepublic static Physical negate(Physical x)
Physical
object.x
- Physical
object which is to be negatedPhysical
object which has been negatedpublic static Physical add(Physical x, Physical y)
Physical
objects.x
- Physical
object which is to be addedy
- Physical
object which is to be addedPhysical
object which is the sum of x + yIllegalArgumentException
- is thrown if x and y are
not compatiblepublic static Physical subtract(Physical x, Physical y)
Physical
objects.x
- Physical
objecty
- Physical
object which is to be subtracted
from xPhysical
object which is the result of x - yIllegalArgumentException
- is thrown if x and y are
not compatiblepublic static Physical multiply(Physical x, Physical y)
Physical
objects.x
- Physical
object which is to be multipliedy
- Physical
object which is to be multipliedPhysical
object which is the product of x and ypublic static Physical multiply(Physical x, double y)
Physical
object and a double
x
- Physical
object which is to be multipliedy
- double
which is to be multipliedPhysical
object which is the product of x and ypublic static Physical multiply(double x, Physical y)
double
and a Physical
objectx
- double
which is to be multipliedy
- Physical
object which is to be multipliedPhysical
object which is the product of x and ypublic static Physical divide(Physical x, Physical y)
Physical
objects.x
- Physical
object which is the numeratory
- Physical
object which is the divisorPhysical
object which is the result of x/ypublic static Physical divide(Physical x, double y)
Physical
object by a double
.x
- Physical
object which is the numeratory
- double
object which is the divisorPhysical
object which is the result of x/ypublic static Physical divide(double x, Physical y)
double
by a Physical
object.x
- double
which is the numeratory
- Physical
object which is the divisorPhysical
object which is the result of x/ypublic int intValue()
intValue
in class Number
int
value of the dimensionless objectIllegalArgumentException
- is thrown if the this object
is not dimensionlesspublic long longValue()
longValue
in class Number
long
value of the dimensionless objectIllegalArgumentException
- is thrown if the this object
is not dimensionlesspublic float floatValue()
floatValue
in class Number
float
value of the dimensionless objectIllegalArgumentException
- is thrown if the this object
is not dimensionlesspublic double doubleValue()
doubleValue
in class Number
double
value of the dimensionless objectIllegalArgumentException
- is thrown if the this object
is not dimensionlesspublic static Physical constant(String name)
name
- is a String
representing the name of the constant to
be returnedPhysical
object containing the value of the constant,
in its default unitsIllegalArgumentException
- is thrown when the name given is
undefinedpublic static double constant(String name, String units)
name
- is a String
representing the name of the constant
to be returned.units
- is a String
representing the units in which the
constant is to be returned.double
containing the value of the constant in the
specified unitsIllegalArgumentException
- is thrown if the constant name is
undefinedpublic static void defineConstant(String name, Physical value)
name
- a String
specifying the name of the constant to be definedvalue
- a Physical
object defining the value of the new constantpublic static void defineUnit(String name, Physical value)
name
- a String
specifying the name of the unit to be definedvalue
- a Physical
object defining the value of one unit in terms of
SI unitspublic static void definePrefix(String name, double value)
name
- a String
specifying the name of the prefix to be definedvalue
- is the double
value of the prefixpublic static Physical convert(Physical pOld, String unitsNew)
pOld
- a Physical
object specifying the value to be convertedunitsNew
- a String
specifying the units to which pOld
is to be convertedPhysical
object containing the value of pOld
converted to the new unitsIllegalArgumentException
- is thrown if the new and old
units are incompatiblepublic static void checkCompatibility(Physical x, Physical y)
Physical
objects.x
- a Physical
objecty
- a Physical
object to be checked against xIllegalArgumentException
- is thrown if the two
Physical
objects are incompatiblepublic String toString()
public String unitsString()
String
specifying the units
of this Physical
objectCopyright © 2020 Rogue Wave Software. All rights reserved.