Psychrometric calculations in swift.

Overview

CI codecov documentation

swift-psychrometrics

A swift package for calculating properties of moist air, as well as conversions for several different units of measure.

Why

Psychrometrics are used by Heating Ventilation and Air Conditioning (HVAC) professionals and engineers, as well by scientests and metorologists. This package aims to provide the calculations used for psychrometric evaluation. Most of the psychrometric calculations are based off of ASHRAE - Fundamentals (2017).

Installation

Include in your project using swift package manager.

let package = Package(
  ...
  dependencies: [
    .package(url: "https://github.com/swift-psychrometrics/swift-psychrometrics.git", from: "0.1.0")
  ],
  ...
)

Getting Started

This package provides several libraries depending on your needs. There are basic units of measure that are convertible to other standard units of measure, including S.I. and I.P. units. As well as calculations for moist and dry air conditions, and a few calculations for water.

Most of the types this library provides support basic mathematical operations (addition, subtraction, multiplication, and division). These operations should for the most part be considered safe, however there is nothing that prevents a value to be operated on with a different unit of measure, which could lead to unexpected results. This library will try to do the right thing and convert the units of measure (taking the left hand side of an operation as precedence), but it is encouraged to operate on the underlying raw values of the type for less error-prone results.

Units of Measure

The following units of measure are provided with the corresponding conversions.

  • Temperature:

    • Fahrenheit
    • Celsius
    • Rankine
    • Kelvin
  • Length:

    • Feet
    • Inches
    • Meters
    • Centimeters
  • Pressure:

    • Atmosphere
    • Bar
    • Inches of Water Column
    • Millibar
    • Pascals
    • PSIG
    • Torr
  • Relative Humidity

Calculations

The following calculations are currently provided. Most of these types are Numeric and support arithmetic. Some of these calculations do not yet support different units of measure.

  • Density:

    • Dry Air
    • Moist Air
    • Water
  • Dew Point

    • From temperature and relative humidity
    • From temperature and partial pressure (vapor pressure)
    • From temperature, humidity ratio, and pressure
  • Enthalpy

    • Dry Air
    • Moist Air
  • Grains of Moisture

  • Humidity Ratio

    • From water mass and dry air mass
    • From specific humidity
    • From total pressure and partial pressure (vapor pressure)
    • From dry bulb temperature and total pressure
    • From dry bulb temperature, relative humidity, and total pressure
    • From dry bulb temperature, relative humidity, and altitude
    • From dew point temperature and pressure
  • Partial Pressure (Vapor Pressure)

  • Pressure as function of Altitude

  • Relative Humidity

    • From dry bulb temperature and dew point temperature
    • From dry bulb temperature and partial pressure (vapor pressure)
  • Saturation Pressure

  • Specific Heat (not yet Numeric supporting):

    • Water
  • Specific Humidity

  • Specific Volume

    • Dry Air
    • Moist Air
  • Temperature as a function of Altitude

  • Total Delivered Heat Quantity

  • Wet Bulb

CLI Utility

This package ships with a command line utility that allows you to explore the different calculations. It currently is pretty generic and still a work in progress. So it does not support all the calculations or units of measure.

To use the command line utility you can use the following command from the project root.

  PSYCHROMETRIC_CLI_ENABLED=1 swift run psychrometrics

Note: To use or build the CLI utility you must pass PSYCHROMETRIC_CLI_ENABLED=1 to the environment of the command.

Or to build the command line utility as an executable to put in your PATH. The following command will build the executable in release mode and open a Finder window at the build location, you can then find and move the psychrometrics executable and put somewhere in your path.

make cli

Playground Support

This package ships with an XCode Playground in the Examples directory that you can use to explore the API's.

Documentation

The documentation is currently being worked on / improved with more examples.

You can view the current api documentation here

License

This project is licensed under the MIT License

Contributions

Contributions are welcome. If errors are found please submit an issue or pull-request.

