pub struct DcOperatingPoint { /* private fields */ }Expand description
A complete ideal DC operating point satisfying Ohm’s law.
Implementations§
Source§impl DcOperatingPoint
impl DcOperatingPoint
Sourcepub fn from_voltage_and_resistance(
voltage: Voltage,
resistance: Resistance,
) -> Result<Self, ElectricError>
pub fn from_voltage_and_resistance( voltage: Voltage, resistance: Resistance, ) -> Result<Self, ElectricError>
Derives current and power from voltage and resistance.
Examples found in repository?
examples/dc_circuit.rs (lines 6-9)
5fn main() -> Result<(), force_electric::ElectricError> {
6 let point = DcOperatingPoint::from_voltage_and_resistance(
7 Voltage::volts(12.0)?,
8 Resistance::ohms(6.0)?,
9 )?;
10 let energy = Energy::from_power_over(point.power(), Duration::hours(3.0)?)?;
11
12 let resistors = [Resistance::ohms(100.0)?, Resistance::ohms(100.0)?];
13 let series = series_resistance(&resistors)?;
14 let parallel = parallel_resistance(&resistors)?;
15
16 println!("current: {:.2} A", point.current().as_amperes());
17 println!("power: {:.2} W", point.power().as_watts());
18 println!("energy over 3 h: {:.2} Wh", energy.as_watt_hours());
19 println!("series resistance: {:.2} ohm", series.as_ohms());
20 println!("parallel resistance: {:.2} ohm", parallel.as_ohms());
21
22 Ok(())
23}Sourcepub fn from_current_and_resistance(
current: Current,
resistance: Resistance,
) -> Result<Self, ElectricError>
pub fn from_current_and_resistance( current: Current, resistance: Resistance, ) -> Result<Self, ElectricError>
Derives voltage and power from current and resistance.
Sourcepub fn from_voltage_and_current(
voltage: Voltage,
current: Current,
) -> Result<Self, ElectricError>
pub fn from_voltage_and_current( voltage: Voltage, current: Current, ) -> Result<Self, ElectricError>
Derives resistance and power from positive voltage and current.
Sourcepub const fn current(self) -> Current
pub const fn current(self) -> Current
Returns current.
Examples found in repository?
examples/dc_circuit.rs (line 16)
5fn main() -> Result<(), force_electric::ElectricError> {
6 let point = DcOperatingPoint::from_voltage_and_resistance(
7 Voltage::volts(12.0)?,
8 Resistance::ohms(6.0)?,
9 )?;
10 let energy = Energy::from_power_over(point.power(), Duration::hours(3.0)?)?;
11
12 let resistors = [Resistance::ohms(100.0)?, Resistance::ohms(100.0)?];
13 let series = series_resistance(&resistors)?;
14 let parallel = parallel_resistance(&resistors)?;
15
16 println!("current: {:.2} A", point.current().as_amperes());
17 println!("power: {:.2} W", point.power().as_watts());
18 println!("energy over 3 h: {:.2} Wh", energy.as_watt_hours());
19 println!("series resistance: {:.2} ohm", series.as_ohms());
20 println!("parallel resistance: {:.2} ohm", parallel.as_ohms());
21
22 Ok(())
23}Sourcepub const fn resistance(self) -> Resistance
pub const fn resistance(self) -> Resistance
Returns resistance.
Sourcepub const fn power(self) -> Power
pub const fn power(self) -> Power
Returns ideal DC power.
Examples found in repository?
examples/dc_circuit.rs (line 10)
5fn main() -> Result<(), force_electric::ElectricError> {
6 let point = DcOperatingPoint::from_voltage_and_resistance(
7 Voltage::volts(12.0)?,
8 Resistance::ohms(6.0)?,
9 )?;
10 let energy = Energy::from_power_over(point.power(), Duration::hours(3.0)?)?;
11
12 let resistors = [Resistance::ohms(100.0)?, Resistance::ohms(100.0)?];
13 let series = series_resistance(&resistors)?;
14 let parallel = parallel_resistance(&resistors)?;
15
16 println!("current: {:.2} A", point.current().as_amperes());
17 println!("power: {:.2} W", point.power().as_watts());
18 println!("energy over 3 h: {:.2} Wh", energy.as_watt_hours());
19 println!("series resistance: {:.2} ohm", series.as_ohms());
20 println!("parallel resistance: {:.2} ohm", parallel.as_ohms());
21
22 Ok(())
23}Trait Implementations§
Source§impl Clone for DcOperatingPoint
impl Clone for DcOperatingPoint
impl Copy for DcOperatingPoint
Source§impl Debug for DcOperatingPoint
impl Debug for DcOperatingPoint
Source§impl PartialEq for DcOperatingPoint
impl PartialEq for DcOperatingPoint
impl StructuralPartialEq for DcOperatingPoint
Auto Trait Implementations§
impl Freeze for DcOperatingPoint
impl RefUnwindSafe for DcOperatingPoint
impl Send for DcOperatingPoint
impl Sync for DcOperatingPoint
impl Unpin for DcOperatingPoint
impl UnsafeUnpin for DcOperatingPoint
impl UnwindSafe for DcOperatingPoint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more