Skip to main content

Crate stem_material

Crate stem_material 

Source
Expand description

§stem_material

This crate provides a Material definition for simulation of electromagnetic devices – especially electric motors – built on top of the var_quantity crate. It is used to define motor components within stem - a Simulation Toolbox for Electric Motors. See the stem book for an introduction to the framework.

Feedback welcome!
Found a bug, missing docs, or have a feature request?
Please open an issue on GitHub.

§Modeling soft magnetism

The following models for soft magnetism can both be used stand-alone and as part of a Material.

§Ferromagnetic permeability

The FerromagneticPermeability struct offers a spline-based way to model the ferromagnetic behaviour of a material from measured datapoints. It is particularily optimized for usage with iterative solvers and slightly modifies the resulting curve to achieve numerical stability and fast convergence. Additionally, it can also take the iron fill factor of lamination sheets into account.

The struct models both µr = f(H) and µr = f(B), meaning that either the magnetic field strength H or the magnetic flux density B can be used to calculate the relative permeability.

The following image shows the (modified) spline derived from raw data both for an iron fill factor of 100 % and of 95 % (the other 5 % are modeled as air with a relative permeability of 1).

§Jordan model for iron losse

The JordanModel type provides a simple and fast model for calculating hysteresis and eddy current losses based on the equation p = kh * f * B² + kec * (f * B)². The accompanying module offers ergonomic ways to obtain the the loss coefficients kh and kec using least-square fitting.

Due to the model only having two parameters, its modeling accuracy is limited. The following image shows the raw loss data for different frequencies and the interpolated curves created by the according JordanModel. It can be clearly seen that the model precision is very good for small frequencies, but degrades for higher frequencies.

§Serialization and deserialization

The serde integration is gated behind the serde feature flag.

Most of the types (except errors) in this crate implement serialization and deserialization. See the docstrings of the individual types for details.

§Documentation

The full API documentation is available at https://docs.rs/stem_material/0.2.3/stem_material/.

Re-exports§

pub use iron_losses::*;
pub use material::*;
pub use relative_permeability::*;

Modules§

dyn_quantity
dyn_quantity
iron_losses
Predefined iron loss models for Materials.
material
stem_material
relative_permeability
Implementation of a spline-based model for ferromagnetic permeability.
typetag
githubcrates-iodocs-rs
unary
This module contains unary functions which implement IsQuantityFunction.

Structs§

ClampedQuantity
A wrapper around a type implementing IsQuantityFunction trait object which clamps the output of IsQuantityFunction::call using the provided upper and lower limits.
DynQuantity
This type represents a physical quantity via its numerical value and a unit of measurement (field exponents). The unit of measurement is not defined via the type system, but rather via the values of the Unit. This means that the unit of measurement is not fixed at compile time, but can change dynamically at runtime.
NotConvertibleFromComplexF64
Error describing a failed attempt to convert a Complex<f64> into the type V of DynQuantity<V>.
ParseError
Error representing a failed attempt to parse a string into a DynQuantity.
QuantityFunction
A thin wrapper around a Box<dyn IsQuantityFunction> trait object which provides some type checks for usage in VarQuantity.
RootError
Error representing a failed attempt to calculate the nth root of an Unit.
Unit
Struct representing a unit of measurement in the SI system via the exponents of the base units. The unit is purely defined by the values of its fields, meaning that it can change at runtime. The struct implements basic arithmetic functions such as multiplication and division (via the Mul, MulAssign, Div, DivAssign traits), exponentiation (Unit::powi) and a fallible version of root calculation (Unit::try_nthroot).
UnitsNotEqual
Error representing unequality of units.

Enums§

ConversionError
Error describing a failed attempt to convert between different types representing quantities.
ParseErrorReason
The varying reasons parsing a string to a DynQuantity can fail. This struct is part of ParseError, which contains the information where the parsing failed.
PredefUnit
An enum representing predefined Units.
VarQuantity
A quantity whose value can either be constant or a function of one or more other quantities.

Traits§

IsQuantity
This is a marker trait which defines trait bounds for all types T which can be used as “quantities” in VarQuantity<T>. It does not provide any methods and is auto-implemented for all T fulfilling the bounds, hence it is not necessary to ever import this trait. It is only public to make compiler error messages more helpful.
IsQuantityFunction
Trait used to construct variable quantities whose value is a (pure) function of other quantities.
UnitFromType
A trait to derive Unit from a type. This trait bridges the gap between (external) types representing physical quantities (such as e.g. the Quantity type from the uom crate) and Unit.

Functions§

deserialize_angle
Deserializes an angle from a valid DynQuantity representation (see docstring of DynQuantity). The output value is always in radians.
deserialize_opt_angle
Like deserialize_angle, but deserializes into an Option<f64> instead of a f64.
deserialize_opt_quantity
Like deserialize_quantity, but deserializes into an Option<T> instead of a T implementing TryFrom<DynQuantity>.
deserialize_opt_vec_of_quantities
Like deserialize_vec_of_quantities, but deserializes into an Option<Vec<T>> instead of a Vec<T>.
deserialize_quantity
Deserializes a type T implementing TryFrom<DynQuantity> from a valid DynQuantity representation (see docstring of DynQuantity).
deserialize_vec_of_quantities
Deserializes a vector of T which implements TryFrom<DynQuantity> from:
filter_unary_function
A helper function which filters the conditions for a quantity with the type match_for. If a matching quantity is found, it is used as argument for F and the result is returned. Otherwise, the result of G() is returned.