mammos-ai quickstart#
mammos-ai contains a collection of pre-trained ai models.
import mammos_ai
import mammos_entity as me
Simple surrogate micromagnetic model#
We can use mammos-ai to predict extrinsic magnetic properties of a permanent magnet based on its micromagnetic parameters. Here we use a model to predict coercivity, remanence, and maximum energy product based on saturation magnetization, exchange stiffness, and uniaxial anisotropy constant.
By default this uses the version 0.1 random forest model trained on a 50 nm cubic grain with anisotropy axis aligned with the external field and also aligned with one of the cube axes. Currently only this model is available, but more models will be added in future releases.
More information about the model and training data can be found in the training repository and the associated metadata.
Note: Be carful when using models outside of their training data range (this information is available in the model metadata). Predictions outside of the training data range will be unreliable.
Ms = me.Ms(1e6)
A = me.A(1e-12)
K = me.Ku(1e7)
extrinsic = mammos_ai.Hc_Mr_BHmax_from_Ms_A_K(Ms, A, K)
extrinsic
ExtrinsicProperties(Hc=Entity(ontology_label='CoercivityHcExternal', value=np.float32(7.232628e+06), unit='A / m'), Mr=Entity(ontology_label='Remanence', value=np.float32(1.0256044e+06), unit='A / m'), BHmax=Entity(ontology_label='MaximumEnergyProduct', value=np.float32(330440.28), unit='J / m3'))
We can access the individual extrinsic properties as follows:
extrinsic.Hc
extrinsic.Mr
extrinsic.BHmax
Internally, the this function checks if the sample is a hard magnet based on the intrinsic properties. If it is, it uses a hard-magnet predictor. If it is not, it switches to a soft-magnet predictor.
mammos-ai also provides a function in order to predict if the micromagnetic parameters correspond to a hard magnetic material
mammos_ai.is_hard_magnet_from_Ms_A_K(Ms, A, K)
True
We can see if we reduce the anisotropy constant that the material is no longer classified as a hard magnet.
K = me.Ku(1e4)
mammos_ai.is_hard_magnet_from_Ms_A_K(Ms, A, K)
False
The the models have metadata associated with them that can be accessed as follows:
mammos_ai.Hc_Mr_BHmax_from_Ms_A_K_metadata()
{'model_name': 'cube50_singlegrain_random_forest_v0.1',
'description': 'Random forest model trained on simulated data for single grain cubic particles with 50 nm edge length with the external field applied parallel to the anisotropy axis.',
'training_data_range': {'Ms': (Entity(ontology_label='SpontaneousMagnetization', value=np.float64(79580.0), unit='A / m'),
Entity(ontology_label='SpontaneousMagnetization', value=np.float64(3980000.0), unit='A / m')),
'A': (Entity(ontology_label='ExchangeStiffnessConstant', value=np.float64(1e-13), unit='J / m'),
Entity(ontology_label='ExchangeStiffnessConstant', value=np.float64(1e-11), unit='J / m')),
'K': (Entity(ontology_label='UniaxialAnisotropyConstant', value=np.float64(10000.0), unit='J / m3'),
Entity(ontology_label='UniaxialAnisotropyConstant', value=np.float64(10000000.0), unit='J / m3'))},
'input_parameters': ['Ms (A/m)', 'A (J/m)', 'K1 (J/m^3)'],
'output_parameters': ['Hc (A/m)', 'Mr (A/m)', 'BHmax (J/m^3)'],
'source': 'https://github.com/MaMMoS-project/ML-models/tree/main/beyond-stoner-wohlfarth/single-grain-easy-axis-model'}
mammos_ai.is_hard_magnet_from_Ms_A_K_metadata()
{'model_name': 'cube50_singlegrain_random_forest_v0.1',
'description': 'Random forest model trained on simulated data for single grain cubic particles with 50 nm edge length with the external field applied parallel to the anisotropy axis.',
'training_data_range': {'Ms': (Entity(ontology_label='SpontaneousMagnetization', value=np.float64(79580.0), unit='A / m'),
Entity(ontology_label='SpontaneousMagnetization', value=np.float64(3980000.0), unit='A / m')),
'A': (Entity(ontology_label='ExchangeStiffnessConstant', value=np.float64(1e-13), unit='J / m'),
Entity(ontology_label='ExchangeStiffnessConstant', value=np.float64(1e-11), unit='J / m')),
'K': (Entity(ontology_label='UniaxialAnisotropyConstant', value=np.float64(10000.0), unit='J / m3'),
Entity(ontology_label='UniaxialAnisotropyConstant', value=np.float64(10000000.0), unit='J / m3'))},
'input_parameters': ['Ms (A/m)', 'A (J/m)', 'K1 (J/m^3)'],
'output_classes': {0: 'soft magnetic', 1: 'hard magnetic'},
'source': 'https://github.com/MaMMoS-project/ML-models/tree/main/beyond-stoner-wohlfarth/single-grain-easy-axis-model'}