DKEnrichedAir

public final class DKEnrichedAir : DiveCalculator

A DiveCalculator to perform calculations involving Enriched Air Nitrox, EANx.

Since

1.0
  • Calculates the maximum operating depth of a specified gas and maximum partial pressure of oxygen.

    Example

    let enrichedAirCalculator = DKEnrichedAir.init(with: diveKit)
    
    do {
        let gas = try Gas.enrichedAir(32)
        // Calculate MOD for EANx32 with maximum fraction oxygen of 1.4
        let maximumOperatingDepth = try enrichedAirCalculator.maximumOperatingDepth(fractionOxygen: 1.4, gas: gas)
        print(maximumOperatingDepth.value) // 111.375
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    public func maximumOperatingDepth(
        fractionOxygen: FractionOxygen,
        gas: Gas
    ) throws -> Calculation

    Parameters

    fractionOxygen

    Double representing the maximum partial pressure of oxygen.

    gas

    Gas representing the gas to be used for calculation.

    Return Value

    Calculation representing the maximum operating depth for specified gas and maximum partial pressure of oxygen.

  • Calculates the equivalent air depth of a specified gas and maximum partial pressure of oxygen.

    Example

    let enrichedAirCalculator = DKEnrichedAir.init(with: diveKit)
    
    do {
        let gas = try Gas.enrichedAir(32)
        // Calculate EAD for EANx32 at 109 feet
        let equivalentAirDepth = try enrichedAirCalculator.equivalentAirDepth(depth: 109, gas: gas)
        print(equivalentAirDepth) // 89.23
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    
    

    Since

    1.0

    Declaration

    Swift

    public func equivalentAirDepth(
        for depth: Depth,
        with gas: Gas
    ) throws -> Calculation

    Parameters

    depth

    Double representing the depth to be used for calculation.

    gas

    Gas representing the gas to be used for calculation.

    Return Value

    Calculation representing the equivalent air depth for specified gas and depth.

  • Calculates the best blend of enriched air, EANx, for a given fraction of oxygen and a given depth.

    Throws

    DiveKit.Error

    Example

    let enrichedAirCalc = DKEnrichedAir.init(waterType: .saltWater, measurementUnit: .imperial)
    do {
        // Calculate 'best blend' for to 90 feet with maximum fraction oxygen of 1.4
        let bestBlend = try enrichedAirCalc.bestBlend(for: 90, fractionOxygen: 1.4)
        print(bestBlend.percentOxygen) // 37.0 (% oxygen)
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    public func bestBlend(
        for depth: Depth,
        fractionOxygen: FractionOxygen
    ) throws -> Gas

    Parameters

    depth

    Double presenting a depth.

    fractionOxygen

    Double representing the fraction of oxygen.

    Return Value

    Gas representing the calculated best blend for the given dive.

  • Calculates if the specified blend of enriched air, EANx, exceeds the maximum operating depth of specified depth and maximum partial pressure of oxygen.

    Example

    let enrichedAirCalc = DKEnrichedAir.init(waterType: .saltWater, measurementUnit: .imperial)
    
    do {
        let gas = try Gas.enrichedAir(32)
        // Calculate if 127 feet exceeds MOD for EANx32 at maximum fraction of oxygen of 1.4
        let exceedsMod = enrichedAirCalc.exceedsMaximumOperatingDepth(with: gas, fractionOxygen: 1.4, depth: 127)
        print(exceedsMod) // true
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    public func exceedsMaximumOperatingDepth(
        with gas: Gas,
        fractionOxygen: FractionOxygen,
        depth: Depth
    ) -> Bool

    Parameters

    fractionOxygen

    Double representing the maximum partial pressure oxygen.

    depth

    Double presenting a depth.

    gas

    Gas representing the gas to be used for calculation.

    Return Value

    Boolean determining if depth exceeds maximum operating depth for specified Gas.

  • Calculates the maximum operating depth of a specified gas and maximum partial pressure of oxygen.

    Example

    let enrichedAirCalc = DKEnrichedAir.init(waterType: .saltWater, measurementUnit: .imperial)
    let gas = DKGas.enrichedAir(percentage: 32)
    do {
        // Calculate MOD for EANx32 with maximum fraction oxygen of 1.4
        let mod = try enrichedAirCalc.maximumOperatingDepth(fractionOxygen: 1.4, gas: gas)
        print(mod) // 111 (feet)
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    @available(*, deprecated, renamed: "maximumOperatingDepth(fractionOxygen:gas:﹚")
    public func maximumOperatingDepth(
        fractionOxygen: FractionOxygen,
        gas: Gas,
        decimalPlaces: Int = 2
    ) throws -> Double

    Parameters

    fractionOxygen

    Double representing the maximum partial pressure of oxygen.

    gas

    Gas representing the gas to be used for calculation.

    decimalPlaces

    Integer representing the desired number of decimal places to return.

    Return Value

    Double representing the maximum operating depth for specified gas and maximum partial pressure of oxygen.

  • Calculates the equivalent air depth of a specified gas and maximum partial pressure of oxygen.

    Example

    let enrichedAirCalc = DKEnrichedAir.init(waterType: .saltWater, measurementUnit: .imperial)
    let gas  = DKGas.enrichedAir(percentage: 32)
    do {
        // Calculate EAD for EANx32 at 109 feet
        let ead = try enrichedAirCalc.equivalentAirDepth(depth: 109, gas: gas)
        print(ead) // 89 (feet)
    } catch {
        // Handle Error
        print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    @available(*, deprecated, renamed: "equivalentAirDepth(for:with:﹚")
    public func equivalentAirDepth(
        depth: Depth,
        gas: Gas,
        decimalPlaces: Int = 2
    ) throws -> Double

    Parameters

    depth

    Double representing the depth to be used for calculation.

    gas

    DKGas representing the gas to be used for calculation.

    decimalPlaces

    Integer representing the desired number of decimal places to return.

    Return Value

    Double representing the equivalent air depth for specified gas and depth.