Git Product home page Git Product logo

thermofluidquantities.jl's Introduction

ThermofluidQuantities

basic tools and definitions of quantities in thermofluids problems

Stable Dev Build Status codecov

The purpose of this package is to enable easy setup of quantities in thermofluids problems. It contains

  • A large set of specialized types based on common thermofluid quantities (e.g. Velocity, Pressure, etc) that enable dispatch on these quantities
  • Treatment of typical units, using the Unitful package.
  • Predefined properties for various common gases and liquids
  • Plot recipes for the associated types

Setting a quantity's value

We can set the value of a quantity through a simple interface, specifying in units with the Unitful interface, or without units, so that it obtains the default units of the quantity. E.g., pressure has default units of Pascals, so we can set it in, say, atmospheres and it will convert it automatically, or we can just supply a number:

Pressure(1u"atm")
Pressure(50)

Quantities, units, and types

Quantities of the same units can be added or subtracted, e.g.,

p = Pressure(1u"atm") + StagnationPressure(3u"atm")

The result of this operation is just a Unitful quantity. This can then be wrapped by a type with the same units:

Pressure(p)

All quantities in this package are typed and are subtypes of either DimensionalPhysicalQuantity or DimensionlessPhysicalQuantity. These are both subtypes of PhysicalQuantity.

Pressure <: DimensionalPhysicalQuantity

Quantities with the same units but different names are of different types, so dispatch can distinguish them:

f(::Pressure) = "I am pressure!"
f(Pressure(5))

but this would fail:

f(StagnationPressure(2.5))

Non-dimensional variables automatically reconcile different units

If we supply a ratio of quantities that are dimensionally compatible but are in disparate units, any non-dimensional variable will automatically convert to common units in performing the ratio and provide a truly dimensionless number, e.g.,

ReynoldsNumber(5u"ft/s"*1u"cm"/KinematicViscosity(0.1))

In this example, KinematicViscosity(0.1) assumes the given value is in default units (m^2/s). Note that we also demonstrated in this example that operations with a PhysicalQuantity can be mixed with Unitful.Quantity types.

If you don't have a name for a dimensionless parameter, then DimensionlessParameter is a catch-all, e.g.,

v = Velocity(1u"m/s")
vref = Velocity(5u"m/s")
DimensionlessParameter(v/vref)

Defining new quantities

The list of predefined dimensional quantities is returned with

ThermofluidQuantities.dimvartypes

and non-dimensional variables with

ThermofluidQuantities.nondimvartypes

It is simple to define a new quantity and use it. For example, a non-dimnesional variable

@nondimvar MyDimensionlessNumber
MyDimensionlessNumber(25.3)

or a new dimensional quantity

@dimvar MyTimeVar TimeType
MyTimeVar(2.3u"minute")

The second argument represents a 'unit type' for time, a union of types with time units. This comes with a default unit (seconds). To see the list of predefined unit types

ThermofluidQuantities.unittypes

If you don't see the one you want, then add it with @displayedunits

import ThermofluidQuantities: ๐‹, ๐“
@displayedunits MyInverseVelocityType "s/m" ๐“/๐‹

Then you can create a quantity:

@dimvar MyInverseVelocityVar MyInverseVelocityType
MyInverseVelocityVar(8u"minute/mi")

Gases and liquids

There are several predefined properties for gases and liquids. You can see the lists here:

ThermofluidQuantities.gases

and

ThermofluidQuantities.liquids

For example, to see the properties of air,

Air

You can access any of the properties individually with, e.g.,

Viscosity(Air)
SpecificHeatRatio(Air)

thermofluidquantities.jl's People

Contributors

jdeldre avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.