Packages

  • package root
    Definition Classes
    root
  • package squants

    The Scala API for Quantities, Units of Measure and Dimensional Analysis

    Squants

    The Scala API for Quantities, Units of Measure and Dimensional Analysis

    Overview

    Squants is a framework of data types and a domain specific language (DSL) for representing Quantities, their Units of Measure, and their Dimensional relationships. The API supports typesafe dimensional analysis, improved domain models and more. All types are immutable and thread-safe.

    Typedefs and implicits for common usages

    Definition Classes
    root
    Version

    0.1

    Since

    0.1

  • package electro

    Definition Classes
    squants
    Since

    0.1

  • package energy

    Definition Classes
    squants
    Since

    0.1

  • package information
    Definition Classes
    squants
  • package market

    Squants Market API

    Squants Market API

    Market Types are similar but not quite the same as other quantities in the library.

    The primary type, squants.market.Money, is derived from Quantity, and its Units of Measure are Currencies. However, because the conversion multipliers between units can not be predefined, many of the behaviors have been overridden and augmented to realize correct behavior.

    squants.market.Prices represent a Ratio between Money and some other Quantity. Prices can be created from ratios of Money and a Quantity

    val money: Money = USD(10)
    val length: Length = Meters(1)
    val price: Price[Length] = money / length

    Multiplying a Price * Quantity will yield Money amount that represents the cost of the quantity

    val cost: Money = price * Meters(3.8)

    and multiplying Price * Money will yield the corresponding Quantity amount

    val budget: Money = USD(250)
    val quote: Length = price * budget

    squants.market.CurrencyExchangeRates represent conversion rates between currencies. Use them to explicitly convert Money values in one currency to values in another.

    squants.market.MoneyContext provide the implicit context necessary to perform cross-currency operations on Money values with conversions automatically applied.

    Some binary math operations will work on Moneys of like Currency with no MoneyContext in scope. Attempts to perform these operations on Moneys of dissimilar currencies will throw an exception at runtime.

    Other operations, including direct conversions to other currencies, require a MoneyContext and will not compile without it. However, there is no compile time check to determine if the correct exchange rates will be available at runtime. Operation requiring conversion without the required rates available will throw a NoSuchExchangeRateException at runtime.

    The defaultMoneyContext uses the USD as the default and provides a list of ~20 common currencies, and NO exchange rates. If your application requires something different you should initialize your own implicit MoneyContext

    Definition Classes
    squants
    Since

    0.1

  • package mass

    Definition Classes
    squants
    Since

    0.1

  • package motion

    Definition Classes
    squants
    Since

    0.1

  • package photo

    Definition Classes
    squants
    Since

    0.1

  • package radio

    Definition Classes
    squants
    Since

    0.1

  • package space

    Definition Classes
    squants
    Since

    0.1

  • package thermal

    Definition Classes
    squants
    Since

    0.1

  • Celsius
  • Fahrenheit
  • JoulesPerKelvin
  • Kelvin
  • Rankine
  • Temperature
  • TemperatureConversions
  • TemperatureScale
  • ThermalCapacity
  • ThermalCapacityConversions
  • ThermalCapacityUnit
  • package time

    Definition Classes
    squants
    Since

    0.1

p

squants

thermal

package thermal

Source
package.scala
Since

0.1

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. thermal
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. final class Temperature extends Quantity[Temperature]

    Represents a quantity of temperature

    Represents a quantity of temperature

    Temperatures are somewhat unique in the world of quantities for a couple of reasons.

    First, different units (scales) have different "zero" values. This means that these scales are not simple multiples of the others. There is a "zero offset" that must be applied to conversions from one scale to another.

    Second, temperatures are often quoted as though they were quantities, when in fact they are just points on a scale. Similar to a mile marker on a highway, the quantity represented is the number degrees (miles) from a specific "zero" value on the scale.

    In fact an absolute quantity of thermodynamic temperature should be measured from absolute zero. Thus, Kelvin, is the SI Base unit for temperature.

    The other scales supported here, Celsius and Fahrenheit, are known as empirical scales. Of course, these scales set their respective zero values well above absolute zero. This is done to provide a granular and reasonably sized ranges of values for dealing with everyday temperatures.

    This library supports another absolute scale, the Rankine scale. Rankine sets its zero at absolute zero, but degrees are measure in Fahrenheit (as opposed to Celsius, as the Kelvin scale uses).

    In consideration of these more unique scale conversions, two conversion types are supported: Degrees and Scale.

    Scale based conversions DO adjust for the zero offset. Thus 5 degrees C is the same as 41 degrees F on the thermometer.

    Degrees based conversions DO NOT adjust for the zero point. Thus 5 degrees C|K is the same amount of temperature as 9 degrees F|R.

    When creating a temperature it is not important to consider these differences. It is also irrelevant when performing operation on temperatures in the same scale. However, when performing operations on two temperatures of different scales these factors do become important.

    The Quantity.to(unit) and Quantity.in(unit) methods are overridden to use Scale conversions for convenience

    The Ordered.compare method is implemented to use Scale conversions

    The Quantity.plus and Quantity.minus methods are implemented to treat right operands as Quantity of Degrees and not a scale Temperature. Operands that differ in scale will use Degree conversions. This supports mixed scale expressions:

    val temp = Fahrenheit(100) - Celsius(5) // returns Fahrenheit(91)

    This also supports declaring temperature ranges using typical nomenclature:

    val tempRange = 65.F +- 5.C // returns QuantityRange(56.0°F,74.0°F)

    The toDegrees(unit) methods are implemented to use Degree conversions.

    Since

    0.1

  2. sealed trait TemperatureScale extends UnitOfMeasure[Temperature]

    Base trait for units of squants.thermal.Temperature

  3. final class ThermalCapacity extends Quantity[ThermalCapacity]

    Represents the capacity of some substance or system to hold thermal energy.

    Represents the capacity of some substance or system to hold thermal energy.

    Also a representation of Entropy

    Since

    0.1

  4. trait ThermalCapacityUnit extends UnitOfMeasure[ThermalCapacity] with UnitConverter

Value Members

  1. lazy val AbsoluteZero: Temperature
  2. lazy val BoilingTemperatureWater: Temperature
  3. lazy val FreezingTemperatureWater: Temperature
  4. object Celsius extends TemperatureScale
  5. object Fahrenheit extends TemperatureScale
  6. object JoulesPerKelvin extends ThermalCapacityUnit with PrimaryUnit with SiUnit
  7. object Kelvin extends TemperatureScale with PrimaryUnit with SiBaseUnit
  8. object Rankine extends TemperatureScale
  9. object Temperature extends Dimension[Temperature] with BaseDimension with Serializable

    Temperature companion object

  10. object TemperatureConversions
  11. object ThermalCapacity extends Dimension[ThermalCapacity] with Serializable
  12. object ThermalCapacityConversions

Inherited from AnyRef

Inherited from Any

Ungrouped