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
- github crates-io docs-rs
- unary
- This module contains unary functions which implement
IsQuantityFunction.
Structs§
- Clamped
Quantity - A wrapper around a type implementing
IsQuantityFunctiontrait object which clamps the output ofIsQuantityFunction::callusing the provided upper and lower limits. - DynQuantity
- This type represents a physical quantity via its numerical
valueand a unit of measurement (fieldexponents). The unit of measurement is not defined via the type system, but rather via the values of theUnit. This means that the unit of measurement is not fixed at compile time, but can change dynamically at runtime. - NotConvertible
From Complex F64 - Error describing a failed attempt to convert a
Complex<f64>into the typeVofDynQuantity<V>. - Parse
Error - Error representing a failed attempt to parse a string into a
DynQuantity. - Quantity
Function - A thin wrapper around a
Box<dyn IsQuantityFunction>trait object which provides some type checks for usage inVarQuantity. - Root
Error - Error representing a failed attempt to calculate the
nth root of anUnit. - 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,DivAssigntraits), exponentiation (Unit::powi) and a fallible version of root calculation (Unit::try_nthroot). - Units
NotEqual - Error representing unequality of units.
Enums§
- Conversion
Error - Error describing a failed attempt to convert between different types representing quantities.
- Parse
Error Reason - The varying reasons parsing a string to a
DynQuantitycan fail. This struct is part ofParseError, which contains the information where the parsing failed. - Predef
Unit - 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
Twhich can be used as “quantities” inVarQuantity<T>. It does not provide any methods and is auto-implemented for allTfulfilling the bounds, hence it is not necessary to ever import this trait. It is only public to make compiler error messages more helpful. - IsQuantity
Function - Trait used to construct variable quantities whose value is a (pure) function of other quantities.
- Unit
From Type - A trait to derive
Unitfrom a type. This trait bridges the gap between (external) types representing physical quantities (such as e.g. theQuantitytype from the uom crate) andUnit.
Functions§
- deserialize_
angle - Deserializes an angle from a valid
DynQuantityrepresentation (see docstring ofDynQuantity). The output value is always in radians. - deserialize_
opt_ angle - Like
deserialize_angle, but deserializes into anOption<f64>instead of af64. - deserialize_
opt_ quantity - Like
deserialize_quantity, but deserializes into anOption<T>instead of aTimplementingTryFrom<DynQuantity>. - deserialize_
opt_ vec_ of_ quantities - Like
deserialize_vec_of_quantities, but deserializes into anOption<Vec<T>>instead of aVec<T>. - deserialize_
quantity - Deserializes a type
TimplementingTryFrom<DynQuantity>from a validDynQuantityrepresentation (see docstring ofDynQuantity). - deserialize_
vec_ of_ quantities - Deserializes a vector of
Twhich implementsTryFrom<DynQuantity>from: - filter_
unary_ function - A helper function which filters the
conditionsfor a quantity with the typematch_for. If a matching quantity is found, it is used as argument forFand the result is returned. Otherwise, the result ofG()is returned.