All notable changes to magpylib are documented here.
4.2.0 - 2023-01-27#
(Re)introducing the powerful
misc.Triangleclass that can be used to compute magnetic fields of arbitrarily shaped bodies by approximating their surface with triangular facets. (#568)
magnet.Tetrahedronclass as a derivate of the Triangle class. (#289)
Change pyvista plotting defaults when using
show(backend='pyvista')to fit better with other libraries. (#551)
Added code of conduct attempting to align with NumFocus standards (#558)
Improved Loop field computation in terms of performance and numerical stability (#374)
magnetization.modestyle to allow showing magnetization direction for any backend #576)
Correct conda install command
Integration of Triangle and Tetrahedron
Changed example gallery substructure
Rewritten and added some passages
Fixed some bugs, minor performance increase, internal refactoring
4.1.2 - 2023-01-15#
4.1.1 - 2022-08-11#
Fix inverted y and z axes colors for sensor representations (#556)
4.1.0 - 2022-08-08#
getHnow supports 2D pandas.dataframe in addition to the
numpy.ndarrayas output type. (#523)
getHrefactoring. The direct interface with
'Line'source argument now also accepts
'vertices'as argument. (#540)
Complete plotting backend rework to prepare for easy implementation of new backends, with minimal maintenance. (#539)
Improvements on the documentation
4.0.4 - 2022-06-09#
4.0.3 - 2022-05-13#
Fix copy order Bug (#530)
4.0.2 - 2022-05-04#
4.0.1 - 2022-04-29#
Graphic performance update for plotly when showing a large number of objects. (#524)
4.0.0 - 2022-04-14#
This is a major update that includes
Improved internal workings
Magpylib class changes/fixes:#
Boxclass renamed to
Circularclass renamed to
CylinderSegmentclass with dimension
(r1,r2,h,phi1,phi2)with the inner radius
r1, the outer radius
hand the cylinder section angles
phi1 < phi2. (#386, #385, #484, #480)
CustomSourceclass for user defined field functions (#349, #409, #411, #506)
All Magpylib objects can now be initialized without excitation and dimension attributes.
All classes now have the
parentattribute to reference to a collection they are part of. Any object can only have a single parent.
All classes have the
describemethod which gives a quick object property overview.
Field computation changes/fixes:#
New computation core. Added top level subpackage
magpylib.corewhere all field implementations can be accessed directly without the position/orienation interface. (#376)
Direct interface functions
getHv) are now integrated into
getH. See docu for details (#449)
Generally improved field expressions: (#374)
Negative dimension input taken as absolute when only positive dimensions are allowed.
Scale invariant field evaluations.
Special cases caught within 1e-15 rtol and atol to account for numerical imprecision with positioning (e.g. object rotation).
Supress numpy divide/invalid warnings. return
(0,0,0)(e.g. on magnet edges or on line currents) and allow return of
New closed form implementation for
Cylinderwith diametral magnetization is much faster (100-1000x) and numerically stable for small
r. (#404, #370)
Improved numerical stability of current loop field. Now 12-14 correct digits everywhere. (#374)
Linesfield computation error. (#368)
Object oriented interface fixes and modifications:
With the new kwarg
pixel_aggit is now possible to apply a numpy function with reducing functionality (like
average) to the pixel output. In this case, it is allowed to provide
getHwith different observer input shapes. (#503)
Major graphic output overhaul:#
show, to be more in-line with standard graphic backends. Functionality completely overhauled to function with styles. (#453, #451)
showarguments replace previous ones. Some are now handed over through styles.
Geometry interface modification#
Added all scipy Rotation forms as rotation object methods. (#427)
rotateinputs differentiate between scalar and vector input. Scalar input is applied to the whole path vector input is merged. (#438, #444, #442)
rotatemethods have default
start=0-> applied to whole path, vector input:
start=len_path-> append) instead of
rotatemethods maintain collection geometry when applied to a collection.
orientationsetter methods in line with
rotatefunctionality and maintain
rotatefunctions (#438, #444)
Modifications to the
Collections can now contain
Collectionobjects and can function as source and observer inputs in
getH. (#502, #410, #415, #297)
Instead of the property
Collection.sourcesthere are now the
Collection.collectionsproperties. Setting these collection properties will automatically override parents. (#446, #502)
Collectionhas it’s own
style. (#444, #461)
All methods applied to a collection maintain relative child-positions in the local reference frame.
Collection, so that
Collection.childrenlength is returned. (#383)
-operation was removed.
+operation now functions as
a + b = Collection(a, b). Warning:
a + b + cnow creates a nested collection !
removeinput is now only
*argsor a single flat list or tuple of Magpylib objects.
removehave some additional functionality related to child-parent relations.
describemethod gives a great Collection tree overview.
Magpylib error message improvement. Msg will now tell you what input is expected.
copymethod now works properly (#477, #470, #476)
Defaults and input checks (#406)
magpylib.Configparameters are now in
config.ITERCYLINDERis now obsolete. The iterative solution replaced by a new analytical expression.
config.inputchecksis removed - input checks are always performed.
3.0.5 - 2022-04-26#
fix docs build
3.0.4 - 2022-02-17#
3.0.3 - 2022-02-17#
When adding with
Source + Collectionto create a new
Collection, the original now remains unaffected (#472)
3.0.2 - 2021-06-27#
3.0.1 - 2021-06-27#
3.0.0 - 2021-06-27#
This is a major update that includes
Improved internal workings
orientationattribute stores the relative rotation of an object with respect to the reference orientation (defined in each class docstring).
The default (
orientation=None) corresponds to a unit rotation.
orientationis stored as a
Calling the attribute
source.orientationreturns a scipy Rotation object
Make use of all advantages of this great scipy package:
combine subsequent rotations
R1 * R2 * R3
Sensor(position, pixel, orientation)class has the argument
(0,0,0)by default and refers to pixel positions inside the Sensor (in the Sensor local CS).
pixelis an arbitrary array_like of the shape (N1, N2, …, 3).
orientationattributes can now store paths in the global CS. For a path of length M the attribute
positionis an array of the shape (M,3) and
orientationis a Rotation object with length M. Each path position is associated with a respective rotation.
getH()will evaluate the field for all source path positions.
Paths can be set by hand
position = X,
orientation = Y, but they can also conveniently be generated using the
Paths can be shown via the
display(). By setting
show_path=xthe object will be displayed at every
x’th path step. This helps to follow up on object rotation along the path.
All objects have a
reset_path()method defined to set their paths to
Streamlining operation with all Magpylib objects:
All objects (Sensors, Sources, Collections) have additional direct access to
.display()method for quick self-inspection.
getH()methods for fast field computations
__repr__attribute defined and will return their type and their
Other new features:
Configallows users to access and edit Magpylib default values.
.currentsub-packages were moved to the top level.
.momentsub-package was renamed to
.miscand was moved to the top level.
.vectorsub-package was completely removed. Functionalities are mostly replaced by new top-level function
.mathsub-package was removed. Functionalities are mostly provided by the
scipy - Rotationpackage.
The top level function
displaySystem()was renamed to
Renamed attributes (parameters cannot be initialized in their short forms anymore):
axisare replaced by
dimensionis replaced by
diameterfor Loop and Sphere classes.
axisare replaced by
orientation(see Added Section)
Modified rotate methods:
The class methods
.rotate(angle, axis, anchor)have been replaced by a new
.rotate(rotation, anchor, increment, start)method where
rotationist a scipy
The original angle-axis-anchor rotation is now provided by the new method
.rotate_from_angax(angle, axis, anchor, increment, start, degrees).
axiscan now easily be set to the global CS axes with
The anchor argument
anchor=0represents the origin
angleargument is in units of deg by default. It can now be set to rad using the
The “move”-class method is now
.move(displacement, increment, start)
Rotation and move methods can now be used to generate paths using vector input and the
All operations can now be chained (e.g.
getB(pos)now takes single AND vector position arguments. If a vector is handed to getB it will automatically execute vectorized code from the vector module.
In a finite region (size defined by
Config.EDGESIZE) about magnet edges and line currents the field evaluates to
(NaN, NaN, NaN). Special case catching reduces performance slightly.
The Box field is now more stable. Numerical instabilities in the outfield were completely removed.
Updated Field computation interface
There are two fundamental arguments for field computation:
sourcesrefers to a source/Collection or to a 1D list of L sources and/or Collections.
observersrefers to a set of positions of shape (N1, N2, …, 3) or a Sensor with
pixelshape (N1, N2, …, 3) or a 1D list of K Sensors.
With Magpylib3 there are several ways to compute the field:
The output shape is always (L, M, K, N1, N2, …, 3) with L sources, M path positions, K sensors and N (pixel) positions.
Objects with shorter paths will be considered as static once their path ends while other paths still continue.
magpylib.getBv(**kwargs)gives direct access to the field formulas and mostly replaces the
getBv_XXX()functionality of v2. All inputs must be arrays of length N or of length 1 (statics will be tiled).
getBvis the fastest way to compute the fields it is much more convenient to use
getB()which mostly provides the same performance. Specifically,the new
getB()automatically groups all inputs for combined vectorized evaluation. This leads to a massive speedup when dealing with large Collections of similar sources.
In addition to
getB, the new
getHreturns the field in [kA/m].
niter=50does not exist anymore for the Cylinder field computation. The functionality was completely replaced by the config setting
2.3.0b - 2020-01-17#
Improved performance of getB for diametral magnetized Cylinders by 20%.
GetB of Line current now uses vectorized code which leads to massive performance enhancement.
IMPORTANT: position arguments of
getBvfunctions have been flipped! First comes the source position POSm THEN the observer position POSo!
completed the library vector functionality adding magnet Cylinder, moment Dipole, current Loop and Line. This includes adding several private vectorized functions (e.g. ellipticV) to mathLib_vector, adding respective tests and docs examples.
2.1.0b - 2019-12-06#
Docstrings for vector functions.
bringing documentation up to speed
init file bug
2.0.0b - 2019-11-29#
This is a major update that includes
API changes New features Improved internal workings
displaySystem is now a top-level function, not a Collection method anymore.
getBsweep and multiprocessing options have been completely removed, this functionality should be overtaken by the new vector functionality which uses the numpy native vectorized code paradigm. If mkl library is set (test by numpy.show_config()) numpy will also automatically use multiprocessing. Code parallelization at magpylib level should be done by hand.
Docstrings are adjusted to work better with intellisense. (Problems with *.rst code)
public rotatePosition() is now called angleAxisRotation(), former private angleAxisRotation is now called angleAxisRotation_priv().
Major rework of the documentation and examples.
Performance computation trough vector functionality included in new top-level subpackage “vector”
Vectorized versions of math functions added to “math” subpackage
1.2.1b0 - 2019-07-31#
Optimized getB call (utility integrated)
Improved Documentation (added Sensor class v1)
1.2.0b0 - 2019-07-16#
This allows users to create a coordinate system-enabled Sensor object, which can be placed, rotated, moved and oriented.
This object can take the B-Field of a system (be it single source or a Collection) with the added functionality of having its own reference in the coordinate space, allowing users to easily acquire relative B-Field measurements of a system from an arbitrarily placed sensor object.
Sensors in a list may be displayed in the
Collection.displaySystem()by using the
Added content to the
__repr__builtin to all source classes for quick console evaluations, simply call a defined object in your Python shell to print out its attributes.
Edge cases in field calculations now return a proper RuntimeWarning instead of console prints
Unused imports and variables
1.1.1b0 - 2019-06-25#
Collection.displaySystem()not having the
block=Falsesetting for matplotlib’s
pyplot.show()by default, this meant that outside interactive mode calling this function would hang the script until the plot was closed.
If for some reason you want to block the application, you may still use
suppress=Truekwarg then call pyplot.show() normally.
This should cause no API changes, if you have problems please notify us.
Fix multiprocessing enabled
Collection.getBsweep()for lots of objects with few positions causing great performance loss. This functionality now behaves as expected for the use case.
Collection.displaySystem()’s drawing of Dipole objects in external axes (plots) using the
subplotAxkwarg crashing the application. This functionality now behaves as expected for the use case.
1.1.0b0 - 2019-06-14#
Implemented one new kwarg for
subplotAx=NoneDraw into a subplot axe that already exists. The subplot needs to be 3D projected
This allows for creating side-by-side plots using displaySystem. Figure information must be set manually in pyplot.figure() in order to not squash the plots upon subplotting.
Click here for Example
getBsweep()for Collections and Sources now always returns a numpy array
Zero-length segments in Line sources now return
[0,0,0]and a warning, making it easier to draw spirals without letting users do this unaware.
Added a workaround fix for a rotation bug we are still working on.
1.0.2b0 - 2019-05-29#
MANIFEST.infile containing the LICENSE for bundling in PyPi
1.0.1b0 - 2019-05-28#
Issue and Pull Request Templates to Repository
Continuous Integration settings (Azure and Appveyor)
Code Coverage Reports with codecov
Support for Python 3.5 and under.
1.0.0b0 - 2019-05-21#
The first official release of the magpylib library.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.