DKPhysics
public final class DKPhysics : DiveCalculator
A DiveCalculator used to perform dive physics calculations.
Since
1.0-
Calculates atmospheres absolute of a depth.
Throws
DiveKit.ErrorSince
1.0Example
let physicsCalculator = DKPhysics.init(with: DiveKit.default) do { // Calculate atmospheres absolute at 32 feet. let atmospheresAbsolute = try physicsCalculator.atmospheresAbsolute(at: 32) print(atmospheresAbsolute.value) // 1.9696969696969697 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func atmospheresAbsolute( at depth: Depth ) throws -> CalculationParameters
depthDouble, representing a depth, expressed in feet or meters.
Return Value
Calculation, representing absolute pressure at input depth. -
Calculates gauge pressure at a given depth.
Throws
Since
1.0
Example
let physicsCalculator = DKPhysics.init(with: DiveKit.default) do { // Calculate gauge pressure at 46 feet rounding to one decimal place. let gaugePressure = try physicsCalculator.gaugePressure(at: 46) print(gaugePressure.round(to: 1)) // 1.4 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func gaugePressure( at depth: Depth ) throws -> CalculationParameters
depthDouble, representing a depth, expressed in feet or meters.
Return Value
Calculation, representing ambient pressure at input depth. -
Calculates pressure change from a given depth to another.
Throws
Since
1.0
Example
let physicsCalculator = DKPhysics.init(with: DiveKit.default) do { // Calculate pressure change from at 33 feet to 99 feet. let pressureChange = try physicsCalculator.pressureChange(from: 33, to: 99) print(pressureChange.value) // 2.0 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func pressureChange( from firstDepth: Depth, to secondDepth: Depth ) throws -> CalculationParameters
firstDepthDouble, representing the first depth, expressed in feet or meters.
secondDepthDouble, representing the second depth, expressed in feet or meters.
Return Value
Calculation, representing the pressure change from one depth to a second expressed in atmospheres absolute. -
Calculates the surface volume of a specified volume of air at a specified depth.
Throws
Since
1.0
Example
let physicsCalculator = DKPhysics.init(with: DiveKit.default) do { let airVolumeToSurface = try physicsCalculator.airVolumeToSurface(from: 10, volume: 10) print(airVolumeToSurface.value) // 13.03030303030303 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func airVolumeToSurface( from depth: Depth, volume: Volume ) throws -> CalculationParameters
depthThe depth to perform calculation.
volumeThe volume of air to calculate.
Return Value
Calculationrepresenting the volume of air at surface pressure -
Calculates the volume of a specified volume of air on the surface to a specified depth.
Throws
Since
1.0
Example
let physicsCalculator = DKPhysics.init(with: DiveKit.default) do { let airVolumeFromSurface = try physicsCalculator.airVolumeFromSurface(to: 10, volume: 10) print(airVolumeFromSurface.value) // 7.674418604651163 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func airVolumeFromSurface( to depth: Depth, volume: Volume ) throws -> CalculationParameters
depthThe depth to perform calculation.
volumeThe volume of air to calculate.
Return Value
Calculationrepresenting the volume of air at specified depth -
Calculates pressure change from a given depth to another.
Since
1.0
Example
let physicsCalculator = DKPhysics.init(waterType: .saltWater, measurementUnit: .imperial) do { // Calculate pressure change from at 33 feet to 99 feet. let pressureChange = try physicsCalculator.pressureChange(from: 33, to: 99) print(pressureChange) // 2 (ata) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func pressureChange( from firstDepth: Double, to secondDepth: Double, decimalPlaces: Int = 2 ) throws -> DoubleParameters
firstDepthDouble, representing the first depth, expressed in feet or meters.
secondDepthDouble, representing the second depth, expressed in feet or meters.
Return Value
Double, representing the pressure change from one depth to a second expressed in atmospheres absolute.
-
Calculates atmospheres absolute of a depth.
Since
1.0Example
let physicsCalculator = DKPhysics.init(waterType: .saltWater, measurementUnit: .imperial) do { // Calculate atmospheres absolute at 32 feet rounding to four decimal places. let ata = try physicsCalculator.atmospheresAbsolute(depth: 32, decimalPlaces: 4) print(ata) // 1.9697 (ata) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func atmospheresAbsolute( depth: Double, decimalPlaces: Int = 2 ) throws -> DoubleParameters
depthDouble, representing a depth, expressed in feet or meters.
decimalPlacesInteger, representing the number of decimal places to round calculation to, defaults to two decimal places.
Return Value
Double, representing absolute pressure at input depth.
-
Calculates gauge pressure at a given depth.
Since
1.0
Example
let physicsCalculator = DKPhysics.init(waterType: .saltWater, measurementUnit: .imperial) do { // Calculate gauge pressure at 46 feet rounding to one decimal place. let gaugePressure = try physicsCalculator.gaugePressure(depth: 46, decimalPlaces: 1) print(gaugePressure) // 1.4 (ata) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func gaugePressure( depth: Double, decimalPlaces: Int = 2 ) throws -> DoubleParameters
depthDouble, representing a depth, expressed in feet or meters.
decimalPlacesInteger, representing the number of decimal places to round calculation to, defaults to two decimal places.
Return Value
Double, representing ambient pressure at input depth.
-
Calculates the volume of a specified volume of air on the surface to a specified depth
Throws
DKErrorDeclaration
Swift
public func airVolumeFromSurface( volume: Double, depth: Double, decimalPlaces: Int = 0 ) throws -> DoubleParameters
volumeThe volume of air to calculate
depthThe depth to perform calculation
decimalPlacesThe number of decimal places to round calculation to
Return Value
The volume of air at specified depth
-
Calculates the surface volume of a specified volume of air at a specified depth
Throws
DKErrorDeclaration
Swift
public func airVolumeToSurface( volume: Double, depth: Double, decimalPlaces: Int = 0 ) throws -> DoubleParameters
volumeThe volume of air to calculate
depthThe depth to perform calculation
decimalPlacesThe number of decimal places to round calculation to
Return Value
The volume of air at surface pressure
DKPhysics Class Reference