Skip to main content

AmplifierModel

Struct AmplifierModel 

Source
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 Block

The 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>

Source

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());
Source

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);
Source

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));
Source

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));
Source

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);
Source

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);
Source

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);
Source

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>

Source§

fn clone(&self) -> AmplifierModel<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for AmplifierModel<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for AmplifierModel<'a>

§

impl<'a> RefUnwindSafe for AmplifierModel<'a>

§

impl<'a> Send for AmplifierModel<'a>

§

impl<'a> Sync for AmplifierModel<'a>

§

impl<'a> Unpin for AmplifierModel<'a>

§

impl<'a> UnsafeUnpin for AmplifierModel<'a>

§

impl<'a> UnwindSafe for AmplifierModel<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more