pub struct AmplifierModel<'a> {
pub block: &'a Block,
pub am_pm_coefficient_deg_per_db: Option<f64>,
pub saturation_power_dbm: Option<f64>,
}Expand description
Amplifier model wrapping a Block with optional AM-PM characterization.
This is intentionally separate from Block to keep the core cascade model
simple while allowing richer amplifier analysis when needed.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 25.0,
noise_figure_db: 6.0,
output_p1db_dbm: Some(33.0),
output_ip3_dbm: Some(45.0),
};
let model = AmplifierModel::with_am_pm(&block, 8.0); // 8 °/dB AM-PM
let phase = model.phase_shift_at(0.0).unwrap();
assert!(phase >= 0.0);Fields§
§block: &'a BlockThe underlying block with gain, NF, P1dB, and IP3.
am_pm_coefficient_deg_per_db: Option<f64>AM-PM conversion coefficient in °/dB near P1dB.
saturation_power_dbm: Option<f64>Saturated output power (dBm).
Implementations§
Source§impl<'a> AmplifierModel<'a>
impl<'a> AmplifierModel<'a>
Sourcepub fn new(block: &'a Block) -> Self
pub fn new(block: &'a Block) -> Self
Create an amplifier model with no AM-PM characterization.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "LNA".to_string(),
gain_db: 20.0,
noise_figure_db: 2.0,
output_p1db_dbm: Some(10.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::new(&block);
assert!(model.phase_shift_at(-30.0).is_none());Sourcepub fn with_am_pm(block: &'a Block, coeff_deg_per_db: f64) -> Self
pub fn with_am_pm(block: &'a Block, coeff_deg_per_db: f64) -> Self
Create an amplifier model with AM-PM coefficient.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(30.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::with_am_pm(&block, 10.0);
// At input P1dB (10 dBm), phase shift is 0
let phase = model.phase_shift_at(10.0).unwrap();
assert!((phase - 0.0).abs() < 1e-10);Sourcepub fn with_saturation(block: &'a Block, psat_dbm: f64) -> Self
pub fn with_saturation(block: &'a Block, psat_dbm: f64) -> Self
Create an amplifier model with saturation power.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(30.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::with_saturation(&block, 35.0);
assert_eq!(model.saturation_power_dbm, Some(35.0));Sourcepub fn builder(block: &'a Block) -> AmplifierModelBuilder<'a>
pub fn builder(block: &'a Block) -> AmplifierModelBuilder<'a>
Return a builder for configuring optional fields.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 25.0,
noise_figure_db: 6.0,
output_p1db_dbm: Some(33.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::builder(&block)
.am_pm_coefficient(8.0)
.saturation_power(37.0)
.build();
assert_eq!(model.saturation_power_dbm, Some(37.0));Sourcepub fn phase_shift_at(&self, input_power_dbm: f64) -> Option<f64>
pub fn phase_shift_at(&self, input_power_dbm: f64) -> Option<f64>
AM-PM phase shift in degrees at a given input power.
Simple model: Δφ = coeff × max(0, Pin − (input_P1dB − backoff_margin))
where the phase shift ramps linearly as input approaches and exceeds the
input-referred P1dB. At deep backoff the phase shift is zero.
Returns None if no AM-PM coefficient is set or if output_p1db_dbm is not
set on the underlying block.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(10.0), // input P1dB = -10 dBm
output_ip3_dbm: None,
};
let model = AmplifierModel::with_am_pm(&block, 10.0);
// 5 dB above input P1dB → 50° phase shift
let phase = model.phase_shift_at(-5.0).unwrap();
assert!((phase - 50.0).abs() < 1e-10);Sourcepub fn am_am_am_pm_sweep(
&self,
start_dbm: f64,
stop_dbm: f64,
step_db: f64,
) -> Vec<AmplifierPoint>
pub fn am_am_am_pm_sweep( &self, start_dbm: f64, stop_dbm: f64, step_db: f64, ) -> Vec<AmplifierPoint>
Combined AM-AM + AM-PM sweep.
Returns one AmplifierPoint for each step from start_dbm to stop_dbm.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(30.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::with_am_pm(&block, 5.0);
let sweep = model.am_am_am_pm_sweep(-40.0, -20.0, 5.0);
assert_eq!(sweep.len(), 5);Sourcepub fn backoff_for_target_phase(&self, max_phase_deg: f64) -> Option<f64>
pub fn backoff_for_target_phase(&self, max_phase_deg: f64) -> Option<f64>
Required input backoff (dB below input P1dB) to stay within a phase shift target.
Returns the backoff in dB (positive means below P1dB). For example, if
max_phase_deg is 5° and the coefficient is 10 °/dB, the amplifier can
tolerate 0.5 dB above input P1dB, so the backoff is −0.5 dB (i.e., you can
actually be 0.5 dB above P1dB). More typically, a tight phase budget
requires operating below P1dB.
Returns None if no AM-PM coefficient is set or coefficient is zero.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(10.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::with_am_pm(&block, 10.0);
let backoff = model.backoff_for_target_phase(5.0).unwrap();
assert!((backoff - (-0.5)).abs() < 1e-10);Sourcepub fn evm_from_am_pm(&self, input_power_dbm: f64) -> Option<f64>
pub fn evm_from_am_pm(&self, input_power_dbm: f64) -> Option<f64>
EVM contribution from AM-PM distortion at a given input power.
Approximation: EVM ≈ sin(Δφ) for small angles, expressed as a ratio (not %).
Returns None if phase shift is unavailable.
§Examples
use gainlineup::{Block, AmplifierModel};
let block = Block {
name: "PA".to_string(),
gain_db: 20.0,
noise_figure_db: 5.0,
output_p1db_dbm: Some(10.0),
output_ip3_dbm: None,
};
let model = AmplifierModel::with_am_pm(&block, 10.0);
// At deep backoff, EVM should be ~0
let evm = model.evm_from_am_pm(-50.0).unwrap();
assert!(evm < 0.001);Trait Implementations§
Source§impl<'a> Clone for AmplifierModel<'a>
impl<'a> Clone for AmplifierModel<'a>
Source§fn clone(&self) -> AmplifierModel<'a>
fn clone(&self) -> AmplifierModel<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more