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.0

    Declaration

    Swift

    public func partialPressure(
        of inputGas: Gas,
        at depth: Depth = 0
    ) throws -> PartialPressure

    Parameters

    gas

    Gas to calculate the partial pressure.

    depth

    Double presenting a depth, defaults to sea level.

    Return Value

    PartialPressure of constituent gases in input Gas at surface pressure or input depth

  • Calculates surface air consumption of a diver

    Throws

    DiveKit.Error

    Since

    1.0

    Example

    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 -> Calculation

    Parameters

    depth

    Double representing the depth expressed in feet or meters that the calculation was performed.

    minutes

    Double representing the time expressed in minutes that the calculation was performed.

    gasConsumed

    Double representing the amount of gas consumed expressed in psi or bar per minute during the calculation.

    Return Value

    Calculation representing the consumed psi or bar per minute calculated for surface pressure.

  • Calculates surface air consumption of a diver

    Throws

    DiveKit.Error

    Since

    1.0

    Example

    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 -> Calculation

    Parameters

    depth

    Double representing the depth expressed in feet or meters that the calculation was performed.

    minutes

    Double representing the time expressed in minutes that the calculation was performed.

    startGas

    Double representing the gas pressure at the beginning of calculation.

    endGas

    Double representing the gas pressure at the end of calculation.

    Return Value

    Calculation representing the consumed psi or bar per minute calculated for surface pressure.

  • Calculates the respiratory minute volume of a diver.

    Throws

    DiveKit.Error

    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(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 -> Calculation

    Parameters

    depth

    Double, representing the depth, expressed in feet or meters, that this calculation was performed.

    time

    Double, representing the length of time, expressed in minutes, that this calculation was performed.

    tank

    DKTank, representing the tank used when this calculation was performed, expressed in psi or bar.

    gasConsumed

    Double, 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.Error

    Since

    1.0

    Example

    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 -> Calculation

    Parameters

    surfaceAirConsumption

    Calculation, representing the surface air consumption to use for calculation of respiratory minute volume.

    tank

    DKTank, 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.Error

    Example

    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.0

    Declaration

    Swift

    public func depthAirConsumption(
        for minutes: Minutes,
        consuming gasConsumed: Pressure
    ) throws -> Calculation

    Parameters

    minutes

    Double representing the time expressed in minutes that the calculation was performed.

    gasConsumed

    Double representing the amount of gas consumed expressed in psi or bar per minute during the calculation.

    Return Value

    Calculation representing 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 -> Double

    Parameters

    gasConsumed

    Double, representing the amount of air that was consumed during this calculation, expressed in psi or bar

    tank

    DKTank, representing the tank used when this calculation was performed, expressed in psi or bar.

    depth

    Double, representing the depth, expressed in feet or meters, that this calculation was performed.

    time

    Double, 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.0

    Declaration

    Swift

    @available(*, deprecated, renamed: "surfaceAirConsumption(at:for:consuming:﹚")
    public func surfaceAirConsumption(time: Double, depth: Double, gasConsumed: Double) throws -> Double

    Parameters

    depth

    Double representing the depth expressed in feet or meters that the calculation was performed.

    time

    Double representing the time expressed in minutes that the calculation was performed.

    gasConsumed

    Double 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.