Find a solution for having one or two magnetizations
The fact that we have two different magnetic orders (magnetic and AFM) makes many parts of the code confusing. Increasing parts of the code are written such that they don't care about the magnetic order. But the fact that mag1
and mag2
always need to be stitched together and bisected when entering or exiting numerical experiments (also when saving) is not good. Several experiments start like this
def some_experiment(sample, ...):
if sample.magnetic_order is MagneticOrder.FERROMAGNET:
mag_initial = sample.mag.to_flattened()
jacobian = jac_spherical_fm
convert_to_cartesian = flattened_spherical_to_cartesian_fm
elif sample.magnetic_order is MagneticOrder.ANTIFERROMAGNET:
mag_initial = make_flattened_AFM(sample.mag1, sample.mag2)
jacobian = jac_spherical_afm
convert_to_cartesian = flattened_spherical_to_cartesian_afm
...
# do some computation
if sample.magnetic_order is MagneticOrder.FERROMAGNET:
sample.mag = m_return.to_unflattened()
qty_to_save = sample.mag
names_to_save = "mag"
elif sample.magnetic_order is MagneticOrder.ANTIFERROMAGNET:
sample.mag1, sample.mag2 = m_return.to_two_unflattened()
qty_to_save = [sample.mag1, sample.mag2]
names_to_save = ["mag1", "mag2"]
This problem is not unique to getting and setting sample attributes (which would make it easy) but also reading/saving files, specific operators that are different for FM/AFM, etc.