Gas

public struct Gas

An object that represents a scuba diving breathing gas.

Since

1.0

Component Gases Properties

  • Percentage of oxygen in gas blend.

    Declaration

    Swift

    private(set) public var percentOxygen: Double { get }
  • Percentage of nitrogen in gas blend.

    Declaration

    Swift

    private(set) public var percentNitrogen: Double { get }
  • Percentage of helium in gas blend, not currently available though any initializers.

    Declaration

    Swift

    private(set) public var percentHelium: Double { get }
  • Percentage of contaminant gases in gas blend

    Declaration

    Swift

    private(set) public var percentContaminantGases: Double { get }
  • Percentage of trace gases in gas blend

    Declaration

    Swift

    private(set) public var percentTraceGases: Double { get }

Pressure/Volume/Density Properties

  • Current absolute pressure on gas.

    Declaration

    Swift

    public var pressure: Double
  • Current fractional volume of gas.

    Declaration

    Swift

    public var fractionVolume: Double
  • Current density of gas.

    Declaration

    Swift

    public var density: Double

Partial Pressure Property

Contaminant Properties and Methods

  • Property that holds a String representing a contaminant and Double representing percentage of the contaminant

    Declaration

    Swift

    private(set) public var contaminants: [String : Double] { get }
  • A Boolean value indicating whether the gas has any gaseous contaminants.

    Declaration

    Swift

    public var isContaminated: Bool { get }

Methods

  • Sets contaminant and its percentage.

    Since

    1.0

    Declaration

    Swift

    public mutating func setContaminants(_ contaminants: [String : Double]) throws

    Parameters

    contaminants

    [String: Double] where String represents a contaminant and Double represents percentage of the contaminant.

Enriched Air Properties

  • A Boolean value indicating whether the gas contains a percentage of oxygen high that 20.9%.

    Declaration

    Swift

    public var isEnrichedAir: Bool { get }

Methods

  • Sets the pressure, volume and density properties to specified depth.

    Since

    1.0

    Declaration

    Swift

    public mutating func setDepth(_ depth: Double, diveKit: DiveKit) throws

    Parameters

    depth

    Double representing a specified depth.

    diveKit

    DiveKit object used to perform calculations.

  • Calculates what the effective percentage of a component gas when breathed at a pressure greater than surface pressure.

    Example

    do {
    var gas = try Gas.init(percentOxygen: 20.8, percentNitrogen: 79, percentTraceGases: 0.1, percentContaminantGases: 0.1)
    try gas.setDepth(99, diveKit: DiveKit.default)
    
    let effectivePercent = gas.effectivePercentage(gas.percentContaminantGases)
    print(effectivePercent) // 0.4 (%)
    } catch {
    // Handle Error
    print(error.localizedDescription)
    }
    

    Since

    1.0

    Declaration

    Swift

    public func effectivePercentage(_ value: Double) -> Double

    Parameters

    value

    Double representing the component gas to perform calculation on.

    Return Value

    Double representing the effective percentage of a component gas when breathed at a pressure greater than surface pressure.

Static Instances

  • air

    A singleton gas object representing compressed air.

    Since

    1.0

    Declaration

    Swift

    public static var air: Gas { get }
  • A singleton gas object representing enriched air blend of a specified percentage of oxygen.

    Since

    1.0

    Declaration

    Swift

    public static func enrichedAir(_ percentOxygen: Double) throws -> Gas

    Parameters

    percentOxygen

    Double representing the percentage of oxygen in gad blend, value must be a positive number less than 100.

Initializer

  • Initializes a Gas object.

    Since

    1.0

    Declaration

    Swift

    public init(
        percentOxygen: Double,
        percentNitrogen: Double,
        percentTraceGases: Double = 0,
        percentContaminantGases: Double = 0) throws

    Parameters

    percentOxygen

    Double representing the percentage of oxygen in the gas blend, the value must be a positive number less than 100.

    percentNitrogen

    Double representing the percentage of nitrogen in the gas blend, the value must be a positive number less than 100.

    percentContaminantGases

    Double representing the percentage of contaminant gases in the gas blend, the value must be a positive number less than 100.

    percentTraceGases

    Double representing the percentage of trace gases in the gas blend, the value must be a positive number less than 100.