You might also like...
swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

Sovran-Swift: Small, efficient, easy. State Management for Swift

Sovran-Swift: Small, efficient, easy. State Management for Swift

Approximate is a Swift package that provides implementations of floating point comparisons for the Swift ecosystem

Approximate Approximate floating point equality comparisons for the Swift Programming Language. Introduction Approximate is a Swift package that provi

A Swift app, named 'iPose', for iPhone's pose measurement based on Swift.

iPhone's pose measurement based on Swift. This is a Swift app, named 'iPose', for iPhone's pose measurement based on Swift. This is a side project to

Swift Package Manager plugin which runs ActionBuilder to create a Github Actions workflow for a swift package.

ActionBuilderPlugin A Swift Package Manager command which builds a Github Actions workflow for the current package. By default the workflow file will

Swift Server Implementation - RESTful APIs, AWS Lambda Serverless For Swift Runtime amazonlinux: AWS Lambda + API Gateway
Swift Server Implementation - RESTful APIs, AWS Lambda Serverless For Swift Runtime amazonlinux: AWS Lambda + API Gateway

Swift Server Implementation - RESTful APIs, AWS Lambda Serverless For Swift Runtime amazonlinux: AWS Lambda + API Gateway deployed on Graviton arm64 build swift:5.6.2-amazonlinux2-docker image

A simple swift package that provides a Swift Concurrency equivalent to `@Published`.

AsyncValue This is a simple package that provides a convenience property wrapper around AsyncStream that behaves almost identically to @Published. Ins

 Zip - A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.
Zip - A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.

Zip A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip. Usage Import Zip at the top of the Swift file

Soulful docs for Swift & Objective-C
Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C About Both Swift and Objective-C projects are supported. Instead

Owner
null
Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Swift Markdown is a Swift package for parsing, building, editing, and analyzing Markdown documents.

Apple 2k Dec 28, 2022
Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer documentation.

Swift-DocC is a documentation compiler for Swift frameworks and packages aimed at making it easy to write and publish great developer docum

Apple 833 Jan 3, 2023
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

null 620 Oct 11, 2022
Swift - ✏️Swift 공부 저장소✏️

Swift 스위프트의 기초 1. Swift의 기본 2. 변수와 상수 [3. 데이터 타입 기본] [4. 데이터 타입 고급] 5. 연산자 6. 흐름 제어 7. 함수 8. 옵셔널 객체지향 프로그래밍과 스위프트 9. 구조체와 클래스 10. 프로퍼티와 메서드 11. 인스턴스 생

Jiwon 0 Mar 9, 2022
Swift-ndi - Swift wrapper around NewTek's NDI SDK

swift-ndi Swift wrapper around NewTek's NDI SDK. Make sure you extracted latest

Alessio Nossa 12 Dec 29, 2022
__.swift is a port of Underscore.js to Swift.

__.swift Now, __.swift is version 0.2.0! With the chain of methods, __.swift became more flexible and extensible. Documentation: http://lotz84.github.

Tatsuya Hirose 86 Jun 29, 2022
SNTabBarDemo-Swift - Cool TabBar With Swift

SNTabBarDemo-Swift Cool TabBar How To Use // MARK: - setup private func setu

iAnchor 3 Sep 29, 2022
Swift-when - Expression switch support in Swift

Swift When - supporting switch expressions in Swift! What is it? Basically, it a

Gordan Glavaš 7 Nov 24, 2022
Swift-compute-runtime - Swift runtime for Fastly Compute@Edge

swift-compute-runtime Swift runtime for Fastly Compute@Edge Getting Started Crea

Andrew Barba 57 Dec 24, 2022
Swift-HorizontalPickerView - Customizable horizontal picker view component written in Swift for UIKit/iOS

Horizontal Picker View Customizable horizontal picker view component written in

Afraz Siddiqui 8 Aug 1, 2022