Zephyr Scientific Library (zscilib)
Files | Functions
Electric

Electric functions. More...

Files

file  electric.h
 API header file for electrics in zscilib.
 

Functions

int zsl_phy_elec_charge_dens (zsl_real_t q, zsl_real_t v, zsl_real_t *d)
 Calculates the uniform charge density of an charged body based on its charge and its volume. More...
 
int zsl_phy_elec_force (zsl_real_t q1, zsl_real_t q2, zsl_real_t r, zsl_real_t *f)
 Calculates the electric force in newtons between two charged bodies based on their charges and the distance between them. More...
 
int zsl_phy_elec_force2 (zsl_real_t q, zsl_real_t e, zsl_real_t *f)
 Calculates the electric force in newtons that a charged body experiences when it enters an electric field. More...
 
int zsl_phy_elec_field (zsl_real_t q, zsl_real_t r, zsl_real_t *e)
 Calculates the electric field created by a charged body anywhere in space. More...
 
int zsl_phy_elec_pot_ener (zsl_real_t q1, zsl_real_t q2, zsl_real_t r, zsl_real_t *u)
 Calculates the electric potential energy in joules of two charged bodies based on their charges and the distance between them. More...
 
int zsl_phy_elec_potential (zsl_real_t q, zsl_real_t r, zsl_real_t *v)
 Calculates the Coulomb's potential of a charged body anywhere in space. More...
 
int zsl_phy_elec_flux (zsl_real_t e, zsl_real_t a, zsl_real_t theta, zsl_real_t *fl)
 Calculates the electric flux that flows across a surface based on the area (a), the electric field (b) and the angle they form. More...
 

Detailed Description

Electric functions.

Function Documentation

◆ zsl_phy_elec_charge_dens()

int zsl_phy_elec_charge_dens ( zsl_real_t  q,
zsl_real_t  v,
zsl_real_t d 
)

Calculates the uniform charge density of an charged body based on its charge and its volume.

Parameters
qCharge of the body in coulombs.
vVolume of the body in meters cubed.
dPointer to the output uniform charge density in coulombs per meter cubed. Will be set to NAN if the volume is negative or zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_field()

int zsl_phy_elec_field ( zsl_real_t  q,
zsl_real_t  r,
zsl_real_t e 
)

Calculates the electric field created by a charged body anywhere in space.

Parameters
qCharge of the body in coulombs.
rDistance to the body in meters.
ePointer to the output electric field in newtons per coulomb. Will be set to NAN if the distance is negative or zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_flux()

int zsl_phy_elec_flux ( zsl_real_t  e,
zsl_real_t  a,
zsl_real_t  theta,
zsl_real_t fl 
)

Calculates the electric flux that flows across a surface based on the area (a), the electric field (b) and the angle they form.

Parameters
eModule of the electric field vector in newtons per coulomb.
aSurface in meters squared.
thetaAngle between the vector normal to the surface and the electric field vector in radians.
flPointer to the output electric flux in newtons and meters squared per coulomb. Will be set to NAN if the area or the electric field are negative values.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_force()

int zsl_phy_elec_force ( zsl_real_t  q1,
zsl_real_t  q2,
zsl_real_t  r,
zsl_real_t f 
)

Calculates the electric force in newtons between two charged bodies based on their charges and the distance between them.

Parameters
q1Charge of the first body in coulombs.
q2Charge of the second body in coulombs.
rDistance between the two bodies.
fPointer to the output electric force in newtons. Will be set to NAN if the distance is negative or zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_force2()

int zsl_phy_elec_force2 ( zsl_real_t  q,
zsl_real_t  e,
zsl_real_t f 
)

Calculates the electric force in newtons that a charged body experiences when it enters an electric field.

Parameters
qCharge of the body in coulombs.
eElectric field in newtons per coulomb.
fPointer to the output electric force in newtons.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_pot_ener()

int zsl_phy_elec_pot_ener ( zsl_real_t  q1,
zsl_real_t  q2,
zsl_real_t  r,
zsl_real_t u 
)

Calculates the electric potential energy in joules of two charged bodies based on their charges and the distance between them.

Parameters
q1Charge of the first body in coulombs.
q2Charge of the second body in coulombs.
rDistance between the two bodies.
uPointer to the output potential energy in joules. Will be set to NAN if the distance is negative or zero.
Returns
0 if everything executed properly, error code on failure.

◆ zsl_phy_elec_potential()

int zsl_phy_elec_potential ( zsl_real_t  q,
zsl_real_t  r,
zsl_real_t v 
)

Calculates the Coulomb's potential of a charged body anywhere in space.

Parameters
qCharge of the body in coulombs.
rDistance to the body in meters.
vPointer to the output potential in volts. Will be set to NAN if the distance is negative or zero.
Returns
0 if everything executed properly, error code on failure.