Skip to main content

Material

Struct Material 

Source
pub struct Material {
    pub epsilon: Aniso,
    pub mue: Aniso,
    pub kappa: Aniso,
    pub sigma: Aniso,
    pub density: Scalar,
    pub density_weight: WeightFn,
    pub isotropic: bool,
}
Expand description

Electric/magnetic material with (optionally anisotropic and position dependent) constitutive parameters.

  • epsilon: relative permittivity
  • mue: relative permeability
  • kappa: electric conductivity (S/m)
  • sigma: magnetic conductivity (Ω/m)
  • density: mass density (kg/m³)

The default is vacuum (εᵣ = μᵣ = 1, lossless), isotropic.

use csx::properties::{Material, MaterialQuantity};
use csx::Vec3;

// isotropic FR4
let fr4 = Material::new(4.3, 0.02);
assert_eq!(fr4.base_value(MaterialQuantity::Epsilon, 2), 4.3);

// anisotropic (uniaxial) material: ε_z differs
let mut m = Material::new(9.4, 0.0);
m.isotropic = false;
m.epsilon.value[2].set(11.6);
assert_eq!(m.values_at(MaterialQuantity::Epsilon, Vec3::ZERO), [9.4, 9.4, 11.6]);

// graded permittivity along x
let mut g = Material::new(2.0, 0.0);
g.epsilon.set_weight("1 + x/10");
assert_eq!(g.value_at(MaterialQuantity::Epsilon, 0, Vec3::new(5.0, 0.0, 0.0)), 3.0);

Fields§

§epsilon: Aniso

Relative permittivity.

§mue: Aniso

Relative permeability.

§kappa: Aniso

Electric conductivity.

§sigma: Aniso

Magnetic conductivity.

§density: Scalar

Mass density.

§density_weight: WeightFn

Weighting function of the density.

§isotropic: bool

If true only the first axis of each quantity is used.

Implementations§

Source§

impl Material

Source

pub fn new(epsilon: f64, kappa: f64) -> Self

Material with the given relative permittivity and conductivity.

Source

pub fn quantity(&self, q: MaterialQuantity) -> &Aniso

The quantity selected by q.

Source

pub fn quantity_mut(&mut self, q: MaterialQuantity) -> &mut Aniso

Mutable access to the quantity selected by q.

Source

pub fn value_at(&self, q: MaterialQuantity, dir: usize, p: Vec3) -> f64

Weighted value of q along axis dir (0..=2; higher values are clamped to 2) at Cartesian point p. Isotropic materials use axis 0 for every direction.

Source

pub fn values_at(&self, q: MaterialQuantity, p: Vec3) -> [f64; 3]

Weighted values of q on all three axes at p.

Source

pub fn base_value(&self, q: MaterialQuantity, dir: usize) -> f64

Unweighted value of q along dir.

Source

pub fn density_at(&self, p: Vec3) -> f64

Weighted density at p.

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Material

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Material

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Material

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Material

Auto Trait Implementations§

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, 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.