Zephyr Scientific Library (zscilib)
Files | Functions
Electricity

Electricity functions. More...

Files

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

Functions

int zsl_phy_elcty_current (zsl_real_t q, zsl_real_t t, zsl_real_t *i)
 Calculates the electric current based on the charge (q) that crosses a transversal area during a period of time (t). More...
 
int zsl_phy_elcty_res_series (struct zsl_vec *v, zsl_real_t *r)
 Calculates the equivalent resistance of a set of resistors in series. More...
 
int zsl_phy_elcty_res_parallel (struct zsl_vec *v, zsl_real_t *r)
 Calculates the equivalent resistance of a set of resistors in parallel. More...
 
int zsl_phy_elcty_cap_series (struct zsl_vec *v, zsl_real_t *c)
 Calculates the equivalent capacitance of a set of capacitors in series. More...
 
int zsl_phy_elcty_cap_parallel (struct zsl_vec *v, zsl_real_t *c)
 Calculates the equivalent capacitance of a set of capacitors in parallels. More...
 
int zsl_phy_elcty_resistivity (zsl_real_t r, zsl_real_t a, zsl_real_t l, zsl_real_t *rty)
 Calculates the resistivity of a uniform piece of material of area section 'a', length 'l' and resistance 'r'. More...
 
int zsl_phy_elcty_ohm_law (zsl_real_t i, zsl_real_t r, zsl_real_t *v)
 Calculates the voltage between two points in an electrical circiut based on the electric current (i) and resistance (r) using Ohm's law. More...
 
int zsl_phy_elcty_power_vi (zsl_real_t v, zsl_real_t i, zsl_real_t *p)
 Calculates the electric power based on the voltage (v) and electric current (i). More...
 
int zsl_phy_elcty_power_ir (zsl_real_t i, zsl_real_t r, zsl_real_t *p)
 Calculates the electric power based on the electric current (i) and the resistance (r). More...
 
int zsl_phy_elcty_power_vr (zsl_real_t v, zsl_real_t r, zsl_real_t *p)
 Calculates the electric power based on the voltage (v) and the resistance (r). More...
 

Detailed Description

Electricity functions.

Function Documentation

◆ zsl_phy_elcty_cap_parallel()

int zsl_phy_elcty_cap_parallel ( struct zsl_vec v,
zsl_real_t c 
)

Calculates the equivalent capacitance of a set of capacitors in parallels.

Parameters
vVector whose coefficients are the capacitances in farads of the capacitors in parallel.
cPointer to the equivalent capacitance in farads. Will be set to NAN if any of the input capacitances is negative.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_cap_series()

int zsl_phy_elcty_cap_series ( struct zsl_vec v,
zsl_real_t c 
)

Calculates the equivalent capacitance of a set of capacitors in series.

Parameters
vVector whose coefficients are the capacitances in farads of the capacitors in series.
cPointer to the equivalent capacitance in farads. Will be set to NAN if any of the input capacitances is negative or zero.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_current()

int zsl_phy_elcty_current ( zsl_real_t  q,
zsl_real_t  t,
zsl_real_t i 
)

Calculates the electric current based on the charge (q) that crosses a transversal area during a period of time (t).

Parameters
qCharge in coulombs.
tTime in seconds.
iPointer to the calculated electric current in amperes. Will be set to NAN if the time is negative ir zero.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_ohm_law()

int zsl_phy_elcty_ohm_law ( zsl_real_t  i,
zsl_real_t  r,
zsl_real_t v 
)

Calculates the voltage between two points in an electrical circiut based on the electric current (i) and resistance (r) using Ohm's law.

Parameters
iElectric current in amperes.
rResistance in ohms.
vPointer to the calculated voltage in volts. Will be set to NAN if the resistance is negative.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_power_ir()

int zsl_phy_elcty_power_ir ( zsl_real_t  i,
zsl_real_t  r,
zsl_real_t p 
)

Calculates the electric power based on the electric current (i) and the resistance (r).

Parameters
iElectric current in amperes.
rResistance in ohms.
pPointer to the output electric power in watts. Will be set to NAN if the resistance is negative.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_power_vi()

int zsl_phy_elcty_power_vi ( zsl_real_t  v,
zsl_real_t  i,
zsl_real_t p 
)

Calculates the electric power based on the voltage (v) and electric current (i).

Parameters
vVoltage in volts.
iElectric current in amperes.
pPointer to the output electric power in watts.
Returns
0 if everything executed correctly, otherwise an appropriate error code.

◆ zsl_phy_elcty_power_vr()

int zsl_phy_elcty_power_vr ( zsl_real_t  v,
zsl_real_t  r,
zsl_real_t p 
)

Calculates the electric power based on the voltage (v) and the resistance (r).

Parameters
vVoltage in volts.
rResistance in ohms.
pPointer to the output electric power in watts. Will be set to NAN if the resistance is negative or zero.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_res_parallel()

int zsl_phy_elcty_res_parallel ( struct zsl_vec v,
zsl_real_t r 
)

Calculates the equivalent resistance of a set of resistors in parallel.

Parameters
vVector whose coefficients are the resistances in Ohms of the resistors in parallel.
rPointer to the equivalent resistance in Ohms. Will be set to NAN if any of the input resistances is negative or zero.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_res_series()

int zsl_phy_elcty_res_series ( struct zsl_vec v,
zsl_real_t r 
)

Calculates the equivalent resistance of a set of resistors in series.

Parameters
vVector whose coefficients are the resistances in Ohms of the resistors in series.
rPointer to the equivalent resistance in Ohms. Will be set to NAN if any of the input resistances is negative.
Returns
0 on success, and non-zero error code on failure.

◆ zsl_phy_elcty_resistivity()

int zsl_phy_elcty_resistivity ( zsl_real_t  r,
zsl_real_t  a,
zsl_real_t  l,
zsl_real_t rty 
)

Calculates the resistivity of a uniform piece of material of area section 'a', length 'l' and resistance 'r'.

Parameters
rResistance of the material in ohms.
aArea section in square meters.
lLength in meters.
rtyPointer to the resistivity in ohms times meters. Will be set to NAN if the area section, length or resistance are negative, or if l = 0.
Returns
0 on success, and non-zero error code on failure.