DKGasCalculator
public final class DKGasCalculator : DiveCalculator
A DiveCalculator used to perform gas calculations.
Since
1.0-
Calculates the partial pressure of a gas at sea-level or a specified depth.
Example
let diveKit = DiveKit.default let gasCalculator = DKGasCalculator(with: diveKit) do { // Calculate partial pressure of component gases in EANx32 at 99 feet. let gas = try Gas.enrichedAir(32) let partialPressure = try gasCalculator.partialPressure(of: gas, at: 99) print(partialPressure) // PartialPressure(oxygen: 1.28, nitrogen: 2.72, trace: 0.0) } catch { // Handle Error print(error.localizedDescription) }Since
1.0Declaration
Swift
public func partialPressure( of inputGas: Gas, at depth: Depth = 0 ) throws -> PartialPressureParameters
gasGasto calculate the partial pressure.depthDouble presenting a depth, defaults to sea level.
Return Value
PartialPressureof constituent gases in inputGasat surface pressure or input depth -
Calculates surface air consumption of a diver
Throws
DiveKit.ErrorSince
1.0Example
let gasCalculator = DKGasCalculator.init() do { // Calculate SAC rate let surfaceAirConsumption = try gasCalculator.surfaceAirConsumption(at: 33, for: 10, consuming: 200) print(surfaceAirConsumption.value) // 10.0 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func surfaceAirConsumption( at depth: Depth, for minutes: Minutes, consuming gasConsumed: Pressure ) throws -> CalculationParameters
depthDouble representing the depth expressed in feet or meters that the calculation was performed.
minutesDouble representing the time expressed in minutes that the calculation was performed.
gasConsumedDouble representing the amount of gas consumed expressed in psi or bar per minute during the calculation.
Return Value
Calculationrepresenting the consumed psi or bar per minute calculated for surface pressure. -
Calculates surface air consumption of a diver
Throws
DiveKit.ErrorSince
1.0Example
let gasCalculator = DKGasCalculator.init() do { // Calculate SAC rate let surfaceAirConsumption = try gasCalculator.surfaceAirConsumption(at: 33, for: 10, startGas: 2400, endGas: 2200) print(surfaceAirConsumption.value) // 10.0 } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func surfaceAirConsumption( at depth: Depth, for minutes: Minutes, startGas: Pressure, endGas: Pressure ) throws -> CalculationParameters
depthDouble representing the depth expressed in feet or meters that the calculation was performed.
minutesDouble representing the time expressed in minutes that the calculation was performed.
startGasDouble representing the gas pressure at the beginning of calculation.
endGasDouble representing the gas pressure at the end of calculation.
Return Value
Calculationrepresenting the consumed psi or bar per minute calculated for surface pressure. -
Calculates the respiratory minute volume of a diver.
Throws
DiveKit.ErrorSince
1.0Example
let gasCalculator = DKGasCalculator.init() do { // Calculate RMV Rate let tank = DKTank(ratedPressure: 3000, volume: 80, type: .aluminumStandard) let respiratoryMinuteVolume = try gasCalculator.respiratoryMinuteVolume(at: 33, for: 10, with: tank, consuming: 200) print(respiratoryMinuteVolume.round(to: 2)) // 0.27 (ft3/min) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func respiratoryMinuteVolume( at depth: Depth, for minutes: Minutes, with tank: DKTank, consuming gasConsumed: Pressure ) throws -> CalculationParameters
depthDouble, representing the depth, expressed in feet or meters, that this calculation was performed.
timeDouble, representing the length of time, expressed in minutes, that this calculation was performed.
tankDKTank, representing the tank used when this calculation was performed, expressed in psi or bar.gasConsumedDouble, representing the amount of air that was consumed during this calculation, expressed in psi or bar
Return Value
Calculation, representing the consumed volume of air per minute express in cubic feet per minute or liters per minute calculated for surface pressure. -
Calculates the respiratory minute volume of a diver.
Throws
DiveKit.ErrorSince
1.0Example
let gasCalculator = DKGasCalculator.init() do { let tank = DKTank(ratedPressure: 3000, volume: 80, type: .aluminumStandard) let surfaceAirConsumption = try gasCalculator.surfaceAirConsumption(at: 33, for: 10, startGas: 1700, endGas: 1500) let respiratoryMinuteVolume = try gasCalculator.respiratoryMinuteVolume(for: surfaceAirConsumption, with: tank) print(respiratoryMinuteVolume.round(to: 2)) // 0.27 (ft3/min) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
public func respiratoryMinuteVolume( for surfaceAirConsumption: SurfaceAirConsumption, with tank: DKTank ) throws -> CalculationParameters
surfaceAirConsumptionCalculation, representing the surface air consumption to use for calculation of respiratory minute volume.tankDKTank, representing the tank used when this calculation was performed, expressed in psi or bar.Return Value
Calculation, representing the consumed volume of air per minute express in cubic feet per minute or liters per minute calculated for surface pressure. -
Calculates air consumption of a diver at depth
Throws
DiveKit.ErrorExample
let gasCalculator = DKGasCalculator.init() do { // Calculate DAC rate let depthAirConsumption = try gasCalculator.depthAirConsumption(for: 10, consuming: 200) print(depthAirConsumption) // 20.0 } catch { // Handle Error print(error.localizedDescription) }Since
1.0Declaration
Swift
public func depthAirConsumption( for minutes: Minutes, consuming gasConsumed: Pressure ) throws -> CalculationParameters
minutesDouble representing the time expressed in minutes that the calculation was performed.
gasConsumedDouble representing the amount of gas consumed expressed in psi or bar per minute during the calculation.
Return Value
Calculationrepresenting the consumed psi or bar per minute calculated for ambient pressure. -
Calculates the respiratory minute volume of a diver.
Since
1.0
Example
let gasCalculator = DKGasCalculator.init() do { // Calculate RMV Rate let tank = DKTank(ratedPressure: 3000, volume: 80, type: .aluminumStandard) let respiratoryMinuteVolume = try gasCalculator.respiratoryMinuteVolume( gasConsumed: 200, tank: tank, depth: 33, time: 10) print(respiratoryMinuteVolume) // 0.27 (ft3/min) } catch { // Handle Error print(error.localizedDescription) }Declaration
Swift
@available(*, deprecated, renamed: "respiratoryMinuteVolume(at:for:with:consuming:﹚") public func respiratoryMinuteVolume(gasConsumed: Double, tank: DKTank, depth: Double, time: Double) throws -> DoubleParameters
gasConsumedDouble, representing the amount of air that was consumed during this calculation, expressed in psi or bar
tankDKTank, representing the tank used when this calculation was performed, expressed in psi or bar.depthDouble, representing the depth, expressed in feet or meters, that this calculation was performed.
timeDouble, representing the length of time, expressed in minutes, that this calculation was performed.
Return Value
Double, representing the consumed volume of air per minute express in cubic feet per minute or liters per minute calculated for surface pressure.
-
Calculates surface air consumption of a diver
Example
let gasCalculator = DKGasCalculator.init() do { // Calculate SAC rate let surfaceAirConsumption = try gasCalculator.surfaceAirConsumption( time: 10, depth: 33, gasConsumed: 200) print(surfaceAirConsumption) // 10.0 (psi/min) } catch { // Handle Error print(error.localizedDescription) }Since
1.0Declaration
Swift
@available(*, deprecated, renamed: "surfaceAirConsumption(at:for:consuming:﹚") public func surfaceAirConsumption(time: Double, depth: Double, gasConsumed: Double) throws -> DoubleParameters
depthDouble representing the depth expressed in feet or meters that the calculation was performed.
timeDouble representing the time expressed in minutes that the calculation was performed.
gasConsumedDouble representing the amount of gas consumed expressed in psi or bar per minute during the calculation.
Return Value
Double, representing the consumed psi or bar per minute calculated for surface pressure.
DKGasCalculator Class Reference