Zephyr Scientific Library (zscilib)
Files | Functions
Gases

Gas functions. More...

Files

file  gases.h
 API header file for gases in zscilib.
 

Functions

int zsl_phy_gas_av_vel (zsl_real_t m, zsl_real_t n, zsl_real_t t, zsl_real_t *v)
 Calculates the average velocity of a gas molecule based on the mass of gas (m), its temperature (t) and the number of moles of gas (n). More...
 
int zsl_phy_gas_press (zsl_real_t v, zsl_real_t n, zsl_real_t t, zsl_real_t *p)
 Calculates the pressure of an ideal gas based on the number of moles, the temperature and the volume of gas. More...
 
int zsl_phy_gas_boyle (zsl_real_t pi, zsl_real_t vi, zsl_real_t pf, zsl_real_t *vf)
 Given the initial and final pressure, and the initial volume of an ideal gas, this function calculates the final volume of the gas supposing the temperature hasn't changed through the process. More...
 
int zsl_phy_gas_charles_lussac (zsl_real_t ti, zsl_real_t vi, zsl_real_t tf, zsl_real_t *vf)
 Given the initial and final temperature, and the initial volume of an ideal gas, this function calculates the final volume of the gas supposing its pressure hasn't changed through the process. More...
 

Detailed Description

Gas functions.

Function Documentation

◆ zsl_phy_gas_av_vel()

int zsl_phy_gas_av_vel ( zsl_real_t  m,
zsl_real_t  n,
zsl_real_t  t,
zsl_real_t v 
)

Calculates the average velocity of a gas molecule based on the mass of gas (m), its temperature (t) and the number of moles of gas (n).

Parameters
mMass of gas in kilograms.
nNumber of moles of gas.
tTemperature in kelvins.
vPointer to the calculated velocity in meters per second. Will be set to NAN if the temperature, mass or moles of gas are negative, or if m = 0.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_gas_boyle()

int zsl_phy_gas_boyle ( zsl_real_t  pi,
zsl_real_t  vi,
zsl_real_t  pf,
zsl_real_t vf 
)

Given the initial and final pressure, and the initial volume of an ideal gas, this function calculates the final volume of the gas supposing the temperature hasn't changed through the process.

Parameters
piInitial pressure in pascals.
viInitial volume in meters cubed.
pfFinal pressure in pascals.
vfPointer to the output final volume in meters cubed. Will be set to NAN if any of the input values are negative or if pf = 0.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_gas_charles_lussac()

int zsl_phy_gas_charles_lussac ( zsl_real_t  ti,
zsl_real_t  vi,
zsl_real_t  tf,
zsl_real_t vf 
)

Given the initial and final temperature, and the initial volume of an ideal gas, this function calculates the final volume of the gas supposing its pressure hasn't changed through the process.

Parameters
tiInitial temperature in kelvins.
viInitial volume in meters cubed.
tfFinal temperature in kelvins.
vfPointer to the output final volume in meters cubed. Will be set to NAN if any of the input values are negative or if ti = 0.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_gas_press()

int zsl_phy_gas_press ( zsl_real_t  v,
zsl_real_t  n,
zsl_real_t  t,
zsl_real_t p 
)

Calculates the pressure of an ideal gas based on the number of moles, the temperature and the volume of gas.

Parameters
vVolume of gas in meters cubed.
nNumber of moles of gas.
tTemperature in kelvins.
pPointer to the placeholder for calculated pressure in pascals. Will be set to NAN if the temperature, volume or moles of gas are negative, or if v = 0.
Returns
0 on success, and non-zero error code on failure.