Zephyr Scientific Library (zscilib)
Files | Functions
Energy

Energy functions. More...

Files

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

Functions

int zsl_phy_ener_kin (zsl_real_t v, zsl_real_t m, zsl_real_t *ke)
 Calculates the kinetic energy of a moving object based on its mass (m) and velocity (v). More...
 
int zsl_phy_ener_rot (zsl_real_t omega, zsl_real_t i, zsl_real_t *rke)
 Calculates the angular kinetic energy of a rotating object based on its angular velocity (omega) and moment of inertia (i). More...
 
int zsl_phy_ener_grav_pot (zsl_real_t m, zsl_real_t h, zsl_real_t *ug)
 Calculates the gravitational potential energy in joules of an object based on its mass (m) and its height (h) with respect to a chosen initial height. More...
 
int zsl_phy_ener_elas_pot (zsl_real_t k, zsl_real_t dist, zsl_real_t *ue)
 Calculates the elastic potential energy of a spring based on the distance it has been compressed/expanded and its characteristic 'k' constant. More...
 
int zsl_phy_ener_power (zsl_real_t ener, zsl_real_t time, zsl_real_t *power)
 Calculates the power by dividing energy or work by time. More...
 
int zsl_phy_ener_fric (zsl_real_t fric, zsl_real_t dist, zsl_real_t *e)
 Calculates the energy lost due to a friction force based on the distance the object experiencing the friction has moved. More...
 
int zsl_phy_ener_mec (zsl_real_t ke, zsl_real_t rke, zsl_real_t ug, zsl_real_t ue, zsl_real_t *me)
 Calculates the total mechanical energy of a system by adding kinetic energy (linear and angular) and potential energy (gravitational and elastic). More...
 
int zsl_phy_ener_final (zsl_real_t ei1, zsl_real_t ei2, zsl_real_t ei3, zsl_real_t ei4, zsl_real_t ef1, zsl_real_t ef2, zsl_real_t ef3, zsl_real_t *ef4)
 Given the initial values of the two kinetic (linear and rotational) and the two potential (gravitational and elastic) energies, and three of the four final values of these energies, this function calculates the fourth value of the unknown final energy using the conservation of mechanical energy. More...
 
int zsl_phy_ener_photon (zsl_real_t f, zsl_real_t *e)
 Calculates the energy in electron volts of a photon based on it's frequency in hertz. More...
 
int zsl_phy_ener_photon2 (zsl_real_t lambda, zsl_real_t *e)
 Calculates the energy in electron volts of a photon based on it's wavelength in ???. More...
 

Detailed Description

Energy functions.

Function Documentation

◆ zsl_phy_ener_elas_pot()

int zsl_phy_ener_elas_pot ( zsl_real_t  k,
zsl_real_t  dist,
zsl_real_t ue 
)

Calculates the elastic potential energy of a spring based on the distance it has been compressed/expanded and its characteristic 'k' constant.

Parameters
kConstant characteristic of the spring, in newtons per meter.
distDistance compressed/expanded in meters.
uePointer to the output elastic potential energy in joules. Will be set to NAN if 'k' is negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_final()

int zsl_phy_ener_final ( zsl_real_t  ei1,
zsl_real_t  ei2,
zsl_real_t  ei3,
zsl_real_t  ei4,
zsl_real_t  ef1,
zsl_real_t  ef2,
zsl_real_t  ef3,
zsl_real_t ef4 
)

Given the initial values of the two kinetic (linear and rotational) and the two potential (gravitational and elastic) energies, and three of the four final values of these energies, this function calculates the fourth value of the unknown final energy using the conservation of mechanical energy.

Parameters
ei1Initial value of one of the energies in joules.
ei2Initial value of one of the energies in joules.
ei3Initial value of one of the energies in joules.
ei4Initial value of one of the energies in joules.
ef1Final value of one of the energies in joules.
ef2Final value of one of the energies in joules.
ef3Final value of one of the energies in joules.
ef4Pointer to the output unknown final energy in joules.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_fric()

int zsl_phy_ener_fric ( zsl_real_t  fric,
zsl_real_t  dist,
zsl_real_t e 
)

Calculates the energy lost due to a friction force based on the distance the object experiencing the friction has moved.

Parameters
fricModule of the friction force in newtons.
distDistance through which the force has been applied, in meters.
ePointer to the output lost energy in joules. Will be set to NAN if either the friction force or the distance are negatives.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_grav_pot()

int zsl_phy_ener_grav_pot ( zsl_real_t  m,
zsl_real_t  h,
zsl_real_t ug 
)

Calculates the gravitational potential energy in joules of an object based on its mass (m) and its height (h) with respect to a chosen initial height.

Parameters
mMass of the body in kilograms.
hHeight in meters.
ugPointer to the output gravitational potential energy in joules. Will be set to NAN if the mass of the body is negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_kin()

int zsl_phy_ener_kin ( zsl_real_t  v,
zsl_real_t  m,
zsl_real_t ke 
)

Calculates the kinetic energy of a moving object based on its mass (m) and velocity (v).

Parameters
vVelocity in meters per second.
mMass of the object in kilograms.
kePointer to the output kinetic energy in joules. Will be set to NAN if the mass is negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_mec()

int zsl_phy_ener_mec ( zsl_real_t  ke,
zsl_real_t  rke,
zsl_real_t  ug,
zsl_real_t  ue,
zsl_real_t me 
)

Calculates the total mechanical energy of a system by adding kinetic energy (linear and angular) and potential energy (gravitational and elastic).

Parameters
keLinear kinetic energy (AKA half of the mass times velocity squared) in joules.
rkeAngular kinetic energy (AKA half of the moment of inertia times angular velocity squared) in joules.
ugGravitational potential energy in joules.
ueElastic potential energy in joules.
mePointer to the output mechanical energy in joules.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_photon()

int zsl_phy_ener_photon ( zsl_real_t  f,
zsl_real_t e 
)

Calculates the energy in electron volts of a photon based on it's frequency in hertz.

Parameters
fFrequency of the photon in hertz.
ePointer to the output energy in electron volts. Will be set to NAN if frequency is less than 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_photon2()

int zsl_phy_ener_photon2 ( zsl_real_t  lambda,
zsl_real_t e 
)

Calculates the energy in electron volts of a photon based on it's wavelength in ???.

Parameters
lambdaWavelength of the photon in ???
ePointer to the output energy in electron volts. Will be set to NAN if wavelength is less than or equal to 0.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_power()

int zsl_phy_ener_power ( zsl_real_t  ener,
zsl_real_t  time,
zsl_real_t power 
)

Calculates the power by dividing energy or work by time.

Parameters
enerEnergy or work supplied in joules.
timeTime in seconds..
powerPointer to the output power in watts. Will be set to NAN if the time is zero or negative.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_ener_rot()

int zsl_phy_ener_rot ( zsl_real_t  omega,
zsl_real_t  i,
zsl_real_t rke 
)

Calculates the angular kinetic energy of a rotating object based on its angular velocity (omega) and moment of inertia (i).

Parameters
omegaAngular velocity in radians per second.
iMoment of inertia in kilograms and meters squared.
rkePointer to the output angular kinetic energy in joules. Will be set to NAN if the moment of inertia of the object is negative.
Returns
0 if everything executed properly, error code on failure.