Zephyr Scientific Library (zscilib)
|
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... | |
Energy functions.
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.
k | Constant characteristic of the spring, in newtons per meter. |
dist | Distance compressed/expanded in meters. |
ue | Pointer to the output elastic potential energy in joules. Will be set to NAN if 'k' is negative. |
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.
ei1 | Initial value of one of the energies in joules. |
ei2 | Initial value of one of the energies in joules. |
ei3 | Initial value of one of the energies in joules. |
ei4 | Initial value of one of the energies in joules. |
ef1 | Final value of one of the energies in joules. |
ef2 | Final value of one of the energies in joules. |
ef3 | Final value of one of the energies in joules. |
ef4 | Pointer to the output unknown final energy in joules. |
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.
fric | Module of the friction force in newtons. |
dist | Distance through which the force has been applied, in meters. |
e | Pointer to the output lost energy in joules. Will be set to NAN if either the friction force or the distance are negatives. |
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.
m | Mass of the body in kilograms. |
h | Height in meters. |
ug | Pointer to the output gravitational potential energy in joules. Will be set to NAN if the mass of the body is negative. |
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).
v | Velocity in meters per second. |
m | Mass of the object in kilograms. |
ke | Pointer to the output kinetic energy in joules. Will be set to NAN if the mass is negative. |
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).
ke | Linear kinetic energy (AKA half of the mass times velocity squared) in joules. |
rke | Angular kinetic energy (AKA half of the moment of inertia times angular velocity squared) in joules. |
ug | Gravitational potential energy in joules. |
ue | Elastic potential energy in joules. |
me | Pointer to the output mechanical energy in joules. |
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.
f | Frequency of the photon in hertz. |
e | Pointer to the output energy in electron volts. Will be set to NAN if frequency is less than 0. |
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 ???.
lambda | Wavelength of the photon in ??? |
e | Pointer to the output energy in electron volts. Will be set to NAN if wavelength is less than or equal to 0. |
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.
ener | Energy or work supplied in joules. |
time | Time in seconds.. |
power | Pointer to the output power in watts. Will be set to NAN if the time is zero or negative. |
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).
omega | Angular velocity in radians per second. |
i | Moment of inertia in kilograms and meters squared. |
rke | Pointer to the output angular kinetic energy in joules. Will be set to NAN if the moment of inertia of the object is negative. |