-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) 2023 Xu Shaohua <shaohua@biofan.org>. All rights reserved. | ||
// Use of this source is governed by General Public License that can be found | ||
// in the LICENSE file. | ||
|
||
// TEMPERATURE (unit = K) | ||
pub const T: f64 = 300.0; | ||
pub const BOLTZMANN: f64 = 1.380_649e-23; | ||
pub const ELECTRON_VOLT: f64 = 1.602_176_634e-19; | ||
|
||
/// This function can calculate the Builtin Voltage of a pn junction diode. | ||
/// | ||
/// This is calculated from the given three values. | ||
/// | ||
/// # Parameters | ||
/// - `donor_conc` - donor concentration | ||
/// - `acceptor_conc` - acceptor concentration | ||
/// - `intrinsic_conc` - intrinsic concentration | ||
#[must_use] | ||
pub fn builtin_voltage(donor_conc: f64, acceptor_conc: f64, intrinsic_conc: f64) -> f64 { | ||
debug_assert!(donor_conc > 0.0); | ||
debug_assert!(acceptor_conc > 0.0); | ||
debug_assert!(intrinsic_conc > 0.0); | ||
debug_assert!(donor_conc > intrinsic_conc); | ||
debug_assert!(acceptor_conc > intrinsic_conc); | ||
BOLTZMANN * T * ((donor_conc * acceptor_conc) / intrinsic_conc.powi(2)).ln() / ELECTRON_VOLT | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::builtin_voltage; | ||
|
||
#[test] | ||
fn test_builtin_voltage() { | ||
assert_eq!(builtin_voltage(1e17, 1e17, 1e10), 0.833370010652644); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,6 @@ | |
)] | ||
|
||
//pub mod apparent_power; | ||
pub mod builtin_voltage; | ||
pub mod electric_power; | ||
pub mod ohms_law; |