Crates.io | magnet_rs |
lib.rs | magnet_rs |
version | 0.2.3 |
source | src |
created_at | 2021-02-19 15:57:33.550784 |
updated_at | 2021-09-19 20:09:59.016091 |
description | User friendly magnetic field calculations in Rust |
homepage | https://www.applied-magnetism.com/ |
repository | https://github.com/pdunne/magnet_rs |
max_upload_size | |
id | 357630 |
size | 1,200,490 |
Magnet_RS is a command line program to calculate the magnetic fields of any
object or objects in 2D and 3D; along with any induced forces and torques. This
uses the lodestone_core
crate, which is a rewrite of a python package,
pymagnet
:
This binary reads a toml file containing the magnets and list of points to run the calculation over. This is then saved to a JSON file with the following keys:
magnets
: an array of the magnets and their propertiespoints
: points where the field is calculatedfield
: calculated magnetic fieldCurrently, only 2D features are available.
Run the demo calculation:
magnet_rs -d
which saves the computed field to example_out.json
The Python script in the data folder, plot_example.py
will plot the resulting
json file.
Save the following into input.toml
[[magnet]]
kind = "rectangle"
size = [1.0, 1.0]
center = [-1.0, -0.5]
magnetisation = [1.0, 90.0]
magAngle = "degrees"
alpha = 0.0
alphaAngle = "degrees"
[[magnet]]
kind = "rectangle"
size = [1.0, 1.0]
center = [1.0, -2.0]
magnetisation = [-1.0, 0.5]
magAngle = "degrees"
alpha = 0.0
alphaAngle = "degrees"
# Then define the type of grid for calculating over
[grid]
kind = "grid"
start = [-2.0, -2.0]
stop = [2.0, 2.0]
numPoints = 101
units = "mm" # NOTE: Units are not yet implemented
then run the following to save the data in a JSON file:
magnet_rs -i input.toml -o out.json
Source code licensed under the Mozilla Public License Version 2.0
Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.
This is a human-readable summary of (and not a substitute for) the license, adapted from CS50x. Official translations of this license are available in other languages.
You are free to:
Under the following terms:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